Changeset 9584 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-01-23T15:35:52+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r9583 r9584 24 24 import org.openstreetmap.josm.data.osm.Way; 25 25 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon; 26 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.PolyData; 26 27 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.PolyData.Intersection; 27 28 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; … … 300 301 primitives.add(r); 301 302 primitives.addAll(openNodes); 302 addError(r, new TestError(this, Severity.WARNING, tr("Multipolygon is not closed"), NON_CLOSED_WAY, 303 primitives, openNodes)); 303 addError(r, new TestError(this, Severity.WARNING, tr("Multipolygon is not closed"), NON_CLOSED_WAY, primitives, openNodes)); 304 304 } 305 305 306 306 // For painting is used Polygon class which works with ints only. For validation we need more precision 307 List<GeneralPath> outerPolygons = createPolygons(polygon.getOuterPolygons()); 308 for (Multipolygon.PolyData pdInner : polygon.getInnerPolygons()) { 307 List<PolyData> innerPolygons = polygon.getInnerPolygons(); 308 List<PolyData> outerPolygons = innerPolygons.isEmpty() ? Collections.<PolyData>emptyList() : polygon.getOuterPolygons(); 309 List<GeneralPath> innerPolygonsPaths = innerPolygons.isEmpty() ? Collections.<GeneralPath>emptyList() : createPolygons(innerPolygons); 310 List<GeneralPath> outerPolygonsPaths = innerPolygons.isEmpty() ? Collections.<GeneralPath>emptyList() : createPolygons(outerPolygons); 311 for (int i = 0; i < innerPolygons.size(); i++) { 312 PolyData pdInner = innerPolygons.get(i); 313 // Check for intersection between inner members 314 for (int j = i+1; j < innerPolygons.size(); j++) { 315 checkCrossingWays(r, innerPolygons, innerPolygonsPaths, pdInner, j); 316 } 317 // Check for intersection between inner and outer members 309 318 boolean outside = true; 310 for (int i = 0; i < polygon.getOuterPolygons().size(); i++) { 311 Intersection intersection = getPolygonIntersection(outerPolygons.get(i), pdInner.getNodes()); 312 outside = outside & intersection == Intersection.OUTSIDE; 313 if (intersection == Intersection.CROSSING) { 314 Multipolygon.PolyData outerWay = polygon.getOuterPolygons().get(i); 315 if (outerWay != null) { 316 addError(r, new TestError(this, Severity.WARNING, tr("Intersection between multipolygon ways"), 317 CROSSING_WAYS, Collections.singletonList(r), Arrays.asList(pdInner.getNodes(), outerWay.getNodes()))); 318 } 319 } 319 for (int o = 0; o < outerPolygons.size(); o++) { 320 outside &= checkCrossingWays(r, outerPolygons, outerPolygonsPaths, pdInner, o) == Intersection.OUTSIDE; 320 321 } 321 322 if (outside) { … … 324 325 } 325 326 } 327 } 328 329 private Intersection checkCrossingWays(Relation r, List<PolyData> polygons, List<GeneralPath> polygonsPaths, PolyData pd, int idx) { 330 Intersection intersection = getPolygonIntersection(polygonsPaths.get(idx), pd.getNodes()); 331 if (intersection == Intersection.CROSSING) { 332 PolyData pdOther = polygons.get(idx); 333 if (pdOther != null) { 334 addError(r, new TestError(this, Severity.WARNING, tr("Intersection between multipolygon ways"), 335 CROSSING_WAYS, Collections.singletonList(r), Arrays.asList(pd.getNodes(), pdOther.getNodes()))); 336 } 337 } 338 return intersection; 326 339 } 327 340
Note:
See TracChangeset
for help on using the changeset viewer.