Changeset 22420 in osm for applications/editors


Ignore:
Timestamp:
2010-07-22T14:00:54+02:00 (14 years ago)
Author:
bastik
Message:

'added support for traffic_sign tag'

Location:
applications/editors/josm/plugins/roadsigns
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/roadsigns/build.xml

    r22202 r22420  
    3131
    3232        <!-- enter the SVN commit message -->
    33         <property name="commit.message" value="fix message/i18n" />
     33        <property name="commit.message" value="added support for traffic_sign tag" />
    3434        <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    3535        <property name="plugin.main.version" value="3338" />
  • applications/editors/josm/plugins/roadsigns/data/defaultroadsignpreset.xml

    r21995 r22420  
    1111(or enter it in the advanced preferences tab in JOSM):
    1212
    13 plugin.roadsign.sources=/path/to/myroadsignpreset.xml
    14 plugin.roadsign.icon.sources=/path/to/image/folder
     13plugin.roadsigns.sources=/path/to/myroadsignpreset.xml
     14plugin.roadsigns.icon.sources=/path/to/image/folder
    1515
    1616(The second one is only needed if you like to display your own icons.)
     
    2323
    2424sign:
    25     ref             Short official designation of the sign that can be used for the traffic_sign tag. (accepts parameters)
    26     id              Unique identifier. (If missing, equals ref. Either id or ref must be present.)
    27     icon            Icon image name. (If missing, id or ref is used as image name. In this case ':' and '.' characters are converted to underscore '_'.)
    28     name            Name of the sign. (required)
    29     long_name       Long (e.g. official) name of the sign.
    30     help            Some notes to guide the user.
    31     wiki            Page in the osm wiki
    32     deprecated      Set to "yes" if authorities have decided to no longer install signs of this kind.
    33                     (But old signs may still be there and need to be recorded.)
     25    ref                 Short official designation of the sign that can be used for the traffic_sign tag. (accepts parameters)
     26    id                  Unique identifier. (If missing, equals ref. Either id or ref must be present.)
     27    icon                Icon image name. (If missing, id or ref is used as image name. In this case ':' and '.' characters are converted to underscore '_'.)
     28    name                Name of the sign. (required)
     29    long_name           Long (e.g. official) name of the sign.
     30    traffic_sign_tag    Value that should be used for traffic_sign tag (if different from ref).
     31    help                Some notes to guide the user.
     32    wiki                Page in the osm wiki
     33    deprecated          Set to "yes" if authorities have decided to no longer install signs of this kind.
     34                        (But old signs may still be there and need to be recorded.)
    3435
    3536tag:
     
    6970-->
    7071<roadsignpreset country="DE">
    71     <sign ref="DE:110" name="Incline" de.name="Steigung"
     72    <sign ref="DE:108/DE:110" icon="DE_110" traffic_sign_tag="" name="Incline" de.name="Steigung"
    7273            help="Applies for the road section with steep incline. (Split the way at the ends of the steep section.)
    7374Positive values indicate movement upward in the direction of the (osm) way and negative values indicate movement downwards in the direction of the way."
     
    7677            wiki="Key:incline"
    7778            de.wiki="DE:Key:incline">
     79        <!--Suppress the traffic_sign tag, because it would be incorrect to add
     80            traffic_sign=DE:110, when in reality it is DE:108.
     81            Both are essentially equal, so in this tool only the incline symbol
     82            should be present.-->
    7883        <tag key="incline" value="$val%"/>
    7984        <parameter input="textfield" name="max. incline" de.name="Maximale Steigung" type="int" ident="val" default="12" suffix="%" field_width="3"/>
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/ParametrizedString.java

    r21967 r22420  
    1 //License: GPL (v2 or later)
     1// License: GPL (v2 or later)
    22package org.openstreetmap.josm.plugins.roadsigns;
    33
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignInputDialog.java

    r21995 r22420  
    1111import java.awt.Rectangle;
    1212import java.awt.event.ActionEvent;
     13import java.awt.event.ActionListener;
    1314import java.awt.event.MouseAdapter;
    1415import java.awt.event.MouseEvent;
     
    2425
    2526import javax.swing.BorderFactory;
     27import javax.swing.JCheckBox;
    2628import javax.swing.JComponent;
    2729import javax.swing.JEditorPane;
     
    5254import org.openstreetmap.josm.plugins.roadsigns.Sign.SignParameter;
    5355import org.openstreetmap.josm.plugins.roadsigns.Sign.Tag;
     56import org.openstreetmap.josm.tools.GBC;
    5457import org.openstreetmap.josm.tools.OpenBrowser;
    5558import org.openstreetmap.josm.tools.Pair;
     
    6972 */
    7073class RoadSignInputDialog extends ExtendedDialog {
    71     private final SignSelection sel;
    72     private final List<Sign> signs;
    73     private JTable previewTable;
    74 
    75     private PreviewTableModel previewModel;
    76     private JPanel pnlSignSelection;
    77     private JPanel pnlPossibleSigns;
    78     private JPanel pnlPossibleSupplements;
    79     private JEditorPane info;
    80     private JScrollPane scrollInfo;
     74    protected final SignSelection sel;
     75    protected final List<Sign> signs;
     76    protected JTable previewTable;
     77    protected JCheckBox addTrafficSignTag;
     78
     79    protected PreviewTableModel previewModel;
     80    protected JPanel pnlSignSelection;
     81    protected JPanel pnlPossibleSigns;
     82    protected JPanel pnlPossibleSupplements;
     83    protected JEditorPane info;
     84    protected JScrollPane scrollInfo;
    8185
    8286    public RoadSignInputDialog(List<Sign> signs) {
     
    9397            Collection<OsmPrimitive> selPrim = Main.main.getCurrentDataSet().getSelected();
    9498            if (selPrim.size() != 0) {
     99                Main.pref.put("plugin.roadsigns.addTrafficSignTag", addTrafficSignTag.isSelected());
     100
    95101                Command cmd = createCommand(selPrim);
    96102                if (cmd != null) {
     
    464470
    465471    public JComponent buildPreviewPanel() {
     472        JPanel previewPanel = new JPanel(new GridBagLayout());
     473       
    466474        String[] columnNames = {tr("Key"), tr("Value")};
    467475        String[][] data = {{}};
    468         previewTable = new JTable(data, columnNames);
     476        previewTable = new JTable(data, columnNames) {
     477            public String getToolTipText(MouseEvent e) {
     478                int rowIndex = rowAtPoint(e.getPoint());
     479                int colIndex = columnAtPoint(e.getPoint());
     480                if (rowIndex == -1 || colIndex == -1)
     481                    return null;
     482                int realColumnIndex = convertColumnIndexToModel(colIndex);
     483                return (String) getValueAt(rowIndex, colIndex);
     484            }
     485        };
    469486        previewTable.setFillsViewportHeight(true);
    470487        previewTable.setRowSelectionAllowed(false);
     
    475492
    476493        JScrollPane scroll = new JScrollPane(previewTable);
    477         Dimension dim = new Dimension(236, 10);
     494        Dimension dim = new Dimension(336, 10);
    478495        scroll.setPreferredSize(dim);
    479496        scroll.setMinimumSize(dim); /* minimum size is relevant for multisplit layout */
    480         return scroll;
     497       
     498        addTrafficSignTag = new JCheckBox(tr("{0} tag", "traffic_sign"));
     499        addTrafficSignTag.setSelected(Main.pref.getBoolean("plugin.roadsigns.addTrafficSignTag"));
     500        addTrafficSignTag.addActionListener(new ActionListener() {
     501            public void actionPerformed(ActionEvent e) {
     502                previewModel.update();
     503            }
     504        });
     505       
     506        previewPanel.add(scroll, GBC.eol().fill());
     507        previewPanel.add(addTrafficSignTag, GBC.eol());
     508        return previewPanel;
    481509    }
    482510
     
    515543        public void update() {
    516544            final TreeMap<String, String> map= new TreeMap<String, String>();
     545            String traffic_sign = "";
     546           
    517547            for (SignCombination sc : sel.combos) {
    518548                final Map<String, String> env = new HashMap<String, String>();
     549                String combo_traffic_sign = "";
    519550
    520551                /**
     
    573604                    if (sw.sign.ref != null) {
    574605                        sw.signRef = sw.sign.ref.evaluate(env);
     606                        if (combo_traffic_sign.length() != 0) {
     607                            combo_traffic_sign += ",";
     608                        }
     609                        if (sw.sign.traffic_sign_tag != null) {
     610                            combo_traffic_sign += sw.sign.traffic_sign_tag.evaluate(env);
     611                        } else {
     612                            combo_traffic_sign += sw.signRef;
     613                        }
    575614                    }
    576615                    for (Tag t : sw.sign.tags) {
     
    615654                    map.putAll(result);
    616655                }
     656               
     657                if (combo_traffic_sign.length() != 0) {
     658                    if (traffic_sign.length() != 0) {
     659                        traffic_sign += ";";
     660                    }
     661                    traffic_sign += combo_traffic_sign;
     662                }
     663            }
     664            if (addTrafficSignTag.isSelected()) {
     665                map.put("traffic_sign", traffic_sign);
    617666            }
    618667
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsPlugin.java

    r21995 r22420  
    6868        presetsLoaded=true;
    6969        List<String> files = new ArrayList<String>(
    70                 Main.pref.getCollection("plugin.roadsign.sources",
     70                Main.pref.getCollection("plugin.roadsigns.sources",
    7171                    Collections.<String>singletonList("resource://data/defaultroadsignpreset.xml")));
    7272        iconDirs = new ArrayList<String>(
    73                 Main.pref.getCollection("plugin.roadsign.icon.sources", Collections.<String>emptySet()));
     73                Main.pref.getCollection("plugin.roadsigns.icon.sources", Collections.<String>emptySet()));
    7474
    75         if (Main.pref.getBoolean("plugin.roadsign.use_default_icon_source", true)) {
     75        if (Main.pref.getBoolean("plugin.roadsigns.use_default_icon_source", true)) {
    7676            iconDirs.add("resource://images/");
    7777        }
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsReader.java

    r21995 r22420  
    7777                try {
    7878                    curSign.ref = ParametrizedString.create(atts.getValue("ref"));
     79                    curSign.traffic_sign_tag = ParametrizedString.create(atts.getValue("traffic_sign_tag"));
    7980                } catch (ParseException ex) {
    8081                    throw new SAXException(ex);
     
    107108                    curSign.isSupplementing = true;
    108109                }
    109 
     110               
    110111                curSign.wiki = atts.getValue("wiki");
    111112                curSign.loc_wiki = getLocalized(atts, "wiki");
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/Sign.java

    r21995 r22420  
    2121    public String id;
    2222    public ParametrizedString ref;
     23    public ParametrizedString traffic_sign_tag;
    2324    public String iconURL;
    2425    public ImageIcon icon;
     
    99100        r = r.replaceAll("\\[.*\\]", "");
    100101        if (r.startsWith("DE:")) {
    101             r=r.replaceFirst("DE:", "");
     102            r=r.replaceAll("DE:", "");
    102103            /* normal sign: starts with 3 digits, then a non-digit */
    103104            {
Note: See TracChangeset for help on using the changeset viewer.