ol 10.1.1-dev.1725805115669 → 10.1.1-dev.1725970564972

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.
@@ -1,4 +1,19 @@
1
1
  export default WMSCapabilities;
2
+ export type RootObject = {
3
+ /**
4
+ * Version
5
+ */
6
+ version: string;
7
+ /**
8
+ * Whether version is 1.3 or higher
9
+ */
10
+ v13: boolean;
11
+ };
12
+ /**
13
+ * @typedef {Object} RootObject
14
+ * @property {string} version Version
15
+ * @property {boolean} v13 Whether version is 1.3 or higher
16
+ */
2
17
  /**
3
18
  * @classdesc
4
19
  * Format for reading WMS capabilities data
@@ -1 +1 @@
1
- {"version":3,"file":"WMSCapabilities.d.ts","sourceRoot":"","sources":["WMSCapabilities.js"],"names":[],"mappings":";AAgDA;;;;;GAKG;AACH;IAII;;OAEG;IACH,SAFU,MAAM,GAAC,SAAS,CAEF;CAoB3B;gBA9Ee,UAAU"}
1
+ {"version":3,"file":"WMSCapabilities.d.ts","sourceRoot":"","sources":["WMSCapabilities.js"],"names":[],"mappings":";;;;;aAwEc,MAAM;;;;SACN,OAAO;;AAHrB;;;;GAIG;AAEH;;;;;GAKG;AACH;IAII;;OAEG;IACH,SAFU,MAAM,GAAC,SAAS,CAEF;CAoB3B;gBA1Ge,UAAU"}
@@ -2,6 +2,7 @@
2
2
  * @module ol/format/WMSCapabilities
3
3
  */
4
4
  import XML from './XML.js';
5
+ import {compareVersions} from '../string.js';
5
6
  import {
6
7
  makeArrayPusher,
7
8
  makeObjectPropertyPusher,
@@ -25,6 +26,10 @@ import {readHref} from './xlink.js';
25
26
  */
26
27
  const NAMESPACE_URIS = [null, 'http://www.opengis.net/wms'];
27
28
 
29
+ function isV13(objectStack) {
30
+ return compareVersions(objectStack[0].version, '1.3') >= 0;
31
+ }
32
+
28
33
  /**
29
34
  * @const
30
35
  * @type {Object<string, Object<string, import("../xml.js").Parser>>}
@@ -35,17 +40,40 @@ const PARSERS = makeStructureNS(NAMESPACE_URIS, {
35
40
  'Capability': makeObjectPropertySetter(readCapability),
36
41
  });
37
42
 
43
+ const COMMON_CAPABILITY_PARSERS = {
44
+ 'Request': makeObjectPropertySetter(readRequest),
45
+ 'Exception': makeObjectPropertySetter(readException),
46
+ 'Layer': makeObjectPropertySetter(readCapabilityLayer),
47
+ };
48
+
38
49
  /**
39
50
  * @const
40
51
  * @type {Object<string, Object<string, import("../xml.js").Parser>>}
41
52
  */
42
53
  // @ts-ignore
43
54
  const CAPABILITY_PARSERS = makeStructureNS(NAMESPACE_URIS, {
44
- 'Request': makeObjectPropertySetter(readRequest),
45
- 'Exception': makeObjectPropertySetter(readException),
46
- 'Layer': makeObjectPropertySetter(readCapabilityLayer),
55
+ ...COMMON_CAPABILITY_PARSERS,
56
+ 'UserDefinedSymbolization': makeObjectPropertySetter(
57
+ readUserDefinedSymbolization,
58
+ ),
47
59
  });
48
60
 
61
+ /**
62
+ * @const
63
+ * @type {Object<string, Object<string, import("../xml.js").Parser>>}
64
+ */
65
+ // @ts-ignore
66
+ const CAPABILITY_PARSERS_V13 = makeStructureNS(
67
+ NAMESPACE_URIS,
68
+ COMMON_CAPABILITY_PARSERS,
69
+ );
70
+
71
+ /**
72
+ * @typedef {Object} RootObject
73
+ * @property {string} version Version
74
+ * @property {boolean} v13 Whether version is 1.3 or higher
75
+ */
76
+
49
77
  /**
50
78
  * @classdesc
51
79
  * Format for reading WMS capabilities data
@@ -81,12 +109,7 @@ class WMSCapabilities extends XML {
81
109
  }
82
110
  }
83
111
 
84
- /**
85
- * @const
86
- * @type {Object<string, Object<string, import("../xml.js").Parser>>}
87
- */
88
- // @ts-ignore
89
- const SERVICE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
112
+ const COMMON_SERVICE_PARSERS = {
90
113
  'Name': makeObjectPropertySetter(readString),
91
114
  'Title': makeObjectPropertySetter(readString),
92
115
  'Abstract': makeObjectPropertySetter(readString),
@@ -95,6 +118,22 @@ const SERVICE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
95
118
  'ContactInformation': makeObjectPropertySetter(readContactInformation),
96
119
  'Fees': makeObjectPropertySetter(readString),
97
120
  'AccessConstraints': makeObjectPropertySetter(readString),
121
+ };
122
+
123
+ /**
124
+ * @const
125
+ * @type {Object<string, Object<string, import("../xml.js").Parser>>}
126
+ */
127
+ // @ts-ignore
128
+ const SERVICE_PARSERS = makeStructureNS(NAMESPACE_URIS, COMMON_SERVICE_PARSERS);
129
+
130
+ /**
131
+ * @const
132
+ * @type {Object<string, Object<string, import("../xml.js").Parser>>}
133
+ */
134
+ // @ts-ignore
135
+ const SERVICE_PARSERS_V13 = makeStructureNS(NAMESPACE_URIS, {
136
+ ...COMMON_SERVICE_PARSERS,
98
137
  'LayerLimit': makeObjectPropertySetter(readPositiveInteger),
99
138
  'MaxWidth': makeObjectPropertySetter(readPositiveInteger),
100
139
  'MaxHeight': makeObjectPropertySetter(readPositiveInteger),
@@ -147,20 +186,11 @@ const EXCEPTION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
147
186
  'Format': makeArrayPusher(readString),
148
187
  });
149
188
 
150
- /**
151
- * @const
152
- * @type {Object<string, Object<string, import("../xml.js").Parser>>}
153
- */
154
- // @ts-ignore
155
- const LAYER_PARSERS = makeStructureNS(NAMESPACE_URIS, {
189
+ const COMMON_LAYER_PARSERS = {
156
190
  'Name': makeObjectPropertySetter(readString),
157
191
  'Title': makeObjectPropertySetter(readString),
158
192
  'Abstract': makeObjectPropertySetter(readString),
159
193
  'KeywordList': makeObjectPropertySetter(readKeywordList),
160
- 'CRS': makeObjectPropertyPusher(readString),
161
- 'EX_GeographicBoundingBox': makeObjectPropertySetter(
162
- readEXGeographicBoundingBox,
163
- ),
164
194
  'BoundingBox': makeObjectPropertyPusher(readBoundingBox),
165
195
  'Dimension': makeObjectPropertyPusher(readDimension),
166
196
  'Attribution': makeObjectPropertySetter(readAttribution),
@@ -170,6 +200,36 @@ const LAYER_PARSERS = makeStructureNS(NAMESPACE_URIS, {
170
200
  'DataURL': makeObjectPropertyPusher(readFormatOnlineresource),
171
201
  'FeatureListURL': makeObjectPropertyPusher(readFormatOnlineresource),
172
202
  'Style': makeObjectPropertyPusher(readStyle),
203
+ 'Layer': makeObjectPropertyPusher(readLayer),
204
+ };
205
+
206
+ /**
207
+ * @const
208
+ * @type {Object<string, Object<string, import("../xml.js").Parser>>}
209
+ */
210
+ // @ts-ignore
211
+ const LAYER_PARSERS = makeStructureNS(NAMESPACE_URIS, {
212
+ ...COMMON_LAYER_PARSERS,
213
+ 'SRS': makeObjectPropertyPusher(readString),
214
+ 'Extent': makeObjectPropertySetter(readExtent),
215
+ 'ScaleHint': makeObjectPropertyPusher(readScaleHint),
216
+ 'LatLonBoundingBox': makeObjectPropertySetter((node, objectStack) =>
217
+ readBoundingBox(node, objectStack, false),
218
+ ),
219
+ 'Layer': makeObjectPropertyPusher(readLayer),
220
+ });
221
+
222
+ /**
223
+ * @const
224
+ * @type {Object<string, Object<string, import("../xml.js").Parser>>}
225
+ */
226
+ // @ts-ignore
227
+ const LAYER_PARSERS_V13 = makeStructureNS(NAMESPACE_URIS, {
228
+ ...COMMON_LAYER_PARSERS,
229
+ 'CRS': makeObjectPropertyPusher(readString),
230
+ 'EX_GeographicBoundingBox': makeObjectPropertySetter(
231
+ readEXGeographicBoundingBox,
232
+ ),
173
233
  'MinScaleDenominator': makeObjectPropertySetter(readDecimal),
174
234
  'MaxScaleDenominator': makeObjectPropertySetter(readDecimal),
175
235
  'Layer': makeObjectPropertyPusher(readLayer),
@@ -280,12 +340,24 @@ function readAttribution(node, objectStack) {
280
340
  return pushParseAndPop({}, ATTRIBUTION_PARSERS, node, objectStack);
281
341
  }
282
342
 
343
+ function readUserDefinedSymbolization(node, objectStack) {
344
+ return {
345
+ 'SupportSLD': !!readBooleanString(
346
+ node.getAttribute('UserDefinedSymbolization'),
347
+ ),
348
+ 'UserLayer': !!readBooleanString(node.getAttribute('UserLayer')),
349
+ 'UserStyle': !!readBooleanString(node.getAttribute('UserStyle')),
350
+ 'RemoteWFS': !!readBooleanString(node.getAttribute('RemoteWFS')),
351
+ };
352
+ }
353
+
283
354
  /**
284
355
  * @param {Element} node Node.
285
356
  * @param {Array<*>} objectStack Object stack.
357
+ * @param {boolean} withCrs Whether to include the CRS attribute.
286
358
  * @return {Object} Bounding box object.
287
359
  */
288
- function readBoundingBox(node, objectStack) {
360
+ function readBoundingBox(node, objectStack, withCrs = true) {
289
361
  const extent = [
290
362
  readDecimalString(node.getAttribute('minx')),
291
363
  readDecimalString(node.getAttribute('miny')),
@@ -298,11 +370,22 @@ function readBoundingBox(node, objectStack) {
298
370
  readDecimalString(node.getAttribute('resy')),
299
371
  ];
300
372
 
301
- return {
302
- 'crs': node.getAttribute('CRS'),
303
- 'extent': extent,
304
- 'res': resolutions,
373
+ const result = {
374
+ extent,
375
+ res: resolutions,
305
376
  };
377
+ if (!withCrs) {
378
+ return result;
379
+ }
380
+
381
+ /** @type {RootObject} */
382
+ if (isV13(objectStack)) {
383
+ result.crs = node.getAttribute('CRS');
384
+ } else {
385
+ result.srs = node.getAttribute('SRS');
386
+ }
387
+
388
+ return result;
306
389
  }
307
390
 
308
391
  /**
@@ -354,7 +437,12 @@ function readEXGeographicBoundingBox(node, objectStack) {
354
437
  * @return {Object|undefined} Capability object.
355
438
  */
356
439
  function readCapability(node, objectStack) {
357
- return pushParseAndPop({}, CAPABILITY_PARSERS, node, objectStack);
440
+ return pushParseAndPop(
441
+ {},
442
+ isV13(objectStack) ? CAPABILITY_PARSERS_V13 : CAPABILITY_PARSERS,
443
+ node,
444
+ objectStack,
445
+ );
358
446
  }
359
447
 
360
448
  /**
@@ -363,7 +451,12 @@ function readCapability(node, objectStack) {
363
451
  * @return {Object|undefined} Service object.
364
452
  */
365
453
  function readService(node, objectStack) {
366
- return pushParseAndPop({}, SERVICE_PARSERS, node, objectStack);
454
+ return pushParseAndPop(
455
+ {},
456
+ isV13(objectStack) ? SERVICE_PARSERS_V13 : SERVICE_PARSERS,
457
+ node,
458
+ objectStack,
459
+ );
367
460
  }
368
461
 
369
462
  /**
@@ -408,7 +501,12 @@ function readException(node, objectStack) {
408
501
  * @return {Object|undefined} Layer object.
409
502
  */
410
503
  function readCapabilityLayer(node, objectStack) {
411
- const layerObject = pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
504
+ const layerObject = pushParseAndPop(
505
+ {},
506
+ isV13(objectStack) ? LAYER_PARSERS_V13 : LAYER_PARSERS,
507
+ node,
508
+ objectStack,
509
+ );
412
510
 
413
511
  if (layerObject['Layer'] === undefined) {
414
512
  return Object.assign(layerObject, readLayer(node, objectStack));
@@ -423,11 +521,18 @@ function readCapabilityLayer(node, objectStack) {
423
521
  * @return {Object|undefined} Layer object.
424
522
  */
425
523
  function readLayer(node, objectStack) {
524
+ const v13 = isV13(objectStack);
525
+
426
526
  const parentLayerObject = /** @type {!Object<string,*>} */ (
427
527
  objectStack[objectStack.length - 1]
428
528
  );
429
529
 
430
- const layerObject = pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
530
+ const layerObject = pushParseAndPop(
531
+ {},
532
+ v13 ? LAYER_PARSERS_V13 : LAYER_PARSERS,
533
+ node,
534
+ objectStack,
535
+ );
431
536
 
432
537
  if (!layerObject) {
433
538
  return undefined;
@@ -469,7 +574,12 @@ function readLayer(node, objectStack) {
469
574
  layerObject['fixedHeight'] = fixedHeight;
470
575
 
471
576
  // See 7.2.4.8
472
- const addKeys = ['Style', 'CRS', 'AuthorityURL'];
577
+ const addKeys = ['Style', 'AuthorityURL'];
578
+ if (v13) {
579
+ addKeys.push('CRS');
580
+ } else {
581
+ addKeys.push('SRS', 'Dimension');
582
+ }
473
583
  addKeys.forEach(function (key) {
474
584
  if (key in parentLayerObject) {
475
585
  const childValue = layerObject[key] || [];
@@ -477,14 +587,17 @@ function readLayer(node, objectStack) {
477
587
  }
478
588
  });
479
589
 
480
- const replaceKeys = [
481
- 'EX_GeographicBoundingBox',
482
- 'BoundingBox',
483
- 'Dimension',
484
- 'Attribution',
485
- 'MinScaleDenominator',
486
- 'MaxScaleDenominator',
487
- ];
590
+ const replaceKeys = ['BoundingBox', 'Attribution'];
591
+ if (v13) {
592
+ replaceKeys.push(
593
+ 'Dimension',
594
+ 'EX_GeographicBoundingBox',
595
+ 'MinScaleDenominator',
596
+ 'MaxScaleDenominator',
597
+ );
598
+ } else {
599
+ replaceKeys.push('LatLonBoundingBox', 'ScaleHint', 'Extent');
600
+ }
488
601
  replaceKeys.forEach(function (key) {
489
602
  if (!(key in layerObject)) {
490
603
  const parentValue = parentLayerObject[key];
@@ -505,13 +618,43 @@ function readDimension(node, objectStack) {
505
618
  'name': node.getAttribute('name'),
506
619
  'units': node.getAttribute('units'),
507
620
  'unitSymbol': node.getAttribute('unitSymbol'),
621
+ };
622
+
623
+ if (isV13(objectStack)) {
624
+ Object.assign(dimensionObject, {
625
+ 'default': node.getAttribute('default'),
626
+ 'multipleValues': readBooleanString(node.getAttribute('multipleValues')),
627
+ 'nearestValue': readBooleanString(node.getAttribute('nearestValue')),
628
+ 'current': readBooleanString(node.getAttribute('current')),
629
+ 'values': readString(node),
630
+ });
631
+ }
632
+ return dimensionObject;
633
+ }
634
+
635
+ /**
636
+ * @param {Element} node Node.
637
+ * @param {Array<*>} objectStack Object stack.
638
+ * @return {Object} Extent object.
639
+ */
640
+ function readExtent(node, objectStack) {
641
+ return {
642
+ 'name': node.getAttribute('name'),
508
643
  'default': node.getAttribute('default'),
509
- 'multipleValues': readBooleanString(node.getAttribute('multipleValues')),
510
644
  'nearestValue': readBooleanString(node.getAttribute('nearestValue')),
511
- 'current': readBooleanString(node.getAttribute('current')),
512
- 'values': readString(node),
513
645
  };
514
- return dimensionObject;
646
+ }
647
+
648
+ /**
649
+ * @param {Element} node Node.
650
+ * @param {Array<*>} objectStack Object stack.
651
+ * @return {Object} ScaleHint object.
652
+ */
653
+ function readScaleHint(node, objectStack) {
654
+ return {
655
+ 'min': readDecimalString(node.getAttribute('min')),
656
+ 'max': readDecimalString(node.getAttribute('max')),
657
+ };
515
658
  }
516
659
 
517
660
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol",
3
- "version": "10.1.1-dev.1725805115669",
3
+ "version": "10.1.1-dev.1725970564972",
4
4
  "description": "OpenLayers mapping library",
5
5
  "keywords": [
6
6
  "map",
package/util.js CHANGED
@@ -33,4 +33,4 @@ export function getUid(obj) {
33
33
  * OpenLayers version.
34
34
  * @type {string}
35
35
  */
36
- export const VERSION = '10.1.1-dev.1725805115669';
36
+ export const VERSION = '10.1.1-dev.1725970564972';