Changeset 14408 in josm
 Timestamp:
 20181103T12:00:27+01:00 (5 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r12941 r14408 266 266 return; 267 267 268 Set<Node> sharedNodes = findIntersectionNodes(r); 268 Set<Node> sharedNodes = new HashSet<>(); 269 Set<Way> intersectionWays = new HashSet<>(); 270 findIntersectionNodes(r, sharedNodes, intersectionWays); 271 269 272 List<PolyData> innerPolygons = polygon.getInnerPolygons(); 270 273 List<PolyData> outerPolygons = polygon.getOuterPolygons(); … … 272 275 allPolygons.addAll(outerPolygons); 273 276 allPolygons.addAll(innerPolygons); 277 274 278 Map<PolyData, List<PolyData>> crossingPolyMap = findIntersectingWays(r, innerPolygons, outerPolygons); 275 279 … … 278 282 PolyData pd1 = allPolygons.get(i); 279 283 checkPolygonForSelfIntersection(r, pd1); 284 // check if this ring has a way that is known to intersect with another way 285 286 if (!hasIntersectionWay(pd1, intersectionWays)) 287 continue; 288 280 289 for (int j = i + 1; j < allPolygons.size(); j++) { 281 290 PolyData pd2 = allPolygons.get(j); 282 291 if (!checkProblemMap(crossingPolyMap, pd1, pd2)) { 283 checkPolygonsForSharedNodes(r, pd1, pd2, sharedNodes); 292 if (hasIntersectionWay(pd2, intersectionWays)) 293 checkPolygonsForSharedNodes(r, pd1, pd2, sharedNodes); 284 294 } 285 295 } … … 298 308 checkRoles(r, allPolygons, wayMap, sharedNodes); 299 309 } 310 } 311 312 /** 313 * Simple check if given ring contains way that is known to intersect. 314 * @param pd the ring 315 * @param intersectionWays the known intersection ways 316 * @return true if one or more ways are in the set of known ways 317 */ 318 private boolean hasIntersectionWay(PolyData pd, Set<Way> intersectionWays) { 319 for (Way w : intersectionWays) { 320 if (pd.getWayIds().contains(w.getUniqueId())) { 321 return true; 322 } 323 } 324 return false; 300 325 } 301 326 … … 340 365 * or two times in one way and at least once in another way we found an intersection. 341 366 * @param r the relation 342 * @ return List of nodes were ways intersect343 * /344 private static Set<Node> findIntersectionNodes(Relation r) {345 Set<Node> intersectionNodes = new HashSet<>();367 * @param sharedNodes We be filled with shared nodes 368 * @param intersectionWays We be filled with ways that have a shared node 369 */ 370 private static void findIntersectionNodes(Relation r, Set<Node> sharedNodes, Set<Way> intersectionWays) { 346 371 Map<Node, List<Way>> nodeMap = new HashMap<>(); 347 372 for (RelationMember rm : r.getMembers()) { … … 361 386 ways.add(rm.getWay()); 362 387 if (ways.size() > 2  (ways.size() == 2 && i != 0 && i + 1 != numNodes)) { 363 intersectionNodes.add(n);364 }365 }366 }367 return intersectionNodes;388 sharedNodes.add(n); 389 intersectionWays.addAll(ways); 390 } 391 } 392 } 368 393 } 369 394
Note: See TracChangeset
for help on using the changeset viewer.