@opengeoweb/webmap 2.1.3 → 2.1.4

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.
@@ -44,10 +44,22 @@ function _slicedToArray(arr, i) {
44
44
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
45
45
  }
46
46
 
47
+ function _toConsumableArray(arr) {
48
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
49
+ }
50
+
51
+ function _arrayWithoutHoles(arr) {
52
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
53
+ }
54
+
47
55
  function _arrayWithHoles(arr) {
48
56
  if (Array.isArray(arr)) return arr;
49
57
  }
50
58
 
59
+ function _iterableToArray(iter) {
60
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
61
+ }
62
+
51
63
  function _iterableToArrayLimit(arr, i) {
52
64
  if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
53
65
  var _arr = [];
@@ -92,6 +104,10 @@ function _arrayLikeToArray(arr, len) {
92
104
  return arr2;
93
105
  }
94
106
 
107
+ function _nonIterableSpread() {
108
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
109
+ }
110
+
95
111
  function _nonIterableRest() {
96
112
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
97
113
  }
@@ -428,6 +444,53 @@ var dateToISO8601 = function dateToISO8601(date) {
428
444
  var iso = "".concat(prf(date.getUTCFullYear(), 4), "-").concat(prf(date.getUTCMonth() + 1, 2), "-").concat(prf(date.getUTCDate(), 2), "T").concat(prf(date.getUTCHours(), 2), ":").concat(prf(date.getUTCMinutes(), 2), ":").concat(prf(date.getUTCSeconds(), 2), "Z");
429
445
  return iso;
430
446
  };
447
+ /**
448
+ * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
449
+ * @param layerObjectFromWMS The layer object from the WMS GetCapabilities JSON document
450
+ * @returns Style[] Array of style objects.
451
+ */
452
+
453
+ var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS) {
454
+ /* Get the Style object */
455
+ if (!layerObjectFromWMS.Style) return [];
456
+ var layerStyles = toArray(layerObjectFromWMS.Style);
457
+ /* Loop through the list of styles from the document, create a default object and try to fill in the object with the props from the WMS GetCapabilities document */
458
+
459
+ return layerStyles.map(function (layerStyle) {
460
+ var style = {
461
+ title: 'default',
462
+ name: 'default',
463
+ legendURL: '',
464
+ "abstract": 'No abstract available'
465
+ };
466
+
467
+ try {
468
+ style.title = layerStyle.Title.value;
469
+ } catch (e) {
470
+ /* Do nothing */
471
+ }
472
+
473
+ try {
474
+ style.name = layerStyle.Name.value;
475
+ } catch (e) {
476
+ /* Do nothing */
477
+ }
478
+
479
+ try {
480
+ style.legendURL = layerStyle.LegendURL.OnlineResource.attr['xlink:href'];
481
+ } catch (e) {
482
+ /* Do nothing */
483
+ }
484
+
485
+ try {
486
+ style["abstract"] = layerStyle.Abstract.value;
487
+ } catch (e) {
488
+ /* Do nothing */
489
+ }
490
+
491
+ return style;
492
+ });
493
+ };
431
494
 
432
495
  /**
433
496
  * WMImage provides an API to the HTML image element. It is used for caching and easier access to images.
@@ -4907,7 +4970,7 @@ var WMJSMap = /*#__PURE__*/function () {
4907
4970
  resolve(_this5);
4908
4971
  };
4909
4972
 
4910
- layer.parseLayer(done, undefined);
4973
+ layer.parseLayer(done, undefined, 'WMJSMap addLayer');
4911
4974
  });
4912
4975
  }
4913
4976
  }, {
@@ -7434,13 +7497,15 @@ rootNode, path) {
7434
7497
  keywords: toArray(layers[j].KeywordList && layers[j].KeywordList.Keyword).map(function (keywords) {
7435
7498
  return keywords.value;
7436
7499
  }),
7437
- "abstract": layers[j].Abstract && layers[j].Abstract.value
7500
+ "abstract": layers[j].Abstract && layers[j].Abstract.value,
7501
+ styles: addStylesForLayer(layers[j])
7438
7502
  };
7439
7503
  } else {
7440
7504
  var nodeText = isNull(layers[j].Title) ? 'Layer' : layers[j].Title.value;
7441
7505
  nodeObject = {
7442
7506
  text: nodeText,
7443
- leaf: isleaf
7507
+ leaf: isleaf,
7508
+ styles: []
7444
7509
  };
7445
7510
  }
7446
7511
 
@@ -7698,12 +7763,7 @@ var WMJSService = /*#__PURE__*/function () {
7698
7763
 
7699
7764
  WMJSGetCapabilities(this.service, succes, fail, options);
7700
7765
  } else {
7701
- /* The callbacks are not allowed to be called in the scope of this object.
7702
- By using window.setTimeOut they are externally called
7703
- */
7704
- window.setTimeout(function () {
7705
- succescallback(_this.getcapabilitiesDoc);
7706
- }, 1);
7766
+ succescallback(this.getcapabilitiesDoc);
7707
7767
  }
7708
7768
  } // eslint-disable-next-line class-methods-use-this
7709
7769
 
@@ -7875,55 +7935,6 @@ var LayerType;
7875
7935
  LayerType["baseLayer"] = "baseLayer";
7876
7936
  LayerType["overLayer"] = "overLayer";
7877
7937
  })(LayerType || (LayerType = {}));
7878
- /**
7879
- * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
7880
- * @param layerStyles The layer styles object from the WMS GetCapabilities
7881
- * @param layer The WMLayer to configure
7882
- */
7883
-
7884
-
7885
- var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS, layer) {
7886
- /* Get the Style object */
7887
- if (!layerObjectFromWMS.Style) return;
7888
- var layerStyles = toArray(layerObjectFromWMS.Style);
7889
- /* Loop through the list of styles from the document, create a default object and try to fill in the object with the props from the WMS GetCapabilities document */
7890
-
7891
- for (var k = 0; k < layerStyles.length; k += 1) {
7892
- var layerStyle = layerStyles[k];
7893
- var style = {
7894
- title: 'default',
7895
- name: 'default',
7896
- legendURL: '',
7897
- "abstract": 'No abstract available'
7898
- };
7899
-
7900
- try {
7901
- style.title = layerStyle.Title.value;
7902
- } catch (e) {
7903
- /* Do nothing */
7904
- }
7905
-
7906
- try {
7907
- style.name = layerStyle.Name.value;
7908
- } catch (e) {
7909
- /* Do nothing */
7910
- }
7911
-
7912
- try {
7913
- style.legendURL = layerStyle.LegendURL.OnlineResource.attr['xlink:href'];
7914
- } catch (e) {
7915
- /* Do nothing */
7916
- }
7917
-
7918
- try {
7919
- style["abstract"] = layerStyle.Abstract.value;
7920
- } catch (e) {
7921
- /* Do nothing */
7922
- }
7923
-
7924
- layer.styles.push(style);
7925
- }
7926
- };
7927
7938
  /**
7928
7939
  * Helper function to figure out the dimensions from the WMS layer object (From WMS GetCapabilities). Parses both WMS 1.1.1 and WMS 1.3.0.
7929
7940
  * @param layerObjectFromWMS The corresponding layer object from the WMS GetCapabilities.
@@ -7931,6 +7942,7 @@ var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS, layer) {
7931
7942
  * @param layerDimNamesToRemove A set of dimensions names which are flagged for removal, this function removes the dimension from the set if found in the layer.
7932
7943
  */
7933
7944
 
7945
+
7934
7946
  var addDimsForLayer = function addDimsForLayer(layerObjectFromWMS, layer, layerDimNamesToRemove) {
7935
7947
  /* Information from the WMS GetCapabilities document */
7936
7948
  var layerDims = toArray(layerObjectFromWMS.Dimension);
@@ -8041,7 +8053,10 @@ var configureStyles = function configureStyles(nestedLayerPath, wmLayer) {
8041
8053
  /* Now add the previous parent layer objects style info (inherit) and end with the Style info from this layer */
8042
8054
  try {
8043
8055
  for (var o = 0; o < nestedLayerPath.length; o += 1) {
8044
- addStylesForLayer(nestedLayerPath[o], wmLayer);
8056
+ var _wmLayer$styles;
8057
+
8058
+ // eslint-disable-next-line no-param-reassign
8059
+ (_wmLayer$styles = wmLayer.styles).push.apply(_wmLayer$styles, _toConsumableArray(addStylesForLayer(nestedLayerPath[o])));
8045
8060
  } // eslint-disable-next-line no-empty
8046
8061
 
8047
8062
  } catch (_a) {}
@@ -8278,7 +8293,7 @@ var WMLayer = /*#__PURE__*/function () {
8278
8293
  if (this.autoupdate) {
8279
8294
  var numDeltaMS = 60000;
8280
8295
  this.timer = setInterval(function () {
8281
- _this.parseLayer(undefined, true);
8296
+ _this.parseLayer(undefined, true, 'WMLayer toggleAutoUpdate');
8282
8297
  }, numDeltaMS);
8283
8298
  } else {
8284
8299
  clearInterval(this.timer);
@@ -8296,7 +8311,7 @@ var WMLayer = /*#__PURE__*/function () {
8296
8311
  clearInterval(this.timer);
8297
8312
  } else {
8298
8313
  this.timer = setInterval(function () {
8299
- _this2.parseLayer(callback, true);
8314
+ _this2.parseLayer(callback, true, 'WMLayer setAutoUpdate');
8300
8315
  }, interval);
8301
8316
  }
8302
8317
  }
@@ -8458,51 +8473,58 @@ var WMLayer = /*#__PURE__*/function () {
8458
8473
  return;
8459
8474
  }
8460
8475
 
8461
- var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8476
+ this.getmapURL = undefined;
8462
8477
 
8463
- var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8464
- _this3.getmapURL = undefined;
8478
+ try {
8479
+ this.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8480
+ } catch (e) {
8481
+ /* Do nothing */
8482
+ }
8465
8483
 
8466
- try {
8467
- _this3.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8468
- } catch (e) {
8469
- /* Do nothing */
8470
- }
8484
+ if (!isDefined(this.getmapURL)) {
8485
+ this.getmapURL = this.service;
8486
+ debug(DebugType.Error);
8487
+ }
8471
8488
 
8472
- if (!isDefined(_this3.getmapURL)) {
8473
- _this3.getmapURL = _this3.service;
8474
- debug(DebugType.Error);
8475
- }
8489
+ this.getfeatureinfoURL = undefined;
8476
8490
 
8477
- _this3.getfeatureinfoURL = undefined;
8491
+ try {
8492
+ this.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8493
+ } catch (e) {
8494
+ /* Do nothing */
8495
+ }
8478
8496
 
8479
- try {
8480
- _this3.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8481
- } catch (e) {
8482
- /* Do nothing */
8483
- }
8497
+ if (!isDefined(this.getfeatureinfoURL)) {
8498
+ this.getfeatureinfoURL = this.service;
8499
+ debug(DebugType.Error);
8500
+ }
8484
8501
 
8485
- if (!isDefined(_this3.getfeatureinfoURL)) {
8486
- _this3.getfeatureinfoURL = _this3.service;
8487
- debug(DebugType.Error);
8488
- }
8502
+ this.getlegendgraphicURL = undefined;
8503
+
8504
+ try {
8505
+ this.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8506
+ } catch (e) {
8507
+ /* Do nothing */
8508
+ }
8489
8509
 
8490
- _this3.getlegendgraphicURL = undefined;
8510
+ if (!isDefined(this.getlegendgraphicURL)) {
8511
+ this.getlegendgraphicURL = this.service;
8512
+ } // TODO Should be arranged also for the other services:
8491
8513
 
8492
- try {
8493
- _this3.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8494
- } catch (e) {
8495
- /* Do nothing */
8496
- }
8497
8514
 
8498
- if (!isDefined(_this3.getlegendgraphicURL)) {
8499
- _this3.getlegendgraphicURL = _this3.service;
8500
- } // TODO Should be arranged also for the other services:
8515
+ this.getmapURL = WMJScheckURL(this.getmapURL);
8516
+ this.getfeatureinfoURL = WMJScheckURL(this.getfeatureinfoURL);
8517
+ this.getlegendgraphicURL = WMJScheckURL(this.getlegendgraphicURL);
8518
+ this.styles = [];
8519
+ this.projectionProperties = [];
8520
+ /* Set default to layer name, try to find details in next steps */
8501
8521
 
8522
+ this.title = this.name;
8523
+ this["abstract"] = '';
8524
+ this.path = '';
8525
+ var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8502
8526
 
8503
- _this3.getmapURL = WMJScheckURL(_this3.getmapURL);
8504
- _this3.getfeatureinfoURL = WMJScheckURL(_this3.getfeatureinfoURL);
8505
- _this3.getlegendgraphicURL = WMJScheckURL(_this3.getlegendgraphicURL);
8527
+ var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8506
8528
  _this3.title = jsonlayer.Title.value;
8507
8529
 
8508
8530
  try {
@@ -8512,7 +8534,6 @@ var WMLayer = /*#__PURE__*/function () {
8512
8534
  }
8513
8535
 
8514
8536
  _this3.path = path;
8515
- _this3.styles = [];
8516
8537
  /** ***************** Go through styles **************** */
8517
8538
 
8518
8539
  configureStyles(nestedLayerPath, _this3);
@@ -8525,7 +8546,6 @@ var WMLayer = /*#__PURE__*/function () {
8525
8546
  gp = toArray(jsonlayer.CRS);
8526
8547
  }
8527
8548
 
8528
- _this3.projectionProperties = [];
8529
8549
  var tempSRS = [];
8530
8550
 
8531
8551
  var getgpbbox = function getgpbbox(data) {
@@ -8686,7 +8706,8 @@ var WMLayer = /*#__PURE__*/function () {
8686
8706
 
8687
8707
  }, {
8688
8708
  key: "parseLayer",
8689
- value: function parseLayer(_layerDoneCallback, forceReload) {
8709
+ value: function parseLayer(_layerDoneCallback, forceReload, // eslint-disable-next-line no-unused-vars
8710
+ origin) {
8690
8711
  var _this4 = this;
8691
8712
 
8692
8713
  this.hasError = false;
@@ -8694,7 +8715,10 @@ var WMLayer = /*#__PURE__*/function () {
8694
8715
  var layerDoneCallback = function layerDoneCallback(__layer) {
8695
8716
  if (isDefined(_layerDoneCallback)) {
8696
8717
  try {
8697
- _layerDoneCallback(__layer);
8718
+ /* Enable these two console timings to do performance measurments of parseLayer */
8719
+ // console.time(origin);
8720
+ _layerDoneCallback(__layer); // console.timeEnd(origin);
8721
+
8698
8722
  } catch (e) {
8699
8723
  debug(DebugType.Error);
8700
8724
  }
@@ -8720,7 +8744,6 @@ var WMLayer = /*#__PURE__*/function () {
8720
8744
  fail(_this4, I18n.no_capability_element_found.text);
8721
8745
  };
8722
8746
 
8723
- var wmjsService = WMGetServiceFromStore(this.service);
8724
8747
  var options = {
8725
8748
  headers: {}
8726
8749
  };
@@ -8729,6 +8752,8 @@ var WMLayer = /*#__PURE__*/function () {
8729
8752
  options.headers = this.headers;
8730
8753
  }
8731
8754
 
8755
+ var wmjsService = WMGetServiceFromStore(this.service);
8756
+
8732
8757
  if (wmjsService.service !== undefined) {
8733
8758
  wmjsService.getCapabilities(function (data) {
8734
8759
  callback(data);
@@ -8755,7 +8780,7 @@ var WMLayer = /*#__PURE__*/function () {
8755
8780
  } else {
8756
8781
  resolve(layer);
8757
8782
  }
8758
- }, forceReload);
8783
+ }, forceReload, 'WMLayer parseLayerPromise');
8759
8784
  });
8760
8785
  }
8761
8786
  }, {
@@ -109,6 +109,16 @@
109
109
  finally { if (e) throw e.error; }
110
110
  }
111
111
  return ar;
112
+ }
113
+
114
+ function __spreadArray(to, from, pack) {
115
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
116
+ if (ar || !(i in from)) {
117
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
118
+ ar[i] = from[i];
119
+ }
120
+ }
121
+ return to.concat(ar || Array.prototype.slice.call(from));
112
122
  }
113
123
 
114
124
  /* *
@@ -381,6 +391,53 @@
381
391
  var iso = prf(date.getUTCFullYear(), 4) + "-" + prf(date.getUTCMonth() + 1, 2) + "-" + prf(date.getUTCDate(), 2) + "T" + prf(date.getUTCHours(), 2) + ":" + prf(date.getUTCMinutes(), 2) + ":" + prf(date.getUTCSeconds(), 2) + "Z";
382
392
  return iso;
383
393
  };
394
+ /**
395
+ * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
396
+ * @param layerObjectFromWMS The layer object from the WMS GetCapabilities JSON document
397
+ * @returns Style[] Array of style objects.
398
+ */
399
+
400
+ var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS) {
401
+ /* Get the Style object */
402
+ if (!layerObjectFromWMS.Style) return [];
403
+ var layerStyles = toArray(layerObjectFromWMS.Style);
404
+ /* Loop through the list of styles from the document, create a default object and try to fill in the object with the props from the WMS GetCapabilities document */
405
+
406
+ return layerStyles.map(function (layerStyle) {
407
+ var style = {
408
+ title: 'default',
409
+ name: 'default',
410
+ legendURL: '',
411
+ "abstract": 'No abstract available'
412
+ };
413
+
414
+ try {
415
+ style.title = layerStyle.Title.value;
416
+ } catch (e) {
417
+ /* Do nothing */
418
+ }
419
+
420
+ try {
421
+ style.name = layerStyle.Name.value;
422
+ } catch (e) {
423
+ /* Do nothing */
424
+ }
425
+
426
+ try {
427
+ style.legendURL = layerStyle.LegendURL.OnlineResource.attr['xlink:href'];
428
+ } catch (e) {
429
+ /* Do nothing */
430
+ }
431
+
432
+ try {
433
+ style["abstract"] = layerStyle.Abstract.value;
434
+ } catch (e) {
435
+ /* Do nothing */
436
+ }
437
+
438
+ return style;
439
+ });
440
+ };
384
441
 
385
442
  /* *
386
443
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -4937,7 +4994,7 @@
4937
4994
  resolve(_this);
4938
4995
  };
4939
4996
 
4940
- layer.parseLayer(done, undefined);
4997
+ layer.parseLayer(done, undefined, 'WMJSMap addLayer');
4941
4998
  });
4942
4999
  };
4943
5000
 
@@ -7412,13 +7469,15 @@
7412
7469
  keywords: toArray(layers[j].KeywordList && layers[j].KeywordList.Keyword).map(function (keywords) {
7413
7470
  return keywords.value;
7414
7471
  }),
7415
- "abstract": layers[j].Abstract && layers[j].Abstract.value
7472
+ "abstract": layers[j].Abstract && layers[j].Abstract.value,
7473
+ styles: addStylesForLayer(layers[j])
7416
7474
  };
7417
7475
  } else {
7418
7476
  var nodeText = isNull(layers[j].Title) ? 'Layer' : layers[j].Title.value;
7419
7477
  nodeObject = {
7420
7478
  text: nodeText,
7421
- leaf: isleaf
7479
+ leaf: isleaf,
7480
+ styles: []
7422
7481
  };
7423
7482
  }
7424
7483
 
@@ -7670,12 +7729,7 @@
7670
7729
 
7671
7730
  WMJSGetCapabilities(this.service, succes, fail_1, options);
7672
7731
  } else {
7673
- /* The callbacks are not allowed to be called in the scope of this object.
7674
- By using window.setTimeOut they are externally called
7675
- */
7676
- window.setTimeout(function () {
7677
- succescallback(_this.getcapabilitiesDoc);
7678
- }, 1);
7732
+ succescallback(this.getcapabilitiesDoc);
7679
7733
  }
7680
7734
  }; // eslint-disable-next-line class-methods-use-this
7681
7735
 
@@ -7861,55 +7915,6 @@
7861
7915
  LayerType["baseLayer"] = "baseLayer";
7862
7916
  LayerType["overLayer"] = "overLayer";
7863
7917
  })(exports.LayerType || (exports.LayerType = {}));
7864
- /**
7865
- * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
7866
- * @param layerStyles The layer styles object from the WMS GetCapabilities
7867
- * @param layer The WMLayer to configure
7868
- */
7869
-
7870
-
7871
- var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS, layer) {
7872
- /* Get the Style object */
7873
- if (!layerObjectFromWMS.Style) return;
7874
- var layerStyles = toArray(layerObjectFromWMS.Style);
7875
- /* Loop through the list of styles from the document, create a default object and try to fill in the object with the props from the WMS GetCapabilities document */
7876
-
7877
- for (var k = 0; k < layerStyles.length; k += 1) {
7878
- var layerStyle = layerStyles[k];
7879
- var style = {
7880
- title: 'default',
7881
- name: 'default',
7882
- legendURL: '',
7883
- "abstract": 'No abstract available'
7884
- };
7885
-
7886
- try {
7887
- style.title = layerStyle.Title.value;
7888
- } catch (e) {
7889
- /* Do nothing */
7890
- }
7891
-
7892
- try {
7893
- style.name = layerStyle.Name.value;
7894
- } catch (e) {
7895
- /* Do nothing */
7896
- }
7897
-
7898
- try {
7899
- style.legendURL = layerStyle.LegendURL.OnlineResource.attr['xlink:href'];
7900
- } catch (e) {
7901
- /* Do nothing */
7902
- }
7903
-
7904
- try {
7905
- style["abstract"] = layerStyle.Abstract.value;
7906
- } catch (e) {
7907
- /* Do nothing */
7908
- }
7909
-
7910
- layer.styles.push(style);
7911
- }
7912
- };
7913
7918
  /**
7914
7919
  * Helper function to figure out the dimensions from the WMS layer object (From WMS GetCapabilities). Parses both WMS 1.1.1 and WMS 1.3.0.
7915
7920
  * @param layerObjectFromWMS The corresponding layer object from the WMS GetCapabilities.
@@ -7917,6 +7922,7 @@
7917
7922
  * @param layerDimNamesToRemove A set of dimensions names which are flagged for removal, this function removes the dimension from the set if found in the layer.
7918
7923
  */
7919
7924
 
7925
+
7920
7926
  var addDimsForLayer = function addDimsForLayer(layerObjectFromWMS, layer, layerDimNamesToRemove) {
7921
7927
  /* Information from the WMS GetCapabilities document */
7922
7928
  var layerDims = toArray(layerObjectFromWMS.Dimension);
@@ -8025,13 +8031,17 @@
8025
8031
  */
8026
8032
 
8027
8033
  var configureStyles = function configureStyles(nestedLayerPath, wmLayer) {
8034
+ var _a;
8028
8035
  /* Now add the previous parent layer objects style info (inherit) and end with the Style info from this layer */
8036
+
8037
+
8029
8038
  try {
8030
8039
  for (var o = 0; o < nestedLayerPath.length; o += 1) {
8031
- addStylesForLayer(nestedLayerPath[o], wmLayer);
8040
+ // eslint-disable-next-line no-param-reassign
8041
+ (_a = wmLayer.styles).push.apply(_a, __spreadArray([], __read(addStylesForLayer(nestedLayerPath[o]))));
8032
8042
  } // eslint-disable-next-line no-empty
8033
8043
 
8034
- } catch (_a) {}
8044
+ } catch (_b) {}
8035
8045
  /* Set the default style */
8036
8046
 
8037
8047
 
@@ -8261,7 +8271,7 @@
8261
8271
  if (this.autoupdate) {
8262
8272
  var numDeltaMS = 60000;
8263
8273
  this.timer = setInterval(function () {
8264
- _this.parseLayer(undefined, true);
8274
+ _this.parseLayer(undefined, true, 'WMLayer toggleAutoUpdate');
8265
8275
  }, numDeltaMS);
8266
8276
  } else {
8267
8277
  clearInterval(this.timer);
@@ -8278,7 +8288,7 @@
8278
8288
  clearInterval(this.timer);
8279
8289
  } else {
8280
8290
  this.timer = setInterval(function () {
8281
- _this.parseLayer(callback, true);
8291
+ _this.parseLayer(callback, true, 'WMLayer setAutoUpdate');
8282
8292
  }, interval);
8283
8293
  }
8284
8294
  }
@@ -8434,51 +8444,58 @@
8434
8444
  return;
8435
8445
  }
8436
8446
 
8437
- var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8447
+ this.getmapURL = undefined;
8438
8448
 
8439
- var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8440
- _this.getmapURL = undefined;
8449
+ try {
8450
+ this.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8451
+ } catch (e) {
8452
+ /* Do nothing */
8453
+ }
8441
8454
 
8442
- try {
8443
- _this.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8444
- } catch (e) {
8445
- /* Do nothing */
8446
- }
8455
+ if (!isDefined(this.getmapURL)) {
8456
+ this.getmapURL = this.service;
8457
+ debug(exports.DebugType.Error, 'GetMap OnlineResource is not specified. Using default.');
8458
+ }
8447
8459
 
8448
- if (!isDefined(_this.getmapURL)) {
8449
- _this.getmapURL = _this.service;
8450
- debug(exports.DebugType.Error, 'GetMap OnlineResource is not specified. Using default.');
8451
- }
8460
+ this.getfeatureinfoURL = undefined;
8452
8461
 
8453
- _this.getfeatureinfoURL = undefined;
8462
+ try {
8463
+ this.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8464
+ } catch (e) {
8465
+ /* Do nothing */
8466
+ }
8454
8467
 
8455
- try {
8456
- _this.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8457
- } catch (e) {
8458
- /* Do nothing */
8459
- }
8468
+ if (!isDefined(this.getfeatureinfoURL)) {
8469
+ this.getfeatureinfoURL = this.service;
8470
+ debug(exports.DebugType.Error, 'GetFeatureInfo OnlineResource is not specified. Using default.');
8471
+ }
8460
8472
 
8461
- if (!isDefined(_this.getfeatureinfoURL)) {
8462
- _this.getfeatureinfoURL = _this.service;
8463
- debug(exports.DebugType.Error, 'GetFeatureInfo OnlineResource is not specified. Using default.');
8464
- }
8473
+ this.getlegendgraphicURL = undefined;
8465
8474
 
8466
- _this.getlegendgraphicURL = undefined;
8475
+ try {
8476
+ this.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8477
+ } catch (e) {
8478
+ /* Do nothing */
8479
+ }
8480
+
8481
+ if (!isDefined(this.getlegendgraphicURL)) {
8482
+ this.getlegendgraphicURL = this.service;
8483
+ } // TODO Should be arranged also for the other services:
8467
8484
 
8468
- try {
8469
- _this.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8470
- } catch (e) {
8471
- /* Do nothing */
8472
- }
8473
8485
 
8474
- if (!isDefined(_this.getlegendgraphicURL)) {
8475
- _this.getlegendgraphicURL = _this.service;
8476
- } // TODO Should be arranged also for the other services:
8486
+ this.getmapURL = WMJScheckURL(this.getmapURL);
8487
+ this.getfeatureinfoURL = WMJScheckURL(this.getfeatureinfoURL);
8488
+ this.getlegendgraphicURL = WMJScheckURL(this.getlegendgraphicURL);
8489
+ this.styles = [];
8490
+ this.projectionProperties = [];
8491
+ /* Set default to layer name, try to find details in next steps */
8477
8492
 
8493
+ this.title = this.name;
8494
+ this["abstract"] = '';
8495
+ this.path = '';
8496
+ var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8478
8497
 
8479
- _this.getmapURL = WMJScheckURL(_this.getmapURL);
8480
- _this.getfeatureinfoURL = WMJScheckURL(_this.getfeatureinfoURL);
8481
- _this.getlegendgraphicURL = WMJScheckURL(_this.getlegendgraphicURL);
8498
+ var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8482
8499
  _this.title = jsonlayer.Title.value;
8483
8500
 
8484
8501
  try {
@@ -8488,7 +8505,6 @@
8488
8505
  }
8489
8506
 
8490
8507
  _this.path = path;
8491
- _this.styles = [];
8492
8508
  /** ***************** Go through styles **************** */
8493
8509
 
8494
8510
  configureStyles(nestedLayerPath, _this);
@@ -8501,7 +8517,6 @@
8501
8517
  gp = toArray(jsonlayer.CRS);
8502
8518
  }
8503
8519
 
8504
- _this.projectionProperties = [];
8505
8520
  var tempSRS = [];
8506
8521
 
8507
8522
  var getgpbbox = function getgpbbox(data) {
@@ -8661,7 +8676,8 @@
8661
8676
  */
8662
8677
 
8663
8678
 
8664
- WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload) {
8679
+ WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload, // eslint-disable-next-line no-unused-vars
8680
+ origin) {
8665
8681
  var _this = this;
8666
8682
 
8667
8683
  this.hasError = false;
@@ -8669,7 +8685,10 @@
8669
8685
  var layerDoneCallback = function layerDoneCallback(__layer) {
8670
8686
  if (isDefined(_layerDoneCallback)) {
8671
8687
  try {
8672
- _layerDoneCallback(__layer);
8688
+ /* Enable these two console timings to do performance measurments of parseLayer */
8689
+ // console.time(origin);
8690
+ _layerDoneCallback(__layer); // console.timeEnd(origin);
8691
+
8673
8692
  } catch (e) {
8674
8693
  debug(exports.DebugType.Error, e);
8675
8694
  }
@@ -8695,7 +8714,6 @@
8695
8714
  fail(_this, I18n.no_capability_element_found.text);
8696
8715
  };
8697
8716
 
8698
- var wmjsService = WMGetServiceFromStore(this.service);
8699
8717
  var options = {
8700
8718
  headers: {}
8701
8719
  };
@@ -8704,6 +8722,8 @@
8704
8722
  options.headers = this.headers;
8705
8723
  }
8706
8724
 
8725
+ var wmjsService = WMGetServiceFromStore(this.service);
8726
+
8707
8727
  if (wmjsService.service !== undefined) {
8708
8728
  wmjsService.getCapabilities(function (data) {
8709
8729
  callback(data);
@@ -8732,7 +8752,7 @@
8732
8752
  } else {
8733
8753
  resolve(layer);
8734
8754
  }
8735
- }, forceReload);
8755
+ }, forceReload, 'WMLayer parseLayerPromise');
8736
8756
  });
8737
8757
  };
8738
8758
 
@@ -1,3 +1,4 @@
1
+ import { Style } from './types';
1
2
  export interface GetCapabilitiesJson {
2
3
  WMS_Capabilities?: any;
3
4
  WMT_MS_Capabilities?: any;
@@ -24,6 +25,7 @@ interface NodeObject {
24
25
  children?: [];
25
26
  keywords?: string[];
26
27
  abstract?: string;
28
+ styles?: Style[];
27
29
  }
28
30
  export declare const sortByKey: (array: NodeObject[], key: string) => NodeObject[];
29
31
  export declare const recursivelyFindLayer: (layers: any[], rootNode: any[], path: string) => void;
@@ -1,3 +1,4 @@
1
+ import type { Style, WMSLayerFromGetCapabilities } from './types';
1
2
  import type WMLayer from './WMLayer';
2
3
  export declare const enableConsoleDebugging = false;
3
4
  export declare enum DebugType {
@@ -58,3 +59,9 @@ export declare const getUriAddParam: (baseUrl: string, params: Record<string, an
58
59
  * @returns ISO8601 string
59
60
  */
60
61
  export declare const dateToISO8601: (date: Date) => string;
62
+ /**
63
+ * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
64
+ * @param layerObjectFromWMS The layer object from the WMS GetCapabilities JSON document
65
+ * @returns Style[] Array of style objects.
66
+ */
67
+ export declare const addStylesForLayer: (layerObjectFromWMS: WMSLayerFromGetCapabilities) => Style[];
@@ -3,7 +3,7 @@ import type WMJSMap from './WMJSMap';
3
3
  import WMJSDimension from './WMJSDimension';
4
4
  import WMProjection from './WMProjection';
5
5
  import { GetCapabilitiesJson } from './WMJSService';
6
- import { Style, Dimension } from './types';
6
+ import { Style, Dimension, WMSLayerFromGetCapabilities } from './types';
7
7
  export declare enum LayerType {
8
8
  mapLayer = "mapLayer",
9
9
  baseLayer = "baseLayer",
@@ -34,20 +34,6 @@ export interface LayerOptions {
34
34
  ReactWMJSLayerId?: string;
35
35
  onLayerError?: (layer: WMLayer, error: Error, webmapInstance: WMJSMap) => void;
36
36
  }
37
- /**
38
- * This interface is for reading from the WMS GetCapabilties document, which can have different structures for V1.1.1 and V1.3.0
39
- */
40
- interface WMSLayerFromGetCapabilities {
41
- Dimension: unknown;
42
- Style: unknown;
43
- Extent: unknown;
44
- }
45
- /**
46
- * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
47
- * @param layerStyles The layer styles object from the WMS GetCapabilities
48
- * @param layer The WMLayer to configure
49
- */
50
- export declare const addStylesForLayer: (layerObjectFromWMS: WMSLayerFromGetCapabilities, layer: WMLayer) => void;
51
37
  /**
52
38
  * Helper function to figure out the dimensions from the WMS layer object (From WMS GetCapabilities). Parses both WMS 1.1.1 and WMS 1.3.0.
53
39
  * @param layerObjectFromWMS The corresponding layer object from the WMS GetCapabilities.
@@ -137,7 +123,7 @@ export default class WMLayer {
137
123
  * Calls options.failure with error message.
138
124
  * Throws string exceptions when someting goes wrong
139
125
  */
140
- parseLayer(_layerDoneCallback: (layer: WMLayer) => void, forceReload: boolean): void;
126
+ parseLayer(_layerDoneCallback: (layer: WMLayer) => void, forceReload: boolean, origin: string): void;
141
127
  /**
142
128
  * A Promise to parse the layer, it will fetch the WMS GetCapabilities document, configure the layer and resolve to a WMLayer object
143
129
  * @param forceReload Do not use the cache of the WMS GetCapabilties document, but instead fetch new data from the server
@@ -191,4 +177,3 @@ export default class WMLayer {
191
177
  setSLDURL(url: string): void;
192
178
  display(displayornot: boolean): void;
193
179
  }
194
- export {};
@@ -1,6 +1,6 @@
1
- import WMJSDimension from './WMJSDimension';
1
+ import type WMJSDimension from './WMJSDimension';
2
2
  import type WMLayer from './WMLayer';
3
- import { DateInterval } from './WMTime';
3
+ import type { DateInterval } from './WMTime';
4
4
  export declare type WMPosition = {
5
5
  x: number;
6
6
  y: number;
@@ -35,3 +35,11 @@ export declare type WMLayerType = {
35
35
  title?: string;
36
36
  headers?: Headers[];
37
37
  };
38
+ /**
39
+ * This interface is for reading from the WMS GetCapabilties document, which can have different structures for V1.1.1 and V1.3.0
40
+ */
41
+ export interface WMSLayerFromGetCapabilities {
42
+ Dimension: unknown;
43
+ Style: unknown;
44
+ Extent: unknown;
45
+ }
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@opengeoweb/webmap",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "GeoWeb webmap library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
- "main": "./webmap.umd.js",
11
- "module": "./webmap.esm.js",
10
+ "main": "./index.umd.js",
11
+ "module": "./index.esm.js",
12
12
  "typings": "./index.d.ts",
13
13
  "dependencies": {},
14
14
  "peerDependencies": {
15
15
  "moment": "^2.29.0",
16
16
  "throttle-debounce": "^3.0.1",
17
17
  "proj4": "^2.6.2",
18
- "react": "16.14.0",
19
- "@material-ui/core": "^4.11.0"
18
+ "react": "^17.0.2",
19
+ "@mui/styles": "^5.2.3"
20
20
  }
21
21
  }