@loaders.gl/wms 4.2.0-alpha.4 → 4.2.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/csw-capabilities-loader.d.ts +1 -1
- package/dist/csw-capabilities-loader.d.ts.map +1 -1
- package/dist/csw-capabilities-loader.js +23 -15
- package/dist/csw-domain-loader.d.ts +1 -1
- package/dist/csw-domain-loader.d.ts.map +1 -1
- package/dist/csw-domain-loader.js +23 -15
- package/dist/csw-records-loader.d.ts +1 -1
- package/dist/csw-records-loader.d.ts.map +1 -1
- package/dist/csw-records-loader.js +23 -15
- package/dist/gml-loader.d.ts +1 -1
- package/dist/gml-loader.d.ts.map +1 -1
- package/dist/gml-loader.js +23 -15
- package/dist/index.cjs +49 -58
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +30 -30
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/lib/parsers/csw/parse-csw-capabilities.js +18 -13
- package/dist/lib/parsers/csw/parse-csw-domain.js +26 -18
- package/dist/lib/parsers/csw/parse-csw-records.js +47 -36
- package/dist/lib/parsers/csw/parse-exception-report.js +26 -8
- package/dist/lib/parsers/gml/deep-strict-equal.js +107 -39
- package/dist/lib/parsers/gml/parse-gml.js +299 -280
- package/dist/lib/parsers/wms/parse-wms-capabilities.js +207 -187
- package/dist/lib/parsers/wms/parse-wms-error.js +17 -6
- package/dist/lib/parsers/wms/parse-wms-features.js +20 -19
- package/dist/lib/parsers/wms/parse-wms-layer-description.js +10 -4
- package/dist/lib/parsers/xml/parse-xml-helpers.js +54 -45
- package/dist/lib/services/create-image-service.d.ts +1 -1
- package/dist/lib/services/create-image-service.d.ts.map +1 -1
- package/dist/lib/services/create-image-service.js +31 -19
- package/dist/lib/services/image-service.js +39 -32
- package/dist/services/arcgis/arcgis-image-service.d.ts +2 -2
- package/dist/services/arcgis/arcgis-image-service.d.ts.map +1 -1
- package/dist/services/arcgis/arcgis-image-service.js +91 -55
- package/dist/services/arcgis/arcgis-server.js +35 -28
- package/dist/services/create-image-source.d.ts +3 -3
- package/dist/services/create-image-source.d.ts.map +1 -1
- package/dist/services/create-image-source.js +11 -2
- package/dist/services/ogc/csw-service.d.ts +3 -3
- package/dist/services/ogc/csw-service.d.ts.map +1 -1
- package/dist/services/ogc/csw-service.js +156 -142
- package/dist/services/ogc/wms-service.d.ts +4 -4
- package/dist/services/ogc/wms-service.d.ts.map +1 -1
- package/dist/services/ogc/wms-service.js +295 -242
- package/dist/wip/data-source.js +58 -1
- package/dist/wip/lib/wcs/parse-wcs-capabilities.js +8 -11
- package/dist/wip/lib/wfs/parse-wfs-capabilities.js +12 -12
- package/dist/wip/lib/wfs/parse-wfs.js +20 -20
- package/dist/wip/lib/wmts/parse-wmts-capabilities.js +70 -12
- package/dist/wip/lib/wmts/parse-wmts.js +23 -20
- package/dist/wip/services/arcgis-feature-service.js +22 -22
- package/dist/wip/wcs-capabilities-loader.d.ts +1 -1
- package/dist/wip/wcs-capabilities-loader.d.ts.map +1 -1
- package/dist/wip/wcs-capabilities-loader.js +21 -15
- package/dist/wip/wfs-capabilities-loader.d.ts +1 -1
- package/dist/wip/wfs-capabilities-loader.d.ts.map +1 -1
- package/dist/wip/wfs-capabilities-loader.js +21 -15
- package/dist/wip/wms-feature-info-loader.d.ts +1 -1
- package/dist/wip/wms-feature-info-loader.d.ts.map +1 -1
- package/dist/wip/wms-feature-info-loader.js +10 -6
- package/dist/wip/wms-layer-description-loader.d.ts +1 -1
- package/dist/wip/wms-layer-description-loader.d.ts.map +1 -1
- package/dist/wip/wms-layer-description-loader.js +9 -6
- package/dist/wip/wmts-capabilities-loader.js +22 -15
- package/dist/wms-capabilities-loader.d.ts +2 -2
- package/dist/wms-capabilities-loader.d.ts.map +1 -1
- package/dist/wms-capabilities-loader.js +27 -15
- package/dist/wms-error-loader.js +33 -28
- package/package.json +10 -8
- package/dist/csw-capabilities-loader.js.map +0 -1
- package/dist/csw-domain-loader.js.map +0 -1
- package/dist/csw-records-loader.js.map +0 -1
- package/dist/gml-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/parsers/csw/parse-csw-capabilities.js.map +0 -1
- package/dist/lib/parsers/csw/parse-csw-domain.js.map +0 -1
- package/dist/lib/parsers/csw/parse-csw-records.js.map +0 -1
- package/dist/lib/parsers/csw/parse-exception-report.js.map +0 -1
- package/dist/lib/parsers/gml/deep-strict-equal.js.map +0 -1
- package/dist/lib/parsers/gml/parse-gml.js.map +0 -1
- package/dist/lib/parsers/wms/parse-wms-capabilities.js.map +0 -1
- package/dist/lib/parsers/wms/parse-wms-error.js.map +0 -1
- package/dist/lib/parsers/wms/parse-wms-features.js.map +0 -1
- package/dist/lib/parsers/wms/parse-wms-layer-description.js.map +0 -1
- package/dist/lib/parsers/xml/parse-xml-helpers.js.map +0 -1
- package/dist/lib/services/create-image-service.js.map +0 -1
- package/dist/lib/services/image-service.js.map +0 -1
- package/dist/services/arcgis/arcgis-image-service.js.map +0 -1
- package/dist/services/arcgis/arcgis-server.js.map +0 -1
- package/dist/services/create-image-source.js.map +0 -1
- package/dist/services/ogc/csw-service.js.map +0 -1
- package/dist/services/ogc/wms-service.js.map +0 -1
- package/dist/wip/data-source.js.map +0 -1
- package/dist/wip/lib/wcs/parse-wcs-capabilities.js.map +0 -1
- package/dist/wip/lib/wfs/parse-wfs-capabilities.js.map +0 -1
- package/dist/wip/lib/wfs/parse-wfs.js.map +0 -1
- package/dist/wip/lib/wmts/parse-wmts-capabilities.js.map +0 -1
- package/dist/wip/lib/wmts/parse-wmts.js.map +0 -1
- package/dist/wip/services/arcgis-feature-service.js.map +0 -1
- package/dist/wip/services/wmts-service.ts.disabled +0 -348
- package/dist/wip/wcs-capabilities-loader.js.map +0 -1
- package/dist/wip/wfs-capabilities-loader.js.map +0 -1
- package/dist/wip/wms-feature-info-loader.js.map +0 -1
- package/dist/wip/wms-layer-description-loader.js.map +0 -1
- package/dist/wip/wms-layer-description-loader.md.disabled.md +0 -47
- package/dist/wip/wmts-capabilities-loader.js.map +0 -1
- package/dist/wms-capabilities-loader.js.map +0 -1
- package/dist/wms-error-loader.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-wmts.js","names":["XMLLoader","parseWMTSCapabilities","text","options","_options","_XMLLoader$parseTextS","xml","removeNSPrefix","parsedXML","parseTextSync","call","xmlCapabilities","Capabilities","uncapitalizeKeys","object","newObject","key","value","Object","entries","uncapitalize","str","charAt","toLowerCase","slice"],"sources":["../../../../src/wip/lib/wmts/parse-wmts.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {XMLLoader} from '@loaders.gl/xml';\n\nexport type WMTSCapabilities = {};\n\n/**\n * Parses a typed data structure from raw XML for `GetCapabilities` response\n * @note Error handlings is fairly weak\n */\nexport function parseWMTSCapabilities(text: string, options): WMTSCapabilities {\n // Remove namespaces in XML\n options = {...options, xml: {...options?.xml, removeNSPrefix: true}};\n const parsedXML = XMLLoader.parseTextSync?.(text, options);\n const xmlCapabilities: any = parsedXML.Capabilities || parsedXML;\n return uncapitalizeKeys(xmlCapabilities);\n}\n\nfunction uncapitalizeKeys(object: any): any {\n if (object && typeof object === 'object') {\n const newObject = {};\n for (const [key, value] of Object.entries(object)) {\n newObject[uncapitalize(key)] = uncapitalizeKeys(value);\n }\n return newObject;\n }\n return object;\n}\n\n/**\n * Uncapitalize first letter of a string\n * @param {string} str\n * @returns {string}\n */\nfunction uncapitalize(str: string): string {\n return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str;\n}\n"],"mappings":"AAEA,SAAQA,SAAS,QAAO,iBAAiB;AAQzC,OAAO,SAASC,qBAAqBA,CAACC,IAAY,EAAEC,OAAO,EAAoB;EAAA,IAAAC,QAAA,EAAAC,qBAAA;EAE7EF,OAAO,GAAG;IAAC,GAAGA,OAAO;IAAEG,GAAG,EAAE;MAAC,KAAAF,QAAA,GAAGD,OAAO,cAAAC,QAAA,uBAAPA,QAAA,CAASE,GAAG;MAAEC,cAAc,EAAE;IAAI;EAAC,CAAC;EACpE,MAAMC,SAAS,IAAAH,qBAAA,GAAGL,SAAS,CAACS,aAAa,cAAAJ,qBAAA,uBAAvBA,qBAAA,CAAAK,IAAA,CAAAV,SAAS,EAAiBE,IAAI,EAAEC,OAAO,CAAC;EAC1D,MAAMQ,eAAoB,GAAGH,SAAS,CAACI,YAAY,IAAIJ,SAAS;EAChE,OAAOK,gBAAgB,CAACF,eAAe,CAAC;AAC1C;AAEA,SAASE,gBAAgBA,CAACC,MAAW,EAAO;EAC1C,IAAIA,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IACxC,MAAMC,SAAS,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,MAAM,CAAC,EAAE;MACjDC,SAAS,CAACK,YAAY,CAACJ,GAAG,CAAC,CAAC,GAAGH,gBAAgB,CAACI,KAAK,CAAC;IACxD;IACA,OAAOF,SAAS;EAClB;EACA,OAAOD,MAAM;AACf;AAOA,SAASM,YAAYA,CAACC,GAAW,EAAU;EACzC,OAAO,OAAOA,GAAG,KAAK,QAAQ,GAAGA,GAAG,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGF,GAAG,CAACG,KAAK,CAAC,CAAC,CAAC,GAAGH,GAAG;AACnF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arcgis-feature-service.js","names":["ArcGISFeatureService","constructor","props","url","loadOptions","fetch","metadataURL","options","getUrl","exportImageURL","boundingBox","path"],"sources":["../../../src/wip/services/arcgis-feature-service.ts"],"sourcesContent":["// @ts-nocheck\n\nimport {LoaderOptions} from '@loaders.gl/loader-utils';\n// import {GeoJSONLoader} from '@loaders.gl/geojson';\n\ntype FetchLike = (url: string, options?: RequestInit) => Promise<Response>;\n\nexport type ArcGISImageServiceQueryOptions = {\n returnGeometry: boolean;\n where: '1%3D1';\n outSR: 4326;\n outFields: string | '*';\n inSR: 4326;\n geometry: `${-90}%2C+${30}%2C+${-70}%2C+${50}`;\n geometryType: 'esriGeometryEnvelope'; // TODO - look up valid values in Esri docs\n spatialRel: 'esriSpatialRelIntersects'; // TODO - look up valid values in Esri docs\n geometryPrecision: number; // TODO - look up valid values in Esri docs\n resultType: 'tile'; // TODO - look up valid values in Esri docs\n f?: 'geojson'; // TODO - look up valid values in Esri docs\n}\n\n// const DEFAULT_QUERY_OPTIONS: Required<ArcGISImageServiceQueryOptions> = {\n// returnGeometry:true,\n// where: '1%3D1',\n// outSR: 4326,\n// outFields: '*',\n// inSR: 4326,\n// geometry: `${-90}%2C+${30}%2C+${-70}%2C+${50}`,\n// geometryType: 'esriGeometryEnvelope',\n// spatialRel: 'esriSpatialRelIntersects',\n// geometryPrecision: 6,\n// resultType: 'tile',\n// f: 'geojson'\n// };\n\nexport type ArcGISFeatureServiceProps = ArcGISImageServiceQueryOptions & {\n url: string;\n loadOptions?: LoaderOptions;\n fetch?: typeof fetch | FetchLike;\n};\n\nexport class ArcGISFeatureService {\n url: string;\n loadOptions: LoaderOptions;\n fetch: typeof fetch | FetchLike;\n\n constructor(props: ArcGISFeatureServiceProps) {\n this.url = props.url;\n this.loadOptions = props.loadOptions || {};\n this.fetch = props.fetch || fetch;\n }\n\n // URL creators\n\n metadataURL(options: {parameters?: Record<string, unknown>}): string {\n return this.getUrl({...options});\n }\n\n /** \n * Form a URL to an ESRI FeatureServer\n// https://services2.arcgis.com/CcI36Pduqd0OR4W9/ArcGIS/rest/services/Bicycle_Routes_Public/FeatureServer/0/query?\n// returnGeometry=true&where=1%3D1&outSR=4326&outFields=*&inSR=4326&geometry=${-90}%2C+${30}%2C+${-70}%2C+${50}&\n// geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&geometryPrecision=6&resultType=tile&f=geojson`\n */\n exportImageURL(options: {\n boundingBox: [number, number, number, number];\n boundingBoxSR?: string;\n width: number;\n height: number;\n imageSR?: string;\n time?: never;\n f?: 'geojson';\n resultType?: 'tile';\n noData?: never;\n noDataInterpretation?: 'esriNoDataMatchAny';\n interpolation?: '+RSP_NearestNeighbor';\n compression?: never\n compressionQuality?: never;\n bandIds?: never;\n mosaicRule?: never;\n renderingRule?: never;\n f?: 'image';\n }): string {\n const {boundingBox} = options;\n // const bbox = `bbox=${boundingBox[0]},${boundingBox[1]},${boundingBox[2]},${boundingBox[3]}`;\n // const size = `size=${width},${height}`\n return this.getUrl({path: 'exportImage', });\n }\n}\n"],"mappings":"AAyCA,OAAO,MAAMA,oBAAoB,CAAC;EAKhCC,WAAWA,CAACC,KAAgC,EAAE;IAAA,KAJ9CC,GAAG;IAAA,KACHC,WAAW;IAAA,KACXC,KAAK;IAGH,IAAI,CAACF,GAAG,GAAGD,KAAK,CAACC,GAAG;IACpB,IAAI,CAACC,WAAW,GAAGF,KAAK,CAACE,WAAW,IAAI,CAAC,CAAC;IAC1C,IAAI,CAACC,KAAK,GAAGH,KAAK,CAACG,KAAK,IAAIA,KAAK;EACnC;EAIAC,WAAWA,CAACC,OAA+C,EAAU;IACnE,OAAO,IAAI,CAACC,MAAM,CAAC;MAAC,GAAGD;IAAO,CAAC,CAAC;EAClC;EAQAE,cAAcA,CAACF,OAkBd,EAAU;IACT,MAAM;MAACG;IAAW,CAAC,GAAGH,OAAO;IAG7B,OAAO,IAAI,CAACC,MAAM,CAAC;MAACG,IAAI,EAAE;IAAe,CAAC,CAAC;EAC7C;AACF"}
|
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
// loaders.gl, MIT license
|
|
2
|
-
|
|
3
|
-
/* eslint-disable camelcase */
|
|
4
|
-
|
|
5
|
-
import type {ImageType} from '@loaders.gl/images';
|
|
6
|
-
import {ImageLoader} from '@loaders.gl/images';
|
|
7
|
-
|
|
8
|
-
import type {TileSourceMetadata, GetTileParameters} from '../sources/tile-source';
|
|
9
|
-
import {TileSource} from '../sources/tile-source';
|
|
10
|
-
import {ImageServiceProps, getFetchFunction, mergeImageServiceProps} from '../sources/tile-service';
|
|
11
|
-
|
|
12
|
-
import type {WMTSCapabilities} from '../../wmts/wmts-types';
|
|
13
|
-
import {WMTSCapabilitiesLoader} from '../../../wmts-capabilities-loader';
|
|
14
|
-
// import {GMLLoader} from '../../../wip/wms-feature-info-loader';
|
|
15
|
-
import {WMSErrorLoader as WMTSErrorLoader} from '../../../wms-error-loader';
|
|
16
|
-
|
|
17
|
-
type WMTSCommonParameters = {
|
|
18
|
-
/** In case the endpoint supports multiple services */
|
|
19
|
-
service?: 'WMTS';
|
|
20
|
-
/** In case the endpoint supports multiple WMTS versions */
|
|
21
|
-
version?: '1.0.0' | '1.3.0';
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type WMTSGetCapabilitiesParameters = WMTSCommonParameters & {
|
|
25
|
-
/** Request type */
|
|
26
|
-
request?: 'GetCapabilities';
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type WMTSGetTileParameters = WMTSCommonParameters & {
|
|
30
|
-
/** Request type */
|
|
31
|
-
request?: 'GetTile';
|
|
32
|
-
/** requested format for the return image */
|
|
33
|
-
format?: 'image/png';
|
|
34
|
-
/** Styling */
|
|
35
|
-
style?: string;
|
|
36
|
-
/** Layer to render */
|
|
37
|
-
layer: string;
|
|
38
|
-
/** Tiling "Schema" (e.g. 'google_maps') */
|
|
39
|
-
tileMatrixSet: string;
|
|
40
|
-
/** Tile zoom level, named */
|
|
41
|
-
tileMatrix: string | number;
|
|
42
|
-
/** tile x coordinate */
|
|
43
|
-
tileCol: number;
|
|
44
|
-
/** tile y coordinate */
|
|
45
|
-
tileRow: number;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export type WMTSGetFeatureInfoParameters = WMTSCommonParameters & {
|
|
49
|
-
/** Request type */
|
|
50
|
-
request?: 'GetFeatureInfo';
|
|
51
|
-
/** Layer to render */
|
|
52
|
-
layer: string[];
|
|
53
|
-
/** Styling */
|
|
54
|
-
style?: string;
|
|
55
|
-
|
|
56
|
-
/** x coordinate for the feature info request */
|
|
57
|
-
x: number;
|
|
58
|
-
/** y coordinate for the feature info request */
|
|
59
|
-
y: number;
|
|
60
|
-
/** list of layer to query (could be different from rendered layer) */
|
|
61
|
-
query_layer: string[];
|
|
62
|
-
/** MIME type of returned feature info */
|
|
63
|
-
info_format?: 'text/plain' | 'application/vnd.ogc.gml';
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export type WMTSDescribeLayerParameters = WMTSCommonParameters & {
|
|
67
|
-
/** Request type */
|
|
68
|
-
request?: 'DescribeLayer';
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export type WMTSGetLegendGraphicParameters = WMTSCommonParameters & {
|
|
72
|
-
/** Request type */
|
|
73
|
-
request?: 'GetLegendGraphic';
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
type WMTSServiceProps = {
|
|
77
|
-
url: string;
|
|
78
|
-
attribution: string;
|
|
79
|
-
layer: string;
|
|
80
|
-
matrixSet: string;
|
|
81
|
-
style: string;
|
|
82
|
-
format: string;
|
|
83
|
-
requestFormat: string;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The WMTSService class provides
|
|
88
|
-
* - provides type safe methods to form URLs to a WMTS service
|
|
89
|
-
* - provides type safe methods to query and parse results (and errors) from a WMTS service
|
|
90
|
-
* - implements the ImageService interface
|
|
91
|
-
* @note Only the URL parameter conversion is supported. XML posts are not supported.
|
|
92
|
-
*/
|
|
93
|
-
export class WMTSService extends TileSource {
|
|
94
|
-
static type: 'wms' = 'wms';
|
|
95
|
-
static testURL = (url: string): boolean => url.toLowerCase().includes('wms');
|
|
96
|
-
|
|
97
|
-
props: Required<ImageServiceProps>;
|
|
98
|
-
fetch: (url: string, options?: RequestInit) => Promise<Response>;
|
|
99
|
-
capabilities: WMTSCapabilities | null = null;
|
|
100
|
-
|
|
101
|
-
/** A list of loaders used by the WMTSService methods */
|
|
102
|
-
readonly loaders = [
|
|
103
|
-
ImageLoader,
|
|
104
|
-
WMTSErrorLoader,
|
|
105
|
-
WMTSCapabilitiesLoader,
|
|
106
|
-
GMLLoader
|
|
107
|
-
];
|
|
108
|
-
|
|
109
|
-
readonly requestEncoding = 'kvp';
|
|
110
|
-
|
|
111
|
-
/** Create a WMTSService */
|
|
112
|
-
constructor(props: ImageServiceProps) {
|
|
113
|
-
super();
|
|
114
|
-
this.props = mergeImageServiceProps(props);
|
|
115
|
-
this.fetch = getFetchFunction(this.props);
|
|
116
|
-
this.props.loadOptions = {
|
|
117
|
-
...this.props.loadOptions,
|
|
118
|
-
// We want error responses to throw exceptions, the WMTSErrorLoader can do this
|
|
119
|
-
wms: {...this.props.loadOptions?.wms, throwOnError: true}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// TileSource implementation
|
|
124
|
-
getMetadata(): Promise<TileSourceMetadata> {
|
|
125
|
-
return this.getCapabilities();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
getTile(parameters: GetTileParameters): Promise<ImageType> {
|
|
129
|
-
const wmtsParameters: WMTSGetTileParameters = {
|
|
130
|
-
layer: parameters.layer,
|
|
131
|
-
tileMatrix: String(parameters.zoom),
|
|
132
|
-
tileCol: parameters.x,
|
|
133
|
-
tileRow: parameters.y
|
|
134
|
-
};
|
|
135
|
-
return this.getTile_(wmtsParameters);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// WMTS Service API Stubs
|
|
139
|
-
|
|
140
|
-
/** Get Capabilities */
|
|
141
|
-
async getCapabilities(
|
|
142
|
-
wmtsParameters?: WMTSGetCapabilitiesParameters,
|
|
143
|
-
vendorParameters?: Record<string, unknown>
|
|
144
|
-
): Promise<WMTSCapabilities> {
|
|
145
|
-
const url = this.getCapabilitiesURL(wmtsParameters, vendorParameters);
|
|
146
|
-
const response = await this.fetch(url);
|
|
147
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
148
|
-
this._checkResponse(response, arrayBuffer);
|
|
149
|
-
const capabilities = await WMTSCapabilitiesLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
150
|
-
this.capabilities = capabilities;
|
|
151
|
-
return capabilities;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/** Get a map image */
|
|
155
|
-
async getTile_(
|
|
156
|
-
options: WMTSGetTileParameters,
|
|
157
|
-
vendorParameters?: Record<string, unknown>
|
|
158
|
-
): Promise<ImageType> {
|
|
159
|
-
const url = this.getTileURL(options, vendorParameters);
|
|
160
|
-
const response = await this.fetch(url);
|
|
161
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
162
|
-
this._checkResponse(response, arrayBuffer);
|
|
163
|
-
try {
|
|
164
|
-
return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
165
|
-
} catch {
|
|
166
|
-
throw this._parseError(arrayBuffer);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/** Get Feature Info for a coordinate */
|
|
171
|
-
async getFeatureInfo(
|
|
172
|
-
options: WMTSGetFeatureInfoParameters,
|
|
173
|
-
vendorParameters?: Record<string, unknown>
|
|
174
|
-
): Promise<WMTSFeatureInfo> {
|
|
175
|
-
const url = this.getFeatureInfoURL(options, vendorParameters);
|
|
176
|
-
const response = await this.fetch(url);
|
|
177
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
178
|
-
this._checkResponse(response, arrayBuffer);
|
|
179
|
-
return await GMLLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/** Get Feature Info for a coordinate */
|
|
183
|
-
async getFeatureInfoText(
|
|
184
|
-
options: WMTSGetFeatureInfoParameters,
|
|
185
|
-
vendorParameters?: Record<string, unknown>
|
|
186
|
-
): Promise<string> {
|
|
187
|
-
options = {...options, info_format: 'text/plain'};
|
|
188
|
-
const url = this.getFeatureInfoURL(options, vendorParameters);
|
|
189
|
-
const response = await this.fetch(url);
|
|
190
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
191
|
-
this._checkResponse(response, arrayBuffer);
|
|
192
|
-
return new TextDecoder().decode(arrayBuffer);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/** Get an image with a semantic legend */
|
|
196
|
-
async getLegendGraphic(
|
|
197
|
-
options: WMTSGetLegendGraphicParameters,
|
|
198
|
-
vendorParameters?: Record<string, unknown>
|
|
199
|
-
): Promise<ImageType> {
|
|
200
|
-
const url = this.getLegendGraphicURL(options, vendorParameters);
|
|
201
|
-
const response = await this.fetch(url);
|
|
202
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
203
|
-
this._checkResponse(response, arrayBuffer);
|
|
204
|
-
try {
|
|
205
|
-
return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
206
|
-
} catch {
|
|
207
|
-
throw this._parseError(arrayBuffer);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Typed URL creators
|
|
212
|
-
// For applications that want full control of fetching and parsing
|
|
213
|
-
|
|
214
|
-
/** Generate a URL for the GetCapabilities request */
|
|
215
|
-
getCapabilitiesURL(
|
|
216
|
-
wmtsParameters?: WMTSGetCapabilitiesParameters,
|
|
217
|
-
vendorParameters?: Record<string, unknown>
|
|
218
|
-
): string {
|
|
219
|
-
const options: Required<WMTSGetCapabilitiesParameters> = {
|
|
220
|
-
service: 'WMTS',
|
|
221
|
-
version: '1.0.0',
|
|
222
|
-
request: 'GetCapabilities',
|
|
223
|
-
...wmtsParameters,
|
|
224
|
-
...vendorParameters
|
|
225
|
-
};
|
|
226
|
-
const url = `${this.props.url}/WMTSCapabilities.xml`;
|
|
227
|
-
return this._getWMTSUrl(options, vendorParameters);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/** Generate a URL for the GetTile request */
|
|
231
|
-
getTileURL(
|
|
232
|
-
wmtsParameters: WMTSGetTileParameters,
|
|
233
|
-
vendorParameters?: Record<string, unknown>
|
|
234
|
-
): string {
|
|
235
|
-
const options: Required<WMTSGetTileParameters> = {
|
|
236
|
-
service: 'WMTS',
|
|
237
|
-
version: '1.0.0',
|
|
238
|
-
request: 'GetTile',
|
|
239
|
-
style: undefined,
|
|
240
|
-
format: 'image/png',
|
|
241
|
-
// tileMatrixSet
|
|
242
|
-
// tileMatrix
|
|
243
|
-
// tileCol
|
|
244
|
-
// tileRow
|
|
245
|
-
...wmtsParameters,
|
|
246
|
-
...vendorParameters
|
|
247
|
-
};
|
|
248
|
-
const {version, layer = 'default', style = 'default', tileMatrixSet = 'default', tileMatrix, tileCol, tileRow} = options;
|
|
249
|
-
const extension = options.format.replace('image/', '');
|
|
250
|
-
const url = `${this.props.url}/tile/${version}/${layer}/${style}/${tileMatrixSet}/${tileMatrix}/${tileCol}/${tileRow}.${extension}`;
|
|
251
|
-
return this._getWMTSUrl(options, vendorParameters);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** Generate a URL for the GetFeatureInfo request */
|
|
255
|
-
getFeatureInfoURL(
|
|
256
|
-
wmtsParameters: WMTSGetFeatureInfoParameters,
|
|
257
|
-
vendorParameters?: Record<string, unknown>
|
|
258
|
-
): string {
|
|
259
|
-
const options: Required<WMTSGetFeatureInfoParameters> = {
|
|
260
|
-
service: 'WMTS',
|
|
261
|
-
version: '1.0.0',
|
|
262
|
-
request: 'GetFeatureInfo',
|
|
263
|
-
// layer: [],
|
|
264
|
-
// bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
|
|
265
|
-
// width: 1200,
|
|
266
|
-
// height: 900,
|
|
267
|
-
// x: undefined!,
|
|
268
|
-
// y: undefined!,
|
|
269
|
-
// query_layer: [],
|
|
270
|
-
// srs: 'EPSG:4326',
|
|
271
|
-
// format: 'image/png',
|
|
272
|
-
info_format: 'text/plain',
|
|
273
|
-
style: undefined!,
|
|
274
|
-
...wmtsParameters,
|
|
275
|
-
...vendorParameters
|
|
276
|
-
};
|
|
277
|
-
return this._getWMTSUrl(options, vendorParameters);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
getLegendGraphicURL(
|
|
281
|
-
wmtsParameters: WMTSGetLegendGraphicParameters,
|
|
282
|
-
vendorParameters?: Record<string, unknown>
|
|
283
|
-
): string {
|
|
284
|
-
const options: Required<WMTSGetLegendGraphicParameters> = {
|
|
285
|
-
service: 'WMTS',
|
|
286
|
-
version: '1.0.0',
|
|
287
|
-
request: 'GetLegendGraphic',
|
|
288
|
-
...wmtsParameters,
|
|
289
|
-
...vendorParameters
|
|
290
|
-
};
|
|
291
|
-
return this._getWMTSUrl(options, vendorParameters);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// INTERNAL METHODS
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* @note case _getWMTSUrl may need to be overridden to handle certain backends?
|
|
298
|
-
* */
|
|
299
|
-
protected _getWMTSUrl(
|
|
300
|
-
options: Record<string, unknown>,
|
|
301
|
-
vendorParameters?: Record<string, unknown>
|
|
302
|
-
): string {
|
|
303
|
-
switch (this.requestEncoding) {
|
|
304
|
-
case 'kvp':
|
|
305
|
-
return this._getWMTSUrlKVP(options, vendorParameters);
|
|
306
|
-
// case 'REST':
|
|
307
|
-
// case 'SOAP':
|
|
308
|
-
default:
|
|
309
|
-
throw new Error(this.requestEncoding);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* @note case _getWMTSUrl may need to be overridden to handle certain backends?
|
|
315
|
-
* */
|
|
316
|
-
protected _getWMTSUrlKVP(
|
|
317
|
-
options: Record<string, unknown>,
|
|
318
|
-
vendorParameters?: Record<string, unknown>
|
|
319
|
-
): string {
|
|
320
|
-
let url = this.props.url;
|
|
321
|
-
let first = true;
|
|
322
|
-
for (const [key, value] of Object.entries(options)) {
|
|
323
|
-
url += first ? '?' : '&';
|
|
324
|
-
first = false;
|
|
325
|
-
if (Array.isArray(value)) {
|
|
326
|
-
url += `${key.toUpperCase()}=${value.join(',')}`;
|
|
327
|
-
} else {
|
|
328
|
-
url += `${key.toUpperCase()}=${value ? String(value) : ''}`;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
return encodeURI(url);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/** Checks for and parses a WMTS XML formatted ServiceError and throws an exception */
|
|
335
|
-
protected _checkResponse(response: Response, arrayBuffer: ArrayBuffer): void {
|
|
336
|
-
const contentType = response.headers['content-type'];
|
|
337
|
-
if (!response.ok || WMTSErrorLoader.mimeTypes.includes(contentType)) {
|
|
338
|
-
const error = WMTSErrorLoader.parseSync(arrayBuffer, this.props.loadOptions);
|
|
339
|
-
throw new Error(error);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/** Error situation detected */
|
|
344
|
-
protected _parseError(arrayBuffer: ArrayBuffer): Error {
|
|
345
|
-
const error = WMTSErrorLoader.parseSync(arrayBuffer, this.props.loadOptions);
|
|
346
|
-
return new Error(error);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wcs-capabilities-loader.js","names":["parseWCSCapabilities","VERSION","WCSCapabilitiesLoader","id","name","module","version","worker","extensions","mimeTypes","testText","testXMLFile","options","wms","parse","arrayBuffer","TextDecoder","decode","parseTextSync","text","startsWith","_typecheckWFSCapabilitiesLoader"],"sources":["../../src/wip/wcs-capabilities-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {WCSCapabilities} from './lib/wcs/parse-wcs-capabilities';\nimport {parseWCSCapabilities} from './lib/wcs/parse-wcs-capabilities';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport {WCSCapabilities};\n\nexport type WCSLoaderOptions = LoaderOptions & {\n wcs?: {};\n};\n\n/**\n * Loader for the response to the WCS GetCapability request\n */\nexport const WCSCapabilitiesLoader = {\n id: 'wcs-capabilities',\n name: 'WFS Capabilities',\n\n module: 'wms',\n version: VERSION,\n worker: false,\n extensions: ['xml'],\n mimeTypes: ['application/vnd.ogc.wcs_xml', 'application/xml', 'text/xml'],\n testText: testXMLFile,\n options: {\n wms: {}\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: WCSLoaderOptions) =>\n parseWCSCapabilities(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: WCSLoaderOptions) => parseWCSCapabilities(text, options)\n};\n\nfunction testXMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<?xml');\n}\n\nexport const _typecheckWFSCapabilitiesLoader: LoaderWithParser = WCSCapabilitiesLoader;\n"],"mappings":"SAIQA,oBAAoB;AAI5B,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAW3E,OAAO,MAAMC,qBAAqB,GAAG;EACnCC,EAAE,EAAE,kBAAkB;EACtBC,IAAI,EAAE,kBAAkB;EAExBC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,MAAM,EAAE,KAAK;EACbC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,6BAA6B,EAAE,iBAAiB,EAAE,UAAU,CAAC;EACzEC,QAAQ,EAAEC,WAAW;EACrBC,OAAO,EAAE;IACPC,GAAG,EAAE,CAAC;EACR,CAAC;EACDC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEH,OAA0B,KAChEZ,oBAAoB,CAAC,IAAIgB,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,WAAW,CAAC,EAAEH,OAAO,CAAC;EACtEM,aAAa,EAAEA,CAACC,IAAY,EAAEP,OAA0B,KAAKZ,oBAAoB,CAACmB,IAAI,EAAEP,OAAO;AACjG,CAAC;AAED,SAASD,WAAWA,CAACQ,IAAY,EAAW;EAE1C,OAAOA,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACjC;AAEA,OAAO,MAAMC,+BAAiD,GAAGnB,qBAAqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wfs-capabilities-loader.js","names":["parseWFSCapabilities","VERSION","WFSCapabilitiesLoader","id","name","module","version","worker","extensions","mimeTypes","testText","testXMLFile","options","wfs","parse","arrayBuffer","TextDecoder","decode","parseTextSync","text","startsWith","_typecheckWFSCapabilitiesLoader"],"sources":["../../src/wip/wfs-capabilities-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {WFSCapabilities} from './lib/wfs/parse-wfs-capabilities';\nimport {parseWFSCapabilities} from './lib/wfs/parse-wfs-capabilities';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type {WFSCapabilities};\n\nexport type WFSLoaderOptions = LoaderOptions & {\n wfs?: {};\n};\n\n/**\n * Loader for the response to the WFS GetCapability request\n */\nexport const WFSCapabilitiesLoader: LoaderWithParser<WFSCapabilities, never, WFSLoaderOptions> = {\n id: 'wfs-capabilities',\n name: 'WFS Capabilities',\n\n module: 'wms',\n version: VERSION,\n worker: false,\n extensions: ['xml'],\n mimeTypes: ['application/vnd.ogc.wfs_xml', 'application/xml', 'text/xml'],\n testText: testXMLFile,\n options: {\n wfs: {}\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: WFSLoaderOptions) =>\n parseWFSCapabilities(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: WFSLoaderOptions) => parseWFSCapabilities(text, options)\n};\n\nfunction testXMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<?xml');\n}\n\nexport const _typecheckWFSCapabilitiesLoader: LoaderWithParser = WFSCapabilitiesLoader;\n"],"mappings":"SAIQA,oBAAoB;AAI5B,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAW3E,OAAO,MAAMC,qBAAiF,GAAG;EAC/FC,EAAE,EAAE,kBAAkB;EACtBC,IAAI,EAAE,kBAAkB;EAExBC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,MAAM,EAAE,KAAK;EACbC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,6BAA6B,EAAE,iBAAiB,EAAE,UAAU,CAAC;EACzEC,QAAQ,EAAEC,WAAW;EACrBC,OAAO,EAAE;IACPC,GAAG,EAAE,CAAC;EACR,CAAC;EACDC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEH,OAA0B,KAChEZ,oBAAoB,CAAC,IAAIgB,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,WAAW,CAAC,EAAEH,OAAO,CAAC;EACtEM,aAAa,EAAEA,CAACC,IAAY,EAAEP,OAA0B,KAAKZ,oBAAoB,CAACmB,IAAI,EAAEP,OAAO;AACjG,CAAC;AAED,SAASD,WAAWA,CAACQ,IAAY,EAAW;EAE1C,OAAOA,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACjC;AAEA,OAAO,MAAMC,+BAAiD,GAAGnB,qBAAqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wms-feature-info-loader.js","names":["WMSCapabilitiesLoader","parseWMSFeatureInfo","WMSFeatureInfoLoader","id","name","parse","arrayBuffer","options","TextDecoder","decode","parseTextSync","text","_typecheckWMSFeatureInfoLoader"],"sources":["../../src/wip/wms-feature-info-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {XMLLoaderOptions} from '@loaders.gl/xml';\nimport {WMSCapabilitiesLoader} from '../wms-capabilities-loader';\n\nimport type {WMSFeatureInfo} from '../lib/parsers/wms/parse-wms-features';\nimport {parseWMSFeatureInfo} from '../lib/parsers/wms/parse-wms-features';\n\nexport {WMSFeatureInfo};\n\n/**\n * Loader for the response to the WMS GetFeatureInfo request\n */\n// @ts-expect-error\nexport const WMSFeatureInfoLoader: LoaderWithParser<WMSFeatureInfo, never, XMLLoaderOptions> = {\n ...WMSCapabilitiesLoader,\n\n id: 'wms-feature-info',\n name: 'WMS FeatureInfo',\n\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseWMSFeatureInfo(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: XMLLoaderOptions) => parseWMSFeatureInfo(text, options)\n};\n\nexport const _typecheckWMSFeatureInfoLoader: LoaderWithParser = WMSFeatureInfoLoader;\n"],"mappings":"SAIQA,qBAAqB;AAAA,SAGrBC,mBAAmB;AAQ3B,OAAO,MAAMC,oBAA+E,GAAG;EAC7F,GAAGF,qBAAqB;EAExBG,EAAE,EAAE,kBAAkB;EACtBC,IAAI,EAAE,iBAAiB;EAEvBC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEC,OAA0B,KAChEN,mBAAmB,CAAC,IAAIO,WAAW,CAAC,CAAC,CAACC,MAAM,CAACH,WAAW,CAAC,EAAEC,OAAO,CAAC;EACrEG,aAAa,EAAEA,CAACC,IAAY,EAAEJ,OAA0B,KAAKN,mBAAmB,CAACU,IAAI,EAAEJ,OAAO;AAChG,CAAC;AAED,OAAO,MAAMK,8BAAgD,GAAGV,oBAAoB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wms-layer-description-loader.js","names":["WMSCapabilitiesLoader","parseWMSLayerDescription","WMSLayerDescriptionLoader","id","name","parse","arrayBuffer","options","TextDecoder","decode","parseTextSync","text","_typecheckWMSFeatureInfoLoader"],"sources":["../../src/wip/wms-layer-description-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {XMLLoaderOptions} from '@loaders.gl/xml';\nimport {WMSCapabilitiesLoader} from '../wms-capabilities-loader';\n\nimport type {WMSLayerDescription} from '../lib/parsers/wms/parse-wms-layer-description';\nimport {parseWMSLayerDescription} from '../lib/parsers/wms/parse-wms-layer-description';\n\nexport {WMSLayerDescription};\n\n/**\n * Loader for the response to the WMS DescribeLayer request\n */\nexport const WMSLayerDescriptionLoader = {\n ...WMSCapabilitiesLoader,\n\n id: 'wms-layer-description',\n name: 'WMS DescribeLayer',\n\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseWMSLayerDescription(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: XMLLoaderOptions) => parseWMSLayerDescription(text, options)\n};\n\nexport const _typecheckWMSFeatureInfoLoader: LoaderWithParser = WMSLayerDescriptionLoader;\n"],"mappings":"SAIQA,qBAAqB;AAAA,SAGrBC,wBAAwB;AAOhC,OAAO,MAAMC,yBAAyB,GAAG;EACvC,GAAGF,qBAAqB;EAExBG,EAAE,EAAE,uBAAuB;EAC3BC,IAAI,EAAE,mBAAmB;EAEzBC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEC,OAA0B,KAChEN,wBAAwB,CAAC,IAAIO,WAAW,CAAC,CAAC,CAACC,MAAM,CAACH,WAAW,CAAC,EAAEC,OAAO,CAAC;EAC1EG,aAAa,EAAEA,CAACC,IAAY,EAAEJ,OAA0B,KAAKN,wBAAwB,CAACU,IAAI,EAAEJ,OAAO;AACrG,CAAC;AAED,OAAO,MAAMK,8BAAgD,GAAGV,yBAAyB"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# WMSLayerDescriptionLoader
|
|
2
|
-
|
|
3
|
-
<p class="badges">
|
|
4
|
-
<img src="https://img.shields.io/badge/From-v3.3-blue.svg?style=flat-square" alt="From-v3.3" />
|
|
5
|
-
<img src="https://img.shields.io/badge/-BETA-teal.svg" alt="BETA" />
|
|
6
|
-
</p>
|
|
7
|
-
|
|
8
|
-
The `WMSLayerDescriptionLoader` parses the XML-formatted response from the
|
|
9
|
-
the [OGC](https://www.opengeospatial.org/) [WMS](https://www.ogc.org/standards/wms) (Web Map Service) standard `DescribeLayer` request into a typed JavaScript data structure.
|
|
10
|
-
|
|
11
|
-
> Note that the WMS standard is rather verbose and the XML responses can contain many rarely used metadata fields, not all of which are extracted by this loader. If this is a problem, it is possible to use the `XMLLoader` directly though the result will be untyped and not normalized.
|
|
12
|
-
|
|
13
|
-
| Loader | Characteristic |
|
|
14
|
-
| --------------------- | ---------------------------------------------------- |
|
|
15
|
-
| File Extension | `.xml` |
|
|
16
|
-
| File Type | Text |
|
|
17
|
-
| File Format | [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) |
|
|
18
|
-
| Data Format | Data structure |
|
|
19
|
-
| Decoder Type | Synchronous |
|
|
20
|
-
| Worker Thread Support | No |
|
|
21
|
-
| Streaming Support | No |
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
```js
|
|
26
|
-
import {WMSLayerDescriptionLoader} from '@loaders.gl/wms';
|
|
27
|
-
import {load} from '@loaders.gl/core';
|
|
28
|
-
|
|
29
|
-
// Form a WMS request
|
|
30
|
-
const url = `${WMS_SERVICE_URL}?REQUEST=DescribeLayer&LAYER=...`;
|
|
31
|
-
|
|
32
|
-
const data = await load(url, WMSLayerDescriptionLoader, options);
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Parsed Data Format
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
/** All capabilities of a WMS service. Typed data structure extracted from XML */
|
|
39
|
-
export type WMSLayerDescription = {
|
|
40
|
-
// TO BE DOCUMENTED
|
|
41
|
-
}
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Options
|
|
45
|
-
|
|
46
|
-
| Option | Type | Default | Description |
|
|
47
|
-
| ------ | ---- | ------- | ----------- |
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wmts-capabilities-loader.js","names":["parseWMTSCapabilities","VERSION","WMTSCapabilitiesLoader","id","name","module","version","worker","extensions","mimeTypes","testText","testXMLFile","options","wms","parse","arrayBuffer","TextDecoder","decode","parseTextSync","text","startsWith","_typecheckWMTSCapabilitiesLoader"],"sources":["../../src/wip/wmts-capabilities-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {XMLLoaderOptions} from '@loaders.gl/xml';\n// import type {WMTSCapabilities} from './lib/wmts/parse-wmts-capabilities';\nimport {parseWMTSCapabilities} from './lib/wmts/parse-wmts-capabilities';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n// export type {WMTSCapabilities};\n\nexport type WMTSLoaderOptions = XMLLoaderOptions & {\n wmts?: {};\n};\n\n/**\n * Loader for the response to the WMTS GetCapability request\n */\nexport const WMTSCapabilitiesLoader = {\n id: 'wmts-capabilities',\n name: 'WMTS Capabilities',\n\n module: 'wms',\n version: VERSION,\n worker: false,\n extensions: ['xml'],\n mimeTypes: ['application/vnd.ogc.wmts_xml', 'application/xml', 'text/xml'],\n testText: testXMLFile,\n options: {\n wms: {}\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: WMTSLoaderOptions) =>\n parseWMTSCapabilities(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: WMTSLoaderOptions) => parseWMTSCapabilities(text, options)\n};\n\nfunction testXMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<?xml');\n}\n\nexport const _typecheckWMTSCapabilitiesLoader: LoaderWithParser = WMTSCapabilitiesLoader;\n"],"mappings":"SAKQA,qBAAqB;AAI7B,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAW3E,OAAO,MAAMC,sBAAsB,GAAG;EACpCC,EAAE,EAAE,mBAAmB;EACvBC,IAAI,EAAE,mBAAmB;EAEzBC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,MAAM,EAAE,KAAK;EACbC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,8BAA8B,EAAE,iBAAiB,EAAE,UAAU,CAAC;EAC1EC,QAAQ,EAAEC,WAAW;EACrBC,OAAO,EAAE;IACPC,GAAG,EAAE,CAAC;EACR,CAAC;EACDC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEH,OAA2B,KACjEZ,qBAAqB,CAAC,IAAIgB,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,WAAW,CAAC,EAAEH,OAAO,CAAC;EACvEM,aAAa,EAAEA,CAACC,IAAY,EAAEP,OAA2B,KAAKZ,qBAAqB,CAACmB,IAAI,EAAEP,OAAO;AACnG,CAAC;AAED,SAASD,WAAWA,CAACQ,IAAY,EAAW;EAE1C,OAAOA,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACjC;AAEA,OAAO,MAAMC,gCAAkD,GAAGnB,sBAAsB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wms-capabilities-loader.js","names":["parseWMSCapabilities","VERSION","WMSCapabilitiesLoader","id","name","module","version","worker","extensions","mimeTypes","testText","testXMLFile","options","wms","parse","arrayBuffer","TextDecoder","decode","parseTextSync","text","startsWith"],"sources":["../src/wms-capabilities-loader.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {XMLLoaderOptions} from '@loaders.gl/xml';\nimport {WMSCapabilities, parseWMSCapabilities} from './lib/parsers/wms/parse-wms-capabilities';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n// Parsed data types\nexport type {\n WMSCapabilities,\n WMSLayer,\n WMSBoundingBox,\n WMSDimension,\n WMSRequest,\n WMSExceptions\n} from './lib/parsers/wms/parse-wms-capabilities';\n\nexport type WMSCapabilitiesLoaderOptions = XMLLoaderOptions & {\n wms?: {\n /** Add inherited layer information to sub layers */\n inheritedLayerProps?: boolean;\n /** Include the \"raw\" JSON (parsed but untyped, unprocessed XML). May contain additional fields */\n includeRawJSON?: boolean;\n /** Include the original XML document text. May contain additional information. */\n includeXMLText?: boolean;\n };\n};\n\n/**\n * Loader for the response to the WMS GetCapability request\n */\nexport const WMSCapabilitiesLoader: LoaderWithParser<\n WMSCapabilities,\n never,\n WMSCapabilitiesLoaderOptions\n> = {\n id: 'wms-capabilities',\n name: 'WMS Capabilities',\n\n module: 'wms',\n version: VERSION,\n worker: false,\n extensions: ['xml'],\n mimeTypes: ['application/vnd.ogc.wms_xml', 'application/xml', 'text/xml'],\n testText: testXMLFile,\n options: {\n wms: {}\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: WMSCapabilitiesLoaderOptions) =>\n // TODO pass in XML options\n parseWMSCapabilities(new TextDecoder().decode(arrayBuffer), options?.wms),\n parseTextSync: (text: string, options?: WMSCapabilitiesLoaderOptions) =>\n // TODO pass in XML options\n parseWMSCapabilities(text, options?.wms)\n};\n\nfunction testXMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<?xml');\n}\n"],"mappings":"SAMyBA,oBAAoB;AAI7C,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AA0B3E,OAAO,MAAMC,qBAIZ,GAAG;EACFC,EAAE,EAAE,kBAAkB;EACtBC,IAAI,EAAE,kBAAkB;EAExBC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,MAAM,EAAE,KAAK;EACbC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,6BAA6B,EAAE,iBAAiB,EAAE,UAAU,CAAC;EACzEC,QAAQ,EAAEC,WAAW;EACrBC,OAAO,EAAE;IACPC,GAAG,EAAE,CAAC;EACR,CAAC;EACDC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEH,OAAsC,KAE5EZ,oBAAoB,CAAC,IAAIgB,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,WAAW,CAAC,EAAEH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG,CAAC;EAC3EK,aAAa,EAAEA,CAACC,IAAY,EAAEP,OAAsC,KAElEZ,oBAAoB,CAACmB,IAAI,EAAEP,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG;AAC3C,CAAC;AAED,SAASF,WAAWA,CAACQ,IAAY,EAAW;EAE1C,OAAOA,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wms-error-loader.js","names":["parseWMSError","VERSION","WMSErrorLoader","id","name","module","version","worker","extensions","mimeTypes","testText","testXMLFile","options","wms","throwOnError","parse","arrayBuffer","parseTextSync","TextDecoder","decode","parseSync","text","startsWith","wmsOptions","error","message","minimalErrors","Error"],"sources":["../src/wms-error-loader.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {parseWMSError} from './lib/parsers/wms/parse-wms-error';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type WMSLoaderOptions = LoaderOptions & {\n wms?: {\n /** By default the error loader will throw an error with the parsed error message */\n throwOnError?: boolean;\n /** Do not add any text to errors */\n minimalErrors?: boolean;\n };\n};\n\n/**\n * Loader for the response to the WMS GetCapability request\n */\nexport const WMSErrorLoader: LoaderWithParser<string, never, WMSLoaderOptions> = {\n id: 'wms-error',\n name: 'WMS Error',\n\n module: 'wms',\n version: VERSION,\n worker: false,\n extensions: ['xml'],\n mimeTypes: ['application/vnd.ogc.se_xml', 'application/xml', 'text/xml'],\n testText: testXMLFile,\n options: {\n wms: {\n throwOnError: false\n }\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: WMSLoaderOptions): Promise<string> =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseSync: (arrayBuffer: ArrayBuffer, options?: WMSLoaderOptions): string =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: WMSLoaderOptions): string => parseTextSync(text, options)\n};\n\nfunction testXMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<?xml');\n}\n\nfunction parseTextSync(text: string, options?: WMSLoaderOptions): string {\n const wmsOptions: WMSLoaderOptions['wms'] = {...WMSErrorLoader.options.wms, ...options?.wms};\n const error = parseWMSError(text, wmsOptions);\n const message = wmsOptions.minimalErrors ? error : `WMS Service error: ${error}`;\n if (wmsOptions.throwOnError) {\n throw new Error(message);\n }\n return message;\n}\n"],"mappings":"SAKQA,aAAa;AAIrB,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAc3E,OAAO,MAAMC,cAAiE,GAAG;EAC/EC,EAAE,EAAE,WAAW;EACfC,IAAI,EAAE,WAAW;EAEjBC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,MAAM,EAAE,KAAK;EACbC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,4BAA4B,EAAE,iBAAiB,EAAE,UAAU,CAAC;EACxEC,QAAQ,EAAEC,WAAW;EACrBC,OAAO,EAAE;IACPC,GAAG,EAAE;MACHC,YAAY,EAAE;IAChB;EACF,CAAC;EACDC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEJ,OAA0B,KAChEK,aAAa,CAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACH,WAAW,CAAC,EAAEJ,OAAO,CAAC;EAC/DQ,SAAS,EAAEA,CAACJ,WAAwB,EAAEJ,OAA0B,KAC9DK,aAAa,CAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACH,WAAW,CAAC,EAAEJ,OAAO,CAAC;EAC/DK,aAAa,EAAEA,CAACI,IAAY,EAAET,OAA0B,KAAaK,aAAa,CAACI,IAAI,EAAET,OAAO;AAClG,CAAC;AAED,SAASD,WAAWA,CAACU,IAAY,EAAW;EAE1C,OAAOA,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACjC;AAEA,SAASL,aAAaA,CAACI,IAAY,EAAET,OAA0B,EAAU;EACvE,MAAMW,UAAmC,GAAG;IAAC,GAAGrB,cAAc,CAACU,OAAO,CAACC,GAAG;IAAE,IAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG;EAAA,CAAC;EAC5F,MAAMW,KAAK,GAAGxB,aAAa,CAACqB,IAAI,EAAEE,UAAU,CAAC;EAC7C,MAAME,OAAO,GAAGF,UAAU,CAACG,aAAa,GAAGF,KAAK,GAAI,sBAAqBA,KAAM,EAAC;EAChF,IAAID,UAAU,CAACT,YAAY,EAAE;IAC3B,MAAM,IAAIa,KAAK,CAACF,OAAO,CAAC;EAC1B;EACA,OAAOA,OAAO;AAChB"}
|