@Override public boolean fullyGeometricallyEncloses(final Rectangle item) { return this.fullyGeometricallyEncloses((Located) item); }
@Override public boolean fullyGeometricallyEncloses(final Location item) { return this.fullyGeometricallyEncloses((Located) item); }
/** * Create a new spatial index * * @return A newly created spatial index */ private SpatialIndex<Node> newNodeSpatialIndex() { return newSpatialIndex((item, bounds) -> bounds.fullyGeometricallyEncloses(item), this::node); }
/** * Create a new spatial index * * @return A newly created spatial index */ private SpatialIndex<Point> newPointSpatialIndex() { return newSpatialIndex((item, bounds) -> bounds.fullyGeometricallyEncloses(item), this::point); }
public Set<Node> leafNodesCovering(final Location location) { final Set<Node> result = new HashSet<>(); if (bounds().fullyGeometricallyEncloses(location)) { if (isFinal()) { result.add(this); } else { for (final Node child : this.children) { result.addAll(child.leafNodesCovering(location)); } } } return result; }
/** * Choose the first shard that overlaps the start point of the PolyLine as sorted by the * SlippyTile class * * @param item * located item to insert * @param possibleBuckets * possible buckets for the item to work into * @return */ @Override protected Shard resolveShard(final PolyLine item, final List<? extends Shard> possibleBuckets) { final Location start = Iterables.head(item); return possibleBuckets.stream().map(shard -> (SlippyTile) shard) .filter(shard -> shard.bounds().fullyGeometricallyEncloses(start)).sorted() .findFirst().get(); } }
@Override public Iterable<? extends Shard> shardsCovering(final Location location) { return Iterables.stream(SlippyTile.allTiles(this.zoom, location.bounds())) .filter(slippyTile -> slippyTile.bounds().fullyGeometricallyEncloses(location)); }
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; }
@Test public void testRandom() { final Rectangle bounds = Rectangle.TEST_RECTANGLE; final Polygon randomPolygon = Polygon.random(50, bounds); for (final Location point : randomPolygon) { Assert.assertTrue(bounds.fullyGeometricallyEncloses(point)); } final PolyLine randomPolyLine = PolyLine.random(50, bounds); for (final Location point : randomPolyLine) { Assert.assertTrue(bounds.fullyGeometricallyEncloses(point)); } }
@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)); }
if (this.fullyGeometricallyEncloses(other)) if (other.fullyGeometricallyEncloses(this)) if (other.fullyGeometricallyEncloses(missing)) if (this.fullyGeometricallyEncloses(missing)) if (other.fullyGeometricallyEncloses(missing)) if (this.fullyGeometricallyEncloses(missing))
@Test public void testCoversAndCoversPartially() { Assert.assertTrue("Rectangle 3 fully contains rectangle 2", this.rectangle3.fullyGeometricallyEncloses(this.rectangle2)); Assert.assertTrue("That means, it should also cover it partially", this.rectangle3.overlaps(this.rectangle2)); Assert.assertTrue("Rectangle 3 only partially covers rectangle 4", this.rectangle3.overlaps(this.rectangle4)); Assert.assertFalse("It should not fully contain it", this.rectangle3.fullyGeometricallyEncloses(this.rectangle4)); Assert.assertTrue("Rectangle 2 only partly overlaps rectangle 4", this.rectangle2.overlaps(this.rectangle4)); Assert.assertFalse("But does not fully contain it", this.rectangle2.fullyGeometricallyEncloses(this.rectangle4)); }
@Test public void testIntersectsAndCoversWithPolyLine() { final PolyLine polyLine = new PolyLine(this.location1, this.location2); Assert.assertTrue("Larger rectangle intersects polyline", this.rectangle4.intersects(polyLine)); Assert.assertTrue("Smaller rectangle intersects polyline", this.rectangle3.intersects(polyLine)); Assert.assertTrue("Smaller rectangle only touches the polyline, but does not cover it", this.rectangle3.fullyGeometricallyEncloses(polyLine)); Assert.assertFalse("Larger rectangle fully contains the polyline", this.rectangle4.fullyGeometricallyEncloses(polyLine)); }
if (!bounds.fullyGeometricallyEncloses(rectangle))
@Test public void testPoint() { final Point point1 = this.atlas.point(1); final Point point2 = this.atlas.point(2); final Point point3 = this.atlas.point(3); final Point point4 = this.atlas.point(4); final Point point5 = this.atlas.point(5); final Point point6 = this.atlas.point(6); final Point point7 = this.atlas.point(7); logger.trace(point1.toString()); logger.trace(point2.toString()); logger.trace(point3.toString()); logger.trace(point4.toString()); logger.trace(point5.toString()); logger.trace(point6.toString()); logger.trace(point7.toString()); Assert.assertTrue(Location.TEST_3.boxAround(Distance.ONE_METER) .fullyGeometricallyEncloses(point1.getLocation())); Assert.assertTrue(Location.TEST_3.boxAround(Distance.kilometers(2)) .fullyGeometricallyEncloses(point3.getLocation())); Assert.assertEquals(1, Iterables .size(this.atlas.pointsWithin(Location.TEST_3.boxAround(Distance.ONE_METER)))); Assert.assertEquals(3, Iterables .size(this.atlas.pointsWithin(Location.TEST_3.boxAround(Distance.kilometers(2))))); final Rectangle box = Location.TEST_3.boxAround(Distance.ONE_METER); Assert.assertEquals(1, Iterables.size( this.atlas.points(point -> box.fullyGeometricallyEncloses(point.getLocation())))); }