| 342 | | if (ChildOrParentSelectorType.ELEMENT_OF == type) { |
| 343 | | /* |
| 344 | | if (e.osm instanceof INode || e.osm.getDataSet() == null) { |
| 345 | | // nodes cannot contain elements |
| 346 | | return false; |
| 347 | | } |
| 348 | | |
| 349 | | ContainsFinder containsFinder; |
| 350 | | try { |
| 351 | | // if right selector also matches relations and if matched primitive is a way which is part of a multipolygon, |
| 352 | | // use the multipolygon for further analysis |
| 353 | | if (!(e.osm instanceof IWay) |
| 354 | | || (right instanceof OptimizedGeneralSelector |
| 355 | | && !((OptimizedGeneralSelector) right).matchesBase(OsmPrimitiveType.RELATION))) { |
| 356 | | throw new NoSuchElementException(); |
| 357 | | } |
| 358 | | final Collection<Relation> multipolygons = Utils.filteredCollection(SubclassFilteredCollection.filter( |
| 359 | | e.osm.getReferrers(), p -> p.hasTag("type", "multipolygon")), Relation.class); |
| 360 | | final Relation multipolygon = multipolygons.iterator().next(); |
| 361 | | if (multipolygon == null) throw new NoSuchElementException(); |
| 362 | | final Set<OsmPrimitive> members = multipolygon.getMemberPrimitives(); |
| 363 | | containsFinder = new ContainsFinder(new Environment(multipolygon)) { |
| 364 | | @Override |
| 365 | | public boolean isPrimitiveUsable(IPrimitive p) { |
| 366 | | return super.isPrimitiveUsable(p) && !members.contains(p); |
| 367 | | } |
| 368 | | }; |
| 369 | | } catch (NoSuchElementException ignore) { |
| 370 | | Logging.trace(ignore); |
| 371 | | containsFinder = new ContainsFinder(e); |
| 372 | | } |
| 373 | | e.parent = e.osm; |
| 374 | | |
| 375 | | if (left instanceof OptimizedGeneralSelector) { |
| 376 | | if (((OptimizedGeneralSelector) left).matchesBase(OsmPrimitiveType.NODE)) { |
| 377 | | containsFinder.visit(e.osm.getDataSet().searchNodes(e.osm.getBBox())); |
| 378 | | } |
| 379 | | if (((OptimizedGeneralSelector) left).matchesBase(OsmPrimitiveType.WAY)) { |
| 380 | | containsFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox())); |
| 381 | | } |
| 382 | | } else { |
| 383 | | // use slow test |
| 384 | | containsFinder.visit(e.osm.getDataSet().allPrimitives()); |
| 385 | | } |
| 386 | | |
| 387 | | return e.child != null; |
| 388 | | */ |
| 389 | | } else if (ChildOrParentSelectorType.CROSSING == type && e.osm instanceof IWay) { |
| | 342 | if (ChildOrParentSelectorType.CROSSING == type && e.osm instanceof IWay) { |