| 251 | | if (e.child == null && left.matches(new Environment(w).withParent(e.osm))) { |
| 252 | | if (e.osm instanceof Way && Geometry.PolygonIntersection.CROSSING.equals( |
| 253 | | Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))) { |
| 254 | | e.child = w; |
| | 254 | if (e.parent.isMultipolygon()) { |
| | 255 | if (((Relation) e.parent).hasIncompleteMembers()) |
| | 256 | return; |
| | 257 | if (e.child == null && left.matches(new Environment(w).withParent(w))) { |
| | 258 | Multipolygon polygon = MultipolygonCache.getInstance().get(Main.map.mapView, (Relation) e.parent); |
| | 259 | if (polygon == null) |
| | 260 | return; |
| | 261 | Area a = Geometry.getArea(w.getNodes()); |
| | 262 | for (PolyData pd : polygon.getCombinedPolygons()) { |
| | 263 | Area b = new Area(pd.get()); |
| | 264 | if (Geometry.PolygonIntersection.CROSSING.equals(Geometry.polygonIntersection(a, b))) { |
| | 265 | e.child = w; |
| | 266 | break; |
| | 267 | } |
| | 268 | } |
| | 270 | if (e.child == null) { |
| | 271 | for (OsmPrimitive parent : w.getReferrers()) { |
| | 272 | if (parent.isMultipolygon() && !parent.isIncomplete()) { |
| | 273 | if (e.parent == parent || ((Relation) parent).hasIncompleteMembers() ) |
| | 274 | return; |
| | 275 | if (left.matches(new Environment(parent).withParent(parent))) { |
| | 276 | Multipolygon p1 = MultipolygonCache.getInstance().get(Main.map.mapView, (Relation) e.parent); |
| | 277 | if (p1 == null) |
| | 278 | return; |
| | 279 | Multipolygon p2 = MultipolygonCache.getInstance().get(Main.map.mapView, (Relation) parent); |
| | 280 | if (p2 == null) |
| | 281 | return; |
| | 282 | for (PolyData pd1 : p1.getCombinedPolygons()) { |
| | 283 | Area a = new Area(pd1.get()); |
| | 284 | for (PolyData pd2 : p2.getCombinedPolygons()) { |
| | 285 | Area b = new Area(pd2.get()); |
| | 286 | if (Geometry.PolygonIntersection.CROSSING.equals(Geometry.polygonIntersection(a, b))) { |
| | 287 | e.child = w; |
| | 288 | break; |
| | 289 | } |
| | 290 | } |
| | 291 | if (e.child != null) |
| | 292 | break; |
| | 293 | } |
| | 294 | } |
| | 295 | } |
| | 296 | if (e.child != null) |
| | 297 | break; |
| | 298 | } |
| | 299 | } |
| | 300 | |
| | 301 | } else { |
| | 302 | if (e.child == null && left.matches(new Environment(w).withParent(e.osm))) { |
| | 303 | if (e.osm instanceof Way && Geometry.PolygonIntersection.CROSSING.equals( |
| | 304 | Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))) { |
| | 305 | e.child = w; |
| | 306 | } |
| | 307 | } |
| | 403 | } else if (ChildOrParentSelectorType.CROSSING.equals(type) && e.osm.isMultipolygon()) { |
| | 404 | List<RelationMember> members = ((Relation) e.osm).getMembers(); |
| | 405 | for (int i = 0; i < members.size(); i++) { |
| | 406 | OsmPrimitive member = members.get(i).getMember(); |
| | 407 | if (member instanceof Way) { |
| | 408 | Environment ew = new Environment(member); |
| | 409 | ew.parent = e.osm; |
| | 410 | final CrossingFinder crossingFinder = new CrossingFinder(ew); |
| | 411 | if (right instanceof OptimizedGeneralSelector |
| | 412 | && ((OptimizedGeneralSelector) right).matchesBase(OsmPrimitiveType.WAY)) { |
| | 413 | crossingFinder.visit(ew.osm.getDataSet().searchWays(ew.osm.getBBox())); |
| | 414 | if (ew.child != null) { |
| | 415 | e.child = ew.child; |
| | 416 | } |
| | 417 | } |
| | 418 | } |
| | 419 | } |
| | 420 | return e.child != null; |