UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

105 lines (104 loc) 4.93 kB
import { Feature } from 'ol'; import { Geometry } from 'ol/geom.js'; import { WriteGetFeatureOptions } from 'ol/format/WFS.js'; import SelectionParam from '../../models/selectionparam.js'; import LayerWms from '../../models/layers/layerwms.js'; import ServerWfs from '../../models/serverwfs.js'; import { XmlTypes } from '../../models/xmlTypes.js'; import ServerOgc from '../../models/serverogc.js'; import IGirafeContext from '../context/icontext.js'; export type WfsClientOptions = { featurePrefix: string; featureNS: string; }; export type WfsClientOptionalOptions = { featurePrefix?: string; featureNS?: string; }; export default class WfsClient<WfsXmlTypes = XmlTypes> { private readonly context; protected version: string; private get state(); protected ogcServer: ServerOgc; maxFeatures: number; protected featurePrefix: string; protected featureNS: string; protected featureNsWithPrefix: Record<string, string>; private readonly urlParameters; private serverWfs; private readonly metadataLayerNamePlaceholder; private readonly metadataAttributeNamePlaceholder; constructor(ogcServer: ServerOgc, options: WfsClientOptions, context: IGirafeContext); private get wfsUrl(); private extractVersionFromUrl; private configMaxFeatures; getServerWfs(): Promise<ServerWfs<WfsXmlTypes>>; protected describeFeatureType(): Promise<ServerWfs<WfsXmlTypes>>; private requestDescribeFeatureType; private parseDescribeFeatureTypeResponse; private initializeAttribute; protected manageLayerAttribute(serverWfs: ServerWfs<WfsXmlTypes>, element: Element, featureType: string): void; protected validateLayerAttributeType(type: string): boolean; protected getElementToTypeName(xml: Document): Record<string, string>; protected getDescribeFeatureTypeUrl(): string; /** * Retrieves the list of valid values for an enumerated attribute within a given layer. */ getAttributeValueList(layerName: string, attributeName: string): Promise<string[]>; /** * Fetch GMF-style value lists in the form of {"items": [{"value": "Curling"}, {"value": "Patinoire"} ]} */ private fetchAttributeValueList; /** * Gets features from a WFS server. * Configure the request by providing a GeoGirafe `SelectionParam` or an ol `GetFeatureOptions` object. */ getFeature(options: SelectionParam): Promise<Feature<Geometry>[]>; getFeature(options: GetFeatureOptionsPartial): Promise<Feature<Geometry>[]>; /** * Transforms a `SelectionParam` object, originating from a map selection, * into a `GetFeatureOptionsPartial` object, needed for performing the WFS GetFeature request. */ protected getFeatureOptionsFromSelectionParam(selectionParam: SelectionParam): GetFeatureOptionsPartial | null; /** * Creates a `WriteGetFeatureOptions` object by expanding the provided partial options. * Required for a ol GetFeature WFS request. */ protected completeGetFeatureOptions(options: GetFeatureOptionsPartial): Promise<WriteGetFeatureOptions[]>; /** * Sends a GetFeature request to a WFS endpoint based on provided options and parses the received GML answer. */ protected getFeatureRaw(getFeatureOptions: WriteGetFeatureOptions): Promise<Feature<Geometry>[]>; /** * Sets or removes a time restriction on the provided query layer. Depending on the presence of a time attribute, * either a temporal XML filter is created or a TIME parameter is added to the URL. * * @param {QueryableLayerWms} queryLayer - The layer on which the time restriction is to be applied. * @return {Filter | undefined} Returns a temporal XML filter if a time attribute exists; otherwise, undefined. */ private setTimeRestriction; private getTimeRestrictionFilter; private addTimeRestrictionAsUrlParameter; private removeTimeRestrictionAsUrlParameter; private checkForExceptions; } export type QueryableLayerWms = Omit<LayerWms, 'queryLayers'> & { queryLayers: string; }; export type GetFeatureOptionsPartial = Omit<WriteGetFeatureOptions, 'featureNS' | 'featurePrefix' | 'featureTypes'> & { featureNS?: string; featurePrefix?: string; featureTypes: string[]; }; export declare class WfsClientMapServer extends WfsClient { constructor(ogcServer: ServerOgc, options: WfsClientOptionalOptions, context: IGirafeContext); } export declare class WfsClientQgis extends WfsClient { constructor(ogcServer: ServerOgc, options: WfsClientOptionalOptions, context: IGirafeContext); } export declare class WfsClientGeorama extends WfsClient { protected version: string; constructor(ogcServer: ServerOgc, options: WfsClientOptionalOptions, context: IGirafeContext); } export declare const WfsClientDefault: typeof WfsClientQgis; export declare const WfsClientGeoServer: typeof WfsClientMapServer;