@Override public PolyLine asPolyLine() { return this.source.asPolyLine(); }
@Override public PolyLine asPolyLine() { return this.edge.asPolyLine(); }
@Override public PolyLine asPolyLine() { return this.getSubEdge().asPolyLine(); }
public SnappedEdge(final SnappedLocation snap, final Edge edge) { super(snap.getOrigin(), snap, edge.asPolyLine()); this.edge = edge; }
public boolean isSameDirection(final Edge edgeA, final Edge edgeB, final boolean useOverallHeading) { // If they are reversed edges, then they are in opposite directions if (!edgeA.isReversedEdge(edgeB)) { return isSameDirection(edgeA.asPolyLine(), edgeB.asPolyLine(), useOverallHeading); } return false; }
@Override public PolyLine asPolyLine() { return subEdge().asPolyLine(); }
public boolean isOppositeDirection(final Edge incomingEdge, final Edge outgoingEdge, final boolean useOverallHeading) { if (incomingEdge.isReversedEdge(outgoingEdge)) { return true; } return isOppositeDirection(incomingEdge.asPolyLine(), outgoingEdge.asPolyLine(), useOverallHeading); }
/** * Create a new spatial index * * @return A newly created spatial index */ private SpatialIndex<Edge> newEdgeSpatialIndex() { return newSpatialIndex((item, bounds) -> bounds.overlaps(item.asPolyLine()), this::edge); }
@Override protected double getValue(final Edge item) { return item.asPolyLine().size() / item.length().asKilometers(); }
public static CompleteEdge from(final Edge edge) { return new CompleteEdge(edge.getIdentifier(), edge.asPolyLine(), edge.getTags(), edge.start().getIdentifier(), edge.end().getIdentifier(), edge.relations().stream().map(Relation::getIdentifier).collect(Collectors.toSet())); }
@Override public Iterable<Edge> edgesIntersecting(final Polygon polygon) { return Iterables.stream(this.getEdgeSpatialIndex().get(polygon.bounds())).filter(edge -> { final PolyLine polyline = edge.asPolyLine(); return polygon.overlaps(polyline); }); }
@Override public Iterable<Edge> edgesContaining(final Location location) { return Iterables.stream(this.getEdgeSpatialIndex().get(location.bounds())).filter(edge -> { final PolyLine polyline = edge.asPolyLine(); return polyline.contains(location); }); }
@Override public Iterable<Edge> edgesWithin(final Polygon polygon) { return Iterables.stream(this.getEdgeSpatialIndex().get(polygon.bounds())).filter(edge -> { final PolyLine polyline = edge.asPolyLine(); return polygon.fullyGeometricallyEncloses(polyline); }); }
@Override public String toString() { return "[Edge" + ": id=" + this.getIdentifier() + ", startNode=" + start().getIdentifier() + ", endNode=" + end().getIdentifier() + ", polyLine=" + this.asPolyLine().toWkt() + ", " + tagString() + "]"; } }
private String convertEdge(final Edge item) { final StringList list = new StringList(); list.add(item.getIdentifier()); list.add(item.asPolyLine().toCompactString()); list.add(convertTags(item)); return list.join(SEPARATOR); }
@Override public String toDiffViewFriendlyString() { final String relationsString = this.parentRelationsAsDiffViewFriendlyString(); return "[Edge" + ": id=" + this.getIdentifier() + ", startNode=" + start().getIdentifier() + ", endNode=" + end().getIdentifier() + ", polyLine=" + this.asPolyLine().toWkt() + ", relations=(" + relationsString + "), " + tagString() + "]"; }
private void verifyFullContainment(final Atlas atlas) { Assert.assertTrue(atlas.area(1).asPolygon() .fullyGeometricallyEncloses(atlas.edge(159019301).asPolyLine())); Assert.assertTrue(atlas.area(1).asPolygon() .fullyGeometricallyEncloses(atlas.edge(-159019301).asPolyLine())); }
private void verifyIntersection(final Atlas atlas) { Assert.assertTrue(atlas.area(1).asPolygon().intersects(atlas.edge(159019301).asPolyLine())); Assert.assertTrue( atlas.area(1).asPolygon().intersects(atlas.edge(-159019301).asPolyLine())); }
private void verifyNoFullContainment(final Atlas atlas) { Assert.assertFalse(atlas.area(1).asPolygon() .fullyGeometricallyEncloses(atlas.edge(159019301).asPolyLine())); Assert.assertFalse(atlas.area(1).asPolygon() .fullyGeometricallyEncloses(atlas.edge(-159019301).asPolyLine())); }
private void verifyNoOverlap(final Atlas atlas) { Assert.assertFalse(atlas.area(1).asPolygon().overlaps(atlas.edge(159019301).asPolyLine())); Assert.assertFalse(atlas.area(1).asPolygon().overlaps(atlas.edge(-159019301).asPolyLine())); }