@Override public Rectangle bounds() { return this.location.bounds(); }
@Override public Rectangle bounds() { return getLocation().bounds(); }
@Override public Rectangle bounds() { if (locationItem != null) { return locationItem.bounds(); } else { return point.bounds(); } }
@Override public Iterable<Point> pointsAt(final Location location) { return this.getPointSpatialIndex().get(location.bounds()); }
@Override public Iterable<Node> nodesAt(final Location location) { return this.getNodeSpatialIndex().get(location.bounds()); }
public CompletePoint(final Long identifier, final Location location, 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 = location != null ? location.bounds() : null; this.aggregateBounds = this.originalBounds; this.identifier = identifier; this.location = location; this.tags = tags; this.relationIdentifiers = relationIdentifiers; }
@SuppressWarnings("unchecked") private void buildLocationTree(final JtsSpatialIndex<Location> index, final List<Location>... lists) { for (final List<Location> list : lists) { list.forEach(location -> index.add(location.bounds(), location)); } }
public static CompletePoint shallowFrom(final Point point) { return new CompletePoint(point.getIdentifier()) .withInitialBounds(point.getLocation().bounds()); }
/** * Create a shallow copy of a given node. All fields (except the identifier and the geometry) * are left null until updated by a with() call. * * @param node * the {@link Node} to copy * @return the new {@link CompleteNode} */ public static CompleteNode shallowFrom(final Node node) { return new CompleteNode(node.getIdentifier()) .withInitialBounds(node.getLocation().bounds()); }
/** * Query country boundaries which cover given {@link Location} * * @param location * Any {@link Location} * @return a list of {@link CountryBoundary} */ public List<CountryBoundary> boundaries(final Location location) { return this.boundariesHelper(() -> this.query(location.bounds().asEnvelope()), boundary -> boundary.covers(JTS_POINT_CONVERTER.convert(location))); }
@Override public Iterable<? extends Shard> shardsCovering(final Location location) { return Iterables.stream(SlippyTile.allTiles(this.zoom, location.bounds())) .filter(slippyTile -> slippyTile.bounds().fullyGeometricallyEncloses(location)); }
@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<Area> areasCovering(final Location location) { return Iterables.stream(this.getAreaSpatialIndex().get(location.bounds())).filter(area -> { final Polygon areaPolygon = area.asPolygon(); return areaPolygon.fullyGeometricallyEncloses(location); }); }
@Override public Iterable<Line> linesContaining(final Location location) { return Iterables.stream(this.getLineSpatialIndex().get(location.bounds())).filter(line -> { final PolyLine polyline = line.asPolyLine(); return polyline.contains(location); }); }
@Test public void testIsland() { final TimeZoneMap map = new TimeZoneMap(BERMUDA_INSIDE.bounds().expand(Distance.miles(50))); Assert.assertEquals("Atlantic/Bermuda", map.timeZone(BERMUDA_INSIDE).getID()); Assert.assertEquals("Atlantic/Bermuda", map.timeZone(BERMUDA_OUTSIDE_CLOSE).getID()); // in the middle of the sea Assert.assertEquals("GMT-04:00", map.timeZone(BERMUDA_OUTSIDE_FARAWAY).getID()); } }
@Test public void testBoundary() { final TimeZoneMap map = new TimeZoneMap( LOCATION_IN_NEVADA.bounds().expand(Distance.miles(50))); Assert.assertEquals("America/Los_Angeles", map.timeZone(LOCATION_IN_NEVADA).getID()); Assert.assertEquals("America/Boise", map.timeZone(LOCATION_IN_IDAHO).getID()); Assert.assertEquals("America/Denver", map.timeZone(LOCATION_IN_UTAH).getID()); }
@Test public void testArizonaMultiPolygon() { final TimeZoneMap map = new TimeZoneMap( ARIZONA_MULTI_POLYGON_LEVEL_3.bounds().expand(Distance.miles(50))); Assert.assertEquals("America/Denver", map.timeZone(ARIZONA_MULTI_POLYGON_LEVEL_3).getID()); Assert.assertEquals("America/Phoenix", map.timeZone(ARIZONA_MULTI_POLYGON_LEVEL_2).getID()); Assert.assertEquals("America/Denver", map.timeZone(ARIZONA_MULTI_POLYGON_LEVEL_1).getID()); }
@Test public void testRawAtlasCreationWithBoundingBox() { final String path = RawAtlasGeneratorTest.class.getResource("9-433-268.osm.pbf").getPath(); final RawAtlasGenerator rawAtlasGenerator = new RawAtlasGenerator(new File(path), MultiPolygon.forPolygon(Location.forWkt("POINT (124.9721500 -8.9466200)").bounds() .expand(Distance.meters(100)))); final Atlas atlas = rawAtlasGenerator.build(); // Verify Atlas Entities assertBasicRawAtlasPrinciples(atlas); Assert.assertEquals(1361, atlas.numberOfPoints()); Assert.assertEquals(25, atlas.numberOfLines()); Assert.assertEquals(0, atlas.numberOfRelations()); }