@loaders.gl/wms 3.3.0-alpha.10 → 3.3.0-alpha.12
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/dist.min.js +3487 -33
- package/dist/es5/gml-loader.js +54 -0
- package/dist/es5/gml-loader.js.map +1 -0
- package/dist/es5/index.js +31 -3
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/data-sources/image-data-source.js.map +1 -1
- package/dist/es5/lib/data-sources/{wms-data-source.js → wms-service.js} +182 -65
- package/dist/es5/lib/data-sources/wms-service.js.map +1 -0
- package/dist/es5/lib/gml/parse-gml.js +416 -0
- package/dist/es5/lib/gml/parse-gml.js.map +1 -0
- package/dist/es5/lib/wfs/parse-wfs.js +43 -0
- package/dist/es5/lib/wfs/parse-wfs.js.map +1 -0
- package/dist/es5/lib/wfs/wfs-types.js +2 -0
- package/dist/es5/lib/wfs/wfs-types.js.map +1 -0
- package/dist/es5/lib/{parse-wms.js → wms/parse-wms.js} +33 -2
- package/dist/es5/lib/wms/parse-wms.js.map +1 -0
- package/dist/es5/{wms-types.js → lib/wms/wms-types.js} +0 -0
- package/dist/es5/lib/wms/wms-types.js.map +1 -0
- package/dist/es5/lib/wmts/parse-wmts.js +43 -0
- package/dist/es5/lib/wmts/parse-wmts.js.map +1 -0
- package/dist/es5/lib/wmts/wmts-types.js +2 -0
- package/dist/es5/lib/wmts/wmts-types.js.map +1 -0
- package/dist/es5/wcs-capabilities-loader.js +54 -0
- package/dist/es5/wcs-capabilities-loader.js.map +1 -0
- package/dist/es5/wfs-capabilities-loader.js +54 -0
- package/dist/es5/wfs-capabilities-loader.js.map +1 -0
- package/dist/es5/wms-capabilities-loader.js +2 -2
- package/dist/es5/wms-capabilities-loader.js.map +1 -1
- package/dist/es5/wms-error-loader.js +54 -0
- package/dist/es5/wms-error-loader.js.map +1 -0
- package/dist/es5/wms-feature-info-loader.js +1 -1
- package/dist/es5/wms-feature-info-loader.js.map +1 -1
- package/dist/es5/wms-layer-description-loader.js +3 -3
- package/dist/es5/wms-layer-description-loader.js.map +1 -1
- package/dist/es5/wmts-capabilities-loader.js +54 -0
- package/dist/es5/wmts-capabilities-loader.js.map +1 -0
- package/dist/esm/gml-loader.js +25 -0
- package/dist/esm/gml-loader.js.map +1 -0
- package/dist/esm/index.js +8 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/data-sources/image-data-source.js.map +1 -1
- package/dist/esm/lib/data-sources/wms-service.js +156 -0
- package/dist/esm/lib/data-sources/wms-service.js.map +1 -0
- package/dist/esm/lib/gml/parse-gml.js +348 -0
- package/dist/esm/lib/gml/parse-gml.js.map +1 -0
- package/dist/esm/lib/wfs/parse-wfs.js +32 -0
- package/dist/esm/lib/wfs/parse-wfs.js.map +1 -0
- package/dist/esm/lib/wfs/wfs-types.js +2 -0
- package/dist/esm/lib/wfs/wfs-types.js.map +1 -0
- package/dist/esm/lib/{parse-wms.js → wms/parse-wms.js} +31 -2
- package/dist/esm/lib/wms/parse-wms.js.map +1 -0
- package/dist/esm/{wms-types.js → lib/wms/wms-types.js} +0 -0
- package/dist/esm/lib/wms/wms-types.js.map +1 -0
- package/dist/esm/lib/wmts/parse-wmts.js +32 -0
- package/dist/esm/lib/wmts/parse-wmts.js.map +1 -0
- package/dist/esm/lib/wmts/wmts-types.js +2 -0
- package/dist/esm/lib/wmts/wmts-types.js.map +1 -0
- package/dist/esm/wcs-capabilities-loader.js +25 -0
- package/dist/esm/wcs-capabilities-loader.js.map +1 -0
- package/dist/esm/wfs-capabilities-loader.js +25 -0
- package/dist/esm/wfs-capabilities-loader.js.map +1 -0
- package/dist/esm/wms-capabilities-loader.js +2 -2
- package/dist/esm/wms-capabilities-loader.js.map +1 -1
- package/dist/esm/wms-error-loader.js +25 -0
- package/dist/esm/wms-error-loader.js.map +1 -0
- package/dist/esm/wms-feature-info-loader.js +1 -1
- package/dist/esm/wms-feature-info-loader.js.map +1 -1
- package/dist/esm/wms-layer-description-loader.js +3 -3
- package/dist/esm/wms-layer-description-loader.js.map +1 -1
- package/dist/esm/wmts-capabilities-loader.js +25 -0
- package/dist/esm/wmts-capabilities-loader.js.map +1 -0
- package/package.json +15 -5
- package/src/gml-loader.ts +40 -0
- package/src/index.ts +23 -4
- package/src/lib/data-sources/image-data-source.ts +1 -2
- package/src/lib/data-sources/wms-service.ts +313 -0
- package/src/lib/gml/parse-gml.ts +500 -0
- package/src/lib/wfs/parse-wfs.ts +39 -0
- package/src/lib/wfs/wfs-types.ts +78 -0
- package/src/lib/{parse-wms.ts → wms/parse-wms.ts} +41 -4
- package/src/{wms-types.ts → lib/wms/wms-types.ts} +3 -1
- package/src/lib/wmts/parse-wmts.ts +39 -0
- package/src/lib/wmts/wmts-types.ts +77 -0
- package/src/wcs-capabilities-loader.ts +40 -0
- package/src/wfs-capabilities-loader.ts +40 -0
- package/src/wms-capabilities-loader.ts +1 -1
- package/src/wms-error-loader.ts +40 -0
- package/src/wms-feature-info-loader.ts +1 -1
- package/src/wms-layer-description-loader.ts +4 -4
- package/src/wmts-capabilities-loader.ts +40 -0
- package/dist/es5/lib/data-sources/wms-data-source.js.map +0 -1
- package/dist/es5/lib/parse-wms.js.map +0 -1
- package/dist/es5/wms-types.js.map +0 -1
- package/dist/esm/lib/data-sources/wms-data-source.js +0 -70
- package/dist/esm/lib/data-sources/wms-data-source.js.map +0 -1
- package/dist/esm/lib/parse-wms.js.map +0 -1
- package/dist/esm/wms-types.js.map +0 -1
- package/src/lib/data-sources/wms-data-source.ts +0 -99
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/wms",
|
|
3
|
-
"version": "3.3.0-alpha.
|
|
3
|
+
"version": "3.3.0-alpha.12",
|
|
4
4
|
"description": "Framework-independent loaders for the WMS (Web Map Service) standard",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -13,9 +13,15 @@
|
|
|
13
13
|
"keywords": [
|
|
14
14
|
"WMS",
|
|
15
15
|
"web map service",
|
|
16
|
+
"WFS",
|
|
17
|
+
"web feature service",
|
|
18
|
+
"WMTS",
|
|
19
|
+
"web map tile service",
|
|
20
|
+
"GML",
|
|
21
|
+
"geographic markup language",
|
|
22
|
+
"gis",
|
|
16
23
|
"loader",
|
|
17
24
|
"geospatial",
|
|
18
|
-
"webgl",
|
|
19
25
|
"OGC"
|
|
20
26
|
],
|
|
21
27
|
"types": "dist/index.d.ts",
|
|
@@ -33,11 +39,15 @@
|
|
|
33
39
|
},
|
|
34
40
|
"dependencies": {
|
|
35
41
|
"@babel/runtime": "^7.3.1",
|
|
36
|
-
"@loaders.gl/
|
|
37
|
-
"@loaders.gl/
|
|
42
|
+
"@loaders.gl/images": "3.3.0-alpha.12",
|
|
43
|
+
"@loaders.gl/loader-utils": "3.3.0-alpha.12",
|
|
44
|
+
"@loaders.gl/schema": "3.3.0-alpha.12",
|
|
45
|
+
"@loaders.gl/xml": "3.3.0-alpha.12",
|
|
46
|
+
"@turf/rewind": "^5.1.5",
|
|
47
|
+
"deep-strict-equal": "^0.2.0"
|
|
38
48
|
},
|
|
39
49
|
"devDependencies": {
|
|
40
50
|
"xmldom": "0.6.0"
|
|
41
51
|
},
|
|
42
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "e807cde8f2fcb3503fa01ae3ac6b148ff5326649"
|
|
43
53
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
4
|
+
import {parseGML} from './lib/gml/parse-gml';
|
|
5
|
+
|
|
6
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
7
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
8
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
9
|
+
|
|
10
|
+
export type GMLLoaderOptions = LoaderOptions & {
|
|
11
|
+
gml?: {};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Loader for the response to the GML GetCapability request
|
|
16
|
+
*/
|
|
17
|
+
export const GMLLoader = {
|
|
18
|
+
name: 'GML',
|
|
19
|
+
id: 'gml',
|
|
20
|
+
|
|
21
|
+
module: 'wms',
|
|
22
|
+
version: VERSION,
|
|
23
|
+
worker: false,
|
|
24
|
+
extensions: ['xml'],
|
|
25
|
+
mimeTypes: ['application/vnd.ogc.gml_xml', 'application/xml', 'text/xml'],
|
|
26
|
+
testText: testXMLFile,
|
|
27
|
+
options: {
|
|
28
|
+
gml: {}
|
|
29
|
+
},
|
|
30
|
+
parse: async (arrayBuffer: ArrayBuffer, options?: GMLLoaderOptions) =>
|
|
31
|
+
parseGML(new TextDecoder().decode(arrayBuffer), options),
|
|
32
|
+
parseTextSync: (text: string, options?: GMLLoaderOptions) => parseGML(text, options)
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function testXMLFile(text: string): boolean {
|
|
36
|
+
// TODO - There could be space first.
|
|
37
|
+
return text.startsWith('<?xml');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const _typecheckGMLLoader: LoaderWithParser = GMLLoader;
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
// loaders.gl, MIT license
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// WMS
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export {WMSErrorLoader} from './wms-error-loader';
|
|
6
6
|
|
|
7
|
+
export type {WMSCapabilities, WMSFeatureInfo, WMSLayerDescription} from './lib/wms/wms-types';
|
|
7
8
|
export type {WMSLoaderOptions} from './wms-capabilities-loader';
|
|
8
9
|
export {WMSCapabilitiesLoader} from './wms-capabilities-loader';
|
|
9
10
|
export {WMSFeatureInfoLoader} from './wms-feature-info-loader';
|
|
10
11
|
export {WMSLayerDescriptionLoader} from './wms-layer-description-loader';
|
|
11
12
|
|
|
12
|
-
export type {
|
|
13
|
-
export {
|
|
13
|
+
export type {WMSServiceProps} from './lib/data-sources/wms-service';
|
|
14
|
+
export {WMSService} from './lib/data-sources/wms-service';
|
|
15
|
+
|
|
16
|
+
// WFS
|
|
17
|
+
|
|
18
|
+
export type {WFSCapabilities} from './lib/wfs/wfs-types';
|
|
19
|
+
export type {WFSLoaderOptions} from './wfs-capabilities-loader';
|
|
20
|
+
export {WFSCapabilitiesLoader} from './wfs-capabilities-loader';
|
|
21
|
+
|
|
22
|
+
// WMTS
|
|
23
|
+
|
|
24
|
+
export type {WMTSCapabilities} from './lib/wmts/wmts-types';
|
|
25
|
+
export type {WMTSLoaderOptions} from './wmts-capabilities-loader';
|
|
26
|
+
export {WMTSCapabilitiesLoader} from './wmts-capabilities-loader';
|
|
27
|
+
|
|
28
|
+
// GML
|
|
29
|
+
|
|
30
|
+
export type {GeoJSON} from '@loaders.gl/schema';
|
|
31
|
+
export type {GMLLoaderOptions} from './gml-loader';
|
|
32
|
+
export {GMLLoader} from './gml-loader';
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
/* eslint-disable camelcase */
|
|
4
|
+
|
|
5
|
+
import type {WMSCapabilities, WMSFeatureInfo, WMSLayerDescription} from '@loaders.gl/wms';
|
|
6
|
+
import {
|
|
7
|
+
WMSCapabilitiesLoader,
|
|
8
|
+
WMSFeatureInfoLoader,
|
|
9
|
+
WMSLayerDescriptionLoader,
|
|
10
|
+
WMSErrorLoader
|
|
11
|
+
} from '@loaders.gl/wms';
|
|
12
|
+
import {ImageLoader, ImageType} from '@loaders.gl/images';
|
|
13
|
+
import {LoaderOptions} from '@loaders.gl/loader-utils';
|
|
14
|
+
|
|
15
|
+
type FetchLike = (url: string, options?: RequestInit) => Promise<Response>;
|
|
16
|
+
|
|
17
|
+
export type WMSGetCapabilitiesParameters = {
|
|
18
|
+
/** In case the endpoint supports multiple services */
|
|
19
|
+
service?: 'WMS';
|
|
20
|
+
/** In case the endpoint supports multiple WMS versions */
|
|
21
|
+
version?: '1.1.1' | '1.3.0';
|
|
22
|
+
/** Request type */
|
|
23
|
+
request?: 'GetCapabilities';
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type WMSGetMapParameters = {
|
|
27
|
+
/** In case the endpoint supports multiple services */
|
|
28
|
+
service?: 'WMS';
|
|
29
|
+
/** In case the endpoint supports multiple WMS versions */
|
|
30
|
+
version?: '1.1.1' | '1.3.0';
|
|
31
|
+
/** Request type */
|
|
32
|
+
request?: 'GetMap';
|
|
33
|
+
/** Layers to render */
|
|
34
|
+
layers: string[];
|
|
35
|
+
/** Styling */
|
|
36
|
+
styles?: unknown;
|
|
37
|
+
/** bounding box of the requested map image */
|
|
38
|
+
bbox: [number, number, number, number];
|
|
39
|
+
/** pixel width of returned image */
|
|
40
|
+
width: number;
|
|
41
|
+
/** pixels */
|
|
42
|
+
height: number;
|
|
43
|
+
/** srs for the image (not the bounding box) */
|
|
44
|
+
srs?: string;
|
|
45
|
+
/** requested format for the return image */
|
|
46
|
+
format?: 'image/png';
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// https://imagery.pasda.psu.edu/arcgis/services/pasda/UrbanTreeCanopy_Landcover/MapServer/WmsServer?SERVICE=WMS&
|
|
50
|
+
export type WMSGetFeatureInfoParameters = {
|
|
51
|
+
/** In case the endpoint supports multiple services */
|
|
52
|
+
service?: 'WMS';
|
|
53
|
+
/** In case the endpoint supports multiple WMS versions */
|
|
54
|
+
version?: '1.1.1' | '1.3.0';
|
|
55
|
+
/** Request type */
|
|
56
|
+
request?: 'GetFeatureInfo';
|
|
57
|
+
|
|
58
|
+
/** x coordinate for the feature info request */
|
|
59
|
+
x: number;
|
|
60
|
+
/** y coordinate for the feature info request */
|
|
61
|
+
y: number;
|
|
62
|
+
/** list of layers to query (could be different from rendered layers) */
|
|
63
|
+
query_layers: string[];
|
|
64
|
+
/** MIME type of returned feature info */
|
|
65
|
+
info_format: 'text/plain';
|
|
66
|
+
|
|
67
|
+
/** Layers to render */
|
|
68
|
+
layers: string[];
|
|
69
|
+
/** Styling */
|
|
70
|
+
styles?: unknown;
|
|
71
|
+
/** bounding box of the requested map image */
|
|
72
|
+
bbox: [number, number, number, number];
|
|
73
|
+
/** pixel width of returned image */
|
|
74
|
+
width: number;
|
|
75
|
+
/** pixels */
|
|
76
|
+
height: number;
|
|
77
|
+
/** srs for the image (not the bounding box) */
|
|
78
|
+
srs?: string;
|
|
79
|
+
/** requested format for the return image */
|
|
80
|
+
format?: 'image/png';
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type WMSDescribeLayerParameters = {
|
|
84
|
+
/** In case the endpoint supports multiple services */
|
|
85
|
+
service?: 'WMS';
|
|
86
|
+
/** In case the endpoint supports multiple WMS versions */
|
|
87
|
+
version?: '1.1.1' | '1.3.0';
|
|
88
|
+
/** Request type */
|
|
89
|
+
request?: 'DescribeLayer';
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type WMSGetLegendGraphicParameters = {
|
|
93
|
+
/** In case the endpoint supports multiple services */
|
|
94
|
+
service?: 'WMS';
|
|
95
|
+
/** In case the endpoint supports multiple WMS versions */
|
|
96
|
+
version?: '1.1.1' | '1.3.0';
|
|
97
|
+
/** Request type */
|
|
98
|
+
request?: 'GetLegendGraphic';
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const WMS_GET_CAPABILITIES_DEFAULT_PARAMETERS: Required<WMSGetCapabilitiesParameters> = {
|
|
102
|
+
service: 'WMS',
|
|
103
|
+
version: '1.1.1',
|
|
104
|
+
request: 'GetCapabilities'
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const WMS_GET_MAP_DEFAULT_PARAMETERS: Required<WMSGetMapParameters> = {
|
|
108
|
+
service: 'WMS',
|
|
109
|
+
version: '1.1.1',
|
|
110
|
+
request: 'GetMap',
|
|
111
|
+
layers: [],
|
|
112
|
+
styles: undefined,
|
|
113
|
+
bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
|
|
114
|
+
width: 1200,
|
|
115
|
+
height: 900,
|
|
116
|
+
srs: 'EPSG:4326',
|
|
117
|
+
format: 'image/png'
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const WMS_GET_FEATURE_INFO_DEFAULT_PARAMETERS: Required<WMSGetFeatureInfoParameters> = {
|
|
121
|
+
service: 'WMS',
|
|
122
|
+
version: '1.1.1',
|
|
123
|
+
request: 'GetFeatureInfo',
|
|
124
|
+
layers: [],
|
|
125
|
+
styles: undefined,
|
|
126
|
+
bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
|
|
127
|
+
width: 1200,
|
|
128
|
+
height: 900,
|
|
129
|
+
srs: 'EPSG:4326',
|
|
130
|
+
format: 'image/png',
|
|
131
|
+
|
|
132
|
+
x: undefined!,
|
|
133
|
+
y: undefined!,
|
|
134
|
+
query_layers: [],
|
|
135
|
+
info_format: 'text/plain'
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const WMS_DESCRIBE_LAYER_DEFAULT_PARAMETERS: Required<WMSDescribeLayerParameters> = {
|
|
139
|
+
service: 'WMS',
|
|
140
|
+
version: '1.1.1',
|
|
141
|
+
request: 'DescribeLayer'
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const WMS_GET_LEGEND_GRAPHIC_DEFAULT_PARAMETERS: Required<WMSGetLegendGraphicParameters> = {
|
|
145
|
+
service: 'WMS',
|
|
146
|
+
version: '1.1.1',
|
|
147
|
+
request: 'GetLegendGraphic'
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type WMSServiceProps = {
|
|
151
|
+
url: string;
|
|
152
|
+
loadOptions?: LoaderOptions;
|
|
153
|
+
fetch?: typeof fetch | FetchLike;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export class WMSService {
|
|
157
|
+
url: string;
|
|
158
|
+
loadOptions: LoaderOptions;
|
|
159
|
+
fetch: typeof fetch | FetchLike;
|
|
160
|
+
|
|
161
|
+
constructor(props: WMSServiceProps) {
|
|
162
|
+
this.url = props.url;
|
|
163
|
+
this.loadOptions = props.loadOptions || {};
|
|
164
|
+
this.fetch = props.fetch || fetch;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Typed URL creators
|
|
168
|
+
|
|
169
|
+
getCapabilitiesURL(
|
|
170
|
+
parameters?: WMSGetCapabilitiesParameters,
|
|
171
|
+
extra?: Record<string, unknown>
|
|
172
|
+
): string {
|
|
173
|
+
const options: Required<WMSGetCapabilitiesParameters> = {
|
|
174
|
+
...WMS_GET_CAPABILITIES_DEFAULT_PARAMETERS,
|
|
175
|
+
...parameters,
|
|
176
|
+
...extra
|
|
177
|
+
};
|
|
178
|
+
return this.getWMSUrl(options, extra);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
getMapURL(parameters: WMSGetMapParameters, extra?: Record<string, unknown>): string {
|
|
182
|
+
const options: Required<WMSGetMapParameters> = {
|
|
183
|
+
...WMS_GET_MAP_DEFAULT_PARAMETERS,
|
|
184
|
+
...parameters,
|
|
185
|
+
...extra
|
|
186
|
+
};
|
|
187
|
+
return this.getWMSUrl(options, extra);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
getFeatureInfoURL(
|
|
191
|
+
parameters: WMSGetFeatureInfoParameters,
|
|
192
|
+
extra?: Record<string, unknown>
|
|
193
|
+
): string {
|
|
194
|
+
const options: Required<WMSGetFeatureInfoParameters> = {
|
|
195
|
+
...WMS_GET_FEATURE_INFO_DEFAULT_PARAMETERS,
|
|
196
|
+
...parameters,
|
|
197
|
+
...extra
|
|
198
|
+
};
|
|
199
|
+
return this.getWMSUrl(options, extra);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
describeLayerURL(
|
|
203
|
+
parameters: WMSDescribeLayerParameters,
|
|
204
|
+
extra?: Record<string, unknown>
|
|
205
|
+
): string {
|
|
206
|
+
const options: Required<WMSDescribeLayerParameters> = {
|
|
207
|
+
...WMS_DESCRIBE_LAYER_DEFAULT_PARAMETERS,
|
|
208
|
+
...parameters,
|
|
209
|
+
...extra
|
|
210
|
+
};
|
|
211
|
+
return this.getWMSUrl(options, extra);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
getLegendGraphicURL(
|
|
215
|
+
parameters: WMSGetLegendGraphicParameters,
|
|
216
|
+
extra?: Record<string, unknown>
|
|
217
|
+
): string {
|
|
218
|
+
const options: Required<WMSGetLegendGraphicParameters> = {
|
|
219
|
+
...WMS_GET_LEGEND_GRAPHIC_DEFAULT_PARAMETERS,
|
|
220
|
+
...parameters,
|
|
221
|
+
...extra
|
|
222
|
+
};
|
|
223
|
+
return this.getWMSUrl(options, extra);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// WMS Service API Stubs
|
|
227
|
+
|
|
228
|
+
/** Get Capabilities */
|
|
229
|
+
async getCapabilities(
|
|
230
|
+
parameters?: WMSGetCapabilitiesParameters,
|
|
231
|
+
extra?: Record<string, unknown>
|
|
232
|
+
): Promise<WMSCapabilities> {
|
|
233
|
+
const url = this.getCapabilitiesURL(parameters, extra);
|
|
234
|
+
const response = await this.fetch(url, this.loadOptions);
|
|
235
|
+
await this.checkResponse(response);
|
|
236
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
237
|
+
return await WMSCapabilitiesLoader.parse(arrayBuffer, this.loadOptions);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Get a map image */
|
|
241
|
+
async getMap(options: WMSGetMapParameters, extra?: Record<string, unknown>): Promise<ImageType> {
|
|
242
|
+
const url = this.getMapURL(options, extra);
|
|
243
|
+
const response = await this.fetch(url, this.loadOptions);
|
|
244
|
+
await this.checkResponse(response);
|
|
245
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
246
|
+
return await ImageLoader.parse(arrayBuffer, this.loadOptions);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Get Feature Info for a coordinate */
|
|
250
|
+
async getFeatureInfo(
|
|
251
|
+
options: WMSGetFeatureInfoParameters,
|
|
252
|
+
extra?: Record<string, unknown>
|
|
253
|
+
): Promise<WMSFeatureInfo> {
|
|
254
|
+
const url = this.getFeatureInfoURL(options, extra);
|
|
255
|
+
const response = await this.fetch(url, this.loadOptions);
|
|
256
|
+
await this.checkResponse(response);
|
|
257
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
258
|
+
return await WMSFeatureInfoLoader.parse(arrayBuffer, this.loadOptions);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Get more information about a layer */
|
|
262
|
+
async describeLayer(
|
|
263
|
+
options: WMSDescribeLayerParameters,
|
|
264
|
+
extra?: Record<string, unknown>
|
|
265
|
+
): Promise<WMSLayerDescription> {
|
|
266
|
+
const url = this.describeLayerURL(options, extra);
|
|
267
|
+
const response = await this.fetch(url, this.loadOptions);
|
|
268
|
+
await this.checkResponse(response);
|
|
269
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
270
|
+
return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.loadOptions);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Get an image with a semantic legend */
|
|
274
|
+
async getLegendGraphic(
|
|
275
|
+
options: WMSGetLegendGraphicParameters,
|
|
276
|
+
extra?: Record<string, unknown>
|
|
277
|
+
): Promise<ImageType> {
|
|
278
|
+
const url = this.getLegendGraphicURL(options, extra);
|
|
279
|
+
const response = await this.fetch(url, this.loadOptions);
|
|
280
|
+
await this.checkResponse(response);
|
|
281
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
282
|
+
return await ImageLoader.parse(arrayBuffer, this.loadOptions);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// INTERNAL METHODS
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* @note protected, since perhaps getWMSUrl may need to be overridden to handle certain backends?
|
|
289
|
+
* @note if override is common, maybe add a callback prop?
|
|
290
|
+
* */
|
|
291
|
+
protected getWMSUrl(
|
|
292
|
+
options: {
|
|
293
|
+
request: string;
|
|
294
|
+
layers?: string[];
|
|
295
|
+
},
|
|
296
|
+
extra?: Record<string, unknown>
|
|
297
|
+
): string {
|
|
298
|
+
let url = `${this.url}?REQUEST=${options.request}`;
|
|
299
|
+
if (options.layers?.length) {
|
|
300
|
+
url += `&LAYERS=[${options.layers.join(',')}]`;
|
|
301
|
+
}
|
|
302
|
+
return url;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Checks for and parses a WMS XML formatted ServiceError and throws an exception */
|
|
306
|
+
protected async checkResponse(response: Response) {
|
|
307
|
+
if (!response.ok || response.headers['content-type'] === WMSErrorLoader.mimeTypes[0]) {
|
|
308
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
309
|
+
const error = await WMSErrorLoader.parse(arrayBuffer, this.loadOptions);
|
|
310
|
+
throw new Error(error);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|