Changeset 9932 in josm
- Timestamp:
- 2016-03-05T17:57:04+01:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/defaultpresets.xml
r9931 r9932 3089 3089 </optional> 3090 3090 <roles> 3091 <role key="stop" text="stop position" requisite="optional" type="node" member_expression="public_transport=stop_position (train OR subway OR monorail OR tram OR light_rail)" />3092 <role key="stop_exit_only" text="stop position (exit only)" requisite="optional" type="node" member_expression="public_transport=stop_position (train OR subway OR monorail OR tram OR light_rail)" />3093 <role key="stop_entry_only" text="stop position (entry only)" requisite="optional" type="node" member_expression="public_transport=stop_position (train OR subway OR monorail OR tram OR light_rail)" />3094 <role key="platform" text="platform" requisite="optional" type="node,way,closedway,multipolygon" member_expression="public_transport= stop_position (train OR subway OR monorail OR tram OR light_rail)" />3095 <role key="platform_exit_only" text="platform (exit only)" requisite="optional" type="node,way,closedway" member_expression="public_transport= stop_position (train OR subway OR monorail OR tram OR light_rail)" />3096 <role key="platform_entry_only" text="platform (entry only)" requisite="optional" type="node,way,closedway" member_expression="public_transport= stop_position (train OR subway OR monorail OR tram OR light_rail)" />3091 <role key="stop" text="stop position" requisite="optional" type="node" member_expression="public_transport=stop_position (train=yes OR subway=yes OR monorail=yes OR tram=yes OR light_rail=yes)" /> 3092 <role key="stop_exit_only" text="stop position (exit only)" requisite="optional" type="node" member_expression="public_transport=stop_position (train=yes OR subway=yes OR monorail=yes OR tram=yes OR light_rail=yes)" /> 3093 <role key="stop_entry_only" text="stop position (entry only)" requisite="optional" type="node" member_expression="public_transport=stop_position (train=yes OR subway=yes OR monorail=yes OR tram=yes OR light_rail=yes)" /> 3094 <role key="platform" text="platform" requisite="optional" type="node,way,closedway,multipolygon" member_expression="public_transport=platform (train=yes OR subway=yes OR monorail=yes OR tram=yes OR light_rail=yes)" /> 3095 <role key="platform_exit_only" text="platform (exit only)" requisite="optional" type="node,way,closedway" member_expression="public_transport=platform (train=yes OR subway=yes OR monorail=yes OR tram=yes OR light_rail=yes)" /> 3096 <role key="platform_entry_only" text="platform (entry only)" requisite="optional" type="node,way,closedway" member_expression="public_transport=platform (train=yes OR subway=yes OR monorail=yes OR tram=yes OR light_rail=yes)" /> 3097 3097 <role key="" text="route segment" requisite="required" type="way,closedway" member_expression="railway" /> 3098 3098 </roles> … … 3109 3109 </optional> 3110 3110 <roles> 3111 <role key="stop" text="stop position" requisite="optional" type="node" member_expression="public_transport=stop_position (bus OR trolleybus)" />3112 <role key="stop_exit_only" text="stop position (exit only)" requisite="optional" type="node" member_expression="public_transport=stop_position (bus OR trolleybus)" />3113 <role key="stop_entry_only" text="stop position (entry only)" requisite="optional" type="node" member_expression="public_transport=stop_position (bus OR trolleybus)" />3114 <role key="platform" text="platform" requisite="optional" type="node,way,closedway,multipolygon" member_expression="public_transport=platform (bus OR trolleybus)" />3115 <role key="platform_exit_only" text="platform (exit only)" requisite="optional" type="node,way,closedway" member_expression="public_transport=platform (bus OR trolleybus)" />3116 <role key="platform_entry_only" text="platform (entry only)" requisite="optional" type="node,way,closedway" member_expression="public_transport=platform (bus OR trolleybus)" />3111 <role key="stop" text="stop position" requisite="optional" type="node" member_expression="public_transport=stop_position (bus=yes OR trolleybus=yes)" /> 3112 <role key="stop_exit_only" text="stop position (exit only)" requisite="optional" type="node" member_expression="public_transport=stop_position (bus=yes OR trolleybus=yes)" /> 3113 <role key="stop_entry_only" text="stop position (entry only)" requisite="optional" type="node" member_expression="public_transport=stop_position (bus=yes OR trolleybus=yes)" /> 3114 <role key="platform" text="platform" requisite="optional" type="node,way,closedway,multipolygon" member_expression="public_transport=platform (bus=yes OR trolleybus=yes)" /> 3115 <role key="platform_exit_only" text="platform (exit only)" requisite="optional" type="node,way,closedway" member_expression="public_transport=platform (bus=yes OR trolleybus=yes)" /> 3116 <role key="platform_entry_only" text="platform (entry only)" requisite="optional" type="node,way,closedway" member_expression="public_transport=platform (bus=yes OR trolleybus=yes)" /> 3117 3117 <role key="" text="route segment" requisite="required" type="way,closedway" member_expression="highway" /> 3118 3118 </roles> -
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r9574 r9932 25 25 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 26 26 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 27 import org.openstreetmap.josm.gui.tagging.presets.items.Key ;27 import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem; 28 28 import org.openstreetmap.josm.gui.tagging.presets.items.Roles; 29 29 import org.openstreetmap.josm.gui.tagging.presets.items.Roles.Role; … … 145 145 146 146 for (TaggingPreset p : relationpresets) { 147 boolean matches = true; 148 Roles r = null; 149 for (TaggingPresetItem i : p.data) { 150 if (i instanceof Key) { 151 Key k = (Key) i; 152 if (!k.value.equals(n.get(k.key))) { 153 matches = false; 154 break; 155 } 156 } else if (i instanceof Roles) { 157 r = (Roles) i; 158 } 159 } 147 final boolean matches = TaggingPresetItem.matches(Utils.filteredCollection(p.data, KeyedItem.class), n.getKeys()); 148 final Roles r = Utils.find(p.data, Roles.class); 160 149 if (matches && r != null) { 161 150 for (Role role: r.roles) { -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r9623 r9932 562 562 else if (!typeMatches(t)) 563 563 return false; 564 boolean atLeastOnePositiveMatch = false; 565 for (TaggingPresetItem item : data) { 566 Boolean m = item.matches(tags); 567 if (m != null && !m) 568 return false; 569 else if (m != null) { 570 atLeastOnePositiveMatch = true; 571 } 572 } 573 return atLeastOnePositiveMatch; 564 else 565 return TaggingPresetItem.matches(data, tags); 574 566 } 575 567 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java
r9574 r9932 134 134 return imgProv.get(); 135 135 } 136 137 /** 138 * Determine whether the given preset items match the tags 139 * @param data the preset items 140 * @param tags the tags to match 141 * @return whether the given preset items match the tags 142 * @sice 9932 143 */ 144 public static boolean matches(Iterable<? extends TaggingPresetItem> data, Map<String, String> tags) { 145 boolean atLeastOnePositiveMatch = false; 146 for (TaggingPresetItem item : data) { 147 Boolean m = item.matches(tags); 148 if (m != null && !m) 149 return false; 150 else if (m != null) { 151 atLeastOnePositiveMatch = true; 152 } 153 } 154 return atLeastOnePositiveMatch; 155 } 136 156 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/RelationCheckerTest.groovy
r8863 r9932 118 118 assert errors.get(0).getDescription() == "Role member does not match expression power in template Power Route" 119 119 } 120 121 void testRouteMemberExpression() { 122 def r = createRelation("type=route route=tram public_transport:version=2") 123 r.addMember(new RelationMember("", createPrimitive("way railway=tram"))) 124 r.addMember(new RelationMember("stop", createPrimitive("node public_transport=stop_position tram=yes"))) 125 r.addMember(new RelationMember("platform", createPrimitive("node public_transport=platform tram=yes"))) 126 assert testRelation(r).size() == 0 127 128 r.addMember(new RelationMember("", createPrimitive("way no-rail-way=yes"))) 129 assert testRelation(r).size() == 1 130 assert testRelation(r).get(0).getDescription() == "Role member does not match expression railway in template Public Transport Route (Rail)" 131 132 r.removeMember(3) 133 r.addMember(new RelationMember("stop", createPrimitive("way no-rail-way=yes"))) 134 assert testRelation(r).size() == 1 135 assert testRelation(r).get(0).getDescription() == "Role member type way does not match accepted list of node in template Public Transport Route (Rail)" 136 137 r.removeMember(3) 138 r.addMember(new RelationMember("stop", createPrimitive("node public_transport=stop_position bus=yes"))) 139 assert testRelation(r).size() == 1 140 assert testRelation(r).get(0).getDescription() == "Role member does not match expression public_transport=stop_position && (train=yes || subway=yes || monorail=yes || tram=yes || light_rail=yes) in template Public Transport Route (Rail)" 141 } 120 142 }
Note:
See TracChangeset
for help on using the changeset viewer.