New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@camptocamp/ogc-client

Package Overview
Dependencies
Maintainers
7
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@camptocamp/ogc-client - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1-dev.a0aadb6

34

dist/ogc-api/endpoint.d.ts

@@ -11,2 +11,3 @@ import { ConformanceClass, OgcApiCollectionInfo, OgcApiCollectionItem, OgcApiEndpointInfo } from './model.js';

private data_;
private tileMatrixSetsFull_;
private get root();

@@ -16,2 +17,3 @@ private get conformance();

private get data();
private get tileMatrixSetsFull();
/**

@@ -34,3 +36,9 @@ * Creates a new OGC API endpoint.

*/
get allCollections(): Promise<string[]>;
get allCollections(): Promise<{
name: string;
hasRecords?: boolean;
hasFeatures?: boolean;
hasVectorTiles?: boolean;
hasMapTiles?: boolean;
}[]>;
/**

@@ -45,2 +53,10 @@ * A Promise which resolves to an array of records collection identifiers as strings.

/**
* A Promise which resolves to an array of vector tile collection identifiers as strings.
*/
get vectorTileCollections(): Promise<string[]>;
/**
* A Promise which resolves to an array of map tile collection identifiers as strings.
*/
get mapTileCollections(): Promise<string[]>;
/**
* A Promise which resolves to a boolean indicating whether the endpoint offer tiles.

@@ -61,2 +77,6 @@ */

get hasRecords(): Promise<boolean>;
/**
* Retrieve the tile matrix sets identifiers advertised by the endpoint. Empty if tiles are not supported
*/
get tileMatrixSets(): Promise<string[]>;
private getCollectionDocument;

@@ -109,3 +129,15 @@ /**

}): Promise<string>;
/**
* Asynchronously retrieves a URL to render a specified collection as vector tiles, with a given tile matrix set.
* @param collectionId - The unique identifier for the collection.
* @param tileMatrixSet - The identifier of the tile matrix set to use. Default is 'WebMercatorQuad'.
*/
getVectorTilesetUrl(collectionId: string, tileMatrixSet?: string): Promise<string>;
/**
* Asynchronously retrieves a URL to render a specified collection as map tiles, with a given tile matrix set.
* @param collectionId - The unique identifier for the collection.
* @param tileMatrixSet - The identifier of the tile matrix set to use. Default is 'WebMercatorQuad'.
*/
getMapTilesetUrl(collectionId: string, tileMatrixSet?: string): Promise<string>;
}
//# sourceMappingURL=endpoint.d.ts.map

@@ -10,3 +10,4 @@ import {

parseConformance,
parseEndpointInfo
parseEndpointInfo,
parseTileMatrixSets
} from "./info.js";

@@ -42,2 +43,3 @@ import {

data_;
tileMatrixSetsFull_;
get root() {

@@ -87,2 +89,16 @@ if (!this.root_) {

}
get tileMatrixSetsFull() {
if (!this.tileMatrixSetsFull_) {
this.tileMatrixSetsFull_ = this.root.then(async (root) => {
if (!await this.hasTiles)
return [];
return fetchLink(
root,
["http://www.opengis.net/def/rel/ogc/1.0/tiling-schemes"],
this.baseUrl
).then(parseTileMatrixSets);
});
}
return this.tileMatrixSetsFull_;
}
/**

@@ -110,3 +126,3 @@ * A Promise which resolves to the endpoint information.

get recordCollections() {
return Promise.all([this.data, this.hasRecords]).then(([data, hasRecords]) => hasRecords ? data : { collections: [] }).then(parseCollections("record"));
return Promise.all([this.data, this.hasRecords]).then(([data, hasRecords]) => hasRecords ? data : { collections: [] }).then(parseCollections("record")).then((collections) => collections.map((collection) => collection.name));
}

@@ -117,5 +133,21 @@ /**

get featureCollections() {
return Promise.all([this.data, this.hasFeatures]).then(([data, hasFeatures]) => hasFeatures ? data : { collections: [] }).then(parseCollections("feature"));
return Promise.all([this.data, this.hasFeatures]).then(([data, hasFeatures]) => hasFeatures ? data : { collections: [] }).then(parseCollections("feature")).then((collections) => collections.map((collection) => collection.name));
}
/**
* A Promise which resolves to an array of vector tile collection identifiers as strings.
*/
get vectorTileCollections() {
return Promise.all([this.data, this.hasTiles]).then(([data, hasTiles]) => hasTiles ? data : { collections: [] }).then(parseCollections()).then(
(collections) => collections.filter((collection) => collection.hasVectorTiles)
).then((collections) => collections.map((collection) => collection.name));
}
/**
* A Promise which resolves to an array of map tile collection identifiers as strings.
*/
get mapTileCollections() {
return Promise.all([this.data, this.hasTiles]).then(([data, hasTiles]) => hasTiles ? data : { collections: [] }).then(parseCollections()).then(
(collections) => collections.filter((collection) => collection.hasMapTiles)
).then((collections) => collections.map((collection) => collection.name));
}
/**
* A Promise which resolves to a boolean indicating whether the endpoint offer tiles.

@@ -150,5 +182,11 @@ */

}
/**
* Retrieve the tile matrix sets identifiers advertised by the endpoint. Empty if tiles are not supported
*/
get tileMatrixSets() {
return this.tileMatrixSetsFull.then((sets) => sets.map((set) => set.id));
}
getCollectionDocument(collectionId) {
return Promise.all([this.allCollections, this.data]).then(([collections, data]) => {
if (collections.indexOf(collectionId) === -1)
if (!collections.find((collection) => collection.name === collectionId))
throw new EndpointError(`Collection not found: ${collectionId}`);

@@ -172,3 +210,3 @@ return data.collections.find(

const baseInfo = parseBaseCollectionInfo(collectionDoc);
const [queryables, sortables] = await Promise.all([
const [queryables, sortables, tilesetsVector, tilesetsMap] = await Promise.all([
fetchLink(

@@ -183,8 +221,45 @@ collectionDoc,

this.baseUrl
).then(parseCollectionParameters).catch(() => [])
).then(parseCollectionParameters).catch(() => []),
fetchLink(
collectionDoc,
["http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector"],
this.baseUrl
).then((tilesetDoc) => tilesetDoc.tilesets).catch(() => []),
fetchLink(
collectionDoc,
["http://www.opengis.net/def/rel/ogc/1.0/tilesets-map"],
this.baseUrl
).then((tilesetDoc) => tilesetDoc.tilesets).catch(() => [])
]);
const tileMatrixSetsFull = await this.tileMatrixSetsFull;
const supportedTileMatrixSets = tilesetsVector.map(
(tileset) => tileMatrixSetsFull.find((set) => set.uri === tileset.tileMatrixSetURI)?.id
).filter(Boolean);
const firstTilesetVector = tilesetsVector[0];
let vectorTileFormats = [];
if (firstTilesetVector) {
const tilesetUrl = getLinkUrl(firstTilesetVector, "self", this.baseUrl);
if (!tilesetUrl) {
throw new Error("No links found for the tileset");
}
const tilesetDoc = await fetchDocument(tilesetUrl);
vectorTileFormats = tilesetDoc.links.filter((link) => link.rel === "item").map((link) => link.type);
}
const firstTilesetMap = tilesetsMap[0];
let mapTileFormats = [];
if (firstTilesetMap) {
const tilesetUrl = getLinkUrl(firstTilesetMap, "self", this.baseUrl);
if (!tilesetUrl) {
throw new Error("No links found for the tileset");
}
const tilesetDoc = await fetchDocument(tilesetUrl);
mapTileFormats = tilesetDoc.links.filter((link) => link.rel === "item").map((link) => link.type);
}
return {
...baseInfo,
queryables,
sortables
sortables,
mapTileFormats,
vectorTileFormats,
supportedTileMatrixSets
};

@@ -290,2 +365,80 @@ }

}
/**
* Asynchronously retrieves a URL to render a specified collection as vector tiles, with a given tile matrix set.
* @param collectionId - The unique identifier for the collection.
* @param tileMatrixSet - The identifier of the tile matrix set to use. Default is 'WebMercatorQuad'.
*/
getVectorTilesetUrl(collectionId, tileMatrixSet = "WebMercatorQuad") {
return this.getCollectionDocument(collectionId).then(async (collectionDoc) => {
const collectionTilesLink = getLinkUrl(
collectionDoc,
"http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector",
this.baseUrl
);
const collectionTiles = await fetchDocument(collectionTilesLink);
const matrixSet = (await this.tileMatrixSetsFull).find(
(set) => set.id === tileMatrixSet
);
if (!matrixSet) {
throw new Error(
`The following tile matrix set does not exist on this endpoint: '${tileMatrixSet}'.`
);
}
const tileset = collectionTiles.tilesets.find(
(tileset2) => tileset2.tileMatrixSetURI === matrixSet.uri
);
if (!tileset) {
throw new Error(
`The collection '${collectionId}' does not support the tile matrix set '${tileMatrixSet}'.`
);
}
const tilesetUrl = getLinkUrl(tileset, "self", this.baseUrl);
if (!tilesetUrl) {
throw new Error("No links found for the tileset");
}
return tilesetUrl;
}).catch((error) => {
console.error("Error fetching collection tileset URL:", error.message);
throw error;
});
}
/**
* Asynchronously retrieves a URL to render a specified collection as map tiles, with a given tile matrix set.
* @param collectionId - The unique identifier for the collection.
* @param tileMatrixSet - The identifier of the tile matrix set to use. Default is 'WebMercatorQuad'.
*/
getMapTilesetUrl(collectionId, tileMatrixSet = "WebMercatorQuad") {
return this.getCollectionDocument(collectionId).then(async (collectionDoc) => {
const collectionTilesLink = getLinkUrl(
collectionDoc,
"http://www.opengis.net/def/rel/ogc/1.0/tilesets-map",
this.baseUrl
);
const collectionTiles = await fetchDocument(collectionTilesLink);
const matrixSet = (await this.tileMatrixSetsFull).find(
(set) => set.id === tileMatrixSet
);
if (!matrixSet) {
throw new Error(
`The following tile matrix set does not exist on this endpoint: '${tileMatrixSet}'.`
);
}
const tileset = collectionTiles.tilesets.find(
(tileset2) => tileset2.tileMatrixSetURI === matrixSet.uri
);
if (!tileset) {
throw new Error(
`The collection '${collectionId}' does not support the tile matrix set '${tileMatrixSet}'.`
);
}
const tilesetUrl = getLinkUrl(tileset, "self", this.baseUrl);
if (!tilesetUrl) {
throw new Error("No links found for the tileset");
}
return tilesetUrl;
}).catch((error) => {
console.error("Error fetching collection tileset URL:", error.message);
throw error;
});
}
}

@@ -292,0 +445,0 @@ export {

@@ -1,5 +0,11 @@

import { CollectionParameter, ConformanceClass, OgcApiCollectionInfo, OgcApiDocument, OgcApiEndpointInfo } from './model.js';
import { CollectionParameter, ConformanceClass, OgcApiCollectionInfo, OgcApiDocument, OgcApiEndpointInfo, TileMatrixSet } from './model.js';
export declare function parseEndpointInfo(rootDoc: OgcApiDocument): OgcApiEndpointInfo;
export declare function parseConformance(doc: OgcApiDocument): ConformanceClass[];
export declare function parseCollections(itemType?: 'record' | 'feature' | null): (doc: OgcApiDocument) => string[];
export declare function parseCollections(itemType?: 'record' | 'feature' | null): (doc: OgcApiDocument) => Array<{
name: string;
hasRecords?: boolean;
hasFeatures?: boolean;
hasVectorTiles?: boolean;
hasMapTiles?: boolean;
}>;
export declare function checkTileConformance(conformance: ConformanceClass[]): boolean;

@@ -20,2 +26,3 @@ export declare function checkStyleConformance(conformance: ConformanceClass[]): boolean;

export declare function parseCollectionParameters(doc: OgcApiDocument): CollectionParameter[];
export declare function parseTileMatrixSets(doc: OgcApiDocument): TileMatrixSet[];
//# sourceMappingURL=info.d.ts.map

@@ -37,3 +37,24 @@ import {

(collection) => itemType === null || collection.itemType === itemType
).map((collection) => collection.id);
).map((collection) => {
const result = {
name: collection.id
};
if (collection.itemType === "record") {
result.hasRecords = true;
}
if (collection.itemType === "feature") {
result.hasFeatures = true;
}
if (collection.links.some(
(link) => link.rel === "http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector"
)) {
result.hasVectorTiles = true;
}
if (collection.links.some(
(link) => link.rel === "http://www.opengis.net/def/rel/ogc/1.0/tilesets-map"
)) {
result.hasMapTiles = true;
}
return result;
});
}

@@ -115,2 +136,13 @@ function checkTileConformance(conformance) {

}
function parseTileMatrixSets(doc) {
if (Array.isArray(doc.tileMatrixSets)) {
return doc.tileMatrixSets.map((set) => {
return {
id: set.id,
uri: set.uri
};
});
}
return [];
}
export {

@@ -125,4 +157,5 @@ checkHasFeatures,

parseConformance,
parseEndpointInfo
parseEndpointInfo,
parseTileMatrixSets
};
//# sourceMappingURL=info.js.map

@@ -39,2 +39,3 @@ import { Geometry } from 'geojson';

export interface OgcApiCollectionInfo {
links: any;
title: string;

@@ -68,2 +69,5 @@ description: string;

sortables: CollectionParameter[];
mapTileFormats: MimeType[];
vectorTileFormats: MimeType[];
supportedTileMatrixSets: string[];
}

@@ -83,2 +87,9 @@ export interface OgcApiDocumentLink {

}[];
tilesets?: {
title: string;
tileMatrixSetURI: string;
crs: string;
dataType: string;
links: OgcApiDocumentLink[];
}[];
} & Record<string, unknown>;

@@ -133,3 +144,7 @@ interface OgcApiItemExternalId {

export type OgcApiCollectionItem = OgcApiRecord;
export interface TileMatrixSet {
id: string;
uri: string;
}
export {};
//# sourceMappingURL=model.d.ts.map

2

package.json
{
"name": "@camptocamp/ogc-client",
"version": "1.1.0",
"version": "1.1.1-dev.a0aadb6",
"description": "A pure JS library for interacting with geospatial services.",

@@ -5,0 +5,0 @@ "main": "./dist/dist-node.js",

@@ -1,2 +0,2 @@

# ogc-client
# ogc-client [![Latest version on NPM](https://img.shields.io/npm/v/%40camptocamp%2Fogc-client)](https://www.npmjs.com/package/@camptocamp/ogc-client) [![Latest @dev version on NPM](https://img.shields.io/npm/v/%40camptocamp%2Fogc-client/dev)](https://www.npmjs.com/package/@camptocamp/ogc-client?activeTab=versions)

@@ -51,2 +51,10 @@ > A Typescript library for interacting with [OGC-compliant services](https://www.ogc.org/docs/is)

### Use the latest development version
[The `@camptocamp/ogc-client` NPM package](https://www.npmjs.com/package/@camptocamp/ogc-client) is updated on every commit on the `main` branch under the `@dev` tag. To use it:
```bash
$ npm install --save @camptocamp/ogc-client@dev
```
### Application

@@ -58,2 +66,3 @@

```bash
$ npm install
$ cd app

@@ -60,0 +69,0 @@ $ npm install

@@ -11,2 +11,3 @@ import {

parseEndpointInfo,
parseTileMatrixSets,
} from './info.js';

@@ -19,2 +20,3 @@ import {

OgcApiEndpointInfo,
TileMatrixSet,
} from './model.js';

@@ -47,2 +49,3 @@ import {

private data_: Promise<OgcApiDocument>;
private tileMatrixSetsFull_: Promise<TileMatrixSet[]>;

@@ -96,2 +99,15 @@ private get root(): Promise<OgcApiDocument> {

}
private get tileMatrixSetsFull(): Promise<TileMatrixSet[]> {
if (!this.tileMatrixSetsFull_) {
this.tileMatrixSetsFull_ = this.root.then(async (root) => {
if (!(await this.hasTiles)) return [];
return fetchLink(
root,
['http://www.opengis.net/def/rel/ogc/1.0/tiling-schemes'],
this.baseUrl
).then(parseTileMatrixSets);
});
}
return this.tileMatrixSetsFull_;
}

@@ -118,6 +134,15 @@ /**

}
/**
* A Promise which resolves to an array of all collection identifiers as strings.
*/
get allCollections(): Promise<string[]> {
get allCollections(): Promise<
{
name: string;
hasRecords?: boolean;
hasFeatures?: boolean;
hasVectorTiles?: boolean;
hasMapTiles?: boolean;
}[]
> {
return this.data.then(parseCollections());

@@ -132,3 +157,4 @@ }

.then(([data, hasRecords]) => (hasRecords ? data : { collections: [] }))
.then(parseCollections('record'));
.then(parseCollections('record'))
.then((collections) => collections.map((collection) => collection.name));
}

@@ -142,6 +168,33 @@

.then(([data, hasFeatures]) => (hasFeatures ? data : { collections: [] }))
.then(parseCollections('feature'));
.then(parseCollections('feature'))
.then((collections) => collections.map((collection) => collection.name));
}
/**
* A Promise which resolves to an array of vector tile collection identifiers as strings.
*/
get vectorTileCollections(): Promise<string[]> {
return Promise.all([this.data, this.hasTiles])
.then(([data, hasTiles]) => (hasTiles ? data : { collections: [] }))
.then(parseCollections())
.then((collections) =>
collections.filter((collection) => collection.hasVectorTiles)
)
.then((collections) => collections.map((collection) => collection.name));
}
/**
* A Promise which resolves to an array of map tile collection identifiers as strings.
*/
get mapTileCollections(): Promise<string[]> {
return Promise.all([this.data, this.hasTiles])
.then(([data, hasTiles]) => (hasTiles ? data : { collections: [] }))
.then(parseCollections())
.then((collections) =>
collections.filter((collection) => collection.hasMapTiles)
)
.then((collections) => collections.map((collection) => collection.name));
}
/**
* A Promise which resolves to a boolean indicating whether the endpoint offer tiles.

@@ -180,6 +233,13 @@ */

/**
* Retrieve the tile matrix sets identifiers advertised by the endpoint. Empty if tiles are not supported
*/
get tileMatrixSets(): Promise<string[]> {
return this.tileMatrixSetsFull.then((sets) => sets.map((set) => set.id));
}
private getCollectionDocument(collectionId: string): Promise<OgcApiDocument> {
return Promise.all([this.allCollections, this.data])
.then(([collections, data]) => {
if (collections.indexOf(collectionId) === -1)
if (!collections.find((collection) => collection.name === collectionId))
throw new EndpointError(`Collection not found: ${collectionId}`);

@@ -207,18 +267,69 @@ return (data.collections as OgcApiDocument[]).find(

const baseInfo = parseBaseCollectionInfo(collectionDoc);
const [queryables, sortables] = await Promise.all([
fetchLink(
collectionDoc,
['queryables', 'http://www.opengis.net/def/rel/ogc/1.0/queryables'],
this.baseUrl
const [queryables, sortables, tilesetsVector, tilesetsMap] =
await Promise.all([
fetchLink(
collectionDoc,
['queryables', 'http://www.opengis.net/def/rel/ogc/1.0/queryables'],
this.baseUrl
)
.then(parseCollectionParameters)
.catch(() => []),
fetchLink(
collectionDoc,
['sortables', 'http://www.opengis.net/def/rel/ogc/1.0/sortables'],
this.baseUrl
)
.then(parseCollectionParameters)
.catch(() => []),
fetchLink(
collectionDoc,
['http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector'],
this.baseUrl
)
.then((tilesetDoc) => tilesetDoc.tilesets)
.catch(() => []),
fetchLink(
collectionDoc,
['http://www.opengis.net/def/rel/ogc/1.0/tilesets-map'],
this.baseUrl
)
.then((tilesetDoc) => tilesetDoc.tilesets)
.catch(() => []),
]);
const tileMatrixSetsFull = await this.tileMatrixSetsFull;
const supportedTileMatrixSets = tilesetsVector
.map(
(tileset) =>
tileMatrixSetsFull.find((set) => set.uri === tileset.tileMatrixSetURI)
?.id
)
.then(parseCollectionParameters)
.catch(() => []),
fetchLink(
collectionDoc,
['sortables', 'http://www.opengis.net/def/rel/ogc/1.0/sortables'],
this.baseUrl
)
.then(parseCollectionParameters)
.catch(() => []),
]);
.filter(Boolean);
const firstTilesetVector = tilesetsVector[0];
let vectorTileFormats = [];
if (firstTilesetVector) {
const tilesetUrl = getLinkUrl(firstTilesetVector, 'self', this.baseUrl);
if (!tilesetUrl) {
throw new Error('No links found for the tileset');
}
const tilesetDoc = await fetchDocument(tilesetUrl);
vectorTileFormats = tilesetDoc.links
.filter((link) => link.rel === 'item')
.map((link) => link.type);
}
const firstTilesetMap = tilesetsMap[0];
let mapTileFormats = [];
if (firstTilesetMap) {
const tilesetUrl = getLinkUrl(firstTilesetMap, 'self', this.baseUrl);
if (!tilesetUrl) {
throw new Error('No links found for the tileset');
}
const tilesetDoc = await fetchDocument(tilesetUrl);
mapTileFormats = tilesetDoc.links
.filter((link) => link.rel === 'item')
.map((link) => link.type);
}
return {

@@ -228,2 +339,5 @@ ...baseInfo,

sortables,
mapTileFormats,
vectorTileFormats,
supportedTileMatrixSets,
};

@@ -369,2 +483,92 @@ }

}
/**
* Asynchronously retrieves a URL to render a specified collection as vector tiles, with a given tile matrix set.
* @param collectionId - The unique identifier for the collection.
* @param tileMatrixSet - The identifier of the tile matrix set to use. Default is 'WebMercatorQuad'.
*/
getVectorTilesetUrl(
collectionId: string,
tileMatrixSet = 'WebMercatorQuad'
): Promise<string> {
return this.getCollectionDocument(collectionId)
.then(async (collectionDoc) => {
const collectionTilesLink = getLinkUrl(
collectionDoc,
'http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector',
this.baseUrl
);
const collectionTiles = await fetchDocument(collectionTilesLink);
const matrixSet = (await this.tileMatrixSetsFull).find(
(set) => set.id === tileMatrixSet
);
if (!matrixSet) {
throw new Error(
`The following tile matrix set does not exist on this endpoint: '${tileMatrixSet}'.`
);
}
const tileset = collectionTiles.tilesets.find(
(tileset) => tileset.tileMatrixSetURI === matrixSet.uri
);
if (!tileset) {
throw new Error(
`The collection '${collectionId}' does not support the tile matrix set '${tileMatrixSet}'.`
);
}
const tilesetUrl = getLinkUrl(tileset, 'self', this.baseUrl);
if (!tilesetUrl) {
throw new Error('No links found for the tileset');
}
return tilesetUrl;
})
.catch((error) => {
console.error('Error fetching collection tileset URL:', error.message);
throw error;
});
}
/**
* Asynchronously retrieves a URL to render a specified collection as map tiles, with a given tile matrix set.
* @param collectionId - The unique identifier for the collection.
* @param tileMatrixSet - The identifier of the tile matrix set to use. Default is 'WebMercatorQuad'.
*/
getMapTilesetUrl(
collectionId: string,
tileMatrixSet = 'WebMercatorQuad'
): Promise<string> {
return this.getCollectionDocument(collectionId)
.then(async (collectionDoc) => {
const collectionTilesLink = getLinkUrl(
collectionDoc,
'http://www.opengis.net/def/rel/ogc/1.0/tilesets-map',
this.baseUrl
);
const collectionTiles = await fetchDocument(collectionTilesLink);
const matrixSet = (await this.tileMatrixSetsFull).find(
(set) => set.id === tileMatrixSet
);
if (!matrixSet) {
throw new Error(
`The following tile matrix set does not exist on this endpoint: '${tileMatrixSet}'.`
);
}
const tileset = collectionTiles.tilesets.find(
(tileset) => tileset.tileMatrixSetURI === matrixSet.uri
);
if (!tileset) {
throw new Error(
`The collection '${collectionId}' does not support the tile matrix set '${tileMatrixSet}'.`
);
}
const tilesetUrl = getLinkUrl(tileset, 'self', this.baseUrl);
if (!tilesetUrl) {
throw new Error('No links found for the tileset');
}
return tilesetUrl;
})
.catch((error) => {
console.error('Error fetching collection tileset URL:', error.message);
throw error;
});
}
}

@@ -9,2 +9,3 @@ import {

OgcApiEndpointInfo,
TileMatrixSet,
} from './model.js';

@@ -46,3 +47,9 @@ import { assertHasLinks } from './link-utils.js';

itemType: 'record' | 'feature' | null = null
): (doc: OgcApiDocument) => string[] {
): (doc: OgcApiDocument) => Array<{
name: string;
hasRecords?: boolean;
hasFeatures?: boolean;
hasVectorTiles?: boolean;
hasMapTiles?: boolean;
}> {
return (doc: OgcApiDocument) =>

@@ -53,3 +60,38 @@ (doc.collections as OgcApiCollectionInfo[])

)
.map((collection) => collection.id as string);
.map((collection) => {
const result: {
name: string;
hasRecords?: boolean;
hasFeatures?: boolean;
hasVectorTiles?: boolean;
hasMapTiles?: boolean;
} = {
name: collection.id as string,
};
if (collection.itemType === 'record') {
result.hasRecords = true;
}
if (collection.itemType === 'feature') {
result.hasFeatures = true;
}
if (
collection.links.some(
(link) =>
link.rel ===
'http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector'
)
) {
result.hasVectorTiles = true;
}
if (
collection.links.some(
(link) =>
link.rel === 'http://www.opengis.net/def/rel/ogc/1.0/tilesets-map'
)
) {
result.hasMapTiles = true;
}
return result;
});
}

@@ -169,1 +211,13 @@

}
export function parseTileMatrixSets(doc: OgcApiDocument): TileMatrixSet[] {
if (Array.isArray(doc.tileMatrixSets)) {
return doc.tileMatrixSets.map((set) => {
return {
id: set.id,
uri: set.uri,
};
});
}
return [];
}

@@ -52,2 +52,3 @@ import { Geometry } from 'geojson';

export interface OgcApiCollectionInfo {
links: any;
title: string;

@@ -81,2 +82,6 @@ description: string;

sortables: CollectionParameter[];
// will be empty if the endpoint does not support tiles
mapTileFormats: MimeType[];
vectorTileFormats: MimeType[];
supportedTileMatrixSets: string[]; // identifiers
}

@@ -98,2 +103,9 @@

}[];
tilesets?: {
title: string;
tileMatrixSetURI: string;
crs: string;
dataType: string;
links: OgcApiDocumentLink[];
}[];
} & Record<string, unknown>;

@@ -152,1 +164,6 @@

export type OgcApiCollectionItem = OgcApiRecord;
export interface TileMatrixSet {
id: string;
uri: string;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc