Changeset 12941 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-10-08T11:28:05+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r12905 r12941 277 277 for (int i = 0; i < allPolygons.size(); i++) { 278 278 PolyData pd1 = allPolygons.get(i); 279 checkPolygonForSelfIntersection(r, pd1); 279 280 for (int j = i + 1; j < allPolygons.size(); j++) { 280 281 PolyData pd2 = allPolygons.get(j); … … 296 297 // now we can calculate the nesting level to verify the roles with some simple node checks 297 298 checkRoles(r, allPolygons, wayMap, sharedNodes); 299 } 300 } 301 302 /** 303 * Check if a polygon ring is self-intersecting when the ring was build from multiple ways. 304 * An self intersection in a single way is checked in {@link SelfIntersectingWay}. 305 * @param r the relation 306 * @param pd the ring 307 */ 308 private void checkPolygonForSelfIntersection(Relation r, PolyData pd) { 309 if (pd.getWayIds().size() == 1) 310 return; 311 List<Node> wayNodes = pd.getNodes(); 312 int num = wayNodes.size(); 313 Set<Node> nodes = new HashSet<>(); 314 Node firstNode = wayNodes.get(0); 315 nodes.add(firstNode); 316 List<Node> isNodes = new ArrayList<>(); 317 for (int i = 1; i < num - 1; i++) { 318 Node n = wayNodes.get(i); 319 if (nodes.contains(n)) { 320 isNodes.add(n); 321 } else { 322 nodes.add(n); 323 } 324 } 325 if (!isNodes.isEmpty()) { 326 List<OsmPrimitive> prims = new ArrayList<>(); 327 prims.add(r); 328 prims.addAll(isNodes); 329 errors.add(TestError.builder(this, Severity.WARNING, CROSSING_WAYS) 330 .message(tr("Self-intersecting polygon ring")) 331 .primitives(prims) 332 .highlight(isNodes) 333 .build()); 334 298 335 } 299 336 }
Note:
See TracChangeset
for help on using the changeset viewer.