use of de.ii.ogcapi.features.core.domain.FeaturesCollectionQueryables in project ldproxy by interactive-instruments.
the class CollectionExtensionFeatures method process.
@Override
public ImmutableOgcApiCollection.Builder process(Builder collection, FeatureTypeConfigurationOgcApi featureType, OgcApi api, URICustomizer uriCustomizer, boolean isNested, ApiMediaType mediaType, List<ApiMediaType> alternateMediaTypes, Optional<Locale> language) {
collection.title(featureType.getLabel()).description(featureType.getDescription()).itemType(featureType.getExtension(FeaturesCoreConfiguration.class).filter(ExtensionConfiguration::isEnabled).flatMap(FeaturesCoreConfiguration::getItemType).map(Enum::toString).orElse(FeaturesCoreConfiguration.ItemType.unknown.toString()));
api.getItemCount(featureType.getId()).filter(count -> count >= 0).ifPresent(count -> collection.putExtensions("itemCount", count));
URICustomizer uriBuilder = uriCustomizer.copy().ensureNoTrailingSlash().clearParameters();
if (isNested) {
// also add an untyped a self link in the Collections resource, otherwise the standard links are already there
collection.addLinks(new ImmutableLink.Builder().href(uriBuilder.copy().ensureLastPathSegments("collections", featureType.getId()).removeParameters("f").toString()).rel("self").title(i18n.get("selfLinkCollection", language).replace("{{collection}}", featureType.getLabel())).build());
}
List<ApiMediaType> featureMediaTypes = extensionRegistry.getExtensionsForType(FeatureFormatExtension.class).stream().filter(outputFormatExtension -> outputFormatExtension.isEnabledForApi(api.getData())).map(outputFormatExtension -> outputFormatExtension.getMediaType()).collect(Collectors.toList());
featureMediaTypes.stream().forEach(mtype -> collection.addLinks(new ImmutableLink.Builder().href(uriBuilder.ensureLastPathSegments("collections", featureType.getId(), "items").setParameter("f", mtype.parameter()).toString()).rel("items").type(mtype.type().toString()).title(i18n.get("itemsLink", language).replace("{{collection}}", featureType.getLabel()).replace("{{type}}", mtype.label())).build()));
Optional<String> describeFeatureTypeUrl = Optional.empty();
if (describeFeatureTypeUrl.isPresent()) {
collection.addLinks(new ImmutableLink.Builder().href(describeFeatureTypeUrl.get()).rel("describedby").type("application/xml").title(i18n.get("describedByXsdLink", language)).build());
}
// only add extents for cases where we can filter using spatial / temporal predicates
Optional<FeaturesCollectionQueryables> queryables = featureType.getExtension(FeaturesCoreConfiguration.class).flatMap(FeaturesCoreConfiguration::getQueryables);
boolean hasSpatialQueryable = queryables.map(FeaturesCollectionQueryables::getSpatial).filter(spatial -> !spatial.isEmpty()).isPresent();
boolean hasTemporalQueryable = queryables.map(FeaturesCollectionQueryables::getTemporal).filter(temporal -> !temporal.isEmpty()).isPresent();
Optional<BoundingBox> spatial = api.getSpatialExtent(featureType.getId());
Optional<TemporalExtent> temporal = api.getTemporalExtent(featureType.getId());
if (hasSpatialQueryable && hasTemporalQueryable && spatial.isPresent() && temporal.isPresent()) {
collection.extent(new OgcApiExtent(temporal.get().getStart(), temporal.get().getEnd(), spatial.get().getXmin(), spatial.get().getYmin(), spatial.get().getXmax(), spatial.get().getYmax()));
} else if (hasSpatialQueryable && spatial.isPresent()) {
collection.extent(new OgcApiExtent(spatial.get().getXmin(), spatial.get().getYmin(), spatial.get().getXmax(), spatial.get().getYmax()));
} else if (hasTemporalQueryable && temporal.isPresent()) {
collection.extent(new OgcApiExtent(temporal.get().getStart(), temporal.get().getEnd()));
}
return collection;
}
Aggregations