@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
87 lines (86 loc) • 4.29 kB
TypeScript
import { Feature } from 'ol';
import { Geometry } from 'ol/geom';
import OgcApiClient from './ogcapiclient';
import ServerOgcApiFeatures, { OapifCollection, OapifSchemaResponse } from '../../models/serverogcapifeatures';
import ServerOgc from '../../models/serverogc';
import { HttpMethod } from '../../models/serverogcapi';
export type OgcApiFeaturesClientOptions = {
crs?: string;
};
/**
* Class representing an OGC API Features (OAPIF) client that interacts with a server implementing
* the OGC API - Features standard. This class provides functionality to fetch, manage, and
* manipulate collections and their spatial data from the server.
*
* Extends `OgcApiClient<ServerOgcApiFeatures>`: Provides base client functionalities.
*/
export default class OgcApiFeaturesClient extends OgcApiClient<ServerOgcApiFeatures> {
private collections;
constructor(serverConfig: ServerOgc);
protected getUrl(): string;
protected loadDescribeServer(): Promise<ServerOgcApiFeatures>;
getCollections(): Promise<OapifCollection[]>;
/**
* Retrieves a collection by its ID. If the collection is not already cached, it fetches it from the remote resource,
* sanitizes its links, and stores it locally.
*/
getCollection(collectionId: string): Promise<OapifCollection>;
/**
* Retrieves the schema associated with a specified collection.
*/
getSchema(collectionId: string): Promise<OapifSchemaResponse>;
getQueryables(collectionId: string): Promise<OapifSchemaResponse>;
/**
* Retrieves the related resource for a specified collection and relation type (e.g. `schema`, `self`, `parent`, etc.)
*/
getCollectionRelation(collectionId: string, relation: string, encodingType?: string): Promise<any>;
/**
* Retrieves items from a specified collection, optionally applying filters like CRS (Coordinate Reference System),
* spatial extent, and limit.
*/
getItems(collectionId: string, crsCode?: string, extent?: number[], limit?: number): Promise<Feature<Geometry>[]>;
/**
* Retrieves a single item from the specified collection by its ID.
*/
getItem(collectionId: string, itemId: string, crsCode?: string): Promise<Feature<Geometry>>;
/**
* Creates an item in the specified collection with the specified geometry and CRS code.
* Geometries are reprojected if the server does not support the items current CRS.
*/
createItem(collectionId: string, item: Feature<Geometry>, crsCode: string): Promise<boolean>;
/**
* Updates an existing item in the specified collection.
*/
updateItem(collectionId: string, itemId: string, item: Feature<Geometry>, crsCode: string): Promise<boolean>;
/**
* Deletes an item from a specific collection.
*/
deleteItem(collectionId: string, itemId: string): Promise<boolean>;
/**
* Retrieves the CRS (Coordinate Reference System) identifier for a specific collection based on the provided CRS code.
* This is necessary because CRS identifiers can vary slightly (e.g. http vs https) between servers,
* and it's best to use the identifiers provided by the server.
*/
private getCrsIdentifier;
private getEpsgCodeFromCrsIdentifier;
/**
* Checks if the provided extent's coordinate reference system (CRS) is supported by a given collection
* and reprojects the extent if necessary.
*/
private reprojectExtentToSupportedCrs;
/**
* Retrieves the storage coordinate reference system (CRS) for a specified collection.
* The storageCrs information is only available if the server supports part 2 of the OGC API Features specification.
*/
private getStorageCrs;
/**
* When performing a write operation, reproject the feature geometry to match the storage coordinate reference system
* (CRS) of the server. If no storage CRS is specified, geometries are reprojected to WGS84 lon / lat,
* which is the default CRS for OAPIF and GeoJson.
*/
private reprojectItemToStorageCrs;
/**
* Expands the method from OgcApiClient by customizing headers to support GeoJson content and optional CRS identifier.
*/
protected getFetchOptions(method?: HttpMethod, crsIdentifier?: string): RequestInit;
}