@loaders.gl/wms 4.0.0-alpha.23 → 4.0.0-alpha.25
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 +1 -1
- package/dist/es5/csw-capabilities-loader.js +1 -1
- package/dist/es5/csw-domain-loader.js +1 -1
- package/dist/es5/csw-records-loader.js +1 -1
- package/dist/es5/gml-loader.js +1 -1
- package/dist/es5/gml-loader.js.map +1 -1
- package/dist/es5/lerc-loader.js +1 -1
- package/dist/es5/lerc-loader.js.map +1 -1
- package/dist/es5/lib/parsers/gml/parse-gml.js.map +1 -1
- package/dist/es5/wip/wcs-capabilities-loader.js +1 -1
- package/dist/es5/wip/wfs-capabilities-loader.js +1 -1
- package/dist/es5/wip/wmts-capabilities-loader.js +1 -1
- package/dist/es5/wms-capabilities-loader.js +1 -1
- package/dist/es5/wms-error-loader.js +1 -1
- package/dist/esm/csw-capabilities-loader.js +1 -1
- package/dist/esm/csw-domain-loader.js +1 -1
- package/dist/esm/csw-records-loader.js +1 -1
- package/dist/esm/gml-loader.js +1 -1
- package/dist/esm/gml-loader.js.map +1 -1
- package/dist/esm/lerc-loader.js +1 -1
- package/dist/esm/lerc-loader.js.map +1 -1
- package/dist/esm/lib/parsers/gml/parse-gml.js.map +1 -1
- package/dist/esm/wip/wcs-capabilities-loader.js +1 -1
- package/dist/esm/wip/wfs-capabilities-loader.js +1 -1
- package/dist/esm/wip/wmts-capabilities-loader.js +1 -1
- package/dist/esm/wms-capabilities-loader.js +1 -1
- package/dist/esm/wms-error-loader.js +1 -1
- package/dist/gml-loader.d.ts +2 -1
- package/dist/gml-loader.d.ts.map +1 -1
- package/dist/lerc-loader.d.ts +2 -1
- package/dist/lerc-loader.d.ts.map +1 -1
- package/dist/lib/parsers/gml/parse-gml.d.ts +1 -0
- package/dist/lib/parsers/gml/parse-gml.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/gml-loader.ts +2 -1
- package/src/lerc-loader.ts +1 -1
- package/src/lib/parsers/gml/parse-gml.ts +2 -0
- package/dist/bundle.js +0 -6
- package/dist/csw-capabilities-loader.js +0 -30
- package/dist/csw-domain-loader.js +0 -30
- package/dist/csw-records-loader.js +0 -30
- package/dist/gml-loader.js +0 -30
- package/dist/index.js +0 -39
- package/dist/lerc-loader.js +0 -55
- package/dist/lib/create-image-source.js +0 -39
- package/dist/lib/parsers/csw/parse-csw-capabilities.js +0 -24
- package/dist/lib/parsers/csw/parse-csw-domain.js +0 -33
- package/dist/lib/parsers/csw/parse-csw-records.js +0 -58
- package/dist/lib/parsers/csw/parse-exception-report.js +0 -30
- package/dist/lib/parsers/gml/deep-strict-equal.js +0 -119
- package/dist/lib/parsers/gml/parse-gml.js +0 -371
- package/dist/lib/parsers/lerc/lerc-types.js +0 -3
- package/dist/lib/parsers/wms/parse-wms-capabilities.js +0 -233
- package/dist/lib/parsers/wms/parse-wms-error.js +0 -22
- package/dist/lib/parsers/wms/parse-wms-features.js +0 -27
- package/dist/lib/parsers/wms/parse-wms-layer-description.js +0 -15
- package/dist/lib/parsers/xml/parse-xml-helpers.js +0 -68
- package/dist/lib/services/arcgis/arcgis-image-service.js +0 -94
- package/dist/lib/services/arcgis/arcgis-server.js +0 -42
- package/dist/lib/services/generic/image-service.js +0 -47
- package/dist/lib/services/ogc/csw-service.js +0 -168
- package/dist/lib/services/ogc/wms-service.js +0 -309
- package/dist/lib/sources/data-source.js +0 -56
- package/dist/lib/sources/image-source.js +0 -13
- package/dist/lib/sources/tile-source.js +0 -13
- package/dist/lib/sources/utils/utils.js +0 -38
- package/dist/lib/wfs/parse-wfs.js +0 -32
- package/dist/lib/wmts/parse-wmts.js +0 -35
- package/dist/wip/arcgis-feature-service.js +0 -28
- package/dist/wip/data-source.js +0 -59
- package/dist/wip/lib/wcs/parse-wcs-capabilities.js +0 -15
- package/dist/wip/lib/wfs/parse-wfs-capabilities.js +0 -19
- package/dist/wip/lib/wmts/parse-wmts-capabilities.js +0 -77
- package/dist/wip/wcs-capabilities-loader.js +0 -31
- package/dist/wip/wfs-capabilities-loader.js +0 -31
- package/dist/wip/wms-feature-info-loader.js +0 -18
- package/dist/wip/wms-layer-description-loader.js +0 -17
- package/dist/wip/wmts-capabilities-loader.js +0 -32
- package/dist/wms-capabilities-loader.js +0 -34
- package/dist/wms-error-loader.js +0 -42
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.parseWMSCapabilities = void 0;
|
|
5
|
-
const xml_1 = require("@loaders.gl/xml");
|
|
6
|
-
const parse_xml_helpers_1 = require("../xml/parse-xml-helpers");
|
|
7
|
-
/**
|
|
8
|
-
* Parses a typed data structure from raw XML for `GetCapabilities` response
|
|
9
|
-
* @note Error handlings is fairly weak
|
|
10
|
-
*/
|
|
11
|
-
function parseWMSCapabilities(xmlText, options) {
|
|
12
|
-
const parsedXML = xml_1.XMLLoader.parseTextSync?.(xmlText, options);
|
|
13
|
-
const xmlCapabilities = parsedXML.WMT_MS_Capabilities || parsedXML.WMS_Capabilities || parsedXML;
|
|
14
|
-
const capabilities = extractCapabilities(xmlCapabilities);
|
|
15
|
-
// In case the processed, normalized capabilities do not contain everything,
|
|
16
|
-
// the user can get the parsed XML structure.
|
|
17
|
-
if (options?.inheritedLayerProps) {
|
|
18
|
-
// Traverse layers and inject missing props from parents
|
|
19
|
-
for (const layer of capabilities.layers) {
|
|
20
|
-
addInheritedLayerProps(layer, null);
|
|
21
|
-
}
|
|
22
|
-
// Not yet implemented
|
|
23
|
-
}
|
|
24
|
-
if (options?.includeRawData || options?.raw) {
|
|
25
|
-
capabilities.raw = xmlCapabilities;
|
|
26
|
-
}
|
|
27
|
-
if (options?.includeXMLText) {
|
|
28
|
-
capabilities.xml = xmlText;
|
|
29
|
-
}
|
|
30
|
-
return capabilities;
|
|
31
|
-
}
|
|
32
|
-
exports.parseWMSCapabilities = parseWMSCapabilities;
|
|
33
|
-
/** Extract typed capability data from XML */
|
|
34
|
-
function extractCapabilities(xml) {
|
|
35
|
-
const capabilities = {
|
|
36
|
-
version: String(xml.version || ''),
|
|
37
|
-
name: String(xml.Service?.Name || 'unnamed'),
|
|
38
|
-
title: xml.Service?.Title ? String(xml.Service?.Title) : undefined,
|
|
39
|
-
abstract: xml.Service?.Abstract ? String(xml.Service?.Abstract) : undefined,
|
|
40
|
-
keywords: (0, parse_xml_helpers_1.getXMLStringArray)(xml.Service?.KeywordList?.Keyword),
|
|
41
|
-
fees: xml.Service?.Fees ? JSON.stringify(xml.Service?.Fees) : undefined,
|
|
42
|
-
accessConstraints: xml.Service?.AccessConstraints
|
|
43
|
-
? JSON.stringify(xml.Service?.AccessConstraints)
|
|
44
|
-
: undefined,
|
|
45
|
-
layerLimit: (0, parse_xml_helpers_1.getXMLInteger)(xml.Service?.LayerLimit),
|
|
46
|
-
maxWidth: (0, parse_xml_helpers_1.getXMLInteger)(xml.Service?.maxWidth),
|
|
47
|
-
maxHeight: (0, parse_xml_helpers_1.getXMLInteger)(xml.Service?.maxHeight),
|
|
48
|
-
layers: [],
|
|
49
|
-
requests: extractRequests(xml.Capability?.Request),
|
|
50
|
-
exceptions: extractExceptions(xml.Exception)
|
|
51
|
-
// contact field is a mess of largely irrelevant information, put it last
|
|
52
|
-
// contact: xml.Service?.Contact ? JSON.stringify(xml.Service?.Contact) : undefined,
|
|
53
|
-
};
|
|
54
|
-
// LAYERS
|
|
55
|
-
const xmlLayers = (0, parse_xml_helpers_1.getXMLArray)(xml.Capability?.Layer);
|
|
56
|
-
for (const xmlSubLayer of xmlLayers) {
|
|
57
|
-
capabilities.layers.push(extractLayer(xmlSubLayer));
|
|
58
|
-
}
|
|
59
|
-
// Clean up object
|
|
60
|
-
for (const [key, value] of Object.entries(capabilities)) {
|
|
61
|
-
if (value === undefined) {
|
|
62
|
-
delete capabilities[key];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return capabilities;
|
|
66
|
-
}
|
|
67
|
-
/** Extract typed request metadata from XML requests field */
|
|
68
|
-
function extractRequests(xmlRequests) {
|
|
69
|
-
const requests = {};
|
|
70
|
-
for (const [name, xmlRequest] of Object.entries(xmlRequests || {})) {
|
|
71
|
-
const mimeTypes = (0, parse_xml_helpers_1.getXMLStringArray)(xmlRequest?.Format);
|
|
72
|
-
requests[name] = { mimeTypes };
|
|
73
|
-
}
|
|
74
|
-
return requests;
|
|
75
|
-
}
|
|
76
|
-
function extractExceptions(xmlException) {
|
|
77
|
-
const xmlExceptionFormats = (0, parse_xml_helpers_1.getXMLArray)(xmlException?.Format);
|
|
78
|
-
if (xmlExceptionFormats.length > 0) {
|
|
79
|
-
return {
|
|
80
|
-
mimeTypes: (0, parse_xml_helpers_1.getXMLStringArray)(xmlException)
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
/** Extract request data */
|
|
86
|
-
// eslint-disable-next-line complexity, max-statements
|
|
87
|
-
function extractLayer(xmlLayer) {
|
|
88
|
-
const layer = {
|
|
89
|
-
// All layers must have a title
|
|
90
|
-
title: String(xmlLayer?.Title || ''),
|
|
91
|
-
// Name is required only if renderable
|
|
92
|
-
name: xmlLayer?.Name && String(xmlLayer?.Name),
|
|
93
|
-
abstract: xmlLayer?.Name && String(xmlLayer?.Abstract),
|
|
94
|
-
keywords: (0, parse_xml_helpers_1.getXMLStringArray)(xmlLayer.KeywordList?.Keyword)
|
|
95
|
-
};
|
|
96
|
-
// WMS 1.3.0 changes SRS to CRS
|
|
97
|
-
const crs = xmlLayer?.CRS || xmlLayer?.SRS;
|
|
98
|
-
if (crs && Array.isArray(crs) && crs.every((_) => typeof _ === 'string')) {
|
|
99
|
-
layer.crs = crs;
|
|
100
|
-
}
|
|
101
|
-
// v1.3.0 extract simple geographic bounding box
|
|
102
|
-
let geographicBoundingBox = xmlLayer?.EX_GeographicBoundingBox && extractEXBoundingBox(xmlLayer?.EX_GeographicBoundingBox);
|
|
103
|
-
if (geographicBoundingBox) {
|
|
104
|
-
layer.geographicBoundingBox = geographicBoundingBox;
|
|
105
|
-
}
|
|
106
|
-
// v1.1.1 extract simple geographic bounding box
|
|
107
|
-
geographicBoundingBox =
|
|
108
|
-
xmlLayer?.LatLonBoundingBox && extractLatLonBoundingBox(xmlLayer?.LatLonBoundingBox);
|
|
109
|
-
if (geographicBoundingBox) {
|
|
110
|
-
layer.geographicBoundingBox = geographicBoundingBox;
|
|
111
|
-
}
|
|
112
|
-
// Extract per-CRS bounding boxes
|
|
113
|
-
const boundingBoxes = xmlLayer?.BoundingBox && extractWMSBoundingBoxes(xmlLayer?.BoundingBox);
|
|
114
|
-
if (boundingBoxes && boundingBoxes.length > 0) {
|
|
115
|
-
layer.boundingBoxes = boundingBoxes;
|
|
116
|
-
}
|
|
117
|
-
// Extract dimensions
|
|
118
|
-
const xmlDimensions = (0, parse_xml_helpers_1.getXMLArray)(xmlLayer?.Dimension);
|
|
119
|
-
const dimensions = xmlDimensions.map((xml) => extractDimension(xml));
|
|
120
|
-
if (dimensions.length) {
|
|
121
|
-
layer.dimensions = dimensions;
|
|
122
|
-
}
|
|
123
|
-
if (xmlLayer?.opaque) {
|
|
124
|
-
layer.opaque = (0, parse_xml_helpers_1.getXMLBoolean)(xmlLayer?.opaque);
|
|
125
|
-
}
|
|
126
|
-
if (xmlLayer?.cascaded) {
|
|
127
|
-
layer.cascaded = (0, parse_xml_helpers_1.getXMLBoolean)(xmlLayer?.cascaded);
|
|
128
|
-
}
|
|
129
|
-
if (xmlLayer?.queryable) {
|
|
130
|
-
layer.queryable = (0, parse_xml_helpers_1.getXMLBoolean)(xmlLayer?.queryable);
|
|
131
|
-
}
|
|
132
|
-
// Single layer is not represented as array in XML
|
|
133
|
-
const xmlLayers = (0, parse_xml_helpers_1.getXMLArray)(xmlLayer?.Layer);
|
|
134
|
-
const layers = [];
|
|
135
|
-
for (const xmlSubLayer of xmlLayers) {
|
|
136
|
-
layers.push(extractLayer(xmlSubLayer));
|
|
137
|
-
}
|
|
138
|
-
if (layers.length > 0) {
|
|
139
|
-
layer.layers = layers;
|
|
140
|
-
}
|
|
141
|
-
// Clean up object
|
|
142
|
-
for (const [key, value] of Object.entries(layer)) {
|
|
143
|
-
if (value === undefined) {
|
|
144
|
-
delete layer[key];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return layer;
|
|
148
|
-
}
|
|
149
|
-
/** WMS 1.3.0 Loosely defined geospatial bounding box in unspecified CRS for quick content searches */
|
|
150
|
-
function extractEXBoundingBox(xmlBoundingBox) {
|
|
151
|
-
const { westBoundLongitude: w, northBoundLatitude: n, eastBoundLongitude: e, southBoundLatitude: s } = xmlBoundingBox;
|
|
152
|
-
return [
|
|
153
|
-
[w, s],
|
|
154
|
-
[e, n]
|
|
155
|
-
];
|
|
156
|
-
}
|
|
157
|
-
/** WMS 1.1.1 Loosely defined geospatial bounding box in unspecified CRS for quick content searches */
|
|
158
|
-
function extractLatLonBoundingBox(xmlBoundingBox) {
|
|
159
|
-
const { minx, miny, maxx, maxy } = xmlBoundingBox;
|
|
160
|
-
return [
|
|
161
|
-
[minx, miny],
|
|
162
|
-
[maxx, maxy]
|
|
163
|
-
];
|
|
164
|
-
}
|
|
165
|
-
/** Loosely defined geospatial bounding box in unspecified CRS for quick content searches */
|
|
166
|
-
function extractWMSBoundingBoxes(xmlBoundingBoxes) {
|
|
167
|
-
const xmlBoxes = (0, parse_xml_helpers_1.getXMLArray)(xmlBoundingBoxes);
|
|
168
|
-
return xmlBoxes.map((xmlBox) => extractWMSBoundingBox(xmlBox));
|
|
169
|
-
}
|
|
170
|
-
/** Loosely defined geospatial bounding box in unspecified CRS for quick content searches */
|
|
171
|
-
function extractWMSBoundingBox(xmlBoundingBox) {
|
|
172
|
-
const { CRS, SRS, minx, miny, maxx, maxy, resx, resy } = xmlBoundingBox;
|
|
173
|
-
const boundingBox = {
|
|
174
|
-
// CRS in 1.3.0, SRS in 1.1.1
|
|
175
|
-
crs: CRS || SRS,
|
|
176
|
-
boundingBox: [
|
|
177
|
-
[(0, parse_xml_helpers_1.getXMLFloat)(minx), (0, parse_xml_helpers_1.getXMLFloat)(miny)],
|
|
178
|
-
[(0, parse_xml_helpers_1.getXMLFloat)(maxx), (0, parse_xml_helpers_1.getXMLFloat)(maxy)]
|
|
179
|
-
]
|
|
180
|
-
};
|
|
181
|
-
if (resx) {
|
|
182
|
-
boundingBox.xResolution = resx;
|
|
183
|
-
}
|
|
184
|
-
if (resy) {
|
|
185
|
-
boundingBox.yResolution = resy;
|
|
186
|
-
}
|
|
187
|
-
return boundingBox;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Extracts optional WMS Dimension layer field
|
|
191
|
-
* @param xmlDimension
|
|
192
|
-
* @example <Dimension name="time" units="ISO8601" default="2018-01-01" nearestValue="0">2001-01-01/2018-01-01/P1Y</Dimension>
|
|
193
|
-
* @see https://mapserver.org/ogc/wms_dimension.html
|
|
194
|
-
*/
|
|
195
|
-
function extractDimension(xmlDimension) {
|
|
196
|
-
const { name, units, value: extent } = xmlDimension;
|
|
197
|
-
const dimension = { name, units, extent };
|
|
198
|
-
if (xmlDimension.unitSymbol) {
|
|
199
|
-
dimension.unitSymbol = xmlDimension.unitSymbol;
|
|
200
|
-
}
|
|
201
|
-
if (xmlDimension.default) {
|
|
202
|
-
dimension.defaultValue = xmlDimension.default;
|
|
203
|
-
}
|
|
204
|
-
if (xmlDimension.multipleValues) {
|
|
205
|
-
dimension.multipleValues = (0, parse_xml_helpers_1.getXMLBoolean)(xmlDimension.multipleValues);
|
|
206
|
-
}
|
|
207
|
-
if (xmlDimension.nearestValue) {
|
|
208
|
-
dimension.nearestValue = (0, parse_xml_helpers_1.getXMLBoolean)(xmlDimension.nearestValue);
|
|
209
|
-
}
|
|
210
|
-
if (xmlDimension.current) {
|
|
211
|
-
dimension.current = (0, parse_xml_helpers_1.getXMLBoolean)(xmlDimension.current);
|
|
212
|
-
}
|
|
213
|
-
return dimension;
|
|
214
|
-
}
|
|
215
|
-
/** Traverse layers and inject missing props from parents */
|
|
216
|
-
// eslint-disable-next-line complexity
|
|
217
|
-
function addInheritedLayerProps(layer, parent) {
|
|
218
|
-
if (parent?.geographicBoundingBox && !layer.geographicBoundingBox) {
|
|
219
|
-
layer.geographicBoundingBox = [...parent.geographicBoundingBox];
|
|
220
|
-
}
|
|
221
|
-
if (parent?.crs && !layer.crs) {
|
|
222
|
-
layer.crs = [...parent.crs];
|
|
223
|
-
}
|
|
224
|
-
if (parent?.boundingBoxes && !layer.boundingBoxes) {
|
|
225
|
-
layer.boundingBoxes = [...parent.boundingBoxes];
|
|
226
|
-
}
|
|
227
|
-
if (parent?.dimensions && !layer.dimensions) {
|
|
228
|
-
layer.dimensions = [...parent.dimensions];
|
|
229
|
-
}
|
|
230
|
-
for (const subLayer of layer.layers || []) {
|
|
231
|
-
addInheritedLayerProps(subLayer, layer);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.parseWMSError = void 0;
|
|
5
|
-
const xml_1 = require("@loaders.gl/xml");
|
|
6
|
-
/**
|
|
7
|
-
* Extract an error message from WMS error response XML
|
|
8
|
-
* @param text
|
|
9
|
-
* @param options
|
|
10
|
-
* @returns a string with a human readable message
|
|
11
|
-
*/
|
|
12
|
-
function parseWMSError(text, options) {
|
|
13
|
-
const parsedXML = xml_1.XMLLoader.parseTextSync?.(text, options);
|
|
14
|
-
const serviceExceptionXML = parsedXML?.ServiceExceptionReport?.ServiceException ||
|
|
15
|
-
parsedXML?.['ogc:ServiceExceptionReport']?.['ogc:ServiceException'];
|
|
16
|
-
// Sigh, can be either a string or an object
|
|
17
|
-
const message = typeof serviceExceptionXML === 'string'
|
|
18
|
-
? serviceExceptionXML
|
|
19
|
-
: serviceExceptionXML.value || serviceExceptionXML.code || 'Unknown error';
|
|
20
|
-
return message;
|
|
21
|
-
}
|
|
22
|
-
exports.parseWMSError = parseWMSError;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.parseWMSFeatureInfo = void 0;
|
|
5
|
-
const xml_1 = require("@loaders.gl/xml");
|
|
6
|
-
/**
|
|
7
|
-
* Parses a typed data structure from raw XML for `GetFeatureInfo` response
|
|
8
|
-
* @note Error handlings is fairly weak
|
|
9
|
-
*/
|
|
10
|
-
function parseWMSFeatureInfo(text, options) {
|
|
11
|
-
const parsedXML = xml_1.XMLLoader.parseTextSync?.(text, options);
|
|
12
|
-
const xmlFeatureInfo = parsedXML.FeatureInfoResponse?.FIELDS || [];
|
|
13
|
-
const xmlFeatures = Array.isArray(xmlFeatureInfo) ? xmlFeatureInfo : [xmlFeatureInfo];
|
|
14
|
-
return {
|
|
15
|
-
features: xmlFeatures.map((xmlFeature) => extractFeature(xmlFeature))
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.parseWMSFeatureInfo = parseWMSFeatureInfo;
|
|
19
|
-
function extractFeature(xmlFeature) {
|
|
20
|
-
const xmlFields = xmlFeature || {};
|
|
21
|
-
// TODO - not correct
|
|
22
|
-
return {
|
|
23
|
-
attributes: xmlFields,
|
|
24
|
-
type: '',
|
|
25
|
-
bounds: { bottom: 0, top: 0, left: 0, right: 0 }
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.parseWMSLayerDescription = void 0;
|
|
5
|
-
const xml_1 = require("@loaders.gl/xml");
|
|
6
|
-
/**
|
|
7
|
-
* Parses a typed data structure from raw XML for `GetFeatureInfo` response
|
|
8
|
-
* @note Error handlings is fairly weak
|
|
9
|
-
*/
|
|
10
|
-
function parseWMSLayerDescription(text, options) {
|
|
11
|
-
const parsedXML = xml_1.XMLLoader.parseTextSync?.(text, options);
|
|
12
|
-
// TODO - implement parser
|
|
13
|
-
return parsedXML;
|
|
14
|
-
}
|
|
15
|
-
exports.parseWMSLayerDescription = parseWMSLayerDescription;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getXMLBoolean = exports.getXMLInteger = exports.getXMLFloat = exports.getXMLStringArray = exports.getXMLArray = void 0;
|
|
5
|
-
/** A single element of an array is not represented as an array in XML */
|
|
6
|
-
function getXMLArray(xmlValue) {
|
|
7
|
-
// Already an array, return as is
|
|
8
|
-
if (Array.isArray(xmlValue)) {
|
|
9
|
-
return xmlValue;
|
|
10
|
-
}
|
|
11
|
-
// Single value, wrap in array
|
|
12
|
-
if (xmlValue) {
|
|
13
|
-
return [xmlValue];
|
|
14
|
-
}
|
|
15
|
-
// nullish, return empty array
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
exports.getXMLArray = getXMLArray;
|
|
19
|
-
/** Get a list of strings from XML */
|
|
20
|
-
function getXMLStringArray(xmlValue) {
|
|
21
|
-
const xmlArray = getXMLArray(xmlValue);
|
|
22
|
-
if (xmlArray.length > 0 && xmlArray.every((_) => typeof _ === 'string')) {
|
|
23
|
-
return xmlArray;
|
|
24
|
-
}
|
|
25
|
-
// TODO - error handling?
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
exports.getXMLStringArray = getXMLStringArray;
|
|
29
|
-
/** Get XML float */
|
|
30
|
-
function getXMLFloat(xmlValue, defaultValue = undefined) {
|
|
31
|
-
switch (typeof xmlValue) {
|
|
32
|
-
case 'number':
|
|
33
|
-
return xmlValue;
|
|
34
|
-
case 'string':
|
|
35
|
-
return parseFloat(xmlValue);
|
|
36
|
-
default:
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.getXMLFloat = getXMLFloat;
|
|
41
|
-
/** Get XML integer */
|
|
42
|
-
function getXMLInteger(xmlValue, defaultValue = undefined) {
|
|
43
|
-
switch (typeof xmlValue) {
|
|
44
|
-
case 'number':
|
|
45
|
-
return xmlValue;
|
|
46
|
-
case 'string':
|
|
47
|
-
return parseInt(xmlValue, 10);
|
|
48
|
-
default:
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.getXMLInteger = getXMLInteger;
|
|
53
|
-
/** Somewhat arbitrary boolean parsing */
|
|
54
|
-
function getXMLBoolean(xmlValue) {
|
|
55
|
-
switch (xmlValue) {
|
|
56
|
-
case 'true':
|
|
57
|
-
return true;
|
|
58
|
-
case 'false':
|
|
59
|
-
return false;
|
|
60
|
-
case '1':
|
|
61
|
-
return true;
|
|
62
|
-
case '0':
|
|
63
|
-
return false;
|
|
64
|
-
default:
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.getXMLBoolean = getXMLBoolean;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ArcGISImageServer = void 0;
|
|
5
|
-
const image_source_1 = require("../../sources/image-source");
|
|
6
|
-
/**
|
|
7
|
-
* ArcGIS ImageServer
|
|
8
|
-
* Note - exports a big API, that could be exposed here if there is a use case
|
|
9
|
-
* @see https://developers.arcgis.com/rest/services-reference/enterprise/image-service.htm
|
|
10
|
-
*/
|
|
11
|
-
class ArcGISImageServer extends image_source_1.ImageSource {
|
|
12
|
-
constructor(props) {
|
|
13
|
-
super(props);
|
|
14
|
-
}
|
|
15
|
-
// ImageSource (normalized endpoints)
|
|
16
|
-
async getMetadata() {
|
|
17
|
-
return (await this.metadata());
|
|
18
|
-
// TODO - normalize metadata
|
|
19
|
-
}
|
|
20
|
-
async getImage(parameters) {
|
|
21
|
-
throw new Error('not implemented');
|
|
22
|
-
// TODO - Map generic parameters to ArcGIS specific parameters
|
|
23
|
-
// return await this.exportImage(parameters);
|
|
24
|
-
}
|
|
25
|
-
// ImageServer endpoints
|
|
26
|
-
async metadata() {
|
|
27
|
-
// We just need a JSON parsing...
|
|
28
|
-
// return this.getUrl({path: '', ...options});
|
|
29
|
-
throw new Error('not implemented');
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Form a URL to an ESRI ImageServer
|
|
33
|
-
// https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer/exportImage?bbox=${bounds[0]},${bounds[1]},${bounds[2]},${bounds[3]}&bboxSR=4326&size=${width},${height}&imageSR=102100&time=&format=jpgpng&pixelType=U8&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_NearestNeighbor&compression=&compressionQuality=&bandIds=&mosaicRule=&renderingRule=&f=image`,
|
|
34
|
-
*/
|
|
35
|
-
exportImage(options) {
|
|
36
|
-
// See WMSService.getMap()
|
|
37
|
-
throw new Error('not implemented');
|
|
38
|
-
}
|
|
39
|
-
// URL creators
|
|
40
|
-
metadataURL(options) {
|
|
41
|
-
return `${this.props.url}?f=pjson`;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Form a URL to an ESRI ImageServer
|
|
45
|
-
// https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer/exportImage?
|
|
46
|
-
// bbox=${bounds[0]},${bounds[1]},${bounds[2]},${bounds[3]}&bboxSR=4326&
|
|
47
|
-
// size=${width},${height}&imageSR=102100&time=&format=jpgpng&pixelType=U8&
|
|
48
|
-
// noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_NearestNeighbor&compression=&
|
|
49
|
-
// compressionQuality=&bandIds=&mosaicRule=&renderingRule=&
|
|
50
|
-
// f=image
|
|
51
|
-
*/
|
|
52
|
-
exportImageURL(options) {
|
|
53
|
-
const bbox = `bbox=${options.bbox[0]},${options.bbox[1]},${options.bbox[2]},${options.bbox[3]}`;
|
|
54
|
-
const size = `size=${options.width},${options.height}`;
|
|
55
|
-
const arcgisOptions = { ...options, bbox, size };
|
|
56
|
-
// @ts-expect-error
|
|
57
|
-
delete arcgisOptions.width;
|
|
58
|
-
// @ts-expect-error
|
|
59
|
-
delete arcgisOptions.height;
|
|
60
|
-
return this.getUrl('exportImage', arcgisOptions);
|
|
61
|
-
}
|
|
62
|
-
// INTERNAL METHODS
|
|
63
|
-
/**
|
|
64
|
-
* @note protected, since perhaps getWMSUrl may need to be overridden to handle certain backends?
|
|
65
|
-
* @note if override is common, maybe add a callback prop?
|
|
66
|
-
* */
|
|
67
|
-
getUrl(path, options, extra) {
|
|
68
|
-
let url = `${this.props.url}/${path}`;
|
|
69
|
-
let first = true;
|
|
70
|
-
for (const [key, value] of Object.entries(options)) {
|
|
71
|
-
url += first ? '?' : '&';
|
|
72
|
-
first = false;
|
|
73
|
-
if (Array.isArray(value)) {
|
|
74
|
-
url += `${key.toUpperCase()}=${value.join(',')}`;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
url += `${key.toUpperCase()}=${value ? String(value) : ''}`;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return url;
|
|
81
|
-
}
|
|
82
|
-
/** Checks for and parses a WMS XML formatted ServiceError and throws an exception */
|
|
83
|
-
async checkResponse(response) {
|
|
84
|
-
if (!response.ok) {
|
|
85
|
-
// } || response.headers['content-type'] === WMSErrorLoader.mimeTypes[0]) {
|
|
86
|
-
// const arrayBuffer = await response.arrayBuffer();
|
|
87
|
-
// const error = await WMSErrorLoader.parse(arrayBuffer, this.loadOptions);
|
|
88
|
-
throw new Error('error');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.ArcGISImageServer = ArcGISImageServer;
|
|
93
|
-
ArcGISImageServer.type = 'arcgis-image-server';
|
|
94
|
-
ArcGISImageServer.testURL = (url) => url.toLowerCase().includes('ImageServer');
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getArcGISServices = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* (Recursively) load the service directory from an ArcGIS Server URL
|
|
7
|
-
* @param url
|
|
8
|
-
* @param fetchFile= Optional fetch function override
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
async function getArcGISServices(url, fetchFile = fetch) {
|
|
12
|
-
if (url.includes('rest/services')) {
|
|
13
|
-
const serverUrl = url.replace(/rest\/services.*$/i, 'rest/services');
|
|
14
|
-
return loadServiceDirectory(serverUrl, fetchFile, []);
|
|
15
|
-
}
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
exports.getArcGISServices = getArcGISServices;
|
|
19
|
-
async function loadServiceDirectory(serverUrl, fetch, path) {
|
|
20
|
-
const serviceUrl = `${serverUrl}/${path.join('/')}`;
|
|
21
|
-
const response = await fetch(`${serviceUrl}?f=pjson`);
|
|
22
|
-
const directory = await response.json();
|
|
23
|
-
const services = extractServices(directory, serviceUrl);
|
|
24
|
-
const folders = (directory.folders || []);
|
|
25
|
-
const promises = folders.map((folder) => loadServiceDirectory(`${serverUrl}`, fetch, [...path, folder]));
|
|
26
|
-
for (const folderServices of await Promise.all(promises)) {
|
|
27
|
-
services.push(...folderServices);
|
|
28
|
-
}
|
|
29
|
-
return services;
|
|
30
|
-
}
|
|
31
|
-
function extractServices(directory, url) {
|
|
32
|
-
const arcgisServices = (directory.services || []);
|
|
33
|
-
const services = [];
|
|
34
|
-
for (const service of arcgisServices) {
|
|
35
|
-
services.push({
|
|
36
|
-
name: service.name,
|
|
37
|
-
type: `arcgis-${service.type.toLocaleLowerCase().replace('server', '-server')}`,
|
|
38
|
-
url: `${url}${service.name}/${service.type}`
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return services;
|
|
42
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ImageService = void 0;
|
|
5
|
-
const images_1 = require("@loaders.gl/images");
|
|
6
|
-
const image_source_1 = require("../../sources/image-source");
|
|
7
|
-
/**
|
|
8
|
-
* Quickly connect to "ad hoc" image sources without subclassing ImageSource.
|
|
9
|
-
* ImageSource allows template url strings to be used to ad hoc connect to arbitrary image data sources
|
|
10
|
-
* Accepts a template url string and builds requests URLs
|
|
11
|
-
*/
|
|
12
|
-
class ImageService extends image_source_1.ImageSource {
|
|
13
|
-
constructor(props) {
|
|
14
|
-
super(props);
|
|
15
|
-
}
|
|
16
|
-
// IMAGE SOURCE API
|
|
17
|
-
async getMetadata() {
|
|
18
|
-
throw new Error('ImageSource.getMetadata not implemented');
|
|
19
|
-
}
|
|
20
|
-
async getImage(parameters) {
|
|
21
|
-
const granularParameters = this.getGranularParameters(parameters);
|
|
22
|
-
const url = this.getURLFromTemplate(granularParameters);
|
|
23
|
-
const response = await this.fetch(url);
|
|
24
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
25
|
-
return await images_1.ImageLoader.parse(arrayBuffer);
|
|
26
|
-
}
|
|
27
|
-
// HELPERS
|
|
28
|
-
/** Break up bounding box in east, north, south, west */
|
|
29
|
-
getGranularParameters(parameters) {
|
|
30
|
-
const [east, north, west, south] = parameters.bbox;
|
|
31
|
-
return { ...parameters, east, north, south, west };
|
|
32
|
-
}
|
|
33
|
-
/** Supports both ${} and {} notations */
|
|
34
|
-
getURLFromTemplate(parameters) {
|
|
35
|
-
let url = this.props.url;
|
|
36
|
-
for (const [key, value] of Object.entries(parameters)) {
|
|
37
|
-
// TODO - parameter could be repeated
|
|
38
|
-
// const regex = new RegExp(`\${${key}}`, 'g');
|
|
39
|
-
url = url.replace(`\${${key}}`, String(value));
|
|
40
|
-
url = url.replace(`{${key}}`, String(value));
|
|
41
|
-
}
|
|
42
|
-
return url;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.ImageService = ImageService;
|
|
46
|
-
ImageService.type = 'template';
|
|
47
|
-
ImageService.testURL = (url) => url.toLowerCase().includes('{');
|