Ignore:
Timestamp:
2013-02-06T13:52:07+01:00 (11 years ago)
Author:
bastik
Message:

add filter option, in order to show only signs with tag info

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/roadsigns/README

    r26341 r29230  
    44Shows a GUI dialog to tag objects by clicking on road sign symbols.
    55It tries to generate the corresponding tags for the object.
    6 As tagging schemes are under constant development, the definitions
    7 need to be updated when needed.
    86
    97Author:
     
    1816    [1] http://osmtools.de/traffic_signs/
    1917
    20     Pics have been derived from
     18    Pics for the German preset have been derived from
    2119        http://de.wikipedia.org/wiki/Bildtafel_der_Verkehrszeichen_in_Deutschland (german street sign SVGs)
     20
     21How to install a custom preset
     22------------------------------
     23
     24Add the following entry in the advanced preferences [1]:
     25
     26  plugin.roadsigns.sources=/path/to/myroadsignpreset.xml
     27
     28(The value can be either "simple" or "list" type)
     29The chosen preset should be loaded automatically after a restart.
     30
     31Images can be placed in the same folder as the preset .xml file. Alternatively, you can also specify a path for icons:
     32
     33  plugin.roadsigns.icon.sources=/path/to/image/folder
     34
     35[1] http://josm.openstreetmap.de/wiki/Help/Preferences/Advanced
     36
     37Preset Format
     38-------------
     39
     40The first preset was data/roadsignpresetDE.xml, so you might want to look there for examples.
     41
     42Some values can contain parameters like $foo, that will be replaced by the value of the parameter named foo.
     43
     44sign:
     45    ref                 Short official designation of the sign that can be used for the traffic_sign tag. (accepts parameters)
     46    id                  Unique identifier. (If missing, equals ref. Either id or ref must be present.)
     47    icon                Icon image name. (If missing, id or ref is used as image name. In this case ':' and '.' characters are converted to underscore '_'.)
     48    name                Name of the sign. (required)
     49    long_name           Long (e.g. official) name of the sign.
     50    traffic_sign_tag    Value that should be used for traffic_sign tag (if different from ref).
     51    help                Some notes to guide the user.
     52    wiki                Page in the osm wiki
     53    deprecated          Set to "yes" if authorities have decided to no longer install signs of this kind.
     54                        (But old signs may still be there and need to be recorded.)
     55    useful              (optional) The user can choose to show only a selection of the most useful signs.
     56                        By default, a sign with <tag> information is treated as useful. This can be overridden
     57                        by setting this attribute. Possible values: true, false.
     58
     59tag:
     60    Some tags can be named (ident=*) and modified by other subsequent tags. If this finally results in an
     61    empty value (""), then the tag is skipped altogether. Note that the default value of a named tag is
     62    only used if there are no appending tags. E.g. access=no becomes access=delivery and not access=no;delivery.
     63
     64    static tags:
     65        key             The key text. (accepts parameters)
     66        value           The value text. (accepts parameters)
     67
     68    named tags:
     69        key             The key text.
     70        value           The default value text. If the final evaluation of the value results in an empty string, the tag is dropped.
     71        ident           Name a tag so it can later be changed by other tags.
     72
     73    modifying tags:
     74        appending:
     75            tag_ref         Name of the tag to be changed.
     76            append_value    Append a string to the value of the tag. The default value of the identified tag is dropped (unless there is no
     77                            modifying tag appending a value).
     78        condition:
     79            tag_ref         Name of the tag to be changed.
     80            condition       The condition to add. (K=V becomes K:cond=V.)
     81
     82parameter:
     83    ident           identifier to get the value of this parameter (required)
     84    input           input type (currently "textfield" and "combo" are possible values) (required)
     85    prefix          text to put before the input area
     86    suffix          text to put after the input area
     87    field_width     for text fields: the width of the field (number of characters)
     88    default         default value (required)
     89
     90supplementary: (list of recommended additional signs)
     91    id         the id of the supplementary sign
     92
    2293
    2394JavaCC usage:
  • applications/editors/josm/plugins/roadsigns/data/roadsignpresetDE.xml

    r29228 r29230  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<!--
    3 Preset file for road signs plugin.
    4 
    5 The plugin is in early state of development (05-2010) and the format is likely to change.
    6 
    7 How to customize
    8 ================
    9 
    10 Add the following to your JOSM preference file
    11 (or enter it in the advanced preferences tab in JOSM):
    12 
    13 plugin.roadsigns.sources=/path/to/myroadsignpreset.xml
    14 plugin.roadsigns.icon.sources=/path/to/image/folder
    15 
    16 (The second one is only needed if you like to display your own icons.)
    17 
    18 
    19 Preset format
    20 =============
    21                
    22 Some values can contain parameters like $foo, that will be replaced by the value of the parameter named foo.
    23 
    24 sign:
    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.)
    35 
    36 tag:
    37     Some tags can be named (ident=*) and modified by other subsequent tags. If this finally results in an
    38     empty value (""), then the tag is skipped altogether. Note that the default value of a named tag is
    39     only used if there are no appending tags. E.g. access=no becomes access=delivery and not access=no;delivery.
    40 
    41     static tags:
    42         key             The key text. (accepts parameters)
    43         value           The value text. (accepts parameters)
    44 
    45     named tags:
    46         key             The key text.
    47         value           The default value text. If the final evaluation of the value results in an empty string, the tag is dropped.
    48         ident           Name a tag so it can later be changed by other tags.
    49 
    50     modifying tags:
    51         appending:
    52             tag_ref         Name of the tag to be changed.
    53             append_value    Append a string to the value of the tag. The default value of the identified tag is dropped (unless there is no
    54                             modifying tag appending a value).
    55         condition:
    56             tag_ref         Name of the tag to be changed.
    57             condition       The condition to add. (K=V becomes K:cond=V.)
    58 
    59 parameter:
    60     ident           identifier to get the value of this parameter (required)
    61     input           input type (currently "textfield" and "combo" are possible values) (required)
    62     prefix          text to put before the input area
    63     suffix          text to put after the input area
    64     field_width     for text fields: the width of the field (number of characters)
    65     default         default value (required)
    66 
    67 supplementary: (list of recommended additional signs)
    68     id         the id of the supplementary sign
    69 
     3roadsigns plugin preset file for Germany
    704-->
    715<roadsignpreset country="DE">
  • applications/editors/josm/plugins/roadsigns/data/roadsignpresetPL.xml

    r29228 r29230  
    13491349        wiki="Tag:highway%3Dpedestrian"
    13501350        >
    1351         <tag key="highway" value="pedestrian"/>
     1351        <tag key="highway" value="living_street"/>
    13521352</sign>
    13531353
  • applications/editors/josm/plugins/roadsigns/data/roadsignpresetSK.xml

    r29228 r29230  
    225225</sign>
    226226<sign icon="B20.png" id="B20"  ref="SK:B20" name="zákaz vjazdu vozidiel alebo súprav vozidiel, ktorých dĺžka presahuje vyznačenú hranicu" sk.name="zákaz vjazdu vozidiel alebo súprav vozidiel, ktorých dĺžka presahuje vyznačenú hranicu">
    227        <tag key="car:distance" value="$val"/>
    228                                        <parameter ident="val" input="textfield" suffix="m" default="70" field_width="2"/>
     227       <tag key="maxlength" value="$val"/>
     228                                       <parameter ident="val" input="textfield" suffix="m" default="10" field_width="2"/>
    229229</sign>
    230230<sign icon="B21.png" id="B21"  ref="SK:B21" name="zákaz vjazdu vozidiel prepravujúcich nebezpečné veci" sk.name="zákaz vjazdu vozidiel prepravujúcich nebezpečné veci">
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignInputDialog.java

    r29228 r29230  
    2929import javax.swing.BorderFactory;
    3030import javax.swing.Box;
     31import javax.swing.ButtonGroup;
    3132import javax.swing.JButton;
    3233import javax.swing.JCheckBox;
     
    3637import javax.swing.JLabel;
    3738import javax.swing.JPanel;
     39import javax.swing.JRadioButton;
    3840import javax.swing.JScrollPane;
    3941import javax.swing.JTabbedPane;
     
    694696            fireTableDataChanged();
    695697        }
    696 
    697 
    698698    }
    699699
     
    814814        private List<PresetMetaData> presetsData;
    815815        private JComboBox selectionBox;
     816        JRadioButton rbAll, rbUseful;
    816817
    817818        public SettingsPanel(boolean standalone, final Action update) {
     
    831832            this.add(selectionBox, GBC.eol().insets(0, 5, 5, 5));
    832833            if (!standalone) {
     834                String snd = "Hide signs that do not have an OSM tag assigned";
     835
     836                rbAll = new JRadioButton(tr("Show all signs"));
     837                rbUseful = new JRadioButton(tr("Show a selection of the most useful signs"));
     838
     839                ButtonGroup grp = new ButtonGroup();
     840                grp.add(rbAll);
     841                grp.add(rbUseful);
     842
     843                String filterPref = Main.pref.get("plugin.roadsigns.preset.filter");
     844                if (filterPref.equals("useful")) {
     845                    rbUseful.setSelected(true);
     846                } else {
     847                    rbAll.setSelected(true);
     848                }
     849
     850                JPanel pnFilter = new JPanel(new GridBagLayout());
     851                pnFilter.setBorder(BorderFactory.createTitledBorder(tr("Filter")));
     852                pnFilter.add(rbAll, GBC.eop());
     853                pnFilter.add(rbUseful, GBC.eop());
     854
     855                this.add(pnFilter, GBC.eol().insets(5, 0, 5, 5));
     856
    833857                JButton apply = new JButton(new AbstractAction(tr("Apply")) {
    834858                    @Override
     
    848872
    849873        public void apply() throws IOException {
     874            String filter = null;
     875            if (rbAll != null) {
     876                if (rbAll.isSelected()) {
     877                    filter = "all";
     878                } else if (rbUseful.isSelected()) {
     879                    filter = "useful";
     880                }
     881            }
     882            if (filter != null) {
     883                Main.pref.put("plugin.roadsigns.preset.filter", filter);
     884            }
    850885            RoadSignsPlugin.setSelectedPreset(presetsData.get(selectionBox.getSelectedIndex()));
    851886        }
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsPlugin.java

    r29228 r29230  
    183183        List<PresetMetaData> presetsData =  getAvailablePresetsMetaData();
    184184        String code = Main.pref.get("plugin.roadsigns.preset.selection", null);
    185         if (selectedPreset != null && selectedPreset.code.equals(code)) return;
    186185
    187186        for (PresetMetaData data : presetsData) {
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsReader.java

    r23192 r29230  
    2222import org.xml.sax.helpers.DefaultHandler;
    2323
     24import org.openstreetmap.josm.Main;
    2425import org.openstreetmap.josm.io.OsmDataParsingException;
    2526import org.openstreetmap.josm.plugins.roadsigns.Sign.SignParameter;
    2627import org.openstreetmap.josm.plugins.roadsigns.Sign.Tag;
    27 import org.openstreetmap.josm.tools.LanguageInfo;
    28 
    2928import org.openstreetmap.josm.plugins.roadsigns.javacc.ParseException;
    3029import org.openstreetmap.josm.plugins.roadsigns.javacc.TokenMgrError;
     30import org.openstreetmap.josm.tools.LanguageInfo;
    3131
    3232/**
     
    113113
    114114                curSign.help = getLocalized(atts, "help");
     115
     116                String useful = atts.getValue("useful");
     117                if (useful != null) {
     118                    curSign.useful = Boolean.parseBoolean(useful);
     119                }
    115120
    116121            } else if (curSign != null && qname.equals("tag")) {
     
    312317            factory.newSAXParser().parse(inputSource, parser);
    313318            parser.wireSupplements();
    314             return parser.allSigns;
     319            String filterPref = Main.pref.get("plugin.roadsigns.preset.filter");
     320            if (filterPref.equals("useful")) {
     321                List<Sign> filtered = new ArrayList<Sign>();
     322                for (Sign s : parser.allSigns) {
     323                    if (s.isUseful()) {
     324                        filtered.add(s);
     325                    }
     326                }
     327                return filtered;
     328            } else {
     329                return parser.allSigns;
     330            }
    315331        } catch (ParserConfigurationException e) {
    316332            e.printStackTrace(); // broken SAXException chaining
  • applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/Sign.java

    r27675 r29230  
    3434    public String wiki;
    3535    public String help;
     36    public Boolean useful;
    3637
    3738    public JLabel label; // FIXME: don't put gui stuff here
     
    120121    }
    121122
     123    public boolean isUseful() {
     124        if (useful != null) return useful;
     125        return !tags.isEmpty();
     126    }
     127
    122128    @Override
    123129    public String toString() {
Note: See TracChangeset for help on using the changeset viewer.