Search in sources :

Example 1 with TilesConfiguration

use of de.ii.ogcapi.tiles.domain.TilesConfiguration in project ldproxy by interactive-instruments.

the class AbstractEndpointTileSetSingleCollection method getTileSet.

protected Response getTileSet(OgcApiDataV2 apiData, ApiRequestContext requestContext, String definitionPath, String collectionId, String tileMatrixSetId) {
    checkPathParameter(extensionRegistry, apiData, definitionPath, "collectionId", collectionId);
    checkPathParameter(extensionRegistry, apiData, definitionPath, "tileMatrixSetId", tileMatrixSetId);
    FeatureTypeConfigurationOgcApi featureType = apiData.getCollections().get(collectionId);
    TilesConfiguration tilesConfiguration = featureType.getExtension(TilesConfiguration.class).get();
    TilesQueriesHandler.QueryInputTileSet queryInput = new Builder().from(getGenericQueryInput(apiData)).collectionId(collectionId).tileMatrixSetId(tileMatrixSetId).center(tilesConfiguration.getCenterDerived()).zoomLevels(tilesConfiguration.getZoomLevelsDerived().get(tileMatrixSetId)).path(definitionPath).build();
    return queryHandler.handle(TilesQueriesHandler.Query.TILE_SET, queryInput, requestContext);
}
Also used : FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) TilesQueriesHandler(de.ii.ogcapi.tiles.domain.TilesQueriesHandler) Builder(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileSet.Builder) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration)

Example 2 with TilesConfiguration

use of de.ii.ogcapi.tiles.domain.TilesConfiguration in project ldproxy by interactive-instruments.

the class TileSetsFormatHtml method getTileSetsEntity.

@Override
public Object getTileSetsEntity(TileSets tiles, Optional<String> collectionId, OgcApi api, ApiRequestContext requestContext) {
    String rootTitle = i18n.get("root", requestContext.getLanguage());
    String collectionsTitle = i18n.get("collectionsTitle", requestContext.getLanguage());
    String tilesTitle = i18n.get("tilesTitle", requestContext.getLanguage());
    URICustomizer resourceUri = requestContext.getUriCustomizer().copy().clearParameters();
    final List<NavigationDTO> breadCrumbs = collectionId.isPresent() ? new ImmutableList.Builder<NavigationDTO>().add(new NavigationDTO(rootTitle, resourceUri.copy().removeLastPathSegments(api.getData().getSubPath().size() + 3).toString())).add(new NavigationDTO(api.getData().getLabel(), resourceUri.copy().removeLastPathSegments(3).toString())).add(new NavigationDTO(collectionsTitle, resourceUri.copy().removeLastPathSegments(2).toString())).add(new NavigationDTO(api.getData().getCollections().get(collectionId.get()).getLabel(), resourceUri.copy().removeLastPathSegments(1).toString())).add(new NavigationDTO(tilesTitle)).build() : new ImmutableList.Builder<NavigationDTO>().add(new NavigationDTO(rootTitle, resourceUri.copy().removeLastPathSegments(api.getData().getSubPath().size() + 1).toString())).add(new NavigationDTO(api.getData().getLabel(), resourceUri.copy().removeLastPathSegments(1).toString())).add(new NavigationDTO(tilesTitle)).build();
    Optional<HtmlConfiguration> htmlConfig = collectionId.isPresent() ? api.getData().getExtension(HtmlConfiguration.class, collectionId.get()) : api.getData().getExtension(HtmlConfiguration.class);
    Map<String, TileMatrixSet> tileMatrixSets = tileMatrixSetRepository.getAll();
    Optional<TilesConfiguration> tilesConfig = collectionId.isEmpty() ? api.getData().getExtension(TilesConfiguration.class) : api.getData().getExtension(TilesConfiguration.class, collectionId.get());
    MapClient.Type mapClientType = tilesConfig.map(TilesConfiguration::getMapClientType).orElse(MapClient.Type.MAP_LIBRE);
    String serviceUrl = new URICustomizer(servicesUri).ensureLastPathSegments(api.getData().getSubPath().toArray(String[]::new)).toString();
    String styleUrl = htmlConfig.map(cfg -> cfg.getStyle(tilesConfig.map(TilesConfiguration::getStyle), collectionId, serviceUrl)).orElse(null);
    boolean removeZoomLevelConstraints = tilesConfig.map(TilesConfiguration::getRemoveZoomLevelConstraints).orElse(false);
    return new TileSetsView(api.getData(), tiles, collectionId, api.getSpatialExtent(collectionId), api.getTemporalExtent(collectionId), tileMatrixSets, breadCrumbs, requestContext.getStaticUrlPrefix(), mapClientType, styleUrl, removeZoomLevelConstraints, htmlConfig.orElseThrow(), isNoIndexEnabledForApi(api.getData()), requestContext.getUriCustomizer(), i18n, requestContext.getLanguage());
}
Also used : ImmutableApiMediaTypeContent(de.ii.ogcapi.foundation.domain.ImmutableApiMediaTypeContent) TileSetsFormatExtension(de.ii.ogcapi.tiles.domain.TileSetsFormatExtension) Singleton(javax.inject.Singleton) AutoBind(com.github.azahnen.dagger.annotations.AutoBind) ApiMediaType(de.ii.ogcapi.foundation.domain.ApiMediaType) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration) Inject(javax.inject.Inject) ImmutableApiMediaType(de.ii.ogcapi.foundation.domain.ImmutableApiMediaType) MediaType(javax.ws.rs.core.MediaType) COLLECTION_ID_PATTERN(de.ii.ogcapi.collections.domain.AbstractPathParameterCollectionId.COLLECTION_ID_PATTERN) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) TileMatrixSetRepository(de.ii.ogcapi.tiles.domain.tileMatrixSet.TileMatrixSetRepository) AppContext(de.ii.xtraplatform.base.domain.AppContext) URI(java.net.URI) NavigationDTO(de.ii.ogcapi.html.domain.NavigationDTO) HtmlConfiguration(de.ii.ogcapi.html.domain.HtmlConfiguration) ApiMediaTypeContent(de.ii.ogcapi.foundation.domain.ApiMediaTypeContent) ApiRequestContext(de.ii.ogcapi.foundation.domain.ApiRequestContext) TileSetsView(de.ii.ogcapi.tiles.domain.TileSetsView) I18n(de.ii.ogcapi.foundation.domain.I18n) OgcApi(de.ii.ogcapi.foundation.domain.OgcApi) URICustomizer(de.ii.ogcapi.foundation.domain.URICustomizer) MapClient(de.ii.ogcapi.html.domain.MapClient) List(java.util.List) StringSchema(io.swagger.v3.oas.models.media.StringSchema) TileSets(de.ii.ogcapi.tiles.domain.TileSets) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) TileMatrixSet(de.ii.ogcapi.tiles.domain.tileMatrixSet.TileMatrixSet) Optional(java.util.Optional) ServicesContext(de.ii.xtraplatform.services.domain.ServicesContext) TileMatrixSet(de.ii.ogcapi.tiles.domain.tileMatrixSet.TileMatrixSet) NavigationDTO(de.ii.ogcapi.html.domain.NavigationDTO) HtmlConfiguration(de.ii.ogcapi.html.domain.HtmlConfiguration) ImmutableList(com.google.common.collect.ImmutableList) URICustomizer(de.ii.ogcapi.foundation.domain.URICustomizer) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration) TileSetsView(de.ii.ogcapi.tiles.domain.TileSetsView) MapClient(de.ii.ogcapi.html.domain.MapClient)

Example 3 with TilesConfiguration

use of de.ii.ogcapi.tiles.domain.TilesConfiguration in project ldproxy by interactive-instruments.

the class TilesHelper method buildTileSet.

// TODO: move to TileSet as static of()
/**
 * generate the tile set metadata according to the OGC Tile Matrix Set standard (version 2.0.0, draft from June 2021)
 * @param api the API
 * @param tileMatrixSet the tile matrix set
 * @param zoomLevels the range of zoom levels
 * @param center the center point
 * @param collectionId the collection, empty = all collections in the dataset
 * @param dataType vector, map or coverage
 * @param links links to include in the object
 * @param uriCustomizer optional URI of the resource
 * @param limitsGenerator helper to generate the limits for each zoom level based on the bbox of the data
 * @param providers helper to access feature providers
 * @return the tile set metadata
 */
public static TileSet buildTileSet(OgcApi api, TileMatrixSet tileMatrixSet, MinMax zoomLevels, List<Double> center, Optional<String> collectionId, TileSet.DataType dataType, List<Link> links, Optional<URICustomizer> uriCustomizer, CrsTransformerFactory crsTransformerFactory, TileMatrixSetLimitsGenerator limitsGenerator, FeaturesCoreProviders providers, EntityRegistry entityRegistry) {
    OgcApiDataV2 apiData = api.getData();
    Builder builder = ImmutableTileSet.builder().dataType(dataType);
    builder.tileMatrixSetId(tileMatrixSet.getId());
    if (tileMatrixSet.getURI().isPresent())
        builder.tileMatrixSetURI(tileMatrixSet.getURI().get().toString());
    else
        builder.tileMatrixSet(tileMatrixSet.getTileMatrixSetData());
    uriCustomizer.ifPresent(uriCustomizer1 -> builder.tileMatrixSetDefinition(uriCustomizer1.removeLastPathSegments(collectionId.isPresent() ? 3 : 1).clearParameters().ensureLastPathSegments("tileMatrixSets", tileMatrixSet.getId()).toString()));
    if (Objects.isNull(zoomLevels))
        builder.tileMatrixSetLimits(ImmutableList.of());
    else
        builder.tileMatrixSetLimits(collectionId.isPresent() ? limitsGenerator.getCollectionTileMatrixSetLimits(api, collectionId.get(), tileMatrixSet, zoomLevels) : limitsGenerator.getTileMatrixSetLimits(api, tileMatrixSet, zoomLevels));
    try {
        BoundingBox boundingBox = api.getSpatialExtent(collectionId).orElse(tileMatrixSet.getBoundingBoxCrs84(crsTransformerFactory));
        builder.boundingBox(ImmutableTilesBoundingBox.builder().lowerLeft(BigDecimal.valueOf(boundingBox.getXmin()).setScale(7, RoundingMode.HALF_UP), BigDecimal.valueOf(boundingBox.getYmin()).setScale(7, RoundingMode.HALF_UP)).upperRight(BigDecimal.valueOf(boundingBox.getXmax()).setScale(7, RoundingMode.HALF_UP), BigDecimal.valueOf(boundingBox.getYmax()).setScale(7, RoundingMode.HALF_UP)).crs(OgcCrs.CRS84.toUriString()).build());
    } catch (CrsTransformationException e) {
    // ignore, just skip the boundingBox
    }
    if ((Objects.nonNull(zoomLevels) && zoomLevels.getDefault().isPresent()) || !center.isEmpty()) {
        ImmutableTilePoint.Builder builder2 = new ImmutableTilePoint.Builder();
        if (Objects.nonNull(zoomLevels))
            zoomLevels.getDefault().ifPresent(def -> builder2.tileMatrix(String.valueOf(def)));
        if (!center.isEmpty())
            builder2.coordinates(center);
        builder.centerPoint(builder2.build());
    }
    // prepare a map with the JSON schemas of the feature collections used in the style
    JsonSchemaCache schemas = new SchemaCacheTileSet(() -> entityRegistry.getEntitiesForType(Codelist.class));
    Map<String, JsonSchemaDocument> schemaMap = collectionId.isPresent() ? apiData.getCollectionData(collectionId.get()).filter(collectionData -> {
        Optional<TilesConfiguration> config = collectionData.getExtension(TilesConfiguration.class);
        return collectionData.getEnabled() && config.isPresent() && config.get().isEnabled();
    }).map(collectionData -> {
        Optional<FeatureSchema> schema = providers.getFeatureSchema(apiData, collectionData);
        if (schema.isPresent())
            return ImmutableMap.of(collectionId.get(), schemas.getSchema(schema.get(), apiData, collectionData, Optional.empty()));
        return null;
    }).filter(Objects::nonNull).orElse(ImmutableMap.of()) : apiData.getCollections().entrySet().stream().filter(entry -> {
        Optional<TilesConfiguration> config = entry.getValue().getExtension(TilesConfiguration.class);
        return entry.getValue().getEnabled() && config.isPresent() && config.get().isMultiCollectionEnabled();
    }).map(entry -> {
        Optional<FeatureSchema> schema = providers.getFeatureSchema(apiData, entry.getValue());
        if (schema.isPresent())
            return new AbstractMap.SimpleImmutableEntry<>(entry.getKey(), schemas.getSchema(schema.get(), apiData, entry.getValue(), Optional.empty()));
        return null;
    }).filter(Objects::nonNull).collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, Map.Entry::getValue));
    // TODO: replace with SchemaDeriverTileLayers
    schemaMap.entrySet().stream().forEach(entry -> {
        String collectionId2 = entry.getKey();
        FeatureTypeConfigurationOgcApi collectionData = apiData.getCollections().get(collectionId2);
        JsonSchemaDocument schema = entry.getValue();
        ImmutableTileLayer.Builder builder2 = ImmutableTileLayer.builder().id(collectionId2).title(collectionData.getLabel()).description(collectionData.getDescription()).dataType(dataType);
        collectionData.getExtension(TilesConfiguration.class).map(config -> config.getZoomLevelsDerived().get(tileMatrixSet.getId())).ifPresent(minmax -> builder2.minTileMatrix(String.valueOf(minmax.getMin())).maxTileMatrix(String.valueOf(minmax.getMax())));
        final JsonSchema geometry = schema.getProperties().get("geometry");
        if (Objects.nonNull(geometry)) {
            String geomAsString = geometry.toString();
            boolean point = geomAsString.contains("GeoJSON Point") || geomAsString.contains("GeoJSON MultiPoint");
            boolean line = geomAsString.contains("GeoJSON LineString") || geomAsString.contains("GeoJSON MultiLineString");
            boolean polygon = geomAsString.contains("GeoJSON Polygon") || geomAsString.contains("GeoJSON MultiPolygon");
            if (point && !line && !polygon)
                builder2.geometryType(TileLayer.GeometryType.points);
            else if (!point && line && !polygon)
                builder2.geometryType(TileLayer.GeometryType.lines);
            else if (!point && !line && polygon)
                builder2.geometryType(TileLayer.GeometryType.polygons);
        }
        final JsonSchemaObject properties = (JsonSchemaObject) schema.getProperties().get("properties");
        builder2.propertiesSchema(ImmutableJsonSchemaObject.builder().required(properties.getRequired()).properties(properties.getProperties()).patternProperties(properties.getPatternProperties()).build());
        builder.addLayers(builder2.build());
    });
    builder.links(links);
    return builder.build();
}
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) Codelist(de.ii.xtraplatform.codelists.domain.Codelist) Builder(de.ii.ogcapi.tiles.domain.ImmutableTileSet.Builder) JsonSchema(de.ii.ogcapi.features.core.domain.JsonSchema) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration) ImmutableTilePoint(de.ii.ogcapi.tiles.domain.ImmutableTilePoint) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) ImmutableTileLayer(de.ii.ogcapi.tiles.domain.ImmutableTileLayer) BoundingBox(de.ii.xtraplatform.crs.domain.BoundingBox) TilesBoundingBox(de.ii.ogcapi.tiles.domain.tileMatrixSet.TilesBoundingBox) ImmutableTilesBoundingBox(de.ii.ogcapi.tiles.domain.tileMatrixSet.ImmutableTilesBoundingBox) JsonSchemaDocument(de.ii.ogcapi.features.core.domain.JsonSchemaDocument) Optional(java.util.Optional) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) JsonSchemaCache(de.ii.ogcapi.features.core.domain.JsonSchemaCache) CrsTransformationException(de.ii.xtraplatform.crs.domain.CrsTransformationException) Objects(java.util.Objects) JsonSchemaObject(de.ii.ogcapi.features.core.domain.JsonSchemaObject) ImmutableJsonSchemaObject(de.ii.ogcapi.features.core.domain.ImmutableJsonSchemaObject)

Example 4 with TilesConfiguration

use of de.ii.ogcapi.tiles.domain.TilesConfiguration in project ldproxy by interactive-instruments.

the class TileProviderFeatures method getQueryInput.

@Override
@JsonIgnore
@Value.Derived
public QueryInput getQueryInput(OgcApiDataV2 apiData, URICustomizer uriCustomizer, Map<String, String> queryParameters, List<OgcApiQueryParameter> allowedParameters, QueryInput genericInput, Tile tile) {
    if (!tile.getFeatureProvider().map(FeatureProvider2::supportsQueries).orElse(false)) {
        throw new IllegalStateException("Tile cannot be generated. The feature provider does not support feature queries.");
    }
    TileFormatExtension outputFormat = tile.getOutputFormat();
    List<String> collections = tile.getCollectionIds();
    if (collections.isEmpty()) {
        return new ImmutableQueryInputTileEmpty.Builder().from(genericInput).tile(tile).build();
    }
    if (!(outputFormat instanceof TileFormatWithQuerySupportExtension))
        throw new RuntimeException(String.format("Unexpected tile format without query support. Found: %s", outputFormat.getClass().getSimpleName()));
    // first execute the information that is passed as processing parameters (e.g., "properties")
    Map<String, Object> processingParameters = new HashMap<>();
    for (OgcApiQueryParameter parameter : allowedParameters) {
        processingParameters = parameter.transformContext(null, processingParameters, queryParameters, apiData);
    }
    if (tile.isDatasetTile()) {
        if (!outputFormat.canMultiLayer() && collections.size() > 1)
            throw new NotAcceptableException("The requested tile format supports only a single layer. Please select only a single collection.");
        Map<String, Tile> singleLayerTileMap = collections.stream().collect(ImmutableMap.toImmutableMap(collectionId -> collectionId, collectionId -> new ImmutableTile.Builder().from(tile).collectionIds(ImmutableList.of(collectionId)).isDatasetTile(false).build()));
        Map<String, FeatureQuery> queryMap = collections.stream().filter(collectionId -> {
            Optional<FeaturesCoreConfiguration> featuresConfiguration = apiData.getCollections().get(collectionId).getExtension(FeaturesCoreConfiguration.class);
            return featuresConfiguration.isPresent() && featuresConfiguration.get().getQueryables().isPresent() && !featuresConfiguration.get().getQueryables().get().getSpatial().isEmpty();
        }).collect(ImmutableMap.toImmutableMap(collectionId -> collectionId, collectionId -> {
            String featureTypeId = apiData.getCollections().get(collectionId).getExtension(FeaturesCoreConfiguration.class).map(cfg -> cfg.getFeatureType().orElse(collectionId)).orElse(collectionId);
            TilesConfiguration layerConfiguration = apiData.getExtension(TilesConfiguration.class, collectionId).orElseThrow();
            FeatureQuery query = ((TileFormatWithQuerySupportExtension) outputFormat).getQuery(singleLayerTileMap.get(collectionId), allowedParameters, queryParameters, layerConfiguration, uriCustomizer);
            return ImmutableFeatureQuery.builder().from(query).type(featureTypeId).build();
        }));
        FeaturesCoreConfiguration coreConfiguration = apiData.getExtension(FeaturesCoreConfiguration.class).orElseThrow();
        return new ImmutableQueryInputTileMultiLayer.Builder().from(genericInput).tile(tile).singleLayerTileMap(singleLayerTileMap).queryMap(queryMap).processingParameters(processingParameters).defaultCrs(apiData.getExtension(FeaturesCoreConfiguration.class).map(FeaturesCoreConfiguration::getDefaultEpsgCrs).orElseThrow()).build();
    } else {
        String collectionId = tile.getCollectionId();
        FeatureTypeConfigurationOgcApi featureType = apiData.getCollectionData(collectionId).orElseThrow();
        TilesConfiguration layerConfiguration = apiData.getExtension(TilesConfiguration.class, collectionId).orElseThrow();
        FeatureQuery query = ((TileFromFeatureQuery) outputFormat).getQuery(tile, allowedParameters, queryParameters, layerConfiguration, uriCustomizer);
        FeaturesCoreConfiguration coreConfiguration = featureType.getExtension(FeaturesCoreConfiguration.class).orElseThrow();
        return new ImmutableQueryInputTileSingleLayer.Builder().from(genericInput).tile(tile).query(query).processingParameters(processingParameters).defaultCrs(featureType.getExtension(FeaturesCoreConfiguration.class).map(FeaturesCoreConfiguration::getDefaultEpsgCrs).orElseThrow()).build();
    }
}
Also used : FeatureQuery(de.ii.xtraplatform.features.domain.FeatureQuery) TileFormatWithQuerySupportExtension(de.ii.ogcapi.tiles.domain.TileFormatWithQuerySupportExtension) TileFromFeatureQuery(de.ii.ogcapi.tiles.domain.TileFromFeatureQuery) QueryInput(de.ii.ogcapi.foundation.domain.QueryInput) HashMap(java.util.HashMap) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) Value(org.immutables.value.Value) PredefinedFilter(de.ii.ogcapi.tiles.domain.PredefinedFilter) SeedingOptions(de.ii.ogcapi.tiles.domain.SeedingOptions) Rule(de.ii.ogcapi.tiles.domain.Rule) Map(java.util.Map) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) Tile(de.ii.ogcapi.tiles.domain.Tile) Nullable(javax.annotation.Nullable) ImmutableQueryInputTileSingleLayer(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileSingleLayer) OgcApiQueryParameter(de.ii.ogcapi.foundation.domain.OgcApiQueryParameter) NotAcceptableException(javax.ws.rs.NotAcceptableException) ImmutableMap(com.google.common.collect.ImmutableMap) MinMax(de.ii.ogcapi.tiles.domain.MinMax) URICustomizer(de.ii.ogcapi.foundation.domain.URICustomizer) Maps(com.google.common.collect.Maps) FeatureProvider2(de.ii.xtraplatform.features.domain.FeatureProvider2) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) Objects(java.util.Objects) ImmutableQueryInputTileEmpty(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileEmpty) List(java.util.List) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) TileFormatExtension(de.ii.ogcapi.tiles.domain.TileFormatExtension) TileProvider(de.ii.ogcapi.tiles.domain.TileProvider) ImmutableFeatureQuery(de.ii.xtraplatform.features.domain.ImmutableFeatureQuery) Optional(java.util.Optional) ImmutableTile(de.ii.ogcapi.tiles.domain.ImmutableTile) JsonDeserialize(com.fasterxml.jackson.databind.annotation.JsonDeserialize) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) ImmutableQueryInputTileMultiLayer(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileMultiLayer) HashMap(java.util.HashMap) FeatureProvider2(de.ii.xtraplatform.features.domain.FeatureProvider2) ImmutableQueryInputTileMultiLayer(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileMultiLayer) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration) FeatureQuery(de.ii.xtraplatform.features.domain.FeatureQuery) TileFromFeatureQuery(de.ii.ogcapi.tiles.domain.TileFromFeatureQuery) ImmutableFeatureQuery(de.ii.xtraplatform.features.domain.ImmutableFeatureQuery) ImmutableQueryInputTileEmpty(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileEmpty) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) TileFromFeatureQuery(de.ii.ogcapi.tiles.domain.TileFromFeatureQuery) TileFormatExtension(de.ii.ogcapi.tiles.domain.TileFormatExtension) Optional(java.util.Optional) Tile(de.ii.ogcapi.tiles.domain.Tile) ImmutableTile(de.ii.ogcapi.tiles.domain.ImmutableTile) OgcApiQueryParameter(de.ii.ogcapi.foundation.domain.OgcApiQueryParameter) NotAcceptableException(javax.ws.rs.NotAcceptableException) TileFormatWithQuerySupportExtension(de.ii.ogcapi.tiles.domain.TileFormatWithQuerySupportExtension) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 5 with TilesConfiguration

use of de.ii.ogcapi.tiles.domain.TilesConfiguration in project ldproxy by interactive-instruments.

the class StaticTileProviderStoreImpl method onStartup.

/**
 * check that all tile set container exist and register them all in a map
 * @param api the API
 * @param apiValidation the validation level
 * @return the validation result
 */
@Override
public ValidationResult onStartup(OgcApi api, MODE apiValidation) {
    ImmutableValidationResult.Builder builder = ImmutableValidationResult.builder().mode(apiValidation);
    try {
        Files.createDirectories(store);
    } catch (IOException e) {
        builder.addErrors(e.getMessage());
    }
    Optional<TilesConfiguration> config = api.getData().getExtension(TilesConfiguration.class);
    if (config.isPresent() && config.get().isEnabled() && config.get().isMultiCollectionEnabled() && config.get().getTileProvider() instanceof TileProviderMbtiles) {
        TileProviderMbtiles provider = (TileProviderMbtiles) config.get().getTileProvider();
        Path path = getTileProvider(api.getData(), provider.getFilename());
        String key = String.join("/", api.getId(), CapabilityTiles.DATASET_TILES);
        try {
            mbtiles.put(key, new MbtilesTileset(path));
        } catch (Exception e) {
            builder.addErrors(MessageFormat.format("The Mbtiles container for the multi-collection tile provider at path ''{0}'' could not be initialized.", path.toString()));
        }
    }
    for (String collectionId : api.getData().getCollections().keySet()) {
        config = api.getData().getExtension(TilesConfiguration.class, collectionId);
        if (config.isPresent() && config.get().isEnabled() && config.get().isSingleCollectionEnabled() && config.get().getTileProvider() instanceof TileProviderMbtiles) {
            TileProviderMbtiles provider = (TileProviderMbtiles) config.get().getTileProvider();
            Path path = getTileProvider(api.getData(), provider.getFilename());
            String key = String.join("/", api.getId(), collectionId);
            try {
                mbtiles.put(key, new MbtilesTileset(path));
            } catch (Exception e) {
                builder.addErrors(MessageFormat.format("The Mbtiles container for the tile provider for collection ''{1}'' at path ''{0}'' could not be initialized.", path.toString(), collectionId));
            }
        }
    }
    return builder.build();
}
Also used : Path(java.nio.file.Path) MbtilesTileset(de.ii.ogcapi.tiles.app.mbtiles.MbtilesTileset) ImmutableValidationResult(de.ii.xtraplatform.store.domain.entities.ImmutableValidationResult) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration) IOException(java.io.IOException) SQLException(java.sql.SQLException) IOException(java.io.IOException) NotFoundException(javax.ws.rs.NotFoundException)

Aggregations

TilesConfiguration (de.ii.ogcapi.tiles.domain.TilesConfiguration)17 OgcApiDataV2 (de.ii.ogcapi.foundation.domain.OgcApiDataV2)13 Map (java.util.Map)10 MinMax (de.ii.ogcapi.tiles.domain.MinMax)9 TileMatrixSet (de.ii.ogcapi.tiles.domain.tileMatrixSet.TileMatrixSet)9 List (java.util.List)9 Optional (java.util.Optional)9 ImmutableList (com.google.common.collect.ImmutableList)8 FeatureTypeConfigurationOgcApi (de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi)8 Objects (java.util.Objects)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 IOException (java.io.IOException)7 AutoBind (com.github.azahnen.dagger.annotations.AutoBind)6 OgcApi (de.ii.ogcapi.foundation.domain.OgcApi)6 URICustomizer (de.ii.ogcapi.foundation.domain.URICustomizer)6 Tile (de.ii.ogcapi.tiles.domain.Tile)6 TilesQueriesHandler (de.ii.ogcapi.tiles.domain.TilesQueriesHandler)6 Collectors (java.util.stream.Collectors)6 FeaturesCoreConfiguration (de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration)5 FeaturesCoreProviders (de.ii.ogcapi.features.core.domain.FeaturesCoreProviders)5