Ticket #18544: 18544.patch
File 18544.patch, 1.9 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
7 7 import java.util.ArrayList; 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; 15 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 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; 223 232 } 224 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 return types; 247 } 248 225 249 @Override 226 250 public void visit(Relation r) { 227 251 for (Way w : r.getMemberPrimitives(Way.class)) {