@opengeoweb/webmap 2.1.2 → 2.2.0

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
+ */
612
716
 
613
- if (this.srcToLoad === this._srcLoaded) {
717
+
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
  */
@@ -4027,7 +4155,6 @@
4027
4155
  this.previousMouseButtonState = 'up';
4028
4156
  /* Binds */
4029
4157
 
4030
- this.setXML2JSONURL = this.setXML2JSONURL.bind(this);
4031
4158
  this.setWMTileRendererTileSettings = this.setWMTileRendererTileSettings.bind(this);
4032
4159
  this.makeComponentId = this.makeComponentId.bind(this);
4033
4160
  this.setMessage = this.setMessage.bind(this);
@@ -4152,10 +4279,6 @@
4152
4279
  this.init();
4153
4280
  }
4154
4281
 
4155
- WMJSMap.prototype.setXML2JSONURL = function (_xml2jsonrequest) {
4156
- this.xml2jsonrequest = _xml2jsonrequest;
4157
- };
4158
-
4159
4282
  WMJSMap.prototype.setWMTileRendererTileSettings = function (_WMTileRendererTileSettings) {
4160
4283
  this.tileRenderSettings = _WMTileRendererTileSettings;
4161
4284
  };
@@ -4927,10 +5050,10 @@
4927
5050
  reject(new Error('layer has no constructor'));
4928
5051
  return;
4929
5052
  }
5053
+ /* Set a reference in the layer to this map */
4930
5054
 
4931
- if (!layer.parentMaps.includes(_this)) {
4932
- layer.parentMaps.push(_this);
4933
- }
5055
+
5056
+ layer.parentMap = _this;
4934
5057
 
4935
5058
  _this.layers.push(layer);
4936
5059
 
@@ -4942,7 +5065,7 @@
4942
5065
  resolve(_this);
4943
5066
  };
4944
5067
 
4945
- layer.parseLayer(done, undefined);
5068
+ layer.parseLayer(done, undefined, 'WMJSMap addLayer');
4946
5069
  });
4947
5070
  };
4948
5071
 
@@ -5453,9 +5576,7 @@
5453
5576
  this.baseLayers = layer;
5454
5577
 
5455
5578
  for (var j = 0; j < this.baseLayers.length; j += 1) {
5456
- if (!this.baseLayers[j].parentMaps.includes(this)) {
5457
- this.baseLayers[j].parentMaps.push(this);
5458
- }
5579
+ this.baseLayers[j].parentMap = this;
5459
5580
 
5460
5581
  if (this.baseLayers[j].keepOnTop !== true) {
5461
5582
  this.numBaseLayers += 1;
@@ -7327,7 +7448,7 @@
7327
7448
  * Global getcapabilities function
7328
7449
  */
7329
7450
 
7330
- var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, xml2jsonrequestURL, options, disableCache) {
7451
+ var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, options, disableCache) {
7331
7452
  if (disableCache === void 0) {
7332
7453
  disableCache = false;
7333
7454
  }
@@ -7375,7 +7496,6 @@
7375
7496
  random: Math.random()
7376
7497
  } : {};
7377
7498
  var url = getWMSUrl(service, addParams);
7378
- var newXml2jsonrequestURL = xml2jsonrequestURL;
7379
7499
  WMXMLParser(url, headers).then(function (data) {
7380
7500
  try {
7381
7501
  succes(data);
@@ -7385,7 +7505,7 @@
7385
7505
  })["catch"](function () {
7386
7506
  loadGetCapabilitiesViaProxy(url, succes, function () {
7387
7507
  fail("Request failed for " + url);
7388
- }, newXml2jsonrequestURL);
7508
+ }, WMServiceStoreXML2JSONRequest.proxy);
7389
7509
  });
7390
7510
  };
7391
7511
  var sortByKey = function sortByKey(array, key) {
@@ -7420,13 +7540,15 @@
7420
7540
  keywords: toArray(layers[j].KeywordList && layers[j].KeywordList.Keyword).map(function (keywords) {
7421
7541
  return keywords.value;
7422
7542
  }),
7423
- "abstract": layers[j].Abstract && layers[j].Abstract.value
7543
+ "abstract": layers[j].Abstract && layers[j].Abstract.value,
7544
+ styles: addStylesForLayer(layers[j])
7424
7545
  };
7425
7546
  } else {
7426
7547
  var nodeText = isNull(layers[j].Title) ? 'Layer' : layers[j].Title.value;
7427
7548
  nodeObject = {
7428
7549
  text: nodeText,
7429
- leaf: isleaf
7550
+ leaf: isleaf,
7551
+ styles: []
7430
7552
  };
7431
7553
  }
7432
7554
 
@@ -7434,7 +7556,7 @@
7434
7556
 
7435
7557
  if (layers[j].Layer) {
7436
7558
  nodeObject.children = [];
7437
- 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]));
7438
7560
  }
7439
7561
  } // Sort nodes alphabetically.
7440
7562
 
@@ -7446,7 +7568,6 @@
7446
7568
  *
7447
7569
  * options:
7448
7570
  * service
7449
- * xml2jsonrequestURL
7450
7571
  * title (optional)
7451
7572
  */
7452
7573
 
@@ -7467,7 +7588,6 @@
7467
7588
  if (options) {
7468
7589
  this.service = options.service;
7469
7590
  this.title = options.title;
7470
- this.xml2jsonrequestURL = options.xml2jsonrequestURL;
7471
7591
  }
7472
7592
 
7473
7593
  this.checkVersion111 = this.checkVersion111.bind(this);
@@ -7584,7 +7704,7 @@
7584
7704
  */
7585
7705
 
7586
7706
 
7587
- WMJSService.prototype.getCapabilities = function (succescallback, failcallback, forceReload, xml2jsonrequestURL, options) {
7707
+ WMJSService.prototype.getCapabilities = function (succescallback, failcallback, forceReload, options) {
7588
7708
  var _this = this;
7589
7709
 
7590
7710
  if (options) {
@@ -7669,7 +7789,7 @@
7669
7789
  return null;
7670
7790
  }, function () {
7671
7791
  return null;
7672
- }, false, xml2jsonrequestURL, options);
7792
+ }, false, options);
7673
7793
 
7674
7794
  var current;
7675
7795
 
@@ -7678,14 +7798,9 @@
7678
7798
  }
7679
7799
  };
7680
7800
 
7681
- WMJSGetCapabilities(this.service, succes, fail_1, xml2jsonrequestURL, options);
7801
+ WMJSGetCapabilities(this.service, succes, fail_1, options);
7682
7802
  } else {
7683
- /* The callbacks are not allowed to be called in the scope of this object.
7684
- By using window.setTimeOut they are externally called
7685
- */
7686
- window.setTimeout(function () {
7687
- succescallback(_this.getcapabilitiesDoc);
7688
- }, 1);
7803
+ succescallback(this.getcapabilitiesDoc);
7689
7804
  }
7690
7805
  }; // eslint-disable-next-line class-methods-use-this
7691
7806
 
@@ -7722,13 +7837,9 @@
7722
7837
  */
7723
7838
 
7724
7839
 
7725
- WMJSService.prototype.getNodes = function (succes, failure, forceReload, xml2jsonrequestURL, options) {
7840
+ WMJSService.prototype.getNodes = function (succes, failure, forceReload, options) {
7726
7841
  var _this = this;
7727
7842
 
7728
- if (xml2jsonrequestURL === void 0) {
7729
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7730
- }
7731
-
7732
7843
  this.nodeCache = undefined;
7733
7844
 
7734
7845
  if (!failure) {
@@ -7765,7 +7876,7 @@
7765
7876
  nodeStructure.text = I18n.unnamed_service.text;
7766
7877
  }
7767
7878
 
7768
- recursivelyFindLayer(WMSLayers, nodeStructure.children, '');
7879
+ recursivelyFindLayer(WMSLayers, nodeStructure.children, []);
7769
7880
  succes(nodeStructure);
7770
7881
  };
7771
7882
 
@@ -7777,29 +7888,20 @@
7777
7888
  failure(data);
7778
7889
  };
7779
7890
 
7780
- this.getCapabilities(callback, fail, forceReload, xml2jsonrequestURL, options);
7891
+ this.getCapabilities(callback, fail, forceReload, options);
7781
7892
  };
7782
7893
  /** Calls succes with an array of all layerobjects
7783
7894
  * Calls failure when something goes wrong
7784
7895
  */
7785
7896
 
7786
7897
 
7787
- WMJSService.prototype.getLayerObjectsFlat = function (succes, failure, forceReload, xml2jsonrequestURL, options) {
7898
+ WMJSService.prototype.getLayerObjectsFlat = function (succes, failure, forceReload, options) {
7788
7899
  var _this = this;
7789
7900
 
7790
- if (xml2jsonrequestURL === void 0) {
7791
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7792
- }
7793
-
7794
7901
  if (options === void 0) {
7795
7902
  options = this._options;
7796
7903
  }
7797
7904
 
7798
- if (!xml2jsonrequestURL) {
7799
- // eslint-disable-next-line no-param-reassign
7800
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7801
- }
7802
-
7803
7905
  if (isDefined(this._flatLayerObject) && forceReload !== true) {
7804
7906
  succes(this._flatLayerObject);
7805
7907
  return;
@@ -7824,7 +7926,7 @@
7824
7926
  succes(_this._flatLayerObject);
7825
7927
  };
7826
7928
 
7827
- this.getNodes(callback, failure, forceReload, xml2jsonrequestURL, options);
7929
+ this.getNodes(callback, failure, forceReload, options);
7828
7930
  };
7829
7931
 
7830
7932
  return WMJSService;
@@ -7847,20 +7949,15 @@
7847
7949
  * Copyright 2020 - Finnish Meteorological Institute (FMI)
7848
7950
  * */
7849
7951
 
7850
- var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName, xml2jsonrequestURL) {
7952
+ var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName) {
7851
7953
  for (var j = 0; j < WMServiceStore.length; j += 1) {
7852
7954
  if (WMServiceStore[j].service === serviceName) {
7853
7955
  return WMServiceStore[j];
7854
7956
  }
7855
7957
  }
7856
7958
 
7857
- if (xml2jsonrequestURL) {
7858
- WMServiceStoreXML2JSONRequest.proxy = xml2jsonrequestURL;
7859
- }
7860
-
7861
7959
  var service = new WMJSService({
7862
- service: serviceName,
7863
- xml2jsonrequestURL: WMServiceStoreXML2JSONRequest.proxy
7960
+ service: serviceName
7864
7961
  });
7865
7962
  WMServiceStore.push(service);
7866
7963
  return service;
@@ -7889,55 +7986,6 @@
7889
7986
  LayerType["baseLayer"] = "baseLayer";
7890
7987
  LayerType["overLayer"] = "overLayer";
7891
7988
  })(exports.LayerType || (exports.LayerType = {}));
7892
- /**
7893
- * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
7894
- * @param layerStyles The layer styles object from the WMS GetCapabilities
7895
- * @param layer The WMLayer to configure
7896
- */
7897
-
7898
-
7899
- var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS, layer) {
7900
- /* Get the Style object */
7901
- if (!layerObjectFromWMS.Style) return;
7902
- var layerStyles = toArray(layerObjectFromWMS.Style);
7903
- /* 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 */
7904
-
7905
- for (var k = 0; k < layerStyles.length; k += 1) {
7906
- var layerStyle = layerStyles[k];
7907
- var style = {
7908
- title: 'default',
7909
- name: 'default',
7910
- legendURL: '',
7911
- "abstract": 'No abstract available'
7912
- };
7913
-
7914
- try {
7915
- style.title = layerStyle.Title.value;
7916
- } catch (e) {
7917
- /* Do nothing */
7918
- }
7919
-
7920
- try {
7921
- style.name = layerStyle.Name.value;
7922
- } catch (e) {
7923
- /* Do nothing */
7924
- }
7925
-
7926
- try {
7927
- style.legendURL = layerStyle.LegendURL.OnlineResource.attr['xlink:href'];
7928
- } catch (e) {
7929
- /* Do nothing */
7930
- }
7931
-
7932
- try {
7933
- style["abstract"] = layerStyle.Abstract.value;
7934
- } catch (e) {
7935
- /* Do nothing */
7936
- }
7937
-
7938
- layer.styles.push(style);
7939
- }
7940
- };
7941
7989
  /**
7942
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.
7943
7991
  * @param layerObjectFromWMS The corresponding layer object from the WMS GetCapabilities.
@@ -7945,6 +7993,7 @@
7945
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.
7946
7994
  */
7947
7995
 
7996
+
7948
7997
  var addDimsForLayer = function addDimsForLayer(layerObjectFromWMS, layer, layerDimNamesToRemove) {
7949
7998
  /* Information from the WMS GetCapabilities document */
7950
7999
  var layerDims = toArray(layerObjectFromWMS.Dimension);
@@ -8017,8 +8066,8 @@
8017
8066
  });
8018
8067
  /* Check if the dimension should take the value from the map */
8019
8068
 
8020
- if (layer.parentMaps.length > 0) {
8021
- var mapDim = layer.parentMaps[0].getDimension(layerDim.name);
8069
+ if (layer.parentMap) {
8070
+ var mapDim = layer.parentMap.getDimension(layerDim.name);
8022
8071
 
8023
8072
  if (mapDim && mapDim.linked && isDefined(mapDim.currentValue)) {
8024
8073
  var dimensionCurrentValue = dimension.getClosestValue(mapDim.currentValue);
@@ -8053,13 +8102,17 @@
8053
8102
  */
8054
8103
 
8055
8104
  var configureStyles = function configureStyles(nestedLayerPath, wmLayer) {
8105
+ var _a;
8056
8106
  /* Now add the previous parent layer objects style info (inherit) and end with the Style info from this layer */
8107
+
8108
+
8057
8109
  try {
8058
8110
  for (var o = 0; o < nestedLayerPath.length; o += 1) {
8059
- addStylesForLayer(nestedLayerPath[o], wmLayer);
8111
+ // eslint-disable-next-line no-param-reassign
8112
+ (_a = wmLayer.styles).push.apply(_a, __spreadArray([], __read(addStylesForLayer(nestedLayerPath[o]))));
8060
8113
  } // eslint-disable-next-line no-empty
8061
8114
 
8062
- } catch (_a) {}
8115
+ } catch (_b) {}
8063
8116
  /* Set the default style */
8064
8117
 
8065
8118
 
@@ -8125,8 +8178,8 @@
8125
8178
  wmLayer.handleReferenceTime('reference_time', refTimeDimension.getValue());
8126
8179
  }
8127
8180
 
8128
- if (wmLayer.parentMaps && wmLayer.parentMaps.length > 0) {
8129
- wmLayer.parentMaps[0].configureMapDimensions(wmLayer);
8181
+ if (wmLayer.parentMap) {
8182
+ wmLayer.parentMap.configureMapDimensions(wmLayer);
8130
8183
  }
8131
8184
  };
8132
8185
 
@@ -8226,8 +8279,8 @@
8226
8279
  this.type = options.type;
8227
8280
  }
8228
8281
 
8229
- if (options.parentMaps) {
8230
- this.parentMaps = options.parentMaps;
8282
+ if (options.parentMap) {
8283
+ this.parentMap = options.parentMap;
8231
8284
  }
8232
8285
 
8233
8286
  if (options.headers) {
@@ -8241,8 +8294,6 @@
8241
8294
  this.timer = undefined;
8242
8295
  this.service = undefined; // URL of the WMS Service
8243
8296
 
8244
- this.WMJSService = undefined; // Corresponding WMJSService
8245
-
8246
8297
  this.getmapURL = undefined;
8247
8298
  this.getfeatureinfoURL = undefined;
8248
8299
  this.getlegendgraphicURL = undefined;
@@ -8273,9 +8324,8 @@
8273
8324
  this.id = '-1';
8274
8325
  this.opacity = 1.0; // Ranges from 0.0-1.0
8275
8326
 
8276
- this.getCapabilitiesDoc = undefined;
8277
8327
  this.serviceTitle = 'not defined';
8278
- this.parentMaps = [];
8328
+ this.parentMap = null;
8279
8329
  this.sldURL = null;
8280
8330
  this.isConfigured = false;
8281
8331
  };
@@ -8292,7 +8342,7 @@
8292
8342
  if (this.autoupdate) {
8293
8343
  var numDeltaMS = 60000;
8294
8344
  this.timer = setInterval(function () {
8295
- _this.parseLayer(undefined, true, undefined);
8345
+ _this.parseLayer(undefined, true, 'WMLayer toggleAutoUpdate');
8296
8346
  }, numDeltaMS);
8297
8347
  } else {
8298
8348
  clearInterval(this.timer);
@@ -8309,7 +8359,7 @@
8309
8359
  clearInterval(this.timer);
8310
8360
  } else {
8311
8361
  this.timer = setInterval(function () {
8312
- _this.parseLayer(callback, true, undefined);
8362
+ _this.parseLayer(callback, true, 'WMLayer setAutoUpdate');
8313
8363
  }, interval);
8314
8364
  }
8315
8365
  }
@@ -8317,10 +8367,7 @@
8317
8367
 
8318
8368
  WMLayer.prototype.setOpacity = function (opacityValue) {
8319
8369
  this.opacity = parseFloat(opacityValue);
8320
-
8321
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8322
- this.parentMaps[j].redrawBuffer();
8323
- }
8370
+ this.parentMap && this.parentMap.redrawBuffer();
8324
8371
  };
8325
8372
 
8326
8373
  WMLayer.prototype.getOpacity = function () {
@@ -8328,37 +8375,37 @@
8328
8375
  };
8329
8376
 
8330
8377
  WMLayer.prototype.remove = function () {
8331
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8332
- this.parentMaps[j].deleteLayer(this);
8333
- this.parentMaps[j].draw('WMLayer::remove');
8378
+ if (this.parentMap) {
8379
+ this.parentMap.deleteLayer(this);
8380
+ this.parentMap.draw('WMLayer::remove');
8334
8381
  }
8335
8382
 
8336
8383
  clearInterval(this.timer);
8337
8384
  };
8338
8385
 
8339
8386
  WMLayer.prototype.moveUp = function () {
8340
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8341
- this.parentMaps[j].moveLayerUp(this);
8342
- this.parentMaps[j].draw('WMLayer::moveUp');
8387
+ if (this.parentMap) {
8388
+ this.parentMap.moveLayerUp(this);
8389
+ this.parentMap.draw('WMLayer::moveUp');
8343
8390
  }
8344
8391
  };
8345
8392
 
8346
8393
  WMLayer.prototype.moveDown = function () {
8347
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8348
- this.parentMaps[j].moveLayerDown(this);
8349
- this.parentMaps[j].draw('WMLayer::moveDown');
8394
+ if (this.parentMap) {
8395
+ this.parentMap.moveLayerDown(this);
8396
+ this.parentMap.draw('WMLayer::moveDown');
8350
8397
  }
8351
8398
  };
8352
8399
 
8353
8400
  WMLayer.prototype.zoomToLayer = function () {
8354
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8355
- this.parentMaps[j].zoomToLayer(this);
8401
+ if (this.parentMap) {
8402
+ this.parentMap.zoomToLayer(this);
8356
8403
  }
8357
8404
  };
8358
8405
 
8359
8406
  WMLayer.prototype.draw = function (e) {
8360
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8361
- this.parentMaps[j].draw("WMLayer::draw::" + e);
8407
+ if (this.parentMap) {
8408
+ this.parentMap.draw("WMLayer::draw::" + e);
8362
8409
  }
8363
8410
  };
8364
8411
 
@@ -8375,9 +8422,9 @@
8375
8422
  timeDim.setTimeValuesForReferenceTime(value, referenceTimeDim);
8376
8423
 
8377
8424
  if (updateMapDimensions) {
8378
- if (this.parentMaps && this.parentMaps.length > 0) {
8425
+ if (this.parentMap) {
8379
8426
  if (this.enabled !== false) {
8380
- this.parentMaps[0].getListener().triggerEvent('ondimchange', 'time');
8427
+ this.parentMap.getListener().triggerEvent('ondimchange', 'time');
8381
8428
  }
8382
8429
  }
8383
8430
  }
@@ -8405,42 +8452,40 @@
8405
8452
 
8406
8453
  if (updateMapDimensions) {
8407
8454
  if (dim.linked === true) {
8408
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8409
- this.parentMaps[j].setDimension(name, dim.getValue());
8455
+ if (this.parentMap) {
8456
+ this.parentMap.setDimension(name, dim.getValue());
8410
8457
  }
8411
8458
  }
8412
8459
  }
8413
8460
  };
8414
8461
 
8415
- WMLayer.prototype.__parseGetCapForLayer = function (layer, getcapabilitiesjson, layerDoneCallback, fail) {
8462
+ WMLayer.prototype.__parseGetCapForLayer = function (getcapabilitiesjson, layerDoneCallback, fail) {
8416
8463
  var _this = this;
8417
8464
 
8418
- var jsondata = getcapabilitiesjson;
8419
-
8420
- if (!jsondata) {
8465
+ if (!getcapabilitiesjson) {
8421
8466
  this.title = I18n.service_has_error.text;
8422
8467
  this["abstract"] = I18n.not_available_message.text;
8423
- fail(layer, I18n.unable_to_connect_server.text);
8468
+ fail(this, I18n.unable_to_connect_server.text);
8424
8469
  return;
8425
8470
  }
8426
8471
 
8427
- var j = 0; // Get the capability object
8472
+ var wmjsService = WMGetServiceFromStore(this.service); // Get the capability object
8428
8473
 
8429
8474
  var capabilityObject;
8430
8475
 
8431
8476
  try {
8432
- capabilityObject = layer.WMJSService.getCapabilityElement(getcapabilitiesjson);
8477
+ capabilityObject = wmjsService.getCapabilityElement(getcapabilitiesjson);
8433
8478
  } catch (_a) {
8434
- fail(layer, 'No capability element in service');
8479
+ fail(this, 'No capability element in service');
8435
8480
  return;
8436
8481
  }
8437
8482
 
8438
- this.version = layer.WMJSService.version; // Get the rootLayer
8483
+ this.version = wmjsService.version; // Get the rootLayer
8439
8484
 
8440
8485
  var rootLayer = capabilityObject.Layer;
8441
8486
 
8442
8487
  if (!isDefined(rootLayer)) {
8443
- fail(layer, 'No Layer element in service');
8488
+ fail(this, 'No Layer element in service');
8444
8489
  return;
8445
8490
  }
8446
8491
 
@@ -8470,52 +8515,58 @@
8470
8515
  return;
8471
8516
  }
8472
8517
 
8473
- var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8518
+ this.getmapURL = undefined;
8474
8519
 
8475
- var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8476
- _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
+ }
8477
8525
 
8478
- try {
8479
- _this.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8480
- } catch (e) {
8481
- /* Do nothing */
8482
- }
8526
+ if (!isDefined(this.getmapURL)) {
8527
+ this.getmapURL = this.service;
8528
+ debug(exports.DebugType.Error, 'GetMap OnlineResource is not specified. Using default.');
8529
+ }
8483
8530
 
8484
- if (!isDefined(_this.getmapURL)) {
8485
- _this.getmapURL = _this.service;
8486
- debug(exports.DebugType.Error, 'GetMap OnlineResource is not specified. Using default.');
8487
- }
8531
+ this.getfeatureinfoURL = undefined;
8532
+
8533
+ try {
8534
+ this.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8535
+ } catch (e) {
8536
+ /* Do nothing */
8537
+ }
8488
8538
 
8489
- _this.getfeatureinfoURL = undefined;
8539
+ if (!isDefined(this.getfeatureinfoURL)) {
8540
+ this.getfeatureinfoURL = this.service;
8541
+ debug(exports.DebugType.Error, 'GetFeatureInfo OnlineResource is not specified. Using default.');
8542
+ }
8490
8543
 
8491
- try {
8492
- _this.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8493
- } catch (e) {
8494
- /* Do nothing */
8495
- }
8544
+ this.getlegendgraphicURL = undefined;
8496
8545
 
8497
- if (!isDefined(_this.getfeatureinfoURL)) {
8498
- _this.getfeatureinfoURL = _this.service;
8499
- debug(exports.DebugType.Error, 'GetFeatureInfo OnlineResource is not specified. Using default.');
8500
- }
8546
+ try {
8547
+ this.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8548
+ } catch (e) {
8549
+ /* Do nothing */
8550
+ }
8501
8551
 
8502
- _this.getlegendgraphicURL = undefined;
8552
+ if (!isDefined(this.getlegendgraphicURL)) {
8553
+ this.getlegendgraphicURL = this.service;
8554
+ } // TODO Should be arranged also for the other services:
8503
8555
 
8504
- try {
8505
- _this.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8506
- } catch (e) {
8507
- /* Do nothing */
8508
- }
8509
8556
 
8510
- if (!isDefined(_this.getlegendgraphicURL)) {
8511
- _this.getlegendgraphicURL = _this.service;
8512
- } // 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 */
8513
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
8514
8568
 
8515
- _this.getmapURL = WMJScheckURL(layer.getmapURL);
8516
- _this.getfeatureinfoURL = WMJScheckURL(layer.getfeatureinfoURL);
8517
- _this.getlegendgraphicURL = WMJScheckURL(layer.getlegendgraphicURL);
8518
- _this.getCapabilitiesDoc = jsondata;
8569
+ var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8519
8570
  _this.title = jsonlayer.Title.value;
8520
8571
 
8521
8572
  try {
@@ -8525,7 +8576,6 @@
8525
8576
  }
8526
8577
 
8527
8578
  _this.path = path;
8528
- _this.styles = [];
8529
8579
  /** ***************** Go through styles **************** */
8530
8580
 
8531
8581
  configureStyles(nestedLayerPath, _this);
@@ -8538,7 +8588,6 @@
8538
8588
  gp = toArray(jsonlayer.CRS);
8539
8589
  }
8540
8590
 
8541
- _this.projectionProperties = [];
8542
8591
  var tempSRS = [];
8543
8592
 
8544
8593
  var getgpbbox = function getgpbbox(data) {
@@ -8546,7 +8595,7 @@
8546
8595
  // Fill in SRS and BBOX on basis of BoundingBox attribute
8547
8596
  var gpbbox = toArray(data.BoundingBox);
8548
8597
 
8549
- for (j = 0; j < gpbbox.length; j += 1) {
8598
+ for (var j = 0; j < gpbbox.length; j += 1) {
8550
8599
  var srs = void 0;
8551
8600
  srs = gpbbox[j].attr.SRS;
8552
8601
 
@@ -8574,8 +8623,8 @@
8574
8623
  geoProperty.srs = srs;
8575
8624
  var swapBBOX = false;
8576
8625
 
8577
- if (layer.version === WMSVersion.version130) {
8578
- if (geoProperty.srs === 'EPSG:4326' && layer.wms130bboxcompatibilitymode === false) {
8626
+ if (_this.version === WMSVersion.version130) {
8627
+ if (geoProperty.srs === 'EPSG:4326' && _this.wms130bboxcompatibilitymode === false) {
8579
8628
  swapBBOX = true;
8580
8629
  }
8581
8630
  }
@@ -8603,7 +8652,7 @@
8603
8652
  getgpbbox(jsonlayer);
8604
8653
  getgpbbox(rootLayer); // Fill in SRS on basis of SRS attribute
8605
8654
 
8606
- for (j = 0; j < gp.length; j += 1) {
8655
+ for (var j = 0; j < gp.length; j += 1) {
8607
8656
  if (tempSRS.indexOf(gp[j].value) === -1) {
8608
8657
  var geoProperty = new WMProjection();
8609
8658
  debug(exports.DebugType.Error, "Warning: BoundingBOX missing for SRS " + gp[j].value);
@@ -8612,7 +8661,8 @@
8612
8661
  geoProperty.bbox.right = 180;
8613
8662
  geoProperty.bbox.top = 90;
8614
8663
  geoProperty.srs = gp[j].value;
8615
- layer.projectionProperties.push(geoProperty);
8664
+
8665
+ _this.projectionProperties.push(geoProperty);
8616
8666
  }
8617
8667
  }
8618
8668
 
@@ -8624,13 +8674,13 @@
8624
8674
  try {
8625
8675
  if (parseInt(jsonlayer.attr.queryable, 10) === 1) _this.queryable = true;else _this.queryable = false;
8626
8676
  } catch (e) {
8627
- debug(exports.DebugType.Error, "Unable to detect whether this layer is queryable (for layer " + layer.title + ")");
8677
+ debug(exports.DebugType.Error, "Unable to detect whether this layer is queryable (for layer " + _this.title + ")");
8628
8678
  }
8629
8679
 
8630
8680
  foundLayer = 1;
8631
8681
  };
8632
8682
 
8633
- function recursivelyFindLayer(JSONLayers, path, _prevNestedLayerPath) {
8683
+ function recursivelyFindLayer(thisLayer, JSONLayers, path, _prevNestedLayerPath) {
8634
8684
  for (var k = 0; k < JSONLayers.length; k += 1) {
8635
8685
  var nestedLayerPath_1 = [];
8636
8686
 
@@ -8649,9 +8699,9 @@
8649
8699
  /* Do nothing */
8650
8700
  }
8651
8701
 
8652
- recursivelyFindLayer(toArray(JSONLayers[k].Layer), pathnew, nestedLayerPath_1);
8702
+ recursivelyFindLayer(thisLayer, toArray(JSONLayers[k].Layer), pathnew, nestedLayerPath_1);
8653
8703
  } else if (JSONLayers[k].Name) {
8654
- if (JSONLayers[k].Name.value === layer.name) {
8704
+ if (JSONLayers[k].Name.value === thisLayer.name) {
8655
8705
  foundLayerFunction(JSONLayers[k], path, nestedLayerPath_1);
8656
8706
  return;
8657
8707
  }
@@ -8663,13 +8713,13 @@
8663
8713
  var JSONLayers = toArray(rootLayer.Layer);
8664
8714
  var path = '';
8665
8715
  var nestedLayerPath = [rootLayer];
8666
- recursivelyFindLayer(JSONLayers, path, nestedLayerPath);
8716
+ recursivelyFindLayer(this, JSONLayers, path, nestedLayerPath);
8667
8717
 
8668
8718
  if (foundLayer === 0) {
8669
8719
  // Layer was not found...
8670
8720
  var message = '';
8671
8721
 
8672
- if (layer.name) {
8722
+ if (this.name) {
8673
8723
  message = "Unable to find layer '" + this.name + "' in service '" + this.service + "'";
8674
8724
  } else {
8675
8725
  message = "Unable to find layer '" + this.title + "' in service '" + this.service + "'";
@@ -8697,7 +8747,8 @@
8697
8747
  */
8698
8748
 
8699
8749
 
8700
- WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload, xml2jsonrequest) {
8750
+ WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload, // eslint-disable-next-line no-unused-vars
8751
+ origin) {
8701
8752
  var _this = this;
8702
8753
 
8703
8754
  this.hasError = false;
@@ -8705,7 +8756,10 @@
8705
8756
  var layerDoneCallback = function layerDoneCallback(__layer) {
8706
8757
  if (isDefined(_layerDoneCallback)) {
8707
8758
  try {
8708
- _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
+
8709
8763
  } catch (e) {
8710
8764
  debug(exports.DebugType.Error, e);
8711
8765
  }
@@ -8724,20 +8778,13 @@
8724
8778
  };
8725
8779
 
8726
8780
  var callback = function callback(data) {
8727
- _this.__parseGetCapForLayer(_this, data, layerDoneCallback, fail);
8781
+ _this.__parseGetCapForLayer(data, layerDoneCallback, fail);
8728
8782
  };
8729
8783
 
8730
8784
  var requestfail = function requestfail() {
8731
8785
  fail(_this, I18n.no_capability_element_found.text);
8732
8786
  };
8733
8787
 
8734
- var newXml2jsonrequest = xml2jsonrequest;
8735
-
8736
- if (!xml2jsonrequest) {
8737
- newXml2jsonrequest = this.parentMaps && this.parentMaps.length > 0 ? this.parentMaps[0].xml2jsonrequest : undefined;
8738
- }
8739
-
8740
- this.WMJSService = WMGetServiceFromStore(this.service, newXml2jsonrequest);
8741
8788
  var options = {
8742
8789
  headers: {}
8743
8790
  };
@@ -8746,10 +8793,12 @@
8746
8793
  options.headers = this.headers;
8747
8794
  }
8748
8795
 
8749
- if (this.WMJSService.service !== undefined) {
8750
- this.WMJSService.getCapabilities(function (data) {
8796
+ var wmjsService = WMGetServiceFromStore(this.service);
8797
+
8798
+ if (wmjsService.service !== undefined) {
8799
+ wmjsService.getCapabilities(function (data) {
8751
8800
  callback(data);
8752
- }, requestfail, forceReload, xml2jsonrequest, options);
8801
+ }, requestfail, forceReload, options);
8753
8802
  }
8754
8803
  };
8755
8804
  /**
@@ -8774,7 +8823,7 @@
8774
8823
  } else {
8775
8824
  resolve(layer);
8776
8825
  }
8777
- }, forceReload);
8826
+ }, forceReload, 'WMLayer parseLayerPromise');
8778
8827
  });
8779
8828
  };
8780
8829
 
@@ -8824,7 +8873,8 @@
8824
8873
  success(layerObjects[currentLayerIndex], currentLayerIndex, layerObjects.length);
8825
8874
  };
8826
8875
 
8827
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8876
+ var wmjsService = WMGetServiceFromStore(this.service);
8877
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8828
8878
  };
8829
8879
 
8830
8880
  WMLayer.prototype.autoSelectLayer = function (success, failure) {
@@ -8841,7 +8891,8 @@
8841
8891
  }
8842
8892
  };
8843
8893
 
8844
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8894
+ var wmjsService = WMGetServiceFromStore(this.service);
8895
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8845
8896
  };
8846
8897
 
8847
8898
  WMLayer.prototype.getNextLayer = function (success, failure) {
@@ -9005,8 +9056,8 @@
9005
9056
  WMLayer.prototype.display = function (displayornot) {
9006
9057
  this.enabled = displayornot;
9007
9058
 
9008
- for (var j = 0; j < this.parentMaps.length; j += 1) {
9009
- this.parentMaps[j].displayLayer(this, this.enabled);
9059
+ if (this.parentMap) {
9060
+ this.parentMap.displayLayer(this, this.enabled);
9010
9061
  }
9011
9062
  };
9012
9063