private Predicate<Edge> intersectsCoreWayInvalidly(final Area building) { // An invalid intersection is determined by checking that its highway tag is car navigable // or core way based on the configuration value return edge -> (this.carNavigableEdgesOnly ? HighwayTag.isCarNavigableHighway(edge) : HighwayTag.isCoreWay(edge)) // And if the edge intersects the building polygon && edge.asPolyLine().intersects(building.asPolygon()) // And ignore intersections where edge has highway=service and building has // Amenity=fuel && !(HIGHWAY_SERVICE_TAG.test(edge) && Validators.isOfType(building, AmenityTag.class, AmenityTag.FUEL)) // And if the layers have the same layer value && LayerTag.getTaggedValue(edge).orElse(0L) .equals(LayerTag.getTaggedValue(building).orElse(0L)) // And if the building/edge intersection is not valid && !isValidIntersection(building, edge) // And if the edge has no Access = Private tag && !Validators.isOfType(edge, AccessTag.class, AccessTag.PRIVATE); }
public Set<Node> leafNodesIntersecting(final PolyLine polyLine) { final Set<Node> result = new HashSet<>(); final Rectangle polyLineBounds = polyLine.bounds(); if (polyLineBounds.overlaps(bounds())) { if (isFinal() && (polyLine.intersects(bounds()) || bounds().fullyGeometricallyEncloses(polyLine))) { result.add(this); } else { for (final Node child : this.children) { result.addAll(child.leafNodesIntersecting(polyLine)); } } } return result; }
@Override public Iterable<? extends Shard> shardsIntersecting(final PolyLine polyLine) { return Iterables.stream(SlippyTile.allTiles(this.zoom, polyLine.bounds())) .filter(slippyTile -> polyLine.intersects(slippyTile.bounds()) || slippyTile.bounds().fullyGeometricallyEncloses(polyLine)); }
Assert.assertTrue(line2.asPolyLine().intersects(line3.asPolyLine())); Assert.assertFalse(line1.asPolyLine().intersects(line3.asPolyLine()));