Search in sources :

Example 1 with TilesBoundingBox

use of de.ii.ogcapi.tiles.domain.tileMatrixSet.TilesBoundingBox 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);
}
Also used : ImmutableTileSet(de.ii.ogcapi.tiles.domain.ImmutableTileSet) SimpleFeatureGeometry(de.ii.xtraplatform.geometries.domain.SimpleFeatureGeometry) CrsTransformationException(de.ii.xtraplatform.crs.domain.CrsTransformationException) Link(de.ii.ogcapi.foundation.domain.Link) LoggerFactory(org.slf4j.LoggerFactory) EpsgCrs(de.ii.xtraplatform.crs.domain.EpsgCrs) JsonSchemaObject(de.ii.ogcapi.features.core.domain.JsonSchemaObject) VectorLayer(de.ii.ogcapi.tiles.domain.VectorLayer) TileLayer(de.ii.ogcapi.tiles.domain.TileLayer) BigDecimal(java.math.BigDecimal) JsonSchemaDocument(de.ii.ogcapi.features.core.domain.JsonSchemaDocument) Locale(java.util.Locale) Map(java.util.Map) JsonSchemaCache(de.ii.ogcapi.features.core.domain.JsonSchemaCache) FeatureSchema(de.ii.xtraplatform.features.domain.FeatureSchema) RoundingMode(java.math.RoundingMode) FeaturesCoreProviders(de.ii.ogcapi.features.core.domain.FeaturesCoreProviders) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableVectorLayer(de.ii.ogcapi.tiles.domain.ImmutableVectorLayer) OgcApi(de.ii.ogcapi.foundation.domain.OgcApi) Codelist(de.ii.xtraplatform.codelists.domain.Codelist) Collectors(java.util.stream.Collectors) TilePoint(de.ii.ogcapi.tiles.domain.TilePoint) Objects(java.util.Objects) List(java.util.List) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) TileMatrixSet(de.ii.ogcapi.tiles.domain.tileMatrixSet.TileMatrixSet) CrsTransformerFactory(de.ii.xtraplatform.crs.domain.CrsTransformerFactory) Optional(java.util.Optional) BoundingBox(de.ii.xtraplatform.crs.domain.BoundingBox) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) EntityRegistry(de.ii.xtraplatform.store.domain.entities.EntityRegistry) TileMatrixSetLimits(de.ii.ogcapi.tiles.domain.tileMatrixSet.TileMatrixSetLimits) CrsTransformer(de.ii.xtraplatform.crs.domain.CrsTransformer) TileSet(de.ii.ogcapi.tiles.domain.TileSet) AtomicReference(java.util.concurrent.atomic.AtomicReference) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration) ImmutableTileLayer(de.ii.ogcapi.tiles.domain.ImmutableTileLayer) ImmutableTilePoint(de.ii.ogcapi.tiles.domain.ImmutableTilePoint) TileMatrixSetLimitsGenerator(de.ii.ogcapi.tiles.domain.tileMatrixSet.TileMatrixSetLimitsGenerator) SchemaBase(de.ii.xtraplatform.features.domain.SchemaBase) ImmutableList(com.google.common.collect.ImmutableList) OgcCrs(de.ii.xtraplatform.crs.domain.OgcCrs) ImmutableFields(de.ii.ogcapi.tiles.domain.ImmutableFields) Builder(de.ii.ogcapi.tiles.domain.ImmutableTileSet.Builder) Logger(org.slf4j.Logger) ImmutableJsonSchemaObject(de.ii.ogcapi.features.core.domain.ImmutableJsonSchemaObject) MinMax(de.ii.ogcapi.tiles.domain.MinMax) TilesBoundingBox(de.ii.ogcapi.tiles.domain.tileMatrixSet.TilesBoundingBox) URICustomizer(de.ii.ogcapi.foundation.domain.URICustomizer) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) GeoJsonConfiguration(de.ii.ogcapi.features.geojson.domain.GeoJsonConfiguration) JsonSchema(de.ii.ogcapi.features.core.domain.JsonSchema) ImmutableTilesBoundingBox(de.ii.ogcapi.tiles.domain.tileMatrixSet.ImmutableTilesBoundingBox) AbstractMap(java.util.AbstractMap) SchemaInfo(de.ii.ogcapi.features.core.domain.SchemaInfo) TilesBoundingBox(de.ii.ogcapi.tiles.domain.tileMatrixSet.TilesBoundingBox) ImmutableTilesBoundingBox(de.ii.ogcapi.tiles.domain.tileMatrixSet.ImmutableTilesBoundingBox) TilePoint(de.ii.ogcapi.tiles.domain.TilePoint) ImmutableTilePoint(de.ii.ogcapi.tiles.domain.ImmutableTilePoint)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 FeaturesCoreConfiguration (de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration)1 FeaturesCoreProviders (de.ii.ogcapi.features.core.domain.FeaturesCoreProviders)1 ImmutableJsonSchemaObject (de.ii.ogcapi.features.core.domain.ImmutableJsonSchemaObject)1 JsonSchema (de.ii.ogcapi.features.core.domain.JsonSchema)1 JsonSchemaCache (de.ii.ogcapi.features.core.domain.JsonSchemaCache)1 JsonSchemaDocument (de.ii.ogcapi.features.core.domain.JsonSchemaDocument)1 JsonSchemaObject (de.ii.ogcapi.features.core.domain.JsonSchemaObject)1 SchemaInfo (de.ii.ogcapi.features.core.domain.SchemaInfo)1 GeoJsonConfiguration (de.ii.ogcapi.features.geojson.domain.GeoJsonConfiguration)1 FeatureTypeConfigurationOgcApi (de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi)1 Link (de.ii.ogcapi.foundation.domain.Link)1 OgcApi (de.ii.ogcapi.foundation.domain.OgcApi)1 OgcApiDataV2 (de.ii.ogcapi.foundation.domain.OgcApiDataV2)1 URICustomizer (de.ii.ogcapi.foundation.domain.URICustomizer)1 ImmutableFields (de.ii.ogcapi.tiles.domain.ImmutableFields)1 ImmutableTileLayer (de.ii.ogcapi.tiles.domain.ImmutableTileLayer)1 ImmutableTilePoint (de.ii.ogcapi.tiles.domain.ImmutableTilePoint)1 ImmutableTileSet (de.ii.ogcapi.tiles.domain.ImmutableTileSet)1