Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/overview/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ This only describes the scheme in the API definition; Hakunapi does not enforce
| `getfeatures.limit.default` | `1000` | `limit` when the request has none. An unparsable value falls back to the default |
| `getfeatures.limit.max` | `10000` | Largest accepted `limit` |
| `hakuna.cors` | `true` | Register the CORS filter |
| `hakuna.features` | `true` | Publish the OGC API - Features endpoints and conformance classes. With `false` the collections are still read for the API extensions, but only the extensions are served, for example OGC API - Tiles (see [hakunapi-tiles-servlet-jakarta](../../src-community/hakunapi-tiles-servlet-jakarta/README.md)); without any collections nothing of Features is published either. `/collections` is then published only if an extension declares the `common-2` collections conformance class |
| `hakuna.gzip` | `true` | Register gzip response/request filters |
| `hakuna.content-length-buffer` | `8192` | Jersey `OUTBOUND_CONTENT_LENGTH_BUFFER`, in bytes |

Expand Down
4 changes: 4 additions & 0 deletions examples/finnish_admin_units/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,7 @@ The Docker build passes `maven-settings.xml` to Maven as a build secret (it does
### Tile URLs

Tile URLs follow the OGC API - Tiles order `/{tileMatrix}/{tileRow}/{tileCol}`, i.e. row (y) before column (x). This differs from the common XYZ `/{z}/{x}/{y}` order, so adapt URL templates accordingly. Find the exact tile endpoints from the `tiles` links of the collection or dataset at http://localhost:8094/features/.

### Tiles only (without the Features API)

To publish only the tiles, uncomment `hakuna.features=false` in `tiles/cfg-kunta/tiles.properties` and restart the example. The Features operations and conformance classes are then left out (`/collections/{id}/items` etc. return 404). The collections stay configured, because the dataset tile layer reads the data from them. Only the dataset tiles `/tiles/...` are served, and the service has no `/collections`. The Features output formats are no longer needed, so `formats=geojson,html` can be reduced to `formats=html`.
3 changes: 3 additions & 0 deletions examples/finnish_admin_units/tiles/cfg-kunta/tiles.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ servers=dev
servers.dev.url=http://localhost:8094/features
servers.dev.description=Local docker

# Uncomment to publish only OGC API - Tiles (and use formats=html below)
#hakuna.features=false

formats=geojson,html
formats.geojson.type=json
formats.html.type=html
Expand Down
15 changes: 15 additions & 0 deletions src-community/hakunapi-tiles-servlet-jakarta/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ the `tiles.*` configuration.
Resources are registered only for the kinds of layer configured. Each map tile
layer is published as a collection of its own, with no `items`.

## Tiles without Features

A service can publish only OGC API - Tiles. Set `hakuna.features=false` (or
configure no collections), so the Features operations, their conformance
classes and the default GeoJSON format are left out. The dataset tiles at
`/tiles` are then the only vector tiles, and their `collections` query
parameter is rejected with 400.

The core declares only the Common classes `core`, `json`, `oas30` and, when HTML
is enabled, `html`. `/collections`, `/collections/{collectionId}` and the
landing page `data` link are registered only when an extension declares
`common-2/conf/collections`: Features does when it is published, and Tiles does
when it has collection-level tilesets (map layers or collection vector
tilesets). A dataset-only service therefore has no `/collections`.

## Status and support

Community module under `src-community/`: built and tested with the core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public Response handle(
if (layers.isEmpty()) {
return ResponseUtil.exception(Status.NOT_FOUND, "Unsupported tileMatrixSetId");
}
if (collectionsParam != null && service.getCollections().isEmpty()) {
return ResponseUtil.exception(Status.BAD_REQUEST, "The collections parameter is not supported");
}
Set<String> requested = parseCollections(collectionsParam);

if (requested != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@
import fi.nls.hakunapi.core.operation.ApiTag;

public class GetDatasetTileOperation implements ApiOperation {
private final boolean collectionsParam;

public GetDatasetTileOperation() {
this(true);
}

public GetDatasetTileOperation(boolean collectionsParam) {
this.collectionsParam = collectionsParam;
}

@Override
public String getSummary() {
return "retrieve a tile of the dataset";
}

@Override
public String getDescription() {
return "Retrieves a single tile of the dataset at the requested tile matrix set, "
+ "tile matrix (zoom level), row and column, carrying one layer per collection. "
+ "The optional collections parameter narrows the tile to the named collections, "
String description = "Retrieves a single tile of the dataset at the requested tile matrix set, "
+ "tile matrix (zoom level), row and column, carrying one layer per collection.";
if (!collectionsParam) {
return description;
}
return description + " The optional collections parameter narrows the tile to the named collections, "
+ "which a tileset serving stored tiles does not support.";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class TilesApiExtension implements ApiExtension {

private final AcceleratedTilesets accelerated;

private final boolean collectionsParam;

public TilesApiExtension(TilesServiceConfig tiles) {
this(tiles, Set.of(), AcceleratedTilesets.NONE);
}
Expand All @@ -47,12 +49,18 @@ public TilesApiExtension(TilesServiceConfig tiles, Set<String> collectionlessVec

public TilesApiExtension(TilesServiceConfig tiles, Set<String> collectionlessVectorLayers,
AcceleratedTilesets accelerated) {
this(tiles, collectionlessVectorLayers, accelerated, true);
}

public TilesApiExtension(TilesServiceConfig tiles, Set<String> collectionlessVectorLayers,
AcceleratedTilesets accelerated, boolean collectionsParam) {
if (!tiles.hasVectorLayers() && !tiles.hasMapLayers()) {
throw new IllegalArgumentException("No tile layers, do not publish OGC API - Tiles!");
}
this.tiles = tiles;
this.collectionlessVectorLayers = Set.copyOf(collectionlessVectorLayers);
this.accelerated = accelerated;
this.collectionsParam = collectionsParam;
}

@Override
Expand All @@ -68,6 +76,7 @@ public List<ConformanceClass> getConformanceClasses() {
classes.add(ConformanceClass.TILES_TILESETS_LIST);

if (hasGeodataTilesets()) {
classes.add(ConformanceClass.COMMON_COLLECTIONS);
classes.add(ConformanceClass.TILES_GEODATA_TILESETS);
}
if (tiles.hasVectorLayers()) {
Expand All @@ -88,7 +97,7 @@ public List<OperationImpl> getOperations() {
operations.add(new OperationImpl(new GetTileMatrixSetsOperation(), TileMatrixSetsImpl.class));
if (tiles.hasVectorLayers()) {
operations.add(new OperationImpl(new GetDatasetTilesetsListOperation(), GetDatasetTilesetsImpl.class));
operations.add(new OperationImpl(new GetDatasetTileOperation(), GetDatasetTileImpl.class));
operations.add(new OperationImpl(new GetDatasetTileOperation(collectionsParam), GetDatasetTileImpl.class));
}

if (hasCollectionVectorTilesets()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public class TilesApiExtensionFactory implements ApiExtensionFactory {
public ApiExtension create(ApiExtensionContext context) throws Exception {
HakunaConfigParser config = context.config();
Path configPath = context.configPath();
Map<String, FeatureType> collections = context.collections();
Map<String, FeatureType> collections = context.dataCollections();
Map<String, FeatureType> published = context.collections();
TilesConfigParser parser = new TilesConfigParser(config);
if (!parser.hasTileLayers() && !parser.isVectorAutoPublishEnabled()) {
return null;
Expand Down Expand Up @@ -93,7 +94,7 @@ public ApiExtension create(ApiExtensionContext context) throws Exception {

Set<String> collectionless = new HashSet<>();
for (VectorTileLayer layer : vectorLayers) {
if (layer.isCollectionTileset() && !collections.containsKey(layer.getId())) {
if (layer.isCollectionTileset() && !published.containsKey(layer.getId())) {
collectionless.add(layer.getId());
}
}
Expand All @@ -105,7 +106,7 @@ public ApiExtension create(ApiExtensionContext context) throws Exception {
accelerated.getTilesetIds().size());
return new TilesApiExtension(
new TilesServiceConfig(vectorLayers, mapLayers, tileMatrixSets), collectionless,
accelerated);
accelerated, !published.isEmpty());
}

private AcceleratedTilesets readAcceleratedTilesets(List<VectorTileLayer> layers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
import fi.nls.hakunapi.core.config.HakunaConfigParser;

public record ApiExtensionContext(HakunaConfigParser config, Path configPath,
Map<String, FeatureType> collections) {
Map<String, FeatureType> collections, Map<String, FeatureType> dataCollections) {

/**
* collections are the ones the service publishes; dataCollections are all configured ones, which can
* be more when some only back other APIs.
*/
public ApiExtensionContext(HakunaConfigParser config, Path configPath, Map<String, FeatureType> collections) {
this(config, configPath, collections, collections);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package fi.nls.hakunapi.simple.servlet.jakarta;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import fi.nls.hakunapi.core.ConformanceClass;
import fi.nls.hakunapi.core.FeatureType;
import fi.nls.hakunapi.core.extension.ApiExtension;
import fi.nls.hakunapi.core.operation.FunctionsMetadataOperation;
import fi.nls.hakunapi.core.operation.GetFeatureByIdOperation;
import fi.nls.hakunapi.core.operation.GetFeaturesOperation;
import fi.nls.hakunapi.core.operation.GetQueryablesOperation;
import fi.nls.hakunapi.core.operation.GetSchemaOperation;
import fi.nls.hakunapi.core.operation.OperationImpl;
import fi.nls.hakunapi.core.schemas.CollectionInfo;
import fi.nls.hakunapi.core.schemas.Link;
import fi.nls.hakunapi.simple.servlet.jakarta.operation.FunctionsMetadataImpl;
import fi.nls.hakunapi.simple.servlet.jakarta.operation.GetCollectionItemByIdOperation;
import fi.nls.hakunapi.simple.servlet.jakarta.operation.GetCollectionItemsOperation;
import fi.nls.hakunapi.simple.servlet.jakarta.operation.GetCollectionQueryablesImpl;
import fi.nls.hakunapi.simple.servlet.jakarta.operation.GetCollectionSchemaImpl;
import fi.nls.hakunapi.simple.servlet.jakarta.operation.GetItemsOperation;

/**
* The OGC API - Features operations and conformance classes. Left out of a service that publishes no feature
* collections, which then exposes neither the paths nor the conformance classes.
*/
public class FeaturesApiExtension implements ApiExtension {

private final boolean htmlEnabled;

public FeaturesApiExtension(boolean htmlEnabled) {
this.htmlEnabled = htmlEnabled;
}

@Override
public String getName() {
return "OGC API - Features";
}

@Override
public List<ConformanceClass> getConformanceClasses() {
List<ConformanceClass> classes = new ArrayList<>();
classes.add(ConformanceClass.COMMON_COLLECTIONS);
classes.add(ConformanceClass.Core);
classes.add(ConformanceClass.OpenAPI30);
classes.add(ConformanceClass.GeoJSON);
if (htmlEnabled) {
classes.add(ConformanceClass.HTML);
}
classes.add(ConformanceClass.CRS);
classes.add(ConformanceClass.GPKG);

classes.add(ConformanceClass.QUERYABLES);
classes.add(ConformanceClass.QUERYABLES_QUERY_PARAMETERS);
classes.add(ConformanceClass.FILTER);
classes.add(ConformanceClass.FEATURES_FILTER);

classes.add(ConformanceClass.CQL2_TEXT);
// classes.add(ConformanceClass.CQL2_JSON_ENCODING);
classes.add(ConformanceClass.BASIC_CQL2);
classes.add(ConformanceClass.ADVANCED_COMPARISON_OPERATORS);
classes.add(ConformanceClass.CASE_INSENSITIVE_COMPARISON);
classes.add(ConformanceClass.BASIC_SPATIAL_FUNCTIONS);
classes.add(ConformanceClass.BAISC_SPATIAL_FUNCTIONS_PLUS);
classes.add(ConformanceClass.SPATIAL_FUNCTIONS);
classes.add(ConformanceClass.FUNCTIONS);
return classes;
}

@Override
public List<OperationImpl> getOperations() {
List<OperationImpl> operations = new ArrayList<>();
operations.add(new OperationImpl(new GetFeatureByIdOperation(), GetCollectionItemByIdOperation.class));
operations.add(new OperationImpl(new GetFeaturesOperation(), GetCollectionItemsOperation.class));
operations.add(new OperationImpl(new GetSchemaOperation(), GetCollectionSchemaImpl.class));
operations.add(new OperationImpl(new GetQueryablesOperation(), GetCollectionQueryablesImpl.class));
operations.add(new OperationImpl(new FunctionsMetadataOperation(), FunctionsMetadataImpl.class));
// Experimental
operations.add(new OperationImpl(new GetFeaturesOperation(), GetItemsOperation.class));
return operations;
}

@Override
public Map<Class<?>, Object> getInjectables() {
return Map.of();
}

@Override
public List<Link> getLandingPageLinks(String baseUrl, Map<String, String> queryParams) {
return List.of();
}

@Override
public List<Link> getCollectionLinks(FeatureType ft, String baseUrl, Map<String, String> queryParams) {
return List.of();
}

@Override
public List<CollectionInfo> getCollections(String baseUrl, Map<String, String> queryParams) {
return List.of();
}

@Override
public List<String> getCollectionIds(String resource) {
return List.of();
}

@Override
public Map<String, List<String>> getFormatMediaTypes() {
return Map.of();
}

@Override
public void close() {
// NOP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import fi.nls.hakunapi.core.i18n.LangNegotiation;
import fi.nls.hakunapi.core.param.LangParam;
import fi.nls.hakunapi.core.schemas.Link;
import fi.nls.hakunapi.core.ConformanceClass;
import fi.nls.hakunapi.core.schemas.Root;
import fi.nls.hakunapi.core.util.Links;
import fi.nls.hakunapi.core.util.U;
Expand Down Expand Up @@ -116,12 +117,17 @@ private Localized localize(String langParam, UriInfo uriInfo, HttpHeaders header
if (html) {
builder.alternate(alternateContentType);
}
builder.api("application/vnd.oai.openapi+json;version=3.0")
.collections(MediaType.APPLICATION_JSON)
.conformance(MediaType.APPLICATION_JSON);
boolean collections = service.getConformanceClasses().contains(ConformanceClass.COMMON_COLLECTIONS);
builder.api("application/vnd.oai.openapi+json;version=3.0");
if (collections) {
builder.collections(MediaType.APPLICATION_JSON);
}
builder.conformance(MediaType.APPLICATION_JSON);
if (html) {
builder.collections(MediaType.TEXT_HTML)
.conformance(MediaType.TEXT_HTML);
if (collections) {
builder.collections(MediaType.TEXT_HTML);
}
builder.conformance(MediaType.TEXT_HTML);
}
Root root = builder
.additionalLinks(additionalLinks)
Expand Down
Loading
Loading