@loaders.gl/wms 4.0.0-alpha.23 → 4.0.0-alpha.24
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/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,371 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.parseMultiSurface = exports.parseCompositeSurface = exports.parseSurface = exports.parsePolygonOrRectangle = exports.parseExteriorOrInterior = exports.parseRing = exports.parseCurveSegments = exports.parseLinearRingOrLineString = exports.parsePoint = exports.parsePos = exports.parsePosList = exports.parseGMLToGeometry = exports.parseGML = void 0;
|
|
8
|
-
const xml_1 = require("@loaders.gl/xml");
|
|
9
|
-
const deep_strict_equal_1 = require("./deep-strict-equal");
|
|
10
|
-
const rewind_1 = __importDefault(require("@turf/rewind"));
|
|
11
|
-
function noTransform(...coords) {
|
|
12
|
-
return coords;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Parses a typed data structure from raw XML for GML features
|
|
16
|
-
* @note Error handlings is fairly weak
|
|
17
|
-
*/
|
|
18
|
-
function parseGML(text, options) {
|
|
19
|
-
// GeoJSON | null {
|
|
20
|
-
const parsedXML = xml_1.XMLLoader.parseTextSync?.(text, options);
|
|
21
|
-
options = { transformCoords: noTransform, stride: 2, ...options };
|
|
22
|
-
const context = createChildContext(parsedXML, options, {});
|
|
23
|
-
return parseGMLToGeometry(parsedXML, options, context);
|
|
24
|
-
}
|
|
25
|
-
exports.parseGML = parseGML;
|
|
26
|
-
/** Parse a GeoJSON geometry from GML XML */
|
|
27
|
-
function parseGMLToGeometry(inputXML, options, context) {
|
|
28
|
-
const childContext = createChildContext(inputXML, options, context);
|
|
29
|
-
let geometry = null;
|
|
30
|
-
const [name, xml] = getFirstKeyValue(inputXML);
|
|
31
|
-
switch (name) {
|
|
32
|
-
// case 'gml:MultiPoint':
|
|
33
|
-
// geometry = {
|
|
34
|
-
// type: 'MultiPoint',
|
|
35
|
-
// coordinates: parseMultiPoint(xml, options, childContext)
|
|
36
|
-
// };
|
|
37
|
-
// break;
|
|
38
|
-
case 'gml:LineString':
|
|
39
|
-
geometry = {
|
|
40
|
-
type: 'LineString',
|
|
41
|
-
coordinates: parseLinearRingOrLineString(xml, options, childContext)
|
|
42
|
-
};
|
|
43
|
-
break;
|
|
44
|
-
// case 'gml:MultiLineString':
|
|
45
|
-
// geometry = {
|
|
46
|
-
// type: 'MultiLineString',
|
|
47
|
-
// coordinates: parseMultiLineString(xml, options, childContext)
|
|
48
|
-
// };
|
|
49
|
-
// break;
|
|
50
|
-
case 'gml:Polygon':
|
|
51
|
-
case 'gml:Rectangle':
|
|
52
|
-
geometry = {
|
|
53
|
-
type: 'Polygon',
|
|
54
|
-
coordinates: parsePolygonOrRectangle(xml, options, childContext)
|
|
55
|
-
};
|
|
56
|
-
break;
|
|
57
|
-
case 'gml:Surface':
|
|
58
|
-
geometry = {
|
|
59
|
-
type: 'MultiPolygon',
|
|
60
|
-
coordinates: parseSurface(xml, options, childContext)
|
|
61
|
-
};
|
|
62
|
-
break;
|
|
63
|
-
case 'gml:MultiSurface':
|
|
64
|
-
geometry = {
|
|
65
|
-
type: 'MultiPolygon',
|
|
66
|
-
coordinates: parseMultiSurface(xml, options, childContext)
|
|
67
|
-
};
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
// todo
|
|
73
|
-
return (0, rewind_1.default)(geometry, { mutate: true });
|
|
74
|
-
}
|
|
75
|
-
exports.parseGMLToGeometry = parseGMLToGeometry;
|
|
76
|
-
/** Parse a list of coordinates from a string */
|
|
77
|
-
function parseCoords(s, options, context) {
|
|
78
|
-
const stride = context.srsDimension || options.stride || 2;
|
|
79
|
-
// Handle white space
|
|
80
|
-
const coords = s.replace(/\s+/g, ' ').trim().split(' ');
|
|
81
|
-
if (coords.length === 0 || coords.length % stride !== 0) {
|
|
82
|
-
throw new Error(`invalid coordinates list (stride ${stride})`);
|
|
83
|
-
}
|
|
84
|
-
const points = [];
|
|
85
|
-
for (let i = 0; i < coords.length - 1; i += stride) {
|
|
86
|
-
const point = coords.slice(i, i + stride).map(parseFloat);
|
|
87
|
-
points.push(options.transformCoords?.(...point) || point);
|
|
88
|
-
}
|
|
89
|
-
return points;
|
|
90
|
-
}
|
|
91
|
-
function parsePosList(xml, options, context) {
|
|
92
|
-
const childContext = createChildContext(xml, options, context);
|
|
93
|
-
const coords = textOf(xml);
|
|
94
|
-
if (!coords) {
|
|
95
|
-
throw new Error('invalid gml:posList element');
|
|
96
|
-
}
|
|
97
|
-
return parseCoords(coords, options, childContext);
|
|
98
|
-
}
|
|
99
|
-
exports.parsePosList = parsePosList;
|
|
100
|
-
function parsePos(xml, options, context) {
|
|
101
|
-
const childContext = createChildContext(xml, options, context);
|
|
102
|
-
const coords = textOf(xml);
|
|
103
|
-
if (!coords) {
|
|
104
|
-
throw new Error('invalid gml:pos element');
|
|
105
|
-
}
|
|
106
|
-
const points = parseCoords(coords, options, childContext);
|
|
107
|
-
if (points.length !== 1) {
|
|
108
|
-
throw new Error('gml:pos must have 1 point');
|
|
109
|
-
}
|
|
110
|
-
return points[0];
|
|
111
|
-
}
|
|
112
|
-
exports.parsePos = parsePos;
|
|
113
|
-
function parsePoint(xml, options, context) {
|
|
114
|
-
const childContext = createChildContext(xml, options, context);
|
|
115
|
-
// TODO AV: Parse other gml:Point options
|
|
116
|
-
const pos = findIn(xml, 'gml:pos');
|
|
117
|
-
if (!pos) {
|
|
118
|
-
throw new Error('invalid gml:Point element, expected a gml:pos subelement');
|
|
119
|
-
}
|
|
120
|
-
return parsePos(pos, options, childContext);
|
|
121
|
-
}
|
|
122
|
-
exports.parsePoint = parsePoint;
|
|
123
|
-
function parseLinearRingOrLineString(xml, options, context) {
|
|
124
|
-
// or a LineStringSegment
|
|
125
|
-
const childContext = createChildContext(xml, options, context);
|
|
126
|
-
let points = [];
|
|
127
|
-
const posList = findIn(xml, 'gml:posList');
|
|
128
|
-
if (posList) {
|
|
129
|
-
points = parsePosList(posList, options, childContext);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
for (const [childName, childXML] of Object.entries(xml)) {
|
|
133
|
-
switch (childName) {
|
|
134
|
-
case 'gml:Point':
|
|
135
|
-
points.push(parsePoint(childXML, options, childContext));
|
|
136
|
-
break;
|
|
137
|
-
case 'gml:pos':
|
|
138
|
-
points.push(parsePos(childXML, options, childContext));
|
|
139
|
-
break;
|
|
140
|
-
default:
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
if (points.length === 0) {
|
|
146
|
-
throw new Error(`${xml.name} must have > 0 points`);
|
|
147
|
-
}
|
|
148
|
-
return points;
|
|
149
|
-
}
|
|
150
|
-
exports.parseLinearRingOrLineString = parseLinearRingOrLineString;
|
|
151
|
-
function parseCurveSegments(xml, options, context) {
|
|
152
|
-
const points = [];
|
|
153
|
-
for (const [childName, childXML] of Object.entries(xml)) {
|
|
154
|
-
switch (childName) {
|
|
155
|
-
case 'gml:LineStringSegment':
|
|
156
|
-
const points2 = parseLinearRingOrLineString(childXML, options, context);
|
|
157
|
-
// remove overlapping
|
|
158
|
-
const end = points[points.length - 1];
|
|
159
|
-
const start = points2[0];
|
|
160
|
-
if (end && start && (0, deep_strict_equal_1.deepStrictEqual)(end, start)) {
|
|
161
|
-
points2.shift();
|
|
162
|
-
}
|
|
163
|
-
points.push(...points2);
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (points.length === 0) {
|
|
170
|
-
throw new Error('gml:Curve > gml:segments must have > 0 points');
|
|
171
|
-
}
|
|
172
|
-
return points;
|
|
173
|
-
}
|
|
174
|
-
exports.parseCurveSegments = parseCurveSegments;
|
|
175
|
-
function parseRing(xml, options, context) {
|
|
176
|
-
const childContext = createChildContext(xml, options, context);
|
|
177
|
-
const points = [];
|
|
178
|
-
for (const [childName, childXML] of Object.entries(xml)) {
|
|
179
|
-
switch (childName) {
|
|
180
|
-
case 'gml:curveMember':
|
|
181
|
-
let points2;
|
|
182
|
-
const lineString = findIn(childXML, 'gml:LineString');
|
|
183
|
-
if (lineString) {
|
|
184
|
-
points2 = parseLinearRingOrLineString(lineString, options, childContext);
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
const segments = findIn(childXML, 'gml:Curve', 'gml:segments');
|
|
188
|
-
if (!segments) {
|
|
189
|
-
throw new Error(`invalid ${childName} element`);
|
|
190
|
-
}
|
|
191
|
-
points2 = parseCurveSegments(segments, options, childContext);
|
|
192
|
-
}
|
|
193
|
-
// remove overlapping
|
|
194
|
-
const end = points[points.length - 1];
|
|
195
|
-
const start = points2[0];
|
|
196
|
-
if (end && start && (0, deep_strict_equal_1.deepStrictEqual)(end, start)) {
|
|
197
|
-
points2.shift();
|
|
198
|
-
}
|
|
199
|
-
points.push(...points2);
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (points.length < 4) {
|
|
204
|
-
throw new Error(`${xml.name} must have >= 4 points`);
|
|
205
|
-
}
|
|
206
|
-
return points;
|
|
207
|
-
}
|
|
208
|
-
exports.parseRing = parseRing;
|
|
209
|
-
function parseExteriorOrInterior(xml, options, context) {
|
|
210
|
-
const linearRing = findIn(xml, 'gml:LinearRing');
|
|
211
|
-
if (linearRing) {
|
|
212
|
-
return parseLinearRingOrLineString(linearRing, options, context);
|
|
213
|
-
}
|
|
214
|
-
const ring = findIn(xml, 'gml:Ring');
|
|
215
|
-
if (!ring) {
|
|
216
|
-
throw new Error(`invalid ${xml.name} element`);
|
|
217
|
-
}
|
|
218
|
-
return parseRing(ring, options, context);
|
|
219
|
-
}
|
|
220
|
-
exports.parseExteriorOrInterior = parseExteriorOrInterior;
|
|
221
|
-
function parsePolygonOrRectangle(xml, options, context) {
|
|
222
|
-
// or PolygonPatch
|
|
223
|
-
const childContext = createChildContext(xml, options, context);
|
|
224
|
-
const exterior = findIn(xml, 'gml:exterior');
|
|
225
|
-
if (!exterior) {
|
|
226
|
-
throw new Error(`invalid ${xml.name} element`);
|
|
227
|
-
}
|
|
228
|
-
const pointLists = [parseExteriorOrInterior(exterior, options, childContext)];
|
|
229
|
-
for (const [childName, childXML] of Object.entries(xml)) {
|
|
230
|
-
switch (childName) {
|
|
231
|
-
case 'gml:interior':
|
|
232
|
-
pointLists.push(parseExteriorOrInterior(childXML, options, childContext));
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return pointLists;
|
|
237
|
-
}
|
|
238
|
-
exports.parsePolygonOrRectangle = parsePolygonOrRectangle;
|
|
239
|
-
function parseSurface(xml, options, context) {
|
|
240
|
-
const childContext = createChildContext(xml, options, context);
|
|
241
|
-
const patches = findIn(xml, 'gml:patches');
|
|
242
|
-
if (!patches) {
|
|
243
|
-
throw new Error(`invalid ${xml.name} element`);
|
|
244
|
-
}
|
|
245
|
-
const polygons = [];
|
|
246
|
-
for (const [childName, childXML] of Object.entries(xml)) {
|
|
247
|
-
switch (childName) {
|
|
248
|
-
case 'gml:PolygonPatch':
|
|
249
|
-
case 'gml:Rectangle':
|
|
250
|
-
polygons.push(parsePolygonOrRectangle(childXML, options, childContext));
|
|
251
|
-
break;
|
|
252
|
-
default:
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
if (polygons.length === 0) {
|
|
257
|
-
throw new Error(`${xml.name} must have > 0 polygons`);
|
|
258
|
-
}
|
|
259
|
-
return polygons;
|
|
260
|
-
}
|
|
261
|
-
exports.parseSurface = parseSurface;
|
|
262
|
-
function parseCompositeSurface(xml, options, context) {
|
|
263
|
-
const childContext = createChildContext(xml, options, context);
|
|
264
|
-
const polygons = [];
|
|
265
|
-
for (const [childName, childXML] of Object.entries(xml)) {
|
|
266
|
-
switch (childName) {
|
|
267
|
-
case 'gml:surfaceMember':
|
|
268
|
-
case 'gml:surfaceMembers':
|
|
269
|
-
const [c2Name, c2Xml] = getFirstKeyValue(childXML);
|
|
270
|
-
switch (c2Name) {
|
|
271
|
-
case 'gml:Surface':
|
|
272
|
-
polygons.push(...parseSurface(c2Xml, options, childContext));
|
|
273
|
-
break;
|
|
274
|
-
case 'gml:Polygon':
|
|
275
|
-
polygons.push(parsePolygonOrRectangle(c2Xml, options, childContext));
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
if (polygons.length === 0) {
|
|
282
|
-
throw new Error(`${xml.name} must have > 0 polygons`);
|
|
283
|
-
}
|
|
284
|
-
return polygons;
|
|
285
|
-
}
|
|
286
|
-
exports.parseCompositeSurface = parseCompositeSurface;
|
|
287
|
-
function parseMultiSurface(xml, options, context) {
|
|
288
|
-
let el = xml;
|
|
289
|
-
const surfaceMembers = findIn(xml, 'gml:LinearRing');
|
|
290
|
-
if (surfaceMembers) {
|
|
291
|
-
el = surfaceMembers;
|
|
292
|
-
}
|
|
293
|
-
const polygons = [];
|
|
294
|
-
for (const [childName, childXML] of Object.entries(el)) {
|
|
295
|
-
switch (childName) {
|
|
296
|
-
case 'gml:Surface':
|
|
297
|
-
const polygons2 = parseSurface(childXML, options, context);
|
|
298
|
-
polygons.push(...polygons2);
|
|
299
|
-
break;
|
|
300
|
-
case 'gml:surfaceMember':
|
|
301
|
-
const polygons3 = parseSurfaceMember(childXML, options, context);
|
|
302
|
-
polygons.push(...polygons3);
|
|
303
|
-
break;
|
|
304
|
-
case 'gml:surfaceMembers':
|
|
305
|
-
const polygonXML = findIn(childXML, 'gml:Polygon');
|
|
306
|
-
for (const surfaceMemberXML of polygonXML) {
|
|
307
|
-
const polygons3 = parseSurfaceMember(surfaceMemberXML, options, context);
|
|
308
|
-
polygons.push(...polygons3);
|
|
309
|
-
}
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
if (polygons.length === 0) {
|
|
314
|
-
throw new Error(`${xml.name} must have > 0 polygons`);
|
|
315
|
-
}
|
|
316
|
-
return polygons;
|
|
317
|
-
}
|
|
318
|
-
exports.parseMultiSurface = parseMultiSurface;
|
|
319
|
-
function parseSurfaceMember(xml, options, context) {
|
|
320
|
-
const [childName, childXml] = getFirstKeyValue(xml);
|
|
321
|
-
switch (childName) {
|
|
322
|
-
case 'gml:CompositeSurface':
|
|
323
|
-
return parseCompositeSurface(childXml, options, context);
|
|
324
|
-
case 'gml:Surface':
|
|
325
|
-
return parseSurface(childXml, options, context);
|
|
326
|
-
case 'gml:Polygon':
|
|
327
|
-
return [parsePolygonOrRectangle(childXml, options, context)];
|
|
328
|
-
}
|
|
329
|
-
throw new Error(`${childName} must have polygons`);
|
|
330
|
-
}
|
|
331
|
-
// Helpers
|
|
332
|
-
function textOf(el) {
|
|
333
|
-
if (typeof el !== 'string') {
|
|
334
|
-
throw new Error('expected string');
|
|
335
|
-
}
|
|
336
|
-
return el;
|
|
337
|
-
}
|
|
338
|
-
function findIn(root, ...tags) {
|
|
339
|
-
let el = root;
|
|
340
|
-
for (const tag of tags) {
|
|
341
|
-
const child = el[tag];
|
|
342
|
-
if (!child) {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
el = child;
|
|
346
|
-
}
|
|
347
|
-
return el;
|
|
348
|
-
}
|
|
349
|
-
/** @returns the first [key, value] pair in an object, or ['', null] if empty object */
|
|
350
|
-
function getFirstKeyValue(object) {
|
|
351
|
-
if (object && typeof object === 'object') {
|
|
352
|
-
for (const [key, value] of Object.entries(object)) {
|
|
353
|
-
return [key, value];
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return ['', null];
|
|
357
|
-
}
|
|
358
|
-
/** A bit heavyweight for just tracking dimension? */
|
|
359
|
-
function createChildContext(xml, options, context) {
|
|
360
|
-
const srsDimensionAttribute = xml.attributes && xml.attributes.srsDimension;
|
|
361
|
-
if (srsDimensionAttribute) {
|
|
362
|
-
const srsDimension = parseInt(srsDimensionAttribute);
|
|
363
|
-
if (Number.isNaN(srsDimension) || srsDimension <= 0) {
|
|
364
|
-
throw new Error(`invalid srsDimension attribute value "${srsDimensionAttribute}", expected a positive integer`);
|
|
365
|
-
}
|
|
366
|
-
const childContext = Object.create(context);
|
|
367
|
-
childContext.srsDimension = srsDimension;
|
|
368
|
-
return childContext;
|
|
369
|
-
}
|
|
370
|
-
return context;
|
|
371
|
-
}
|
|
@@ -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;
|