UNPKG

@loaders.gl/wms

Version:

Framework-independent loaders for the WMS (Web Map Service) standard

214 lines 10.3 kB
import type { DataSourceOptions, ImageSourceMetadata, GetImageParameters } from '@loaders.gl/loader-utils'; import { DataSource, ImageSource } from '@loaders.gl/loader-utils'; import type { ImageType } from '@loaders.gl/images'; import type { WMSCapabilities } from "./wms-capabilities-loader.js"; import type { WMSFeatureInfo } from "./wip/wms-feature-info-loader.js"; import type { WMSLayerDescription } from "./wip/wms-layer-description-loader.js"; /** Properties for creating a enw WMS service */ export type WMSSourceOptions = DataSourceOptions & { wms?: { /** In 1.3.0, replaces references to EPSG:4326 with CRS:84 */ substituteCRS84?: boolean; /** Default WMS parameters. If not provided here, must be provided in the various request */ wmsParameters?: WMSParameters; /** Any additional service specific parameters */ vendorParameters?: Record<string, unknown>; }; }; export declare const WMSSource: { readonly name: "Web Map Service (OGC WMS)"; readonly id: "wms"; readonly module: "wms"; readonly version: "0.0.0"; readonly extensions: []; readonly mimeTypes: []; readonly type: "wms"; readonly fromUrl: true; readonly fromBlob: false; readonly defaultOptions: { readonly wms: {}; }; readonly testURL: (url: string) => boolean; readonly createDataSource: (url: string | Blob, options: WMSSourceOptions) => WMSImageSource; }; /** * "Static" WMS parameters (not viewport or selected pixel dependent) * These can be provided as defaults in the WMSImageSource constructor */ export type WMSParameters = { /** WMS version (all requests) */ version?: '1.3.0' | '1.1.1'; /** Layers to render (GetMap, GetFeatureInfo) */ layers?: string[]; /** list of layers to query.. (GetFeatureInfo) */ query_layers?: string[]; /** Coordinate Reference System (CRS) for the image (not the bounding box) */ crs?: string; /** Requested format for the return image (GetMap, GetLegendGraphic) */ format?: 'image/png'; /** Requested MIME type of returned feature info (GetFeatureInfo) */ info_format?: 'text/plain' | 'application/geojson' | 'application/vnd.ogc.gml'; /** Styling - Not yet supported */ styles?: unknown; /** Any additional parameters specific to this WMSImageSource (GetMap) */ transparent?: boolean; /** If layer supports time dimension */ time?: string; /** If layer supports elevation dimension */ elevation?: string; }; /** Parameters for GetCapabilities */ export type WMSGetCapabilitiesParameters = { /** In case the endpoint supports multiple WMS versions */ version?: '1.3.0' | '1.1.1'; }; /** Parameters for GetMap */ export type WMSGetMapParameters = { /** In case the endpoint supports multiple WMS versions */ version?: '1.3.0' | '1.1.1'; /** bounding box of the requested map image `[[w, s], [e, n]]` */ /** bounding box of the requested map image @deprecated Use .boundingBox */ bbox: [number, number, number, number]; /** pixel width of returned image */ width: number; /** pixels */ height: number; /** requested format for the return image. can be provided in service constructor */ format?: 'image/png'; /** Layers to render - can be provided in service constructor */ layers?: string | string[]; /** Coordinate Reference System for the image (not bounding box). can be provided in service constructor. */ crs?: string; /** Styling. can be provided in service constructor */ styles?: unknown; /** Don't render background when no data. can be provided in service constructor */ transparent?: boolean; /** If layer supports time dimension */ time?: string; /** If layer supports elevation dimension */ elevation?: string; }; /** * Parameters for GetFeatureInfo * @see https://imagery.pasda.psu.edu/arcgis/services/pasda/UrbanTreeCanopy_Landcover/MapServer/WmsServer?SERVICE=WMS& */ export type WMSGetFeatureInfoParameters = { /** In case the endpoint supports multiple WMS versions */ version?: '1.3.0' | '1.1.1'; /** x coordinate for the feature info request */ x: number; /** y coordinate for the feature info request */ y: number; /** MIME type of returned feature info. Can be specified in service constructor */ info_format?: 'text/plain' | 'application/geojson' | 'application/vnd.ogc.gml'; /** list of layers to query. Required but can be specified in service constructor. */ query_layers?: string[]; /** Layers to render. Required, but can be specified in service constructor */ layers?: string[]; /** Styling */ styles?: unknown; /** bounding box of the requested map image */ bbox: [number, number, number, number]; /** pixel width of returned image */ width: number; /** pixels */ height: number; /** srs for the image (not the bounding box) */ crs?: string; }; /** GetMap parameters that are specific to the current view */ export type WMSGetFeatureInfoViewParameters = { /** x coordinate for the feature info request */ x: number; /** y coordinate for the feature info request */ y: number; /** pixel width of returned image */ width: number; /** pixels */ height: number; /** bounding box of the requested map image */ bbox: [number, number, number, number]; /** srs for the image (not the bounding box) */ crs?: string; }; /** Parameters for DescribeLayer */ export type WMSDescribeLayerParameters = { /** In case the endpoint supports multiple WMS versions */ version?: '1.3.0' | '1.1.1'; }; /** Parameters for GetLegendGraphic */ export type WMSGetLegendGraphicParameters = { /** In case the endpoint supports multiple WMS versions */ version?: '1.3.0' | '1.1.1'; }; /** * The WMSImageSource class provides * - provides type safe methods to form URLs to a WMS service * - provides type safe methods to query and parse results (and errors) from a WMS service * - implements the ImageSource interface * @note Only the URL parameter conversion is supported. XML posts are not supported. */ export declare class WMSImageSource extends DataSource<string, WMSSourceOptions> implements ImageSource { /** In WMS 1.3.0, replaces references to EPSG:4326 with CRS:84. But not always supported. Default: false */ substituteCRS84: boolean; /** In WMS 1.3.0, flips x,y (lng, lat) coordinates for the supplied coordinate systems. Default: ['ESPG:4326'] */ flipCRS: string[]; /** Default static WMS parameters */ wmsParameters: Required<WMSParameters>; /** Default static vendor parameters */ vendorParameters?: Record<string, unknown>; capabilities: WMSCapabilities | null; /** Create a WMSImageSource */ constructor(url: string, options: WMSSourceOptions); getMetadata(): Promise<ImageSourceMetadata>; getImage(parameters: GetImageParameters): Promise<ImageType>; normalizeMetadata(capabilities: WMSCapabilities): ImageSourceMetadata; /** Get Capabilities */ getCapabilities(wmsParameters?: WMSGetCapabilitiesParameters, vendorParameters?: Record<string, unknown>): Promise<WMSCapabilities>; /** Get a map image */ getMap(wmsParameters: WMSGetMapParameters, vendorParameters?: Record<string, unknown>): Promise<ImageType>; /** Get Feature Info for a coordinate */ getFeatureInfo(wmsParameters: WMSGetFeatureInfoParameters, vendorParameters?: Record<string, unknown>): Promise<WMSFeatureInfo>; /** Get Feature Info for a coordinate */ getFeatureInfoText(wmsParameters: WMSGetFeatureInfoParameters, vendorParameters?: Record<string, unknown>): Promise<string>; /** Get more information about a layer */ describeLayer(wmsParameters: WMSDescribeLayerParameters, vendorParameters?: Record<string, unknown>): Promise<WMSLayerDescription>; /** Get an image with a semantic legend */ getLegendGraphic(wmsParameters: WMSGetLegendGraphicParameters, vendorParameters?: Record<string, unknown>): Promise<ImageType>; /** Generate a URL for the GetCapabilities request */ getCapabilitiesURL(wmsParameters?: WMSGetCapabilitiesParameters, vendorParameters?: Record<string, unknown>): string; /** Generate a URL for the GetMap request */ getMapURL(wmsParameters: WMSGetMapParameters, vendorParameters?: Record<string, unknown>): string; /** Generate a URL for the GetFeatureInfo request */ getFeatureInfoURL(wmsParameters: WMSGetFeatureInfoParameters, vendorParameters?: Record<string, unknown>): string; /** Generate a URL for the GetFeatureInfo request */ describeLayerURL(wmsParameters: WMSDescribeLayerParameters, vendorParameters?: Record<string, unknown>): string; getLegendGraphicURL(wmsParameters: WMSGetLegendGraphicParameters, vendorParameters?: Record<string, unknown>): string; _parseWMSUrl(url: string): { url: string; parameters: Record<string, unknown>; }; /** * Generate a URL with parameters * @note case _getWMSUrl may need to be overridden to handle certain backends? * @note at the moment, only URLs with parameters are supported (no XML payloads) * */ protected _getWMSUrl(request: string, wmsParameters: { version?: '1.3.0' | '1.1.1'; [key: string]: unknown; }, vendorParameters?: Record<string, unknown>): string; _getWMS130Parameters<ParametersT extends { crs?: string; srs?: string; }>(wmsParameters: ParametersT): ParametersT; _getURLParameter(key: string, value: unknown, wmsParameters: WMSParameters): string; /** Coordinate order is flipped for certain CRS in WMS 1.3.0 */ _flipBoundingBox(bboxValue: unknown, wmsParameters: WMSParameters): [number, number, number, number] | null; /** Fetches an array buffer and checks the response (boilerplate reduction) */ protected _fetchArrayBuffer(url: string): Promise<ArrayBuffer>; /** Checks for and parses a WMS XML formatted ServiceError and throws an exception */ protected _checkResponse(response: Response, arrayBuffer: ArrayBuffer): void; /** Error situation detected */ protected _parseError(arrayBuffer: ArrayBuffer): Error; } //# sourceMappingURL=wms-source.d.ts.map