@Override public Rectangle bounds() { return this.polygon.bounds(); }
@Override public Rectangle bounds() { return this.polygon.bounds(); }
/** * @return the area as degrees */ public Surface area() { return this.polygon.bounds().surface(); }
@Override public Rectangle bounds() { return asPolygon().bounds(); }
public CompleteArea(final Long identifier, final Polygon polygon, final Map<String, String> tags, final Set<Long> relationIdentifiers) { super(new EmptyAtlas()); if (identifier == null) { throw new CoreException("Identifier can never be null."); } this.originalBounds = polygon != null ? polygon.bounds() : null; this.aggregateBounds = this.originalBounds; this.identifier = identifier; this.polygon = polygon; this.tags = tags; this.relationIdentifiers = relationIdentifiers; }
/** * Get all the Atlas intersecting some bounds * * @param bounds * The bounds * @return All the Atlas intersecting the bounds */ public Set<Atlas> atlasIntersecting(final Polygon bounds) { if (!(bounds instanceof Rectangle)) { throw new UnsupportedOperationException("Non-Rectangle Polygons not supported yet."); } return Iterables.asSet(Iterables.translate(this.atlasSpatialIndex.get(bounds.bounds()), atlasIndex -> this.atlases.get(atlasIndex))); }
@Override public Iterable<Relation> relationsWithEntitiesWithin(final Polygon polygon) { final Iterable<Relation> relations = this.getRelationSpatialIndex().get(polygon.bounds()); return Iterables.filter(relations, relation -> relation.within(polygon)); }
@Override public Iterable<Relation> relationsWithEntitiesIntersecting(final Polygon polygon) { final Iterable<Relation> relations = this.getRelationSpatialIndex().get(polygon.bounds()); return Iterables.filter(relations, relation -> relation.intersects(polygon)); }
private boolean awtOverflows() { if (this.awtOverflows == null) { final Rectangle bounds = bounds(); this.awtOverflows = bounds.width().asDm7() <= 0 || bounds.height().asDm7() <= 0; } return this.awtOverflows; }
public static CompleteArea shallowFrom(final Area area) { return new CompleteArea(area.getIdentifier()).withInitialBounds(area.asPolygon().bounds()); }
@Override public Iterable<Node> nodesWithin(final Polygon polygon) { final Iterable<Node> nodes = this.getNodeSpatialIndex().get(polygon.bounds()); if (polygon instanceof Rectangle) { return nodes; } return Iterables.filter(nodes, node -> polygon.fullyGeometricallyEncloses(node.getLocation())); }
@Override public Iterable<Point> pointsWithin(final Polygon polygon) { final Iterable<Point> points = this.getPointSpatialIndex().get(polygon.bounds()); if (polygon instanceof Rectangle) { return points; } return Iterables.filter(points, point -> polygon.fullyGeometricallyEncloses(point.getLocation())); }
@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<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<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<Line> linesWithin(final Polygon polygon) { return Iterables.stream(this.getLineSpatialIndex().get(polygon.bounds())).filter(line -> { final PolyLine polyline = line.asPolyLine(); return polygon.fullyGeometricallyEncloses(polyline); }); }
@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 Iterable<Line> linesIntersecting(final Polygon polygon) { return Iterables.stream(this.getLineSpatialIndex().get(polygon.bounds())).filter(line -> { final PolyLine polyline = line.asPolyLine(); return polygon.overlaps(polyline); }); }
@Test public void testAreasNoIntersectingPolygon() { final Atlas atlas = this.rule.getNoIntersectionAtlas(); final Polygon triangle = new Polygon(Location.forString("47.6263, -122.209198"), Location.forString("47.628685, -122.209305"), Location.forString("47.628704, -122.211761")); Assert.assertEquals("There should be no intersecting area", 0, Iterables.size(atlas.areasIntersecting(triangle))); Assert.assertEquals("There should be no intersecting area", 0, Iterables.size(atlas.areasIntersecting(triangle.bounds()))); }