@Override protected boolean isValid(final Relation item, final Rectangle bounds) { return item.intersects(bounds); }
/** * Create a new spatial index * * @return A newly created spatial index */ private SpatialIndex<Relation> newRelationSpatialIndex() { return newSpatialIndex((item, bounds) -> item.intersects(bounds), this::relation); }
@Test public void testIntersects() { final boolean intersects3 = this.combined.relation(3).intersects(Polygon.SILICON_VALLEY); logger.info("Relation 3: {}", intersects3); final boolean intersects4 = this.combined.relation(4).intersects(Polygon.SILICON_VALLEY); logger.info("Relation 4: {}", intersects4); } }
@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)); }