# @open-pioneer/ogc-features

> This package provides utilities to work with OGC API Features services.

Latest version **1.7.0** (published 2026-11-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @open-pioneer/ogc-features
pnpm add @open-pioneer/ogc-features
yarn add @open-pioneer/ogc-features
bun add @open-pioneer/ogc-features
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.7.0 |
| Published | 2026-11-19 |
| First published | 2023-11-20 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 6 |
| Unpacked size | 98.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 13 |
| Maintainers | mbeckem_conterra, jessebluemr, antoniave_conterra, open_pioneer |
| Keywords | open-pioneer-trails |

## Links

- npm: https://www.npmjs.com/package/@open-pioneer/ogc-features
- Repository: https://github.com/open-pioneer/trails-openlayers-base-packages
- Homepage: https://github.com/open-pioneer
- npm.io page: https://npm.io/package/@open-pioneer/ogc-features

## Dependencies (6)

- [ol](https://npm.io/package/ol.md) ^10.11.0
- [uuid](https://npm.io/package/uuid.md) ^14.0.3
- [@open-pioneer/core](https://npm.io/package/@open-pioneer/core.md) ^4.10.0
- [@open-pioneer/http](https://npm.io/package/@open-pioneer/http.md) ^4.10.0
- [@open-pioneer/search](https://npm.io/package/@open-pioneer/search.md) 1.7.0
- [@open-pioneer/runtime](https://npm.io/package/@open-pioneer/runtime.md) ^4.10.0

## Recent versions

- 1.7.0 (latest) — 2026-11-19
- 1.7.0-dev.20261119092321 (dev) — 2026-11-19
- 1.7.0-dev-test-123.20261117141135 (dev-test-123) — 2026-11-17
- 1.7.0-dev.20261110145318 — 2026-11-10
- 1.6.0 — 2026-10-30
- 1.6.0-dev.20261029095559 — 2026-10-29
- 1.5.0 — 2026-09-17
- 1.5.0-dev.20260917081843 — 2026-09-17
- 1.5.0-dev.20260911123645 — 2026-09-11
- 1.5.0-dev.20260910103330 — 2026-09-10
- 1.4.0 — 2026-07-28
- 1.4.0-dev.20260727093741 — 2026-07-27
- 1.4.0-dev.20260625074633 — 2026-06-25
- 1.4.0-dev.20260624132304 — 2026-06-24
- 1.4.0-dev-chakra-336.20260616133316 — 2026-06-16
- … 54 more at https://npm.io/package/@open-pioneer/ogc-features/versions

## README

# @open-pioneer/ogc-features

This package provides utilities to work with OGC API Features services.

## Usage

### Vector source

This vector source should be used together with a vector layer.

Inject the vector source factory by referencing `"ogc-features.VectorSourceFactory"`:

```js
// build.config.mjs
import { defineBuildConfig } from "@open-pioneer/build-support";

export default defineBuildConfig({
    services: {
        YourService: {
            // ...
            references: {
                vectorSourceFactory: "ogc-features.VectorSourceFactory"
            }
        }
    }
});
```

and use it inside a VectorLayer:

```ts
const vectorSourceFactory = ...; // injected
const vectorLayer = new VectorLayer({
    source: vectorSourceFactory.createVectorSource({
        baseUrl: "https://ogc-api.nrw.de/inspire-us-kindergarten/v1",
        collectionId: "governmentalservice",
        attributions:
            "<a href='https://www.govdata.de/dl-de/by-2-0'>Datenlizenz Deutschland - Namensnennung - Version 2.0</a>",

        /** Optional: number of features loaded per request. */
        limit: 5000,

        /** Optional: passed to the Open Layers Vector Source constructor. */
        additionalOptions: {},
    })
});
```

Additional options of the `VectorSource` (see [OpenLayers documentation](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html)) can be given by the property
`additionalOptions`.

#### Loading strategies

The vector source supports two different strategies to load features from the server:

- `"next"`: Fetch large feature results by walking the `next` link of the previous response.
  This is well supported by most implementations, but can be slow for very large result sets
  because it does not allow for parallel requests.
- `"offset"`: Fetch large feature results using parallel requests.
  Each request fetches a page of results using an `"offset"` and `"limit"` parameter.
  This can be much faster than the `"next"` strategy, but it is not supported by all server implementations.

By default, the vector source will attempt to detect the server's capabilities and will prefer `"offset"`, if supported.
You can overwrite the default behavior by explicitly defining the `strategy` option.

If the `"offset"` strategy is used, you can configure the maximum number of concurrent requests (default: 6).

Example:

```ts
vectorSourceFactory.createVectorSource({
    baseUrl: "https://ogc-api.nrw.de/inspire-us-kindergarten/v1",
    collectionId: "governmentalservice",

    strategy: "offset",
    limit: 2500,
    maxConcurrentRequests: 6
});
```

#### Rewriting request URLs

The optional `rewriteUrl` option can be used to modify the feature requests made by the vector source.
This is useful, for example, to filter the OGC service on the server side.

Note that modifying the vector source's URL requires some care: existing query parameters should not be overwritten unless you know what you're doing.
The vector source may add additional query parameters in the future, which might conflict with the changes done by custom `rewriteUrl` implementations.

Example:

```ts
vectorSourceFactory.createVectorSource({
    baseUrl: "https://ogc-api.nrw.de/inspire-us-kindergarten/v1",
    collectionId: "governmentalservice",

    rewriteUrl(url) {
        url.searchParams.set("property", "value");
        return url;
    }
});
```

### Search source

This search source is used to search in OGC API features.

Inject the search source factory by referencing `"ogc-features.SearchSourceFactory"`:

```js
// build.config.mjs
import { defineBuildConfig } from "@open-pioneer/build-support";

export default defineBuildConfig({
    services: {
        YourService: {
            // ...
            references: {
                ogcSearchSourceFactory: "ogc-features.SearchSourceFactory"
            }
        }
    }
});
```

and create a search source instance:

```ts
const ogcSearchSourceFactory = ...; // injected
const searchSource = ogcSearchSourceFactory.createSearchSource({
    label: this.intl.formatMessage({ id: "searchSources.lika" }),
    baseUrl: "https://ogc-api.nrw.de/lika/v1",
    collectionId: "flurstueck",
    searchProperty: "flurstid",
    labelProperty: "objid"
});
```

Use the callback function `renderLabel` to create a custom label for the result.

```ts
searchSourceFactory.createSearchSource({
    // ...
    renderLabel(feature) {
        const tntxt = feature?.properties?.tntxt;
        const id = feature?.id;
        if (typeof tntxt === "string") {
            return tntxt + " (" + id + ")";
        } else {
            return String(id);
        }
    }
    // ...
});
```

The label is generated by one of the following methods, weighted by order:

1. `renderLabel` function
2. `labelProperty`
3. `searchProperty`

To overwrite the service URL, use the callback function `rewriteUrl`.
This is useful, for example, to return only a specific attribute in the response, as in the following example:

```ts
searchSourceFactory.createSearchSource({
    // ...
    rewriteUrl(url) {
        url.searchParams.set("properties", "objid");
        return url;
    }
    // ...
});
```

## License

Apache-2.0 (see `LICENSE` file)

---
_Source: https://npm.io/package/@open-pioneer/ogc-features · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
