Changeset 4869 in josm for trunk/src/org/openstreetmap/josm/data/validation/tests/BuildingInBuilding.java
- Timestamp:
- 2012-01-24T21:52:43+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/BuildingInBuilding.java
r4806 r4869 24 24 public class BuildingInBuilding extends Test { 25 25 26 protected static int BUILDING_INSIDE_BUILDING = 2001;26 protected static final int BUILDING_INSIDE_BUILDING = 2001; 27 27 protected List<OsmPrimitive> primitivesToCheck = new LinkedList<OsmPrimitive>(); 28 28 protected QuadBuckets<Way> index = new QuadBuckets<Way>(); … … 57 57 // Check that all nodes of w are in polygon 58 58 for (Node n : w.getNodes()) { 59 if (!isInPolygon(n, polygon)) {59 if (!isInPolygon(n, polygon)) 60 60 return false; 61 }62 61 } 63 62 // All nodes can be inside polygon and still, w outside: … … 73 72 for (int i=1; i<w.getNodesCount(); i++) { 74 73 LatLon center = w.getNode(i).getCoor().getCenter(w.getNode(i-1).getCoor()); 75 if (center != null && !isInPolygon(new Node(center), polygon)) {74 if (center != null && !isInPolygon(new Node(center), polygon)) 76 75 return false; 77 }78 76 } 79 77 return true; … … 86 84 @Override 87 85 public boolean evaluate(Way object) { 88 if (p.equals(object)) {86 if (p.equals(object)) 89 87 return false; 90 } else if (p instanceof Node) {88 else if (p instanceof Node) 91 89 return isInPolygon((Node) p, object.getNodes()) || object.getNodes().contains(p); 92 } else if (p instanceof Way) {90 else if (p instanceof Way) 93 91 return isInPolygon((Way) p, object.getNodes()) && !isInInnerWay((Way)p, object); 94 } else {92 else 95 93 return false; 96 }97 94 } 98 95 }); … … 103 100 } 104 101 } 105 102 106 103 private boolean isInInnerWay(Way w, Way outer) { 107 104 for (OsmPrimitive r : outer.getReferrers()) { … … 113 110 if (isInPolygon(inner, outer.getNodes())) { 114 111 // If the tested way is inside this inner, outer is a false positive 115 if (isInPolygon(w, inner.getNodes())) {112 if (isInPolygon(w, inner.getNodes())) 116 113 return true; 117 }118 114 } 119 115 }
Note:
See TracChangeset
for help on using the changeset viewer.