- Timestamp:
- 2020-01-12T14:54:20+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r15515 r15691 8 8 import java.util.Arrays; 9 9 import java.util.HashMap; 10 import java.util.HashSet; 10 11 import java.util.List; 11 12 import java.util.Map; 12 13 import java.util.Objects; 14 import java.util.Set; 13 15 14 16 import org.openstreetmap.josm.data.coor.EastNorth; … … 214 216 @Override 215 217 public boolean isPrimitiveUsable(OsmPrimitive p) { 216 return super.isPrimitiveUsable(p) && p.hasKey("boundary") 217 && (!(p instanceof Relation) || (((Relation) p).isMultipolygon() && !((Relation) p).hasIncompleteMembers()));218 return super.isPrimitiveUsable(p) && p.hasKey("boundary") && !p.hasTag("boundary", "protected_area") 219 && (!(p instanceof Relation) || (((Relation) p).isMultipolygon())); 218 220 } 219 221 220 222 @Override 221 223 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 222 return !Objects.equals(w1.get("boundary"), w2.get("boundary")); 224 // ignore ways which have no common boundary tag value 225 Set<String> s1 = getBoundaryTags(w1); 226 Set<String> s2 = getBoundaryTags(w2); 227 for (String type : s1) { 228 if (s2.contains(type)) 229 return false; 230 } 231 return true; 232 } 233 234 /** 235 * Collect all boundary tag values of the way and its parent relations 236 * @param w the way to check 237 * @return set with the found boundary tag values 238 */ 239 private static Set<String> getBoundaryTags(Way w) { 240 final Set<String> types = new HashSet<>(); 241 String type = w.get("boundary"); 242 if (type != null) 243 types.add(type); 244 w.referrers(Relation.class).filter(Relation::isMultipolygon).map(r -> r.get("boundary")) 245 .filter(Objects::nonNull).forEach(types::add); 246 types.remove("protected_area"); 247 return types; 223 248 } 224 249 … … 226 251 public void visit(Relation r) { 227 252 for (Way w : r.getMemberPrimitives(Way.class)) { 228 visit(w); 253 if (!w.isIncomplete()) 254 visit(w); 229 255 } 230 256 }
Note:
See TracChangeset
for help on using the changeset viewer.