@opengeoweb/webmap 2.1.3 → 2.2.1

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.
@@ -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");
@@ -398,6 +455,14 @@
398
455
  * Copyright 2020 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
399
456
  * Copyright 2020 - Finnish Meteorological Institute (FMI)
400
457
  * */
458
+ /**
459
+ * Returns the current time in ms
460
+ * @returns the current time in ms
461
+ */
462
+
463
+ var getCurrentImageTime = function getCurrentImageTime() {
464
+ return new Date().getTime();
465
+ };
401
466
  /**
402
467
  * WMImage provides an API to the HTML image element. It is used for caching and easier access to images.
403
468
  */
@@ -419,6 +484,8 @@
419
484
  this._isLoaded = undefined;
420
485
  this._isLoading = undefined;
421
486
  this._hasError = undefined;
487
+ this._imageTimeStampAtError = getCurrentImageTime();
488
+ this._numFailedAttempts = 0;
422
489
  this.srcToLoad = src;
423
490
  this.loadEventCallback = callback;
424
491
  this.el = new Image();
@@ -437,6 +504,9 @@
437
504
  this.hasError = this.hasError.bind(this);
438
505
  this._load = this._load.bind(this);
439
506
  this.load = this.load.bind(this);
507
+ this.forceReload = this.forceReload.bind(this);
508
+ this.getLastErrorMSecondsAgo = this.getLastErrorMSecondsAgo.bind(this);
509
+ this.getNumFailedAttempts = this.getNumFailedAttempts.bind(this);
440
510
  this._loadEvent = this._loadEvent.bind(this);
441
511
  this.getWidth = this.getWidth.bind(this);
442
512
  this.getHeight = this.getHeight.bind(this);
@@ -447,6 +517,9 @@
447
517
  _this._loadEvent(false);
448
518
  });
449
519
  this.el.addEventListener('error', function () {
520
+ _this._imageTimeStampAtError = getCurrentImageTime();
521
+ _this._numFailedAttempts += 1;
522
+
450
523
  _this._loadEvent(true);
451
524
  });
452
525
 
@@ -464,6 +537,8 @@
464
537
  this._isLoaded = false;
465
538
  this._isLoading = false;
466
539
  this._hasError = false;
540
+ this._numFailedAttempts = 0;
541
+ this._imageTimeStampAtError = getCurrentImageTime();
467
542
  };
468
543
  /**
469
544
  * Returns true if the image has been loaded
@@ -482,6 +557,23 @@
482
557
  WMImage.prototype.isLoading = function () {
483
558
  return this._isLoading;
484
559
  };
560
+ /**
561
+ * Get the amount of milliseconds since the image experienced an image load.
562
+ * @returns milliseconds since the image had an error
563
+ */
564
+
565
+
566
+ WMImage.prototype.getLastErrorMSecondsAgo = function () {
567
+ return getCurrentImageTime() - this._imageTimeStampAtError;
568
+ };
569
+ /**
570
+ * @returns The number of failed attempts for this image
571
+ */
572
+
573
+
574
+ WMImage.prototype.getNumFailedAttempts = function () {
575
+ return this._numFailedAttempts;
576
+ };
485
577
  /**
486
578
  * Set source of image, but it will not load the image yet.
487
579
  * @param src URL of the image to load
@@ -506,6 +598,8 @@
506
598
  return;
507
599
  }
508
600
 
601
+ this._numFailedAttempts = 0;
602
+ this._imageTimeStampAtError = getCurrentImageTime();
509
603
  this._isLoaded = false;
510
604
  };
511
605
  /**
@@ -541,6 +635,13 @@
541
635
  this._load();
542
636
  };
543
637
 
638
+ WMImage.prototype.forceReload = function () {
639
+ this._isLoaded = false;
640
+ this._srcLoaded = undefined;
641
+
642
+ this._load();
643
+ };
644
+
544
645
  WMImage.prototype._getImageWithHeaders = function (url, headers) {
545
646
  var _this = this;
546
647
 
@@ -609,8 +710,12 @@
609
710
  var hostName = splittedHREF[0] + "//" + splittedHREF[1] + "/";
610
711
  this.srcToLoad = hostName + this.srcToLoad;
611
712
  }
713
+ /*
714
+ * If the image has already loaded this source succesfully (without error), simply trigger the loadevent.
715
+ */
716
+
612
717
 
613
- if (this.srcToLoad === this._srcLoaded) {
718
+ if (this.srcToLoad === this._srcLoaded && !this._hasError) {
614
719
  this._loadEvent(false);
615
720
 
616
721
  return;
@@ -1272,13 +1377,14 @@
1272
1377
  /* It is not in the list, so add it */
1273
1378
 
1274
1379
  if (imageIsAlreadyIndex === -1) {
1275
- sharedImagesList[sigImageUrl].push(newLayer);
1276
- }
1277
- /* Ensure that the oldest images are removed, keep a maximum of 10 images per signature url */
1380
+ /* Ensure that the oldest images are removed, keep a maximum of 10 images per signature url */
1381
+ while (sharedImagesList[sigImageUrl].length >= 10) {
1382
+ sharedImagesList[sigImageUrl].pop();
1383
+ }
1384
+ /* Add it to the beginning of the array for efficieny in searching at a later stage */
1278
1385
 
1279
1386
 
1280
- while (sharedImagesList[sigImageUrl].length > 10) {
1281
- sharedImagesList[sigImageUrl].splice(0, 1);
1387
+ sharedImagesList[sigImageUrl].unshift(newLayer);
1282
1388
  }
1283
1389
  };
1284
1390
  /**
@@ -1303,38 +1409,17 @@
1303
1409
  }
1304
1410
  };
1305
1411
  /**
1306
- * Algorithm two determine how much two bboxes are similar
1307
- * @param rect1
1308
- * @param rect2
1309
- * @returns
1310
- */
1311
-
1312
- var geClosestBBox = function geClosestBBox(rect1, rect2) {
1313
- var diffTLX = rect1.left - rect2.left;
1314
- var diffTLY = rect1.top - rect2.top;
1315
- var diffBRX = rect1.right - rect2.right;
1316
- var diffBRY = rect1.bottom - rect2.bottom;
1317
- return Math.sqrt(diffTLX * diffTLX + diffTLY * diffTLY) + Math.sqrt(diffBRX * diffBRX + diffBRY * diffBRY);
1318
- };
1319
- /**
1320
- * Sort the imageslist by overlapping area, highest area first
1412
+ * Sort the imageslist by imagedate, newewst image first.
1321
1413
  * @param imagesList
1322
- * @param bbox
1323
1414
  * @returns
1324
1415
  */
1325
1416
 
1326
- var sortByOverlappingArea = function sortByOverlappingArea(imagesList, bbox) {
1327
- var toSort = imagesList.map(function (im) {
1328
- return {
1329
- dist: geClosestBBox(im.bbox, bbox),
1330
- image: im
1331
- };
1332
- });
1333
- var sorted = toSort.sort(function (a, b) {
1334
- return a.dist > b.dist ? 1 : -1;
1417
+ var sortByImageDate = function sortByImageDate(imagesList) {
1418
+ var sorted = imagesList.sort(function (a, b) {
1419
+ return a.imageAge < b.imageAge ? 1 : -1;
1335
1420
  });
1336
1421
  return sorted.map(function (i) {
1337
- return i.image;
1422
+ return i;
1338
1423
  });
1339
1424
  };
1340
1425
  /**
@@ -1345,17 +1430,18 @@
1345
1430
  * @returns A canvasLayer, containing the new image source with its geo properties
1346
1431
  */
1347
1432
 
1348
- var getAlternativeImage = function getAlternativeImage(imageUrl, imageStore, bbox) {
1433
+ var getAlternativeImage = function getAlternativeImage(imageUrl, imageStore, // eslint-disable-next-line no-unused-vars
1434
+ _bbox) {
1349
1435
  var sigImageUrl = makeQueryStringWithoutGeoInfo(imageUrl);
1350
1436
  var imagesForUrl = sharedImagesList[sigImageUrl];
1351
1437
 
1352
1438
  if (imagesForUrl && imagesForUrl.length > 0) {
1353
- var sortedImagesForUrl = sortByOverlappingArea(imagesForUrl, bbox);
1354
- /* Find the first image in this list which is also loaded */
1439
+ var sortedImagesForUrl = sortByImageDate(imagesForUrl);
1440
+ /* Find the first image in this list which is also loaded and has no error */
1355
1441
 
1356
1442
  var index = sortedImagesForUrl.findIndex(function (altImage) {
1357
1443
  var cachedImage = imageStore.getImageForSrc(altImage.imageSource);
1358
- return cachedImage && cachedImage.isLoaded();
1444
+ return cachedImage && cachedImage.isLoaded() && !cachedImage.isLoading() && !cachedImage.hasError();
1359
1445
  });
1360
1446
  if (index !== -1) return sortedImagesForUrl[index];
1361
1447
  }
@@ -1516,16 +1602,29 @@
1516
1602
  for (var j = 0; j < this.layers.length; j += 1) {
1517
1603
  var imageToDisplay = this._imageStore.getImageForSrc(this.layers[j].imageSource);
1518
1604
 
1519
- if (!imageToDisplay || imageToDisplay.isLoaded() === false) {
1520
- /* Find closest image */
1605
+ if (imageToDisplay && imageToDisplay.isLoaded() && !imageToDisplay.isLoading() && !imageToDisplay.hasError()) {
1606
+ // Draw this image, it is loaded and OK
1607
+ this._drawImage(this.layers[j]);
1608
+ } else {
1609
+ /**
1610
+ * Check if this image has an error.
1611
+ * If the error has occured some time ago, and the amount of retries is low, just retry to load the image.
1612
+ */
1613
+ if (imageToDisplay.hasError()) {
1614
+ if (imageToDisplay.isLoading() === false && imageToDisplay.getLastErrorMSecondsAgo() > 5000) {
1615
+ if (imageToDisplay.getNumFailedAttempts() < 10) {
1616
+ imageToDisplay.forceReload();
1617
+ }
1618
+ }
1619
+ }
1620
+ /* Find closest alternative and display instead image */
1621
+
1622
+
1521
1623
  var im = getAlternativeImage(this.layers[j].imageSource, this._imageStore, this._currentnewbbox);
1522
1624
 
1523
1625
  if (im) {
1524
1626
  this._drawImage(im);
1525
1627
  }
1526
- } else {
1527
- // Draw
1528
- this._drawImage(this.layers[j]);
1529
1628
  }
1530
1629
  }
1531
1630
 
@@ -1612,6 +1711,7 @@
1612
1711
 
1613
1712
  var newLayer = {
1614
1713
  imageSource: imageSource,
1714
+ imageAge: getCurrentImageTime(),
1615
1715
  opacity: opacity,
1616
1716
  bbox: {
1617
1717
  left: bbox.left,
@@ -1840,8 +1940,9 @@
1840
1940
  for (var i = 0; i < this._map.animationList[nextStep].requests.length; i += 1) {
1841
1941
  var url = this._map.animationList[nextStep].requests[i].url;
1842
1942
  var image = getMapImageStore.getImageForSrc(url);
1943
+ /* Get a loaded image which has no error */
1843
1944
 
1844
- if (image && image.isLoaded()) {
1945
+ if (image && image.isLoaded() && !image.isLoading() && !image.hasError()) {
1845
1946
  numReady += 1;
1846
1947
  } else {
1847
1948
  /* Check if a similar image is available instead, then we can continue with the smoother animation */
@@ -1849,11 +1950,14 @@
1849
1950
 
1850
1951
  if (im) {
1851
1952
  numReady += 1;
1953
+ } else if (!(image && image.isLoading())) {
1954
+ /* No alternatives and current image is not loading, so lets continue the animation */
1955
+ numReady += 1;
1852
1956
  }
1853
1957
  }
1854
1958
  }
1855
1959
 
1856
- if (numReady === this._map.animationList[nextStep].requests.length) {
1960
+ if (numReady >= this._map.animationList[nextStep].requests.length) {
1857
1961
  continueAnimation = true;
1858
1962
  }
1859
1963
 
@@ -1906,9 +2010,11 @@
1906
2010
  this._map.setDimension(animationStep.name, animationStep.value, false);
1907
2011
 
1908
2012
  this._map.animationList[index].imagesInPrefetch = prefetch(this._map.animationList[index].requests);
1909
- getNumImagesLoading += this._map.animationList[index].imagesInPrefetch.length; // imageStore.getNumImagesLoading();
2013
+ getNumImagesLoading = this._imageStore.getNumImagesLoading();
1910
2014
 
1911
- if (getNumImagesLoading > maxSimultaneousLoads - 1) break;
2015
+ if (getNumImagesLoading > maxSimultaneousLoads - 1) {
2016
+ break;
2017
+ }
1912
2018
  }
1913
2019
  }
1914
2020
  }
@@ -2846,6 +2952,7 @@
2846
2952
  this.initialize = this.initialize.bind(this);
2847
2953
  this.getValue = this.getValue.bind(this);
2848
2954
  this.setValue = this.setValue.bind(this);
2955
+ this.getValues = this.setValue.bind(this);
2849
2956
  this.setClosestValue = this.setClosestValue.bind(this);
2850
2957
  this.addTimeRangeDurationToValue = this.addTimeRangeDurationToValue.bind(this);
2851
2958
  this.setTimeRangeDuration = this.setTimeRangeDuration.bind(this);
@@ -2854,6 +2961,7 @@
2854
2961
  this.get = this.get.bind(this);
2855
2962
  this.getFirstValue = this.getFirstValue.bind(this);
2856
2963
  this.getLastValue = this.getLastValue.bind(this);
2964
+ this.getDimInterval = this.getDimInterval.bind(this);
2857
2965
  this.getIndexForValue = this.getIndexForValue.bind(this);
2858
2966
  this.size = this.size.bind(this);
2859
2967
  this.clone = this.clone.bind(this);
@@ -3132,6 +3240,16 @@
3132
3240
 
3133
3241
  this.currentValue = value;
3134
3242
  };
3243
+ /**
3244
+ * Returns values of the dimension, according to values defined in WMS specification, e.g. 2011-01-01T00:00:00Z/2012-01-01T00:00:00Z/P1M or list of values.
3245
+ * @returns
3246
+ */
3247
+
3248
+
3249
+ WMJSDimension.prototype.getValues = function () {
3250
+ this.initialize();
3251
+ return this.values;
3252
+ };
3135
3253
 
3136
3254
  WMJSDimension.prototype.setClosestValue = function (newValue, evenWhenOutsideRange) {
3137
3255
  if (newValue === void 0) {
@@ -3278,6 +3396,16 @@
3278
3396
  if (this._type === 'anyvalue') return this._allValues[index];
3279
3397
  return null;
3280
3398
  };
3399
+ /**
3400
+ * Hint about the timestep size / time resolution of this dimension.
3401
+ * @returns The dimTimeInterval
3402
+ */
3403
+
3404
+
3405
+ WMJSDimension.prototype.getDimInterval = function () {
3406
+ this.initialize();
3407
+ return this.dimTimeInterval;
3408
+ };
3281
3409
  /**
3282
3410
  * Shorthand functionf or getValueForIndex
3283
3411
  */
@@ -4937,7 +5065,7 @@
4937
5065
  resolve(_this);
4938
5066
  };
4939
5067
 
4940
- layer.parseLayer(done, undefined);
5068
+ layer.parseLayer(done, undefined, 'WMJSMap addLayer');
4941
5069
  });
4942
5070
  };
4943
5071
 
@@ -7412,13 +7540,15 @@
7412
7540
  keywords: toArray(layers[j].KeywordList && layers[j].KeywordList.Keyword).map(function (keywords) {
7413
7541
  return keywords.value;
7414
7542
  }),
7415
- "abstract": layers[j].Abstract && layers[j].Abstract.value
7543
+ "abstract": layers[j].Abstract && layers[j].Abstract.value,
7544
+ styles: addStylesForLayer(layers[j])
7416
7545
  };
7417
7546
  } else {
7418
7547
  var nodeText = isNull(layers[j].Title) ? 'Layer' : layers[j].Title.value;
7419
7548
  nodeObject = {
7420
7549
  text: nodeText,
7421
- leaf: isleaf
7550
+ leaf: isleaf,
7551
+ styles: []
7422
7552
  };
7423
7553
  }
7424
7554
 
@@ -7426,7 +7556,7 @@
7426
7556
 
7427
7557
  if (layers[j].Layer) {
7428
7558
  nodeObject.children = [];
7429
- recursivelyFindLayer(toArray(layers[j].Layer), nodeObject.children, path + layers[j].Title.value);
7559
+ recursivelyFindLayer(toArray(layers[j].Layer), nodeObject.children, __spreadArray(__spreadArray([], __read(path)), [layers[j].Title.value]));
7430
7560
  }
7431
7561
  } // Sort nodes alphabetically.
7432
7562
 
@@ -7670,12 +7800,7 @@
7670
7800
 
7671
7801
  WMJSGetCapabilities(this.service, succes, fail_1, options);
7672
7802
  } 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);
7803
+ succescallback(this.getcapabilitiesDoc);
7679
7804
  }
7680
7805
  }; // eslint-disable-next-line class-methods-use-this
7681
7806
 
@@ -7751,7 +7876,7 @@
7751
7876
  nodeStructure.text = I18n.unnamed_service.text;
7752
7877
  }
7753
7878
 
7754
- recursivelyFindLayer(WMSLayers, nodeStructure.children, '');
7879
+ recursivelyFindLayer(WMSLayers, nodeStructure.children, []);
7755
7880
  succes(nodeStructure);
7756
7881
  };
7757
7882
 
@@ -7861,55 +7986,6 @@
7861
7986
  LayerType["baseLayer"] = "baseLayer";
7862
7987
  LayerType["overLayer"] = "overLayer";
7863
7988
  })(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
7989
  /**
7914
7990
  * 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
7991
  * @param layerObjectFromWMS The corresponding layer object from the WMS GetCapabilities.
@@ -7917,6 +7993,7 @@
7917
7993
  * @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
7994
  */
7919
7995
 
7996
+
7920
7997
  var addDimsForLayer = function addDimsForLayer(layerObjectFromWMS, layer, layerDimNamesToRemove) {
7921
7998
  /* Information from the WMS GetCapabilities document */
7922
7999
  var layerDims = toArray(layerObjectFromWMS.Dimension);
@@ -8025,13 +8102,17 @@
8025
8102
  */
8026
8103
 
8027
8104
  var configureStyles = function configureStyles(nestedLayerPath, wmLayer) {
8105
+ var _a;
8028
8106
  /* Now add the previous parent layer objects style info (inherit) and end with the Style info from this layer */
8107
+
8108
+
8029
8109
  try {
8030
8110
  for (var o = 0; o < nestedLayerPath.length; o += 1) {
8031
- addStylesForLayer(nestedLayerPath[o], wmLayer);
8111
+ // eslint-disable-next-line no-param-reassign
8112
+ (_a = wmLayer.styles).push.apply(_a, __spreadArray([], __read(addStylesForLayer(nestedLayerPath[o]))));
8032
8113
  } // eslint-disable-next-line no-empty
8033
8114
 
8034
- } catch (_a) {}
8115
+ } catch (_b) {}
8035
8116
  /* Set the default style */
8036
8117
 
8037
8118
 
@@ -8261,7 +8342,7 @@
8261
8342
  if (this.autoupdate) {
8262
8343
  var numDeltaMS = 60000;
8263
8344
  this.timer = setInterval(function () {
8264
- _this.parseLayer(undefined, true);
8345
+ _this.parseLayer(undefined, true, 'WMLayer toggleAutoUpdate');
8265
8346
  }, numDeltaMS);
8266
8347
  } else {
8267
8348
  clearInterval(this.timer);
@@ -8278,7 +8359,7 @@
8278
8359
  clearInterval(this.timer);
8279
8360
  } else {
8280
8361
  this.timer = setInterval(function () {
8281
- _this.parseLayer(callback, true);
8362
+ _this.parseLayer(callback, true, 'WMLayer setAutoUpdate');
8282
8363
  }, interval);
8283
8364
  }
8284
8365
  }
@@ -8434,51 +8515,58 @@
8434
8515
  return;
8435
8516
  }
8436
8517
 
8437
- var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8518
+ this.getmapURL = undefined;
8438
8519
 
8439
- var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8440
- _this.getmapURL = undefined;
8520
+ try {
8521
+ this.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8522
+ } catch (e) {
8523
+ /* Do nothing */
8524
+ }
8441
8525
 
8442
- try {
8443
- _this.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8444
- } catch (e) {
8445
- /* Do nothing */
8446
- }
8526
+ if (!isDefined(this.getmapURL)) {
8527
+ this.getmapURL = this.service;
8528
+ debug(exports.DebugType.Error, 'GetMap OnlineResource is not specified. Using default.');
8529
+ }
8447
8530
 
8448
- if (!isDefined(_this.getmapURL)) {
8449
- _this.getmapURL = _this.service;
8450
- debug(exports.DebugType.Error, 'GetMap OnlineResource is not specified. Using default.');
8451
- }
8531
+ this.getfeatureinfoURL = undefined;
8452
8532
 
8453
- _this.getfeatureinfoURL = undefined;
8533
+ try {
8534
+ this.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8535
+ } catch (e) {
8536
+ /* Do nothing */
8537
+ }
8454
8538
 
8455
- try {
8456
- _this.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8457
- } catch (e) {
8458
- /* Do nothing */
8459
- }
8539
+ if (!isDefined(this.getfeatureinfoURL)) {
8540
+ this.getfeatureinfoURL = this.service;
8541
+ debug(exports.DebugType.Error, 'GetFeatureInfo OnlineResource is not specified. Using default.');
8542
+ }
8460
8543
 
8461
- if (!isDefined(_this.getfeatureinfoURL)) {
8462
- _this.getfeatureinfoURL = _this.service;
8463
- debug(exports.DebugType.Error, 'GetFeatureInfo OnlineResource is not specified. Using default.');
8464
- }
8544
+ this.getlegendgraphicURL = undefined;
8465
8545
 
8466
- _this.getlegendgraphicURL = undefined;
8546
+ try {
8547
+ this.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8548
+ } catch (e) {
8549
+ /* Do nothing */
8550
+ }
8551
+
8552
+ if (!isDefined(this.getlegendgraphicURL)) {
8553
+ this.getlegendgraphicURL = this.service;
8554
+ } // TODO Should be arranged also for the other services:
8467
8555
 
8468
- try {
8469
- _this.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8470
- } catch (e) {
8471
- /* Do nothing */
8472
- }
8473
8556
 
8474
- if (!isDefined(_this.getlegendgraphicURL)) {
8475
- _this.getlegendgraphicURL = _this.service;
8476
- } // TODO Should be arranged also for the other services:
8557
+ this.getmapURL = WMJScheckURL(this.getmapURL);
8558
+ this.getfeatureinfoURL = WMJScheckURL(this.getfeatureinfoURL);
8559
+ this.getlegendgraphicURL = WMJScheckURL(this.getlegendgraphicURL);
8560
+ this.styles = [];
8561
+ this.projectionProperties = [];
8562
+ /* Set default to layer name, try to find details in next steps */
8477
8563
 
8564
+ this.title = this.name;
8565
+ this["abstract"] = '';
8566
+ this.path = '';
8567
+ var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8478
8568
 
8479
- _this.getmapURL = WMJScheckURL(_this.getmapURL);
8480
- _this.getfeatureinfoURL = WMJScheckURL(_this.getfeatureinfoURL);
8481
- _this.getlegendgraphicURL = WMJScheckURL(_this.getlegendgraphicURL);
8569
+ var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8482
8570
  _this.title = jsonlayer.Title.value;
8483
8571
 
8484
8572
  try {
@@ -8488,7 +8576,6 @@
8488
8576
  }
8489
8577
 
8490
8578
  _this.path = path;
8491
- _this.styles = [];
8492
8579
  /** ***************** Go through styles **************** */
8493
8580
 
8494
8581
  configureStyles(nestedLayerPath, _this);
@@ -8501,7 +8588,6 @@
8501
8588
  gp = toArray(jsonlayer.CRS);
8502
8589
  }
8503
8590
 
8504
- _this.projectionProperties = [];
8505
8591
  var tempSRS = [];
8506
8592
 
8507
8593
  var getgpbbox = function getgpbbox(data) {
@@ -8661,7 +8747,8 @@
8661
8747
  */
8662
8748
 
8663
8749
 
8664
- WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload) {
8750
+ WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload, // eslint-disable-next-line no-unused-vars
8751
+ origin) {
8665
8752
  var _this = this;
8666
8753
 
8667
8754
  this.hasError = false;
@@ -8669,7 +8756,10 @@
8669
8756
  var layerDoneCallback = function layerDoneCallback(__layer) {
8670
8757
  if (isDefined(_layerDoneCallback)) {
8671
8758
  try {
8672
- _layerDoneCallback(__layer);
8759
+ /* Enable these two console timings to do performance measurments of parseLayer */
8760
+ // console.time(origin);
8761
+ _layerDoneCallback(__layer); // console.timeEnd(origin);
8762
+
8673
8763
  } catch (e) {
8674
8764
  debug(exports.DebugType.Error, e);
8675
8765
  }
@@ -8695,7 +8785,6 @@
8695
8785
  fail(_this, I18n.no_capability_element_found.text);
8696
8786
  };
8697
8787
 
8698
- var wmjsService = WMGetServiceFromStore(this.service);
8699
8788
  var options = {
8700
8789
  headers: {}
8701
8790
  };
@@ -8704,6 +8793,8 @@
8704
8793
  options.headers = this.headers;
8705
8794
  }
8706
8795
 
8796
+ var wmjsService = WMGetServiceFromStore(this.service);
8797
+
8707
8798
  if (wmjsService.service !== undefined) {
8708
8799
  wmjsService.getCapabilities(function (data) {
8709
8800
  callback(data);
@@ -8732,7 +8823,7 @@
8732
8823
  } else {
8733
8824
  resolve(layer);
8734
8825
  }
8735
- }, forceReload);
8826
+ }, forceReload, 'WMLayer parseLayerPromise');
8736
8827
  });
8737
8828
  };
8738
8829