Changeset 2948 in josm
- Timestamp:
- 2010-02-07T10:58:30+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
r2793 r2948 4 4 import java.awt.Point; 5 5 import java.awt.Polygon; 6 import java.awt.Rectangle; 6 7 import java.util.ArrayList; 7 8 import java.util.Collection; … … 24 25 public final boolean selected; 25 26 private Point lastP; 27 private Rectangle bounds; 26 28 27 29 public PolyData(NavigatableComponent nc, List<Node> nodes, boolean selected) { … … 68 70 public Polygon get() { 69 71 return poly; 72 } 73 74 public Rectangle getBounds() { 75 if (bounds == null) { 76 bounds = poly.getBounds(); 77 } 78 return bounds; 79 } 80 81 @Override 82 public String toString() { 83 return "Points: " + poly.npoints + " Selected: " + selected; 70 84 } 71 85 } … … 228 242 public PolyData findOuterPolygon(PolyData inner, List<PolyData> outerPolygons) { 229 243 PolyData result = null; 244 245 {// First try to test only bbox, use precise testing only if we don't get unique result 246 Rectangle innerBox = inner.getBounds(); 247 PolyData insidePolygon = null; 248 PolyData intersectingPolygon = null; 249 int insideCount = 0; 250 int intersectingCount = 0; 251 252 for (PolyData outer: outerPolygons) { 253 if (outer.getBounds().contains(innerBox)) { 254 insidePolygon = outer; 255 insideCount++; 256 } else if (outer.getBounds().intersects(innerBox)) { 257 intersectingPolygon = outer; 258 intersectingCount++; 259 } 260 } 261 262 if (insideCount == 1) 263 return insidePolygon; 264 else if (intersectingCount == 1) 265 return intersectingPolygon; 266 } 267 230 268 for (PolyData combined : outerPolygons) { 231 269 Intersection c = combined.contains(inner.poly); 232 270 if(c != Intersection.OUTSIDE) 233 271 { 234 if(result == null || result.contains(combined.poly) != Intersection. OUTSIDE) {272 if(result == null || result.contains(combined.poly) != Intersection.INSIDE) { 235 273 result = combined; 236 274 }
Note: See TracChangeset
for help on using the changeset viewer.