Search in sources :

Example 1 with FeatureQueries

use of de.ii.xtraplatform.features.domain.FeatureQueries in project ldproxy by interactive-instruments.

the class CapabilityFeaturesCore method onStartup.

@Override
public ValidationResult onStartup(OgcApi api, MODE apiValidation) {
    // TODO: add capability to periodically reinitialize metadata from the feature data (to account
    // for lost notifications,
    // because extent changes because of deletes are not taken into account, etc.)
    // initialize dynamic collection metadata
    OgcApiDataV2 apiData = api.getData();
    apiData.getCollections().entrySet().forEach(entry -> {
        final String collectionId = entry.getKey();
        final Optional<CollectionExtent> optionalExtent = apiData.getExtent(collectionId);
        Optional<BoundingBox> optionalBoundingBox;
        if (optionalExtent.isEmpty() || optionalExtent.get().getSpatialComputed().orElse(true)) {
            optionalBoundingBox = computeBbox(apiData, collectionId);
        } else {
            optionalBoundingBox = optionalExtent.get().getSpatial();
        }
        optionalBoundingBox.ifPresent(bbox -> api.updateSpatialExtent(collectionId, bbox));
        Optional<TemporalExtent> optionalTemporalExtent;
        if (optionalExtent.isEmpty() || optionalExtent.get().getTemporalComputed().orElse(true)) {
            optionalTemporalExtent = computeInterval(apiData, collectionId);
        } else {
            optionalTemporalExtent = optionalExtent.get().getTemporal();
        }
        optionalTemporalExtent.ifPresent(interval -> api.updateTemporalExtent(collectionId, interval));
        final FeatureTypeConfigurationOgcApi collectionData = apiData.getCollections().get(collectionId);
        final Optional<FeatureProvider2> provider = providers.getFeatureProvider(apiData, collectionData);
        if (provider.map(FeatureProvider2::supportsQueries).orElse(false)) {
            final String featureTypeId = collectionData.getExtension(FeaturesCoreConfiguration.class).map(cfg -> cfg.getFeatureType().orElse(collectionId)).orElse(collectionId);
            final long count = ((FeatureQueries) provider.get()).getFeatureCount(featureTypeId);
            api.updateItemCount(collectionId, count);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Number of items in collection '{}': {}", collectionId, count);
            }
        }
    });
    providers.getFeatureProvider(apiData).ifPresent(provider -> provider.getFeatureChangeHandler().addListener(onFeatureChange(api)));
    return ValidationResult.of();
}
Also used : FeatureQuery(de.ii.xtraplatform.features.domain.FeatureQuery) ExtensionConfiguration(de.ii.ogcapi.foundation.domain.ExtensionConfiguration) CrsTransformationException(de.ii.xtraplatform.crs.domain.CrsTransformationException) LoggerFactory(org.slf4j.LoggerFactory) CrsTransformer(de.ii.xtraplatform.crs.domain.CrsTransformer) FeatureChangeListener(de.ii.xtraplatform.features.domain.FeatureChangeListener) DEFAULT_PAGE_SIZE(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration.DEFAULT_PAGE_SIZE) MODE(de.ii.xtraplatform.store.domain.entities.ValidationResult.MODE) Singleton(javax.inject.Singleton) AutoBind(com.github.azahnen.dagger.annotations.AutoBind) Inject(javax.inject.Inject) ImmutableList(com.google.common.collect.ImmutableList) CollectionExtent(de.ii.ogcapi.foundation.domain.CollectionExtent) ValidationResult(de.ii.xtraplatform.store.domain.entities.ValidationResult) MINIMUM_PAGE_SIZE(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration.MINIMUM_PAGE_SIZE) OgcCrs(de.ii.xtraplatform.crs.domain.OgcCrs) ApiBuildingBlock(de.ii.ogcapi.foundation.domain.ApiBuildingBlock) Interval(org.threeten.extra.Interval) Logger(org.slf4j.Logger) FeaturesCoreProviders(de.ii.ogcapi.features.core.domain.FeaturesCoreProviders) Collection(java.util.Collection) ImmutableFeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.ImmutableFeaturesCoreConfiguration) OgcApi(de.ii.ogcapi.foundation.domain.OgcApi) FeaturesCollectionQueryables(de.ii.ogcapi.features.core.domain.FeaturesCollectionQueryables) MAX_PAGE_SIZE(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration.MAX_PAGE_SIZE) FeatureProvider2(de.ii.xtraplatform.features.domain.FeatureProvider2) FeatureQueries(de.ii.xtraplatform.features.domain.FeatureQueries) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) Objects(java.util.Objects) List(java.util.List) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) CrsTransformerFactory(de.ii.xtraplatform.crs.domain.CrsTransformerFactory) ImmutableFeatureQuery(de.ii.xtraplatform.features.domain.ImmutableFeatureQuery) TemporalExtent(de.ii.ogcapi.foundation.domain.TemporalExtent) Optional(java.util.Optional) BoundingBox(de.ii.xtraplatform.crs.domain.BoundingBox) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) FeatureProvider2(de.ii.xtraplatform.features.domain.FeatureProvider2) CollectionExtent(de.ii.ogcapi.foundation.domain.CollectionExtent) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) TemporalExtent(de.ii.ogcapi.foundation.domain.TemporalExtent) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) BoundingBox(de.ii.xtraplatform.crs.domain.BoundingBox) FeatureQueries(de.ii.xtraplatform.features.domain.FeatureQueries)

Aggregations

AutoBind (com.github.azahnen.dagger.annotations.AutoBind)1 ImmutableList (com.google.common.collect.ImmutableList)1 FeaturesCollectionQueryables (de.ii.ogcapi.features.core.domain.FeaturesCollectionQueryables)1 FeaturesCoreConfiguration (de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration)1 DEFAULT_PAGE_SIZE (de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration.DEFAULT_PAGE_SIZE)1 MAX_PAGE_SIZE (de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration.MAX_PAGE_SIZE)1 MINIMUM_PAGE_SIZE (de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration.MINIMUM_PAGE_SIZE)1 FeaturesCoreProviders (de.ii.ogcapi.features.core.domain.FeaturesCoreProviders)1 ImmutableFeaturesCoreConfiguration (de.ii.ogcapi.features.core.domain.ImmutableFeaturesCoreConfiguration)1 ApiBuildingBlock (de.ii.ogcapi.foundation.domain.ApiBuildingBlock)1 CollectionExtent (de.ii.ogcapi.foundation.domain.CollectionExtent)1 ExtensionConfiguration (de.ii.ogcapi.foundation.domain.ExtensionConfiguration)1 FeatureTypeConfigurationOgcApi (de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi)1 OgcApi (de.ii.ogcapi.foundation.domain.OgcApi)1 OgcApiDataV2 (de.ii.ogcapi.foundation.domain.OgcApiDataV2)1 TemporalExtent (de.ii.ogcapi.foundation.domain.TemporalExtent)1 BoundingBox (de.ii.xtraplatform.crs.domain.BoundingBox)1 CrsTransformationException (de.ii.xtraplatform.crs.domain.CrsTransformationException)1 CrsTransformer (de.ii.xtraplatform.crs.domain.CrsTransformer)1 CrsTransformerFactory (de.ii.xtraplatform.crs.domain.CrsTransformerFactory)1