npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ogcopenapis

v1.9.0

Published

OGC API Features, Maps, Tiles and Styles for LuciadRIA

Readme

OGC API for LuciadRIA

Description

The ogcopenapis package provides OGC API functionalities to LuciadRIA applications.

Implements

  • OGC API - Features, with the filters and queryables of Part 3, the schemas of Part 5, and writing features (create, replace, update and delete) of Part 4, a draft
  • OGC API - Maps, maps of collections and of the dataset, with several collections in one image, and in the server's styles
  • OGC API - Tiles, map (raster) tiles and vector tiles, of collections and of the dataset, and map tiles in the server's styles
  • OGC API - Styles, the styles of vector tiles (Mapbox GL), and the styles of maps and map tiles with their legends

The Main Components are:

  • OgcOpenApiGetCapabilities: a helper to retrieve the capabilities of a server such as available collections, available formats, tilesets and tile matrix sets, and the filter support and queryables for features
  • OgcOpenApiFeatureStore: a ready to use LuciadRIA store that retrieves features from an OGC API Features service, and writes them
  • OgcOpenApiMapsModel: a ready to use model that retrieves images from an OGC API Maps service
  • OgcOpenApiTilesModel: a ready to use model that retrieves map tiles from an OGC API Tiles service
  • OgcOpenApiVectorTilesModel: a ready to use model that retrieves vector tiles (Mapbox Vector Tiles) from an OGC API Tiles service
  • OgcOpenApiStyleTools: a helper to retrieve OGC API Styles: Mapbox GL styles for vector tiles, or a generated default style, and the styles of maps and map tiles with their links and legends

And the helpers they share:

  • OgcOpenApiTileMatrixTools: maps an OGC TileMatrixSet onto a LuciadRIA tile structure, shared by both tiles models
  • OgcOpenApiWmtsTools: describes an OGC API tileset as a WMTS layer, for LuciadRIA's WMTS support
  • OgcOpenApiMvtTools: reads the layers in a Mapbox Vector Tile
  • OgcOpenApiCrsTools: converts OGC CRS URIs to LuciadRIA reference identifiers, http://www.opengis.net/def/crs/EPSG/0/3857 to EPSG:3857
  • OgcOpenApiFetchTools: the requests of all components, with URL completion and the proxify option

To build

This is the source code that produces a library delivered as a npm package of native ES modules, in the lib folder, with type declarations and source maps. To build the source code use the npm scripts:

npm install
npm run build

build runs build:lib, which compiles with tsc (TypeScript 5, module: NodeNext, target ES2020): one module per source file, with the .js extensions that native ES modules need. LuciadRIA is never bundled: it is a peer dependency, and every @luciad/ria/... import stays an import of the application's single copy.

Then you can publish the package to npm or other repository. npm publish first runs the tests and the package check.

To test

The tests run in Node.js using Vitest, with jsdom as environment.

The default tests run offline, on fixtures in src/fixtures and test/fixtures/servers, with a mocked fetch:

npm run test

The servers the tests use are listed in test/servers.ts, with an example of each kind of data they serve (features, maps, map tiles, vector tiles of a collection and of the dataset, styles, and map tiles per style): pygeoapi (https://demo.pygeoapi.io/master/), ldproxy (https://demo.ldproxy.net/), CubeWerx (https://test.cubewerx.com/cubewerx/cubeserv/demo/ogcapi/) and PDOK (https://api.pdok.nl/). npm run test replays their recorded responses in test/fixtures/servers, and the live tests (*.live.test.ts) check that the servers still answer as recorded:

npm run test:live

The servers are reliable and stable, but take into account that changes at a server may break some of these tests. When a server changed, record its responses again:

npm run test:record

GNOSIS (https://maps.gnosis.earth/ogcapi/) is in the list but not tested: its /collections response is 9 MB, and its tiles need a login.

The writes are tested on servers of their own, in Docker, each with its own PostGIS: ldproxy 4.8.2 and pygeoapi 0.24.0 write, QGIS Server 4.2.3 tells per user what may be written, and GeoServer 3.0.2 is read-only (see test/servers/write/README.md). npm run test replays the recorded write scenario of ldproxy and pygeoapi (test/fixtures/write). The live write tests need the servers running, they are not run in CI:

test/servers/write/up.sh
npm run test:live-write
npm run test:record-write   # records the write scenario again
test/servers/write/down.sh

The package check builds and packs the package, and checks it as published: only lib/, the sources of its source maps, README, CHANGELOG, LICENSE and package.json are in it, nothing of LuciadRIA; lib/ imports only its own modules and @luciad/ria; publint and Are the Types Wrong find no problems; and every module loads through the package exports, installed in a node_modules folder, by Node's own ES module loader, as in the tests of an application:

npm run test:package

The browser tests run the demo in Chrome: for each test server and each kind of data, they add a layer and check that the map paints it, without failed requests or page errors. They need the LuciadRIA license in demo/license (see demo/README.md) and Google Chrome, or another Chrome set with CHROME_PATH. HEADED=1 shows the browser, and screenshots are saved in test/browser/screenshots.

npm run test:browser

Layers that are not painted yet are marked with knownIssue in test/servers.ts, the browser tests expect them to fail.

Demo

The demo folder contains a minimal page to open Features, Maps, Tiles and Vector Tiles collections, and the tiles of a dataset, in a LuciadRIA map. It combines several collections in one layer, merged by the server when it can and stacked in LuciadRIA when it can't: an example for your own UI, see Several collections in one layer. It offers the styles of maps and map tiles, and changes the style of a layer already added, see Styles of maps and map tiles. It needs a LuciadRIA development license in demo/license/luciadria_development.txt, see demo/README.md.

npm run demo

Ideas for an application on top of the library, from how other clients present OGC API data, are in docs/ux-recommendations.md.

To use in your project

Simply import the NPM package into your project, with LuciadRIA, its peer dependency:

npm install ogcopenapis @luciad/ria

The package is native ES modules. Import each component by its name, ogcopenapis/OgcOpenApiFeatureStore for instance. The paths of version 0.0.12, ogcopenapis/lib/OgcOpenApiFeatureStore, still work.

Capabilities

fromURL reads the landing page of a server and its collections, optionally only those with links of one type. Everything the examples below need comes from these capabilities: links and their formats, extents, the CRSs a collection offers, tilesets, tile matrix sets and styles. Nothing is configured by hand.

import {CollectionLinkType, OgcOpenApiGetCapabilities} from "ogcopenapis/OgcOpenApiGetCapabilities";

const capabilities = await OgcOpenApiGetCapabilities.fromURL(serverUrl, {filterCollectionsByLinkType: CollectionLinkType.Items});
// The collections, as the server lists them: id, title, extent, crs and links
const collection = capabilities.collections.find(c => c.id === collectionId);

Links that are relative are resolved against the document that has them. fromURL asks for JSON with the Accept header, and rejects with an OgcOpenApiError when the landing page or the collections cannot be read; a request that fails without an answer rejects with the error of fetch, an AbortError included, so a request can be cancelled through proxify. The API document and the conformance classes are optional.

The keywords of a collection are always strings, as OGC API Common Part 2 defines them, and a server's strings are kept as they are. A keyword sent as an object with a string keyword, the shape of OGC Web Services Common that PDOK sends ({"keyword": "bak"}), is read as that string; this is not in the standard. Anything else is left out.

All components accept credentials and requestHeaders for their requests, and proxify, a function that rewrites each request, for instance to send it through a proxy:

const proxify = (url: string, fetchOptions: RequestInit) => ({url: "https://proxy.example.com/?url=" + encodeURIComponent(url), fetchOptions});
const capabilities = await OgcOpenApiGetCapabilities.fromURL(serverUrl, {proxify});

credentials means what it means in LuciadRIA, which loads the map and tile images: true sends the credentials, cookies among them, also to another origin ("include"), and false or unset only to the same origin ("same-origin", what fetch does by default). A login in a header, such as HTTP Basic or a bearer token, goes in requestHeaders.

requestHeaders and credentials go only to the origin of the server, the origin of the URL given to fromURL. A link of the server to another origin is requested without them, with Accept only and credentials: "same-origin", so that a password given for one server never reaches a host its documents name. http and https are different origins. Other origins that may receive them are listed in credentialsOrigins:

const capabilities = await OgcOpenApiGetCapabilities.fromURL(serverUrl, {requestHeaders, credentialsOrigins: ["https://data.example.com"]});

The models send them to the URLs the application gives them, and so are the requestParameters of OgcOpenApiMapsModel and OgcOpenApiTilesModel: query parameters of the app sent with every image, such as a token, given as an option or set on the model as in LuciadRIA. They never replace a parameter of the request itself (the link's query, bbox, crs, collections, ...). A model whose style is changed in place (setMapLink, setTileSet) to a link on another origin requests it without them, see Styles of maps and map tiles. The style of OgcOpenApiVectorTilesModel (styleUrl) is loaded by LuciadRIA with requestHeaders, and so are the URLs that style names.

What the library fetches itself rejects with an OgcOpenApiError when the server answers with a status it does not accept, or when the answer cannot be used. Its status is the HTTP status, its url the request, and its problem the details the server gives in application/problem+json (RFC 9457), such as detail. A request that fails without an answer, a network error or an AbortError, rejects with the error of fetch:

import {OgcOpenApiError} from "ogcopenapis/OgcOpenApiError";

try {
    await OgcOpenApiGetCapabilities.fromURL(serverUrl, {requestHeaders: {Authorization: "Basic " + btoa(user + ":" + password)}});
} catch (e) {
    if (e instanceof OgcOpenApiError && (e.status === 401 || e.status === 403)) askForCredentials(e.problem?.detail);
    else throw e;
}

The examples below share these imports and constants:

import type {Map} from "@luciad/ria/view/Map.js";
import {getReference} from "@luciad/ria/reference/ReferenceProvider.js";
import {
    CollectionLinkType, OgcOpenApiCapabilitiesCollection, OgcOpenApiCapabilitiesObject, OgcOpenApiGetCapabilities,
    CollectionTileSet, CollectionTileSetInfo, TileSetData
} from "ogcopenapis/OgcOpenApiGetCapabilities";
import {OgcOpenApiCrsTools} from "ogcopenapis/OgcOpenApiCrsTools";

const CRS84 = "http://www.opengis.net/def/crs/OGC/1.3/CRS84";

Features

OgcOpenApiFeatureStore implements a LuciadRIA store, to use with FeatureModel and FeatureLayer:

import {FeatureModel} from "@luciad/ria/model/feature/FeatureModel.js";
import {FeatureLayer} from "@luciad/ria/view/feature/FeatureLayer.js";
import {LoadSpatially} from "@luciad/ria/view/feature/loadingstrategy/LoadSpatially.js";
import {GeoJsonCodec} from "@luciad/ria/model/codec/GeoJsonCodec.js";
import {OgcOpenApiFeatureStore} from "ogcopenapis/OgcOpenApiFeatureStore";

function createFeatureLayer(collection: OgcOpenApiCapabilitiesCollection) {
    const items = OgcOpenApiGetCapabilities.filterCollectionLinks(collection.links, CollectionLinkType.Items);
    // GeoJSON, the encoding that GeoJsonCodec reads. Not JSON-FG, which some servers also type application/geo+json
    const geoJson = items.filter(l => !OgcOpenApiGetCapabilities.isJsonFgLink(l));
    const link = geoJson.find(l => l.type === "application/geo+json") || geoJson.find(l => l.type === "application/json");
    if (!link) throw new Error("Collection " + collection.id + " has no GeoJSON items");
    // CRS84: OGC API Features requires every server to support it
    const crs = CRS84;
    const store = new OgcOpenApiFeatureStore({
        dataUrl: link.href,
        outputFormat: link.type,
        // The ids of the server: get(id) requests items/{id} with them
        codec: new GeoJsonCodec({generateIDs: false}),
        crs,
        extent: collection.extent,
        useCrs84Bounds: true,
    });
    const model = new FeatureModel(store, {reference: getReference(OgcOpenApiCrsTools.getReferenceName(crs))});
    return new FeatureLayer(model, {label: collection.title || collection.id, loadingStrategy: new LoadSpatially()});
}

The store requests the features in view, and a query does not follow the next links of a response: a map layer shows the features of its view, up to limit, without paging. Paging belongs with a table of the features, it needs a UI to move through the pages. The store keeps the parameters of the items link, such as profile or an api key, and encodes the values of its own. Its writes do not keep them, see Writing features.

onQueryResult tells what the response to each query says about its size, to show for example "3,460 match, 1,000 shown":

const store = new OgcOpenApiFeatureStore({
    // ...the options above
    onQueryResult: ({url, query, numberMatched, numberReturned, hasNext}) => {
        if (hasNext) console.log((numberMatched ?? "More") + " match, " + numberReturned + " shown");
    },
});
  • It is called once for each query whose features are decoded, not for get, a failed query or an aborted one. With LoadSpatially every view sends a query of its own: numberMatched counts the features in its bbox, and url and query tell which request it answers.
  • numberMatched is left out when the server gives none, it is optional (PDOK). numberReturned can be less than limit, servers cap it (pygeoapi at 10).
  • hasNext: the response links a next page, in its links or its Link header: not every match is shown. The store does not request that page. Left out when the response has no links to tell, such as GML whose Link header the browser cannot read (CORS).
  • The counts come from the response: the members of JSON, or the attributes of the root element of GML. Reading them parses a JSON response a second time, only when onQueryResult is set.

JSON-FG (OGC Features and Geometries JSON) needs a JSON-FG codec, which LuciadRIA does not have yet. Servers offer it as application/vnd.ogc.fg+json, or as application/geo+json with the JSON-FG profile (ldproxy); isJsonFgLink tells them apart, and outputFormats of a collection reports JSON-FG as application/vnd.ogc.fg+json. To read JSON-FG, pass a JSON-FG codec of your own to the store with that link.

Keep the ids of the server: generateIDs: false. Each feature of an OGC API Features collection has an id, get(id) of the store requests items/{id} with it, and LuciadRIA updates only the features that changed when the ids stay the same between queries. generateIDs: true replaces them with ids of its own on every query.

Filters

The store passes a server-side filter through the query (OGC API Features Part 3): filter, filter-lang and filter-crs. getFilterSupport says whether, and how, the server filters, as its conformance classes declare:

const support = OgcOpenApiGetCapabilities.getFilterSupport(capabilities);
// {filter: true, encodings: ["cql2-json", "cql2-text"], levels: ["advanced-comparison-operators", "basic-cql2", ...]}
if (support.filter && support.encodings.indexOf("cql2-text") > -1) {
    // Within the levels the server declares: like, between and in need advanced-comparison-operators
    const cursor = await store.query({filter: "F_CODE='AP030'", "filter-lang": "cql2-text"});
}
  • filter: the server declares the Features Filter class of Part 3, http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter.
  • encodings and levels: the CQL2 1.0 classes the server declares (http://www.opengis.net/spec/cql2/1.0/conf/…), by their names. The encodings are also the values of filter-lang.
  • Each is reported as the server declares it. pygeoapi, for example, declares cql2-text and basic-cql2 without the Features Filter class: filter is false, and accepting the encoding alone is up to the application.
  • Pre-standard CQL classes, such as ogcapi-features-3/1.0/conf/cql-text (CubeWerx), are not CQL2 and are left out.

The properties a filter can use are the queryables of the collection, a JSON Schema. fetchQueryables returns it as the server sends it, to interpret in the application:

const queryables = await OgcOpenApiGetCapabilities.fetchQueryables(capabilities, collection);
if (queryables) {
    for (const [name, schema] of Object.entries(queryables.properties || {})) {
        // F_CODE {type: "string", title: "Feature Type Code", enum: ["AN010", ...], "x-ogc-role": "type"}
        console.log(name, schema.type, schema.format, schema.title, schema.enum);
    }
}
  • It requests the queryables link of the collection, JSON Schema or JSON, with Accept: application/schema+json, application/json. ldproxy and PDOK list that link only in the collection document, not in /collections: then it requests the path of the standard, /collections/{collectionId}/queryables.
  • It resolves null for a collection without features, without a request, and when the server answers 404. An answer that is not a JSON Schema rejects (QGIS Server 4.2 answers its landing page).
  • The geometry is a queryable too, with "x-ogc-role": "primary-geometry" and a format such as geometry-point.

The queryables are the properties a filter can use, not always all the properties of the features (6 of 21 on PDOK BGT). The schema of the collection (OGC API Features Part 5) describes them all, and what a client writes. The queryables are no substitute for it, for a form that edits features for example: a replace built from them would remove the other properties.

The schema of a collection

fetchSchema resolves what a client needs to decide: the properties in the same form for every server, or why there are none.

const result = await OgcOpenApiGetCapabilities.fetchSchema(capabilities, collection);
if (result.available) {
    for (const property of result.properties) {
        // kennung string "Kennung" id readOnly
        console.log(property.name, property.type, property.title, property.role, property.readOnly ? "readOnly" : "");
    }
    if (result.issues.length > 0) console.warn("The schema of " + collection.id + " is incomplete:", result.issues);
} else {
    // not-supported: The server offers no schemas: it declares no conformance class of them, ...
    console.info(result.reason + ": " + result.message);
}

A collection with a schema resolves {available: true} with:

  • properties, in their order (x-ogc-propertySeq, then that of the document). Each has name, type (the JSON Schema type, or "geometry" for a spatial property), geometryType (point, multipolygon, any... from the format geometry-*), format, title, description, role (x-ogc-role: id, primary-geometry, primary-instant...), readOnly, writeOnly, required, enum, unit (x-ogc-unit), order, and schema, the JSON Schema of the property for its other keywords (minimum, pattern, items...). An object property has its properties too, its $ref resolved from the $defs of the schema (ldproxy).
  • issues: what does not follow the standard (23-058r2), each with the requirement it breaks, such as a $schema other than JSON Schema 2020-12, a property without type, two properties with the role id, a $ref outside the schema, or a server that does not declare the conformance class returnables-and-receivables. Empty for a complete schema. The properties are given anyway, as far as the schema describes them.
  • title, description, additionalProperties (whether features can have other properties, true unless false), url, and schema, the schema as the server sent it.

A collection without a schema resolves {available: false} with a reason, a message to show, and the url and status of the answer:

| reason | Cause | Seen on | |---|---|---| | no-features | The collection has no features (no items link). No request is made | Collections of maps or tiles only | | not-supported | The server offers no schemas: no schema link, no conformance class of schemas, and the path of the standard answers 404 | GeoServer 3.0 | | not-found | The server links the schema, or declares its conformance class, but the schema answers 404 | | | invalid | The answer is not a JSON Schema | QGIS Server 4.2, which answers its landing page |

Any other answer rejects with an OgcOpenApiError with its status, such as 401, 403 or 500, and a request that fails with its error, an AbortError included, as the other requests do.

  • It requests the schema link of the collection (http://www.opengis.net/def/rel/ogc/1.0/schema), JSON Schema or JSON, with Accept: application/schema+json, application/json, and the requestHeaders and credentials of the app for the server's origin only. ldproxy lists that link only in the collection document, not in /collections: then it requests the path of the standard, /collections/{collectionId}/schema.
  • The conformance classes are read in both documents that publish them, OGC API Common Part 3 (ogcapi-common-3/1.0/conf/…, ldproxy and pygeoapi) and OGC API Features Part 5 (ogcapi-features-5/1.0/conf/…, PDOK).

| Server | fetchSchema | |---|---| | ldproxy 4.8 | available, no issues; $defs for structured properties | | PDOK | available, no issues | | pygeoapi 0.24 | available, 2 issues: JSON Schema 2019-09, and no conformance class returnables-and-receivables | | GeoServer 3.0 | not-supported | | QGIS Server 4.2 | invalid |

Writing features

The store writes features too (OGC API Features Part 4, Create, Replace, Update and Delete, a draft standard): give it the write operations it may perform in writeOperations. It is read-only without them:

const store = new OgcOpenApiFeatureStore({
    // ...the options above
    writeOperations: ["add", "put", "remove"],
    // The login of the user, see below
    requestHeaders: {Authorization: "Bearer " + token},
});
const layer = new FeatureLayer(new FeatureModel(store), {editable: true});
  • add(feature) POSTs it to the items, in GeoJSON. The server gives it its id, in the Location of its answer: the feature takes that id, the store emits "add" and the promise resolves the id.
  • put(feature) replaces it, a PUT to items/{id}, with the id in the body too. It emits "update", or "add" when the server answers 201.
  • remove(id) deletes it, a DELETE: it resolves true and emits "remove", false when the server has no such feature (404).
  • patch(id, {properties, geometry}) updates part of it with a JSON Merge Patch (RFC 7396): a property set to null is removed. LuciadRIA does not call it, its editing replaces the whole feature with put; an application can. It needs put in writeOperations, and a server that declares the update class.
  • get(id) resolves undefined for a feature the server does not have (404), as LuciadRIA's Store requires, and a store with write operations asks the server again for it each time (cache: "no-cache"): a browser could otherwise give a feature as it was before a write (ldproxy marks its items as immutable).
  • Features are written in GeoJSON in CRS84, the CRS every server takes without Content-Crs: shapes in another reference are transformed. Writes go to the items and item URLs without the parameters of the items link (f, profile), which choose a representation to read.
  • LuciadRIA asks the store once, when a layer is made, which operations it supports: writeOperations fixes them. A FeatureLayer is editable only when the store supports all of add, put and remove.

Each write the server refuses rejects with an OgcOpenApiError: its status, its url, and the reason the server gives, problem for application/problem+json (the store asks for it) or body, the text of any other answer. Servers answer differently to the same refusal, so the store does not interpret the status: ldproxy 4.8 answers 401 to a user without the right to write as to one without login, QGIS Server 403 to both, pygeoapi 400 for a collection that is not editable, and GeoServer 3.0, whose OGC API Features is read-only, 500.

Give the login of the user as an Authorization header in requestHeaders, not with credentials: true. credentials: true is the fetch mode "include", which browsers refuse for servers that answer CORS with Access-Control-Allow-Origin: * (ldproxy 4.8, GeoServer 3.0) or without Access-Control-Allow-Credentials (pygeoapi), with no status to tell why. An Authorization header is sent in every mode, and only to the origin of the server.

Whether this user may write is known only from the answer to a write. fetchWriteSupport tells what the server advertises, to choose writeOperations:

const support = await OgcOpenApiGetCapabilities.fetchWriteSupport(capabilities, collection,
    {requestHeaders: {Authorization: "Bearer " + token}, featureId: 1});
// {conformance: {createReplaceDelete: true, update: true}, allow: {items: ["HEAD", "POST", "GET", "OPTIONS"],
//  item: [...]}, suggested: ["add", "put", "remove"], patch: true, issues: []}
const store = new OgcOpenApiFeatureStore({/* ... */ writeOperations: support.suggested});
  • conformance: the server declares the create-replace-delete and update classes of Part 4, in any of the URIs its drafts and servers use (ogcapi-features-4/1.0, ogcapi-common-5/1.0, ogcapi-features-4/0.0 of ldproxy 4.8). They are for the whole server, not for a collection or a user.
  • allow: the Allow header of OPTIONS on the items, and on the item of featureId when given (pygeoapi lists PUT and DELETE only there). Sent with the login of the user: QGIS Server answers per user. Left out when OPTIONS fails or its Allow cannot be read: not sent, or not exposed to the browser (ldproxy 4.8).
  • suggested: add, put and remove as Allow lists them, only when the server declares create-replace-delete. patch: it declares update, and Allow, when known, lists PATCH.
  • issues: what does not agree, as found, such as GeoServer 3.0, whose Allow lists every method while it declares no write class and refuses every write, or QGIS Server 4.2, which writes without declaring the class.

It is a hint, not a permission: only ldproxy, pygeoapi and QGIS Server were tested, and on two of them Allow is the same for every user.

Not supported: batch writes and transactions (OGC API Features Part 11, a proposal), and optimistic locking (ETag and If-Match, Last-Modified and If-Unmodified-Since): two users who replace the same feature both succeed, the last one wins.

Maps

OgcOpenApiMapsModel extends WMSTileSetModel, use it with a RasterTileSetLayer. It requests the map as tiles, in the reference of the map when the collection offers it, otherwise in CRS84, which every server supports, and LuciadRIA reprojects it:

import {RasterTileSetLayer} from "@luciad/ria/view/tileset/RasterTileSetLayer.js";
import {OgcOpenApiMapsModel} from "ogcopenapis/OgcOpenApiMapsModel";

function createMapLayer(map: Map, collection: OgcOpenApiCapabilitiesCollection) {
    const mapLinks = OgcOpenApiGetCapabilities.filterCollectionLinks(collection.links, CollectionLinkType.Map);
    // PNG, with transparency, when the server types its links. The link carries the f value the server accepts
    const link = mapLinks.find(l => l.type === "image/png") || mapLinks[0];
    if (!link) throw new Error("Collection " + collection.id + " has no map");
    const crs = (collection.crs || []).find(c => OgcOpenApiCrsTools.getReferenceName(c) === map.reference.identifier) || CRS84;
    const model = new OgcOpenApiMapsModel({crs, baseURL: link.href, collection: collection.id});
    return new RasterTileSetLayer(model, {label: collection.title || collection.id});
}

Leave out the format of OgcOpenApiMapsModel: the map link carries the f value the server accepts, and the model keeps it. format replaces that value as it is, so it must be an f value as the server names its formats (pygeoapi: png), not a media type. pygeoapi refuses f=image/png. This differs from the format of OgcOpenApiTilesModel below, which is a media type (image/png).

Some servers offer a collection's map only per style (OGC API Maps, Styled Map class, OGC 20-058 clause 21): the collection has no map link, its styles have one each, at …/styles/{styleId}/map. GeoServer 2.28 does so. mayOfferStyledMap tells such a collection without a request; fetchMapStyles reads its styles, the default one first, and a map link of a style is the baseURL of the model as above:

import {OgcOpenApiStyleTools} from "ogcopenapis/OgcOpenApiStyleTools";

async function createStyledMapLayer(map: Map, capabilities: OgcOpenApiCapabilitiesObject, collection: OgcOpenApiCapabilitiesCollection, styleId?: string) {
    if (!OgcOpenApiGetCapabilities.mayOfferStyledMap(capabilities, collection)) throw new Error("Collection " + collection.id + " has no styled map");
    // Read when the collection is chosen: one request per collection
    const styles = await OgcOpenApiStyleTools.fetchMapStyles(capabilities, collection);
    const style = styles.find(s => s.id === styleId) || styles[0];
    if (!style) throw new Error("Collection " + collection.id + " has no map");
    const link = style.mapLinks.find(l => l.type === "image/png") || style.mapLinks[0];
    const crs = (collection.crs || []).find(c => OgcOpenApiCrsTools.getReferenceName(c) === map.reference.identifier) || CRS84;
    const model = new OgcOpenApiMapsModel({crs, baseURL: link.href, collection: collection.id});
    return new RasterTileSetLayer(model, {label: (collection.title || collection.id) + " (" + style.title + ")"});
}

mayOfferStyledMap needs the server to declare a conformance class of OGC API Maps Part 1, so that the styles of a vector tiles server are not taken for maps. A collection with a map link gives false: its map is the one of that link. GeoServer 3.0 gives each collection a map link of its own, as well as maps per style: see Styles of maps and map tiles to offer those.

Map of the dataset, several collections in one image

Some servers draw a map of the dataset, linked from the landing page (/map, OGC API Maps, Dataset Map class). The server draws several collections into each image, for example satellite imagery with roads on it. With the collections parameter (Collections Selection class), it draws only the collections you list. OgcOpenApiMapsModel takes them as collections:

function createDatasetMapLayer(map: Map, capabilities: OgcOpenApiCapabilitiesObject, collections: string[]) {
    const links = OgcOpenApiGetCapabilities.getDatasetMapLinks(capabilities);
    const link = links.find(l => l.type === "image/png") || links[0];
    if (!link) throw new Error("The server has no map of the dataset");
    if (collections.length > 0 && !OgcOpenApiGetCapabilities.supportsMapCollectionSelection(capabilities)) {
        throw new Error("The server draws all collections of the dataset, it can't choose");
    }
    const crs = (capabilities.crs || []).find(c => OgcOpenApiCrsTools.getReferenceName(c) === map.reference.identifier) || CRS84;
    const model = new OgcOpenApiMapsModel({
        crs,
        baseURL: link.href,
        // The label of the layer: the dataset map is not a collection
        collection: "dataset",
        // The dataset map links of CubeWerx and GeoServer have no f, see below
        format: new URL(link.href).searchParams.has("f") ? undefined : "image/png",
        // Drawn in this order, the first at the bottom. All collections when empty
        collections,
    });
    return new RasterTileSetLayer(model, {label: collections.length > 0 ? "Dataset: " + collections.join(", ") : "Dataset"});
}

// CubeWerx Daraa: the 2019 satellite mosaic, with the roads on it
map.layerTree.addChild(createDatasetMapLayer(map, capabilities, ["Daraa_mosaic_2019", "TransportationGroundCrv"]));
  • The server merges the collections, and each request returns one finished image. LuciadRIA can't change the order or visibility of one collection; that takes a new model. To control them on the map instead, add one layer per collection.
  • Order. The first collection is drawn at the bottom. Labels may not follow the order: GeoServer draws all labels above every collection, while CubeWerx keeps them with their collection.
  • Ids. Use the ids that capabilities.collections lists. One unknown id fails every request: CubeWerx and GeoServer answer 400.
  • Format. The dataset map links of CubeWerx and GeoServer give neither a type nor an f, so pass format. Without f, GeoServer chooses by the browser's Accept header and answers SVG, which leaves out raster collections. image/png is the f value both servers accept; GeoServer refuses png.
  • Encoding. A comma inside a collection id is encoded, the commas between ids are not: CubeWerx reads encoded commas as part of one id. A collections parameter in the map link is replaced.
  • getDatasetMapLinks returns the map links of the landing page, hasDatasetMap tells whether there is one. supportsMapCollectionSelection reads the conformance class https://www.opengis.net/spec/ogcapi-maps-1/1.0/conf/collections-selection (MAPS_COLLECTIONS_SELECTION_CONFORMANCE), in https or http, or the Collections Selection class of OGC API Tiles, which OGC 20-058 (20.4) also names for /map. See Several collections in one layer for detection in every API.
  • Tested with CubeWerx and with GeoServer 3.0.x and its OGC API Maps community module. GNOSIS also offers it, but needs a login.

Tilesets

Map tiles and vector tiles start from the tilesets: of a collection, or of the dataset (collection null), all its collections in each tile. Each tileset is in one tile matrix set. Servers give tile matrix sets their own ids (CubeWerx calls WebMercatorQuad smerc), fetchTileMatrixSetOfTileSet matches them by URI.

import {OgcOpenApiTileMatrixTools} from "ogcopenapis/OgcOpenApiTileMatrixTools";

interface UsableTileSet {
    tileSet: CollectionTileSetInfo;
    tileMatrix: TileSetData;
}

// The tilesets that LuciadRIA can use, each with its tile matrix set. Left out: tile matrix sets in a reference that is
// not registered (see References below), and for vector tiles those that LuciadRIA cannot address as a quad-tree
async function fetchUsableTileSets(capabilities: OgcOpenApiCapabilitiesObject, collection: OgcOpenApiCapabilitiesCollection | null, linkType: CollectionLinkType) {
    // fetchTileSetsInFull leaves out definitions that cannot be read, it rejects only when none can
    const tileMatrixSets = await OgcOpenApiGetCapabilities.fetchTileSetsInFull(capabilities);
    const tileSets = collection ?
        await OgcOpenApiGetCapabilities.fetchCollectionTileSets(capabilities, collection, linkType) :
        await OgcOpenApiGetCapabilities.fetchDatasetTileSets(capabilities, linkType);
    const usable = await Promise.all(tileSets.map(async (tileSet): Promise<UsableTileSet | null> => {
        try {
            const tileMatrix = await OgcOpenApiGetCapabilities.fetchTileMatrixSetOfTileSet(capabilities, tileSet, tileMatrixSets);
            const grid = OgcOpenApiTileMatrixTools.createTileGrid(tileMatrix);
            return linkType === CollectionLinkType.VectorTiles && grid.levelCount <= 1 ? null : {tileSet, tileMatrix};
        } catch (e) {
            return null;
        }
    }));
    return usable.filter(t => t !== null);
}

// The tileset in the reference of the map, which needs no reprojection, otherwise the first one
function pickTileSet(map: Map, tileSets: UsableTileSet[]) {
    if (tileSets.length === 0) throw new Error("No tileset in a tile matrix set that LuciadRIA can use");
    return tileSets.find(t => OgcOpenApiCrsTools.getReferenceName(t.tileMatrix.crs) === map.reference.identifier) || tileSets[0];
}

// Where the data is, in CRS84 as [minX, minY, maxX, maxY]: the extent of the collection, or for the dataset the
// bounding box of the tileset, when the server gives them in CRS84
function getExtent(collection: OgcOpenApiCapabilitiesCollection | null, tileSet: CollectionTileSet): number[] | undefined {
    if (collection) {
        const spatial = collection.extent && collection.extent.spatial;
        return spatial && spatial.bbox && (!spatial.crs || /CRS84$/.test(spatial.crs)) ? spatial.bbox[0] : undefined;
    }
    const box = tileSet.boundingBox;
    return box && box.crs && /CRS84$/.test(box.crs) ? [...box.lowerLeft, ...box.upperRight] : undefined;
}

Map tiles

OgcOpenApiTilesModel extends WMTSTileSetModel, use it with a RasterTileSetLayer. Create it with createFromTileSet: it describes the tileset to LuciadRIA's WMTS support, which handles tile matrix sets that are quad-trees and tile matrix sets that are not (such as GlobalCRS84Scale), and it does not request tiles outside the tileMatrixSetLimits:

import {OgcOpenApiTilesModel} from "ogcopenapis/OgcOpenApiTilesModel";

async function createTileLayer(map: Map, capabilities: OgcOpenApiCapabilitiesObject, collection: OgcOpenApiCapabilitiesCollection | null) {
    const {tileSet: tileSetInfo, tileMatrix} = pickTileSet(map, await fetchUsableTileSets(capabilities, collection, CollectionLinkType.Tiles));
    const tileSet = await OgcOpenApiGetCapabilities.fetchCollectionTileSet(capabilities, collection, tileSetInfo, {}, CollectionLinkType.Tiles);
    // PNG, with transparency, when the server types its links
    const link = tileSet.links.find(l => l.type === "image/png") || tileSet.links[0];
    const model = await OgcOpenApiTilesModel.createFromTileSet({
        tileMatrix,
        baseURL: link.href,
        collection: collection ? collection.id : "dataset",
        format: link.type && link.type.indexOf("image/") === 0 ? link.type : undefined,
        tileMatrixSetLimits: tileSet.tileMatrixSetLimits,
        extent: getExtent(collection, tileSet),
    });
    return new RasterTileSetLayer(model, {label: collection ? collection.title || collection.id : "All collections"});
}

The constructor new OgcOpenApiTilesModel(options) still works, but is deprecated: it supports quad-tree tile matrix sets only.

Transparent background

Maps and map tiles over a basemap, rasterized vector data above all, need a transparent background. The transparent and bgcolor parameters belong to OGC API Maps (Background class, OGC 20-058 clause 9); OGC API Tiles doesn't define them, and a server that implements Tiles only may reject them: ldproxy answers 400. Both models send them only when you give them. Without them the server's default applies, which the standard defines as transparent (Requirement 7). To ask for it explicitly, pass transparent: true when the server declares the Background class:

const model = await OgcOpenApiTilesModel.createFromTileSet({
    // ... as above
    transparent: OgcOpenApiGetCapabilities.supportsMapBackground(capabilities) ? true : undefined,
});

Tested: CubeWerx, GeoServer 3.0.x and GNOSIS declare it; ldproxy, GeoServer's OGC API Tiles and pygeoapi don't. With and without the parameter, CubeWerx and GeoServer return the same images, transparent where there is no data.

Styles of maps and map tiles

The server draws maps and map tiles, so a style is a resource of the server, not something the client applies: the same map at …/styles/{styleId}/map (OGC API Maps, Styled Map class, OGC 20-058 clause 21), the same tiles at …/styles/{styleId}/map/tiles (styled map tilesets, OGC 20-057 Table 4). There is no style parameter and no SLD, see docs/styling-in-ogc-api.md. Without a style, nothing changes: the map or tiles of the collection or dataset, as above. With a style, follow the links of the style, as the server gives them:

import {OgcOpenApiStyleTools} from "ogcopenapis/OgcOpenApiStyleTools";

// collection null: the styles of the dataset. One request
const mapStyles = await OgcOpenApiStyleTools.fetchMapStyles(capabilities, collection);       // the styles with a map
const tileStyles = await OgcOpenApiStyleTools.fetchMapTileStyles(capabilities, collection);  // the styles with map tiles

// Maps: a map link of the style is the baseURL of the model
const style = mapStyles.find(s => s.id === styleId);
const link = style.mapLinks.find(l => l.type === "image/png") || style.mapLinks[0];
const model = new OgcOpenApiMapsModel({crs, baseURL: link.href, collection: collection.id});

// Map tiles: the tilesets of the style, then as any tileset
const tileSets = await OgcOpenApiGetCapabilities.fetchStyleTileSets(capabilities, tileStyles.find(s => s.id === styleId));
const tileMatrix = await OgcOpenApiGetCapabilities.fetchTileMatrixSetOfTileSet(capabilities, tileSets[0], tileMatrixSets);
const tileSet = await OgcOpenApiGetCapabilities.fetchCollectionTileSet(capabilities, collection, tileSets[0], {}, CollectionLinkType.Tiles);
// tileSet.style: the id of the style the tiles are drawn in, when the server tells (ldproxy does)
  • Each style lists its legends in legendLinks (rel legend, OGC 20-058 Recommendation 4), an image to show next to the layer, for an application that wants a legend; the demo doesn't show it. GeoServer has them.
  • The default style of the styles document comes first. The map or tiles without a style need not be the same images, the standard doesn't say so.
  • A dataset can have map tiles only per style: ldproxy Strassen does, its landing page has no map tiles of its own.
  • To change the style of a layer, change it on its model: the layer stays the same, with its id, and redraws.
    // Maps: another map link of the collection or dataset, of a style, or the own map link to go back to no style
    mapsModel.setMapLink(style.mapLinks.find(l => l.type === "image/png").href);
    // Map tiles: the tileset of the other style in the model's tile matrix set
    const tileSet = await OgcOpenApiGetCapabilities.fetchCollectionTileSet(capabilities, collection, styleTileSet, {}, CollectionLinkType.Tiles);
    tilesModel.setTileSet({tileMatrix, baseURL: tileSet.links.find(l => l.type === "image/png").href, tileMatrixSetLimits: tileSet.tileMatrixSetLimits});
    // Vector tiles are styled in the browser: give the layer another MapboxStyle
    vectorTileLayer.style = MapboxStyle.createFromObject(await OgcOpenApiStyleTools.fetchMapboxStyle(capabilities, stylesheet));
    The link's query, such as its f value, replaces that of the previous link; the other options of the model are kept. The app's requestHeaders, requestParameters and credentials stay on the origin of the link the model was made with: while a link is on another origin, the images are requested without them, and they are back when a link is on that origin again. Use these methods, not LuciadRIA's getMapRoot or baseURL setters, which leave the previous link's query and limits behind and send the app's credentials anywhere. When the change can't be made live they throw an OgcOpenApiError and leave the model as it was: a tileset in another tile matrix set than the model's (its grid is fixed when it is created). The app decides then, for example by making a new model and replacing the layer, as the demo does (createStyleChoice in demo/src/main.ts).
  • A style with chosen collections (collections): OGC 20-057 Requirement 16 B allows it, ldproxy answers 400 and no other test server has dataset styles. The library doesn't prevent it; the demo offers styles for one collection, or for the whole dataset without collections.
  • mayOfferMapStyles(capabilities, collection) tells, without a request, whether a collection may have map styles: it links its styles, and the server declares OGC API Maps or Tiles. A collection list need not link the styles: GeoServer's OGC API Tiles links them only in the collection document, so the demo asks for the styles of the collection anyway; a collection without styles answers 404, an empty list.

Tested: | Server | Styles of | Maps | Map tiles | |---|---|---|---| | GeoServer 3.0.x, OGC API Maps (local) | collections | ✅ map and legend per style | | | GeoServer 3.0.x, OGC API Tiles (local) | collections | | ⚠️ the tiles work by path, but each style's tilesets-map link leaves out the style id and answers 404: to report, not worked around | | ldproxy Strassen | the dataset | | ✅ asb and topo, the tileset names its style | | CubeWerx Daraa | | ⚠️ /styles answers 500 | ⚠️ same | | GNOSIS | collections | links read, maps 401 | links read, tiles 401 |

Vector tiles

OgcOpenApiVectorTilesModel extends LuciadRIA's MapboxVectorTileSetModel, use it with a MapboxVectorTileSetLayer and a MapboxStyle. The style is one of the server (OGC API Styles) for the tile matrix set in use, or a style generated from the layers in the tiles when the server has none:

import {MapboxVectorTileSetLayer} from "@luciad/ria/view/mapbox/MapboxVectorTileSetLayer.js";
import {MapboxStyle} from "@luciad/ria/view/mapbox/MapboxStyle.js";
import {OgcOpenApiVectorTilesModel} from "ogcopenapis/OgcOpenApiVectorTilesModel";
import {OgcOpenApiStyleTools} from "ogcopenapis/OgcOpenApiStyleTools";

async function createVectorTileLayer(map: Map, capabilities: OgcOpenApiCapabilitiesObject, collection: OgcOpenApiCapabilitiesCollection | null) {
    const tileSets = await fetchUsableTileSets(capabilities, collection, CollectionLinkType.VectorTiles);
    const {tileSet: tileSetInfo, tileMatrix} = pickTileSet(map, tileSets);
    const tileSet = await OgcOpenApiGetCapabilities.fetchCollectionTileSet(capabilities, collection, tileSetInfo, {}, CollectionLinkType.VectorTiles);
    // Mapbox Vector Tiles, the vector tile encoding LuciadRIA reads
    const link = tileSet.links.find(l => l.type === "application/vnd.mapbox-vector-tile") || tileSet.links.find(l => !l.type);
    if (!link) throw new Error("The tileset has no Mapbox Vector Tiles");
    const label = collection ? collection.title || collection.id : "All collections";
    const model = new OgcOpenApiVectorTilesModel({
        tileMatrix,
        baseURL: link.href,
        collection: collection ? collection.id : "dataset",
        tileMatrixSetLimits: tileSet.tileMatrixSetLimits,
    });
    // The styles of the collection, or of the dataset, for this tile matrix set. An application can let the user pick one
    const styles = OgcOpenApiStyleTools.getStylesForTileMatrixSet(
        await OgcOpenApiStyleTools.fetchStyles(capabilities, collection), tileMatrix.id, tileSets.map(t => t.tileMatrix.id));
    let styleJson;
    if (styles.length > 0) {
        styleJson = await OgcOpenApiStyleTools.fetchMapboxStyle(capabilities, OgcOpenApiStyleTools.pickStylesheet(styles[0], tileMatrix.id));
    } else {
        // The layers in the tiles: from the tileset, or read from a few tiles where the data is
        const layers = tileSet.layers.length > 0 ? tileSet.layers : await model.discoverLayers({extent: getExtent(collection, tileSet)});
        styleJson = OgcOpenApiStyleTools.createDefaultStyle(layers, label);
    }
    return new MapboxVectorTileSetLayer(model, {label, style: MapboxStyle.createFromObject(styleJson)});
}

Tiles of the dataset

Some servers tile the dataset as a whole, with all its collections in each tile, and some only the dataset (PDOK). The tilesets and styles of the dataset are linked from the landing page. The functions above take null for them:

if (OgcOpenApiGetCapabilities.hasDatasetTileSets(capabilities, CollectionLinkType.VectorTiles)) {
    map.layerTree.addChild(await createVectorTileLayer(map, capabilities, null));
}

The tiles of the dataset can hold only some of its collections, when the server supports the collections parameter (OGC API Tiles, collections selection). Both tiles models take them as collections:

if (OgcOpenApiGetCapabilities.supportsCollectionSelection(capabilities)) {
    const model = new OgcOpenApiVectorTilesModel({
        tileMatrix,
        baseURL: link.href,
        collection: "dataset",
        tileMatrixSetLimits: tileSet.tileMatrixSetLimits,
        // The ids of the collections, as capabilities.collections lists them
        collections: ["abschnitteaeste"],
    });
}
  • supportsCollectionSelection reads the conformance classes of the server (capabilities.conformsTo): the class of the standard, http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/collections-selection (OGC 20-057, Table 7). Given CollectionLinkType.Tiles, for map tiles, it also accepts the Collections Selection class of OGC API Maps, which selects the collections of "maps or map tiles" (OGC 20-058, 10.2).
  • It also accepts http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/collection-selection, a name that is not in the standard: ldproxy declares the class so, and supports the parameter as the standard requires. COLLECTIONS_SELECTION_CONFORMANCE_VARIANTS lists it, to be removed once ldproxy declares the class of the standard.
  • The models do not check the conformance classes: they request the collections they are given. Use collections for tilesets of the dataset only, the tiles of a collection hold that collection.
  • A comma inside a collection id is encoded, the commas between ids are not. A collections parameter in the tile URL template is replaced.
  • Tested on live servers with vector tiles (ldproxy). Map (raster) tiles of the dataset with collections are not: none of the test servers offers them except GNOSIS, which needs a login. The demo's browser tests run them against a mock server that follows OGC API Tiles. For a raster image of several collections, the map of the dataset (OGC API Maps, above) is tested with CubeWerx and GeoServer.

Several collections in one layer

Users often want one layer that combines several collections: satellite imagery with roads and rivers on it. The OGC standards define this for three APIs, always on the resources of the dataset, with the collections parameter of their Collections Selection class:

| API | Resource of the dataset | Standard | |---|---|---| | Maps | /map?collections=a,b | OGC 20-058, Dataset Map and Collections Selection | | Map tiles | /map/tiles/{tileMatrixSetId}/{z}/{y}/{x}?collections=a,b | OGC 20-057, Dataset Tilesets and Collections Selection | | Vector tiles | /tiles/{tileMatrixSetId}/{z}/{y}/{x}?collections=a,b | OGC 20-057, Dataset Tilesets and Collections Selection |

OGC API Features has no such parameter: items are always those of one collection. The map or tiles of a single collection (/collections/{id}/…) hold only that collection, a collections parameter there is ignored.

Not every server implements it. The library tells you whether a server merges collections, and lets it merge them; what to do when it can't is up to your application. Below: detecting, letting the server merge, and one possible fallback, the one the demo uses, see In the demo.

1. Detect what the server merges

Two checks per API, read from the landing page and the conformance classes, without requests:

function serverMergesCollections(capabilities: OgcOpenApiCapabilitiesObject, linkType: CollectionLinkType) {
    switch (linkType) {
        case CollectionLinkType.Map:
            return OgcOpenApiGetCapabilities.hasDatasetMap(capabilities) &&
                OgcOpenApiGetCapabilities.supportsMapCollectionSelection(capabilities);
        case CollectionLinkType.Tiles:
        case CollectionLinkType.VectorTiles:
            return OgcOpenApiGetCapabilities.hasDatasetTileSets(capabilities, linkType) &&
                OgcOpenApiGetCapabilities.supportsCollectionSelection(capabilities, linkType);
        default:
            // Features: not defined by the standard
            return false;
    }
}
  • The first check is the resource of the dataset, linked from the landing page. The second is the Collections Selection class in capabilities.conformsTo, in https or http.

  • OGC API Maps and OGC API Tiles each define a Collections Selection class, and the standards let either apply to maps and map tiles (OGC 20-058, 10.2 and 20.4). supportsMapCollectionSelection accepts both. supportsCollectionSelection accepts both when given CollectionLinkType.Tiles; for vector tiles, or without a link type, it accepts the class of OGC API Tiles only.

  • On every server we tested, what a server declares is what it does. Servers that declare the class honour the parameter and answer 400 for an unknown collection id. Servers that don't declare it reject the parameter with 400 (ldproxy Zoomstack) or ignore it (PDOK):

    | Server | Maps | Map tiles | Vector tiles | |---|---|---|---| | CubeWerx | merges | no tiles of the dataset | no tiles of the dataset | | GeoServer 3.0 with the OGC API Maps community module | merges | no tiles of the dataset | no tiles of the dataset | | ldproxy | no maps | no tiles of the dataset | merges | | PDOK, ldproxy Zoomstack | no maps | no tiles of the dataset | all collections only | | pygeoapi | maps of collections only | no tiles of the dataset | no tiles of the dataset |

  • The detection is false when /conformance can't be read. A server may refuse some combinations of collections, which the standard allows: the request then fails, as for an unknown id.

2. Let the server merge them

When the server merges, one layer requests the resource of the dataset with the collections. The server draws them in the order given, the first at the bottom, unless its style says otherwise (OGC 20-058 Req. 12 B, OGC 20-057 Req. 16 B):

// Maps: createDatasetMapLayer of "Map of the dataset, several collections in one image" above
map.layerTree.addChild(createDatasetMapLayer(map, capabilities, ["Daraa_mosaic_2019", "TransportationGroundCrv"]));

// Map tiles and vector tiles: the tileset of the dataset, with collections on the model
const {tileSet: tileSetInfo, tileMatrix} = pickTileSet(map, await fetchUsableTileSets(capabilities, null, CollectionLinkType.Tiles));
const tileSet = await OgcOpenApiGetCapabilities.fetchCollectionTileSet(capabilities, null, tileSetInfo, {}, CollectionLinkType.Tiles);
const link = tileSet.links.find(l => l.type === "image/png") || tileSet.links[0];
const model = await OgcOpenApiTilesModel.createFromTileSet({
    tileMatrix, baseURL: link.href, collection: "dataset", tileMatrixSetLimits: tileSet.tileMatrixSetLimits,
    // The first drawn at the bottom
    collections: ["imagery", "roads"],
});
map.layerTree.addChild(new RasterTileSetLayer(model, {label: "Dataset: roads, imagery"}));
  • Pass the ids that capabilities.collections lists: one unknown id fails every request.
  • For vector tiles, OgcOpenApiVectorTilesModel takes collections the same way. Each collection stays a layer inside the tile, and the style decides what is drawn on top. All collections: leave collections out, the tiles of the dataset hold them all.
  • A map, or a map tile, is one image the server draws: the order and visibility of one collection change only with a new layer.

3. When the server can't: a suggestion

When the server has no resource of the dataset, or doesn't declare Collections Selection, how to deal with it is your choice: offer one collection at a time, explain why, or open the collections as individual layers. The demo does the last: one layer per collection, grouped, and LuciadRIA draws the children of a group in order, the last added on top. This is a hint, not part of the library:

import {Layer} from "@luciad/ria/view/Layer.js";
import {LayerGroup} from "@luciad/ria/view/LayerGroup.js";

// ids in drawing order, the first at the bottom. createLayerOf creates the layer of one collection:
// createMapLayer, createTileLayer or createVectorTileLayer above
async function stackCollections(capabilities: OgcOpenApiCapabilitiesObject, ids: string[],
                                createLayerOf: (collection: OgcOpenApiCapabilitiesCollection) => Promise<Layer>) {
    const collections = ids.map(id => capabilities.collections.find(c => c.id === id));
    const layers = await Promise.all(collections.map(createLayerOf));
    const group = new LayerGroup({label: "Combined in the browser: " + [...collections].reverse().map(c => c.title || c.id).join(", ")});
    layers.forEach(layer => group.addChild(layer));
    return group;
}

const group = await stackCollections(capabilities, ["Daraa_mosaic_2019", "TransportationGroundCrv"],
    collection => createTileLayer(map, capabilities, collection));
map.layerTree.addChild(group);
  • The picture is the same as a merged one, but it costs one tile or map request per collection, and labels are placed per collection.
  • Each collection must be offered in the same tile matrix set, otherwise LuciadRIA reprojects or the tiles don't line up. The demo uses the tile matrix set the user picked, and reports a collection that lacks it.
  • A stacked group keeps each collection's own layer: users can hide one, which a merged layer can't do. Show the group as a group in your layer list.

In the demo

npm run demo implements the three steps, as an example for your own UI. In demo/src/main.ts:

| What | Where | |---|---| | Detection per API | isMultiPick (the server merges) and isBrowserCombine (the demo stacks) | | Why a server can't merge, shown in the status line | combineReason, combineNote | | Checkboxes instead of a dropdown, with "All collections" | fillCollectionsList, setPickedCollections | | The draw order, the top one on top, with ▲/▼ | renderDrawOrder | | Server-side merging | createDatasetMapLayer (Maps), createLayer with the tileset of the dataset (map and vector tiles) | | The fallback, a LuciadRIA layer group | createBrowserGroup, createCollectionTilesLayer, createCollectionMapLayer | | A group in the layer list, its layers each with their own visibility | addToLayerList, createGroupChildren |

Try it with:

  • CubeWerx Daraa, Maps: the server merges.
  • ldproxy Daraa, vector tiles: the server merges.
  • CubeWerx Daraa, map tiles or vector tiles: the demo stacks them in LuciadRIA.

Styles

  • LuciadRIA reads the Mapbox GL encoding of OGC API Styles only, not SLD or other encodings.
  • A server can publish a stylesheet per tile matrix set, because zoom levels depend on it. pickStylesheet picks the one for the tile matrix set in use.
  • A server can also publish a style per tile matrix set, named after it (PDOK: bgt_standaardvisualisatie__netherlandsrdnewquad). getStylesForTileMatrixSet leaves out the styles named after another tile matrix set.
  • fetchMapboxStyle removes properties without a value ("filter" : ,), so that styles that are not valid JSON can still be used.
  • createDefaultStyle paints points, lines and surfaces by the geometryDimension of the layers, without labels.
  • Not all servers list the layers of a tileset (CubeWerx, pygeoapi and PDOK do not), and the names of the layers in the tiles differ per server: ldproxy and CubeWerx name the layer of a collection after it, pygeoapi after its source data. discoverLayers of the vector tiles model reads them from a few tiles where the data is.

References

LuciadRIA reprojects tiles and features to the reference of the map, but it knows only some EPSG references by default. LuciadRIA 2026.1.1 does not know the references of five of the tile matrix sets of the OGC standard (UTM31WGS84Quad EPSG:32631, UPSArcticWGS84Quad EPSG:5041, UPSAntarcticWGS84Quad EPSG:5042, EuropeanETRS89_LAEAQuad EPSG:3035 and CanadianNAD83_LCC EPSG:3978), nor of PDOK's NetherlandsRDNewQuad (EPSG:28992). The library does not register references itself: register the ones your servers use before creating a model, as the demo does in demo/src/references.ts:

import {addReference, parseWellKnownText} from "@luciad/ria/reference/ReferenceProvider.js";

addReference(parseWellKnownText('PROJCS["RD",GEOGCS["Amersfoort", ...]]'), "EPSG:28992");

Applications that load references on demand, such as MapEvolution with requireReference and retryOnUnknownReference, need nothing more. When a reference is unknown, the models throw LuciadRIA's own UnknownIdentifierError with its identifier (EPSG:3035), so the reference can be loaded and the model created again:

import {OgcOpenApiCrsTools} from "ogcopenapis/OgcOpenApiCrsTools";

// Before listing tile matrix sets: load their references, so that none is left out because its reference is not loaded yet
await Promise.all(tileMatrixSets.map(t => requireReference(OgcOpenApiCrsTools.getReferenceName(t.crs)).catch(() => undefined)));
// When creating a model: a tile matrix set fetched later can bring another reference
const model = await retryOnUnknownReference(() => OgcOpenApiTilesModel.createFromTileSet(options));
// The vector tiles model is created synchronously, an async wrapper lets the same retry apply
const vectorModel = await retryOnUnknownReference(async () => new OgcOpenApiVectorTilesModel(vectorOptions));

getReferenceName turns http://www.opengis.net/def/crs/EPSG/0/28992 into EPSG:28992, the identifier to load. It does not convert the https:// form of those URIs, nor a CRS given as an object ({uri} or {wkt}, allowed by OGC 2D Tile Matrix Set 2.0): none of the test servers uses them in a tile matrix set.

The axis order of a reference matters for raster tiles: EPSG:3035 is northing first. Its WKT should declare that with AXIS["Northing",NORTH],AXIS["Easting",EAST], as the EPSG definitions in LuciadRIA's sample data (epsg_coord_ref.txt, which MapEvolution uses) do. The WKT of epsg.io that the demo uses has no AXIS, which is enough for vector tiles only.

Notes

  • Map tiles support any tile matrix set of LuciadRIA's WMTS support. Vector tiles support only tile matrix sets that LuciadRIA can address as a quad-tree, LuciadRIA's vector tile structure is a quad-tree.
  • Tile matrix sets with a bottomLeft corner of origin are not in WMTS 1.0, createFromTileSet supports them as quad-trees only.
  • variableMatrixWidths (coalesced tile matrices) is not supported.
  • A tileset can include its tile matrix set instead of linking it, fetchTileMatrixSetOfTileSet uses it then.
  • OGC URIs (www.opengis.net: conformance classes, link relations, profiles) are read with http or https. OGC standards write them both ways (OGC API Tiles and Features with http, OGC API Maps with https), and servers follow either. Only the scheme may differ: the /0 version alias and CURIEs are not read. isSameOgcUri compares two so.
  • Tile matrix sets are read in the OGC 2D TMS 2.0 encoding (OGC 17-083r4), the one OGC API Tiles 1.0 uses. A definition without what TMS 2.0 requires (crs, tileMatrices, and of each tile matrix id, scaleDenominator, cellSize, pointOfOrigin, tileWidth, tileHeight, matrixWidth, matrixHeight) is left out, with a message that names what it lacks. The TMS 1.0 encoding (supportedCRS, no cellSize) is not read: GeoServer 2.28 and 3.0 serve it, so their OGC API Tiles can't be used. GeoServer's WMTS (/geoserver/gwc/service/wmts) serves the same tiles, from the same GeoWebCache layers, and LuciadRIA reads it with its own WMTS model.
  • Levels that are not in the tileMatrixSetLimits of a tileset have no tiles. PDOK tiles BGT at one level only, RD level 12: nothing shows until the map is zoomed in to about 1 m per pixel, and LuciadRIA over-zooms beyond it.
  • LuciadRIA 2026.1.1 paints nothing for a vector tiles model with minLevel > 0. OgcOp