Ticket #5933: building-presets.2.patch

File building-presets.2.patch, 3.6 KB (added by bilbo, 8 years ago)

Fixed and simplified building presets

  • src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

     
    10341034    public static class Key extends Item {
    10351035        public String key;
    10361036        public String value;
     1037        public boolean match_only_key = false;
    10371038
    10381039        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { return false; }
    10391040        @Override public void addCommands(List<Tag> changedTags) {
  • src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java

     
    100100                    if(i instanceof TaggingPreset.Key) {
    101101                        String val = ((TaggingPreset.Key)i).value;
    102102                        String key = ((TaggingPreset.Key)i).key;
     103                        boolean match_only_key = ((TaggingPreset.Key)i).match_only_key;
    103104                        // we subtract 100 if not found and add 1 if found
    104105                        found -= 100;
    105106                        if(key == null || !valueCount.containsKey(key)) {
     
    107108                        }
    108109
    109110                        Map<String, Integer> v = valueCount.get(key);
    110                         if(v.size() == 1 && val != null && v.containsKey(val) && v.get(val) == total) {
     111                        if (match_only_key) {
     112                            int sum = 0;
     113                            for (Integer vi : v.values()) sum+=vi;
     114                            if (total == sum) {
     115                                found += 101;
     116                            }
     117                        } else if(v.size() == 1 && val != null && v.containsKey(val) && v.get(val) == total) {
    111118                            found += 101;
    112119                        }
    113120                    } else {
  • data/defaultpresets.xml

     
    2424key: fixed key/value pair to be set
    2525  key: key to set
    2626  value: value to set
     27  match_only_key: if true, only key would be considered when looking for matching preset to show in panel
    2728
    2829text: text box
    2930  key: key to set
     
    29062907  <group name="Man Made" icon="presets/works.png">
    29072908    <group name="Man Made" icon="presets/works.png">
    29082909        <item name="Building" icon="styles/standard/misc/landmark/building.png" type="node,closedway,relation">
    2909             <key key="building" value="yes" />
     2910            <link href="http://wiki.openstreetmap.org/wiki/Proposed_features/Building_attributes" />
     2911            <key key="building" value="yes" match_only_key="true" />
     2912            <combo key="building" text="Type of building" values="train_station,hangar,yes" default="yes" use_last_as_default="true"/>
     2913            <label text="Value 'yes' means that no type is specified" />
     2914            <optional>
     2915                <label text="Building size" />
     2916                <text key="height" text="Height (meters) from ground to roof" delete_if_empty="true" />
     2917                <text key="building:levels" text="Number of stories, including the ground floor" delete_if_empty="true" />
     2918            </optional>
    29102919        </item>
    29112920        <item name="Tower" icon="presets/tower.png" type="node,closedway">
    29122921            <label text="Edit Tower" />