use of de.ii.ogcapi.tiles.domain.TilePoint in project ldproxy by interactive-instruments.
the class TilesHelper method getCenter.
// TODO: move to TileSet as @Value.Lazy
/**
* derive the default view as longitude, latitude, zoom level
* @param tileset the tile set metadata according to the OGC Tile Matrix Set standard
* @return the default view
*/
public static List<Number> getCenter(TileSet tileset) {
TilesBoundingBox bbox = tileset.getBoundingBox();
double centerLon = tileset.getCenterPoint().map(TilePoint::getCoordinates).filter(coord -> coord.size() >= 2).map(coord -> coord.get(0)).orElse(bbox.getLowerLeft()[0].doubleValue() + (bbox.getUpperRight()[0].doubleValue() - bbox.getLowerLeft()[0].doubleValue()) * 0.5);
double centerLat = tileset.getCenterPoint().map(TilePoint::getCoordinates).filter(coord -> coord.size() >= 2).map(coord -> coord.get(1)).orElse(bbox.getLowerLeft()[1].doubleValue() + (bbox.getUpperRight()[1].doubleValue() - bbox.getLowerLeft()[1].doubleValue()) * 0.5);
int defaultZoomLevel = tileset.getCenterPoint().map(TilePoint::getTileMatrix).flatMap(level -> level).map(Integer::valueOf).orElse(0);
return ImmutableList.of(centerLon, centerLat, defaultZoomLevel);
}
Aggregations