/** * @return The underlying {@link PolyLine}, which will not have the end {@link Location} equal * to the start {@link Location}. i.e. the area will not be closed. */ @Override public Iterable<Location> getRawGeometry() { return asPolygon(); }
@Override public Polygon asPolygon() { return getRepresentativeSubArea().asPolygon(); }
@Override public Rectangle bounds() { return asPolygon().bounds(); }
@Override public boolean intersects(final GeometricSurface surface) { return surface.overlaps(asPolygon()); }
@Override public String toString() { return "[Area: id=" + this.getIdentifier() + ", polygon=" + this.asPolygon() + ", " + tagString() + "]"; }
private boolean areaCoversInitialShardBounds(final Area area) { return this.policy.getInitialShardsBounds().overlaps(area.asPolygon()); }
/** * Create a new spatial index * * @return A newly created spatial index */ private SpatialIndex<Area> newAreaSpatialIndex() { return newSpatialIndex((item, bounds) -> bounds.overlaps(item.asPolygon()), this::area); }
/** * @return The closed {@link Polygon}, with the end {@link Location} equal to the start * {@link Location}. */ public Polygon getClosedGeometry() { return new Polygon(asPolygon().closedLoop()); }
@Override public JsonObject asGeoJsonGeometry() { return GeoJsonUtils.feature(asPolygon().asGeoJsonGeometry(), geoJsonProperties()); }
@Override public String toDiffViewFriendlyString() { final String relationsString = this.parentRelationsAsDiffViewFriendlyString(); return "[Area: id=" + this.getIdentifier() + ", polygon=" + this.asPolygon() + ", relations=(" + relationsString + "), " + tagString() + "]"; }
@Override public Iterable<Area> areasIntersecting(final Polygon polygon) { return Iterables.stream(this.getAreaSpatialIndex().get(polygon.bounds())).filter(area -> { final Polygon areaPolygon = area.asPolygon(); return polygon.overlaps(areaPolygon); }); }
@Override public Iterable<Area> areasWithin(final Polygon polygon) { return Iterables.stream(this.getAreaSpatialIndex().get(polygon.bounds())).filter(area -> { final Polygon areaPolygon = area.asPolygon(); return polygon.fullyGeometricallyEncloses(areaPolygon); }); }
@Override public Iterable<Area> areasCovering(final Location location) { return Iterables.stream(this.getAreaSpatialIndex().get(location.bounds())).filter(area -> { final Polygon areaPolygon = area.asPolygon(); return areaPolygon.fullyGeometricallyEncloses(location); }); }
private String convertArea(final Area item) { final StringList list = new StringList(); list.add(item.getIdentifier()); list.add(item.asPolygon().toCompactString()); list.add(convertTags(item)); return list.join(SEPARATOR); }