Changeset 12002 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-04-25T19:33:21+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r11998 r12002 8 8 import java.util.EnumSet; 9 9 import java.util.HashMap; 10 import java.util.LinkedHashMap; 10 11 import java.util.LinkedList; 11 12 import java.util.List; … … 101 102 @Override 102 103 public void visit(Relation n) { 103 List<Role> allroles = buildAllRoles(n);104 Map<Role, String> allroles = buildAllRoles(n); 104 105 if (allroles.isEmpty() && n.hasTag("type", "route") 105 106 && n.hasTag("route", "train", "subway", "monorail", "tram", "bus", "trolleybus", "aerialway", "ferry")) { … … 141 142 142 143 // return Roles grouped by key 143 private static List<Role> buildAllRoles(Relation n) {144 List<Role> allroles = new LinkedList<>();144 private static Map<Role, String> buildAllRoles(Relation n) { 145 Map<Role, String> allroles = new LinkedHashMap<>(); 145 146 146 147 for (TaggingPreset p : relationpresets) { … … 148 149 final Roles r = Utils.find(p.data, Roles.class); 149 150 if (matches && r != null) { 150 allroles.addAll(r.roles); 151 for (Role role: r.roles) { 152 allroles.put(role, p.name); 153 } 151 154 } 152 155 } … … 185 188 * 186 189 */ 187 private boolean checkMemberExpressionAndType( List<Role> allroles, RelationMember member, Relation n) {190 private boolean checkMemberExpressionAndType(Map<Role, String> allroles, RelationMember member, Relation n) { 188 191 String role = member.getRole(); 189 192 String name = null; … … 193 196 // iterate through all of the role definition within preset 194 197 // and look for any matching definition 195 for (Role r: allroles) { 198 for (Map.Entry<Role, String> e : allroles.entrySet()) { 199 Role r = e.getKey(); 196 200 if (!r.isRole(role)) { 197 201 continue; 198 202 } 199 name = r.key;203 name = e.getValue(); 200 204 types.addAll(r.types); 201 205 if (checkMemberType(r, member)) { … … 266 270 * @param map contains statistics of occurances of specified role types in relation 267 271 */ 268 private void checkRoles(Relation n, List<Role> allroles, Map<String, RoleInfo> map) {272 private void checkRoles(Relation n, Map<Role, String> allroles, Map<String, RoleInfo> map) { 269 273 // go through all members of relation 270 274 for (RelationMember member: n.getMembers()) { … … 274 278 275 279 // verify role counts based on whole role sets 276 for (Role r: allroles ) {280 for (Role r: allroles.keySet()) { 277 281 String keyname = r.key; 278 282 if (keyname.isEmpty()) { … … 287 291 for (String key : map.keySet()) { 288 292 boolean found = false; 289 for (Role r: allroles ) {293 for (Role r: allroles.keySet()) { 290 294 if (r.isRole(key)) { 291 295 found = true; … … 295 299 296 300 if (!found) { 297 String templates = allroles. stream().map(r -> r.key).collect(Collectors.joining("/"));301 String templates = allroles.keySet().stream().map(r -> r.key).collect(Collectors.joining("/")); 298 302 299 303 if (!key.isEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.