@opengeoweb/webmap 2.1.0 → 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.
@@ -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");
@@ -3433,15 +3490,11 @@
3433
3490
  * Copyright 2020 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3434
3491
  * Copyright 2020 - Finnish Meteorological Institute (FMI)
3435
3492
  * */
3436
- var WMDrawMarker = function WMDrawMarker(context, coordx, coordy, fillColor, outlineColor) {
3493
+ var WMDrawMarker = function WMDrawMarker(context, coordx, coordy, fillColor) {
3437
3494
  if (fillColor === void 0) {
3438
3495
  fillColor = '#FFF';
3439
3496
  }
3440
3497
 
3441
- if (outlineColor === void 0) {
3442
- outlineColor = '#000';
3443
- }
3444
-
3445
3498
  var ctx = context;
3446
3499
  var coord = {
3447
3500
  x: parseInt(coordx.toString(), 10),
@@ -3450,8 +3503,8 @@
3450
3503
  ctx.fillStyle = fillColor;
3451
3504
  ctx.globalAlpha = 1.0;
3452
3505
  ctx.beginPath();
3453
- var topRadius = 9;
3454
- var topHeight = 2.5 * topRadius;
3506
+ var topRadius = 7;
3507
+ var topHeight = 2 * topRadius;
3455
3508
  ctx.arc(coord.x, coord.y - topHeight, topRadius, Math.PI, Math.PI * 2);
3456
3509
  ctx.bezierCurveTo(coord.x + topRadius, coord.y - topHeight, coord.x + topRadius / 1.6, coord.y - topRadius, coord.x, coord.y);
3457
3510
  ctx.bezierCurveTo(coord.x, coord.y, coord.x - topRadius / 1.6, coord.y - topRadius, coord.x - topRadius, coord.y - topHeight);
@@ -3461,13 +3514,7 @@
3461
3514
 
3462
3515
  ctx.fillStyle = '#FFF';
3463
3516
  ctx.beginPath();
3464
- ctx.arc(coord.x, coord.y - topHeight, topRadius / 2, Math.PI * 2, 0);
3465
- ctx.fill();
3466
- /* Fill marker exact location */
3467
-
3468
- ctx.fillStyle = outlineColor;
3469
- ctx.beginPath();
3470
- ctx.arc(coord.x, coord.y, 2, Math.PI * 2, 0);
3517
+ ctx.arc(coord.x, coord.y - topHeight, topRadius / 2.5, Math.PI * 2, 0);
3471
3518
  ctx.fill();
3472
3519
  };
3473
3520
 
@@ -3563,7 +3610,7 @@
3563
3610
 
3564
3611
  MapPin.prototype.drawMarker = function (ctx) {
3565
3612
  if (isDefined(this.x) && isDefined(this.y)) {
3566
- WMDrawMarker(ctx, this.x, this.y, '#9090FF', '#000');
3613
+ WMDrawMarker(ctx, this.x, this.y, '#051039');
3567
3614
  }
3568
3615
  };
3569
3616
 
@@ -4037,7 +4084,6 @@
4037
4084
  this.previousMouseButtonState = 'up';
4038
4085
  /* Binds */
4039
4086
 
4040
- this.setXML2JSONURL = this.setXML2JSONURL.bind(this);
4041
4087
  this.setWMTileRendererTileSettings = this.setWMTileRendererTileSettings.bind(this);
4042
4088
  this.makeComponentId = this.makeComponentId.bind(this);
4043
4089
  this.setMessage = this.setMessage.bind(this);
@@ -4162,10 +4208,6 @@
4162
4208
  this.init();
4163
4209
  }
4164
4210
 
4165
- WMJSMap.prototype.setXML2JSONURL = function (_xml2jsonrequest) {
4166
- this.xml2jsonrequest = _xml2jsonrequest;
4167
- };
4168
-
4169
4211
  WMJSMap.prototype.setWMTileRendererTileSettings = function (_WMTileRendererTileSettings) {
4170
4212
  this.tileRenderSettings = _WMTileRendererTileSettings;
4171
4213
  };
@@ -4474,6 +4516,7 @@
4474
4516
 
4475
4517
  ctx.font = '10px Helvetica';
4476
4518
  ctx.textBaseline = 'middle';
4519
+ ctx.textAlign = 'left';
4477
4520
 
4478
4521
  if (isDefined(this.mouseGeoCoordXY)) {
4479
4522
  var roundingFactor = 1.0 / Math.pow(10, parseInt(Math.log((this.bbox.right - this.bbox.left) / this.width) / Math.log(10), 10) - 2);
@@ -4505,6 +4548,30 @@
4505
4548
 
4506
4549
  ctx.fillStyle = '#000000';
4507
4550
  ctx.fillText("Map projection: " + this.srs, 5, this.height - 26);
4551
+ /* Show layer metadata */
4552
+
4553
+ if (this.showLayerInfo === true) {
4554
+ var metadataX = 100;
4555
+ var metadataY = 100;
4556
+ var dimStartX = 150;
4557
+ var rowHeight = 26;
4558
+ var rowNumber = 0;
4559
+ drawTextBG(ctx, 'Layer name', metadataX, metadataY + rowNumber * rowHeight, 10);
4560
+ drawTextBG(ctx, 'Dimensions', metadataX + dimStartX, metadataY + rowNumber * rowHeight, 10);
4561
+ rowNumber += 1;
4562
+
4563
+ for (var j = 0; j < this.layers.length; j += 1) {
4564
+ var layer = this.layers[j];
4565
+ drawTextBG(ctx, "#" + j + ":" + layer.name, metadataX, metadataY + rowNumber * rowHeight, 10);
4566
+
4567
+ for (var d = 0; d < layer.dimensions.length; d += 1) {
4568
+ var dimension = layer.dimensions[d];
4569
+ drawTextBG(ctx, dimension.name + " = " + dimension.currentValue, metadataX + d * 200 + dimStartX, metadataY + rowNumber * rowHeight, 10);
4570
+ }
4571
+
4572
+ rowNumber += 1;
4573
+ }
4574
+ }
4508
4575
  };
4509
4576
  /* Is called when the WebMapJS object is created */
4510
4577
 
@@ -4912,10 +4979,10 @@
4912
4979
  reject(new Error('layer has no constructor'));
4913
4980
  return;
4914
4981
  }
4982
+ /* Set a reference in the layer to this map */
4915
4983
 
4916
- if (!layer.parentMaps.includes(_this)) {
4917
- layer.parentMaps.push(_this);
4918
- }
4984
+
4985
+ layer.parentMap = _this;
4919
4986
 
4920
4987
  _this.layers.push(layer);
4921
4988
 
@@ -4927,7 +4994,7 @@
4927
4994
  resolve(_this);
4928
4995
  };
4929
4996
 
4930
- layer.parseLayer(done, undefined);
4997
+ layer.parseLayer(done, undefined, 'WMJSMap addLayer');
4931
4998
  });
4932
4999
  };
4933
5000
 
@@ -4950,6 +5017,11 @@
4950
5017
  }
4951
5018
 
4952
5019
  if (!_srs) _srs = 'EPSG:4326';
5020
+
5021
+ if (this.srs !== _srs) {
5022
+ this.defaultBBOX.setBBOX(_bbox);
5023
+ }
5024
+
4953
5025
  this.srs = _srs;
4954
5026
 
4955
5027
  if (this.proj4.srs !== this.srs || !isDefined(this.proj4.projection)) {
@@ -4963,7 +5035,6 @@
4963
5035
  }
4964
5036
 
4965
5037
  this.setBBOX(_bbox);
4966
- this.defaultBBOX.setBBOX(_bbox);
4967
5038
  this.updateMouseCursorCoordinates(undefined);
4968
5039
  this.callBack.triggerEvent('onsetprojection', [this.srs, this.bbox]);
4969
5040
  };
@@ -5250,12 +5321,19 @@
5250
5321
  if (animationList !== undefined) {
5251
5322
  if (_typeof(animationList) === 'object') {
5252
5323
  if (animationList.length > 0) {
5324
+ // Ensure the time dimension has been loaded for the map before starting animation
5325
+ var timeDim = this.getDimension('time');
5326
+
5327
+ if (!timeDim) {
5328
+ return;
5329
+ }
5330
+
5331
+ var selectedTime = timeDim.currentValue;
5253
5332
  this.isAnimating = true;
5254
5333
  this.callBack.triggerEvent('onstartanimation', this);
5255
5334
  this.currentAnimationStep = 0;
5256
5335
  this.animationList = [];
5257
5336
  this.mouseHoverAnimationBox = false;
5258
- var selectedTime = this.getDimension('time').currentValue;
5259
5337
 
5260
5338
  for (var j = 0; j < animationList.length; j += 1) {
5261
5339
  if (selectedTime && animationList[j].value === selectedTime) {
@@ -5427,9 +5505,7 @@
5427
5505
  this.baseLayers = layer;
5428
5506
 
5429
5507
  for (var j = 0; j < this.baseLayers.length; j += 1) {
5430
- if (!this.baseLayers[j].parentMaps.includes(this)) {
5431
- this.baseLayers[j].parentMaps.push(this);
5432
- }
5508
+ this.baseLayers[j].parentMap = this;
5433
5509
 
5434
5510
  if (this.baseLayers[j].keepOnTop !== true) {
5435
5511
  this.numBaseLayers += 1;
@@ -7301,7 +7377,7 @@
7301
7377
  * Global getcapabilities function
7302
7378
  */
7303
7379
 
7304
- var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, xml2jsonrequestURL, options, disableCache) {
7380
+ var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, options, disableCache) {
7305
7381
  if (disableCache === void 0) {
7306
7382
  disableCache = false;
7307
7383
  }
@@ -7349,7 +7425,6 @@
7349
7425
  random: Math.random()
7350
7426
  } : {};
7351
7427
  var url = getWMSUrl(service, addParams);
7352
- var newXml2jsonrequestURL = xml2jsonrequestURL;
7353
7428
  WMXMLParser(url, headers).then(function (data) {
7354
7429
  try {
7355
7430
  succes(data);
@@ -7359,7 +7434,7 @@
7359
7434
  })["catch"](function () {
7360
7435
  loadGetCapabilitiesViaProxy(url, succes, function () {
7361
7436
  fail("Request failed for " + url);
7362
- }, newXml2jsonrequestURL);
7437
+ }, WMServiceStoreXML2JSONRequest.proxy);
7363
7438
  });
7364
7439
  };
7365
7440
  var sortByKey = function sortByKey(array, key) {
@@ -7394,13 +7469,15 @@
7394
7469
  keywords: toArray(layers[j].KeywordList && layers[j].KeywordList.Keyword).map(function (keywords) {
7395
7470
  return keywords.value;
7396
7471
  }),
7397
- "abstract": layers[j].Abstract && layers[j].Abstract.value
7472
+ "abstract": layers[j].Abstract && layers[j].Abstract.value,
7473
+ styles: addStylesForLayer(layers[j])
7398
7474
  };
7399
7475
  } else {
7400
7476
  var nodeText = isNull(layers[j].Title) ? 'Layer' : layers[j].Title.value;
7401
7477
  nodeObject = {
7402
7478
  text: nodeText,
7403
- leaf: isleaf
7479
+ leaf: isleaf,
7480
+ styles: []
7404
7481
  };
7405
7482
  }
7406
7483
 
@@ -7420,7 +7497,6 @@
7420
7497
  *
7421
7498
  * options:
7422
7499
  * service
7423
- * xml2jsonrequestURL
7424
7500
  * title (optional)
7425
7501
  */
7426
7502
 
@@ -7441,7 +7517,6 @@
7441
7517
  if (options) {
7442
7518
  this.service = options.service;
7443
7519
  this.title = options.title;
7444
- this.xml2jsonrequestURL = options.xml2jsonrequestURL;
7445
7520
  }
7446
7521
 
7447
7522
  this.checkVersion111 = this.checkVersion111.bind(this);
@@ -7558,7 +7633,7 @@
7558
7633
  */
7559
7634
 
7560
7635
 
7561
- WMJSService.prototype.getCapabilities = function (succescallback, failcallback, forceReload, xml2jsonrequestURL, options) {
7636
+ WMJSService.prototype.getCapabilities = function (succescallback, failcallback, forceReload, options) {
7562
7637
  var _this = this;
7563
7638
 
7564
7639
  if (options) {
@@ -7643,7 +7718,7 @@
7643
7718
  return null;
7644
7719
  }, function () {
7645
7720
  return null;
7646
- }, false, xml2jsonrequestURL, options);
7721
+ }, false, options);
7647
7722
 
7648
7723
  var current;
7649
7724
 
@@ -7652,14 +7727,9 @@
7652
7727
  }
7653
7728
  };
7654
7729
 
7655
- WMJSGetCapabilities(this.service, succes, fail_1, xml2jsonrequestURL, options);
7730
+ WMJSGetCapabilities(this.service, succes, fail_1, options);
7656
7731
  } else {
7657
- /* The callbacks are not allowed to be called in the scope of this object.
7658
- By using window.setTimeOut they are externally called
7659
- */
7660
- window.setTimeout(function () {
7661
- succescallback(_this.getcapabilitiesDoc);
7662
- }, 1);
7732
+ succescallback(this.getcapabilitiesDoc);
7663
7733
  }
7664
7734
  }; // eslint-disable-next-line class-methods-use-this
7665
7735
 
@@ -7696,13 +7766,9 @@
7696
7766
  */
7697
7767
 
7698
7768
 
7699
- WMJSService.prototype.getNodes = function (succes, failure, forceReload, xml2jsonrequestURL, options) {
7769
+ WMJSService.prototype.getNodes = function (succes, failure, forceReload, options) {
7700
7770
  var _this = this;
7701
7771
 
7702
- if (xml2jsonrequestURL === void 0) {
7703
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7704
- }
7705
-
7706
7772
  this.nodeCache = undefined;
7707
7773
 
7708
7774
  if (!failure) {
@@ -7751,29 +7817,20 @@
7751
7817
  failure(data);
7752
7818
  };
7753
7819
 
7754
- this.getCapabilities(callback, fail, forceReload, xml2jsonrequestURL, options);
7820
+ this.getCapabilities(callback, fail, forceReload, options);
7755
7821
  };
7756
7822
  /** Calls succes with an array of all layerobjects
7757
7823
  * Calls failure when something goes wrong
7758
7824
  */
7759
7825
 
7760
7826
 
7761
- WMJSService.prototype.getLayerObjectsFlat = function (succes, failure, forceReload, xml2jsonrequestURL, options) {
7827
+ WMJSService.prototype.getLayerObjectsFlat = function (succes, failure, forceReload, options) {
7762
7828
  var _this = this;
7763
7829
 
7764
- if (xml2jsonrequestURL === void 0) {
7765
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7766
- }
7767
-
7768
7830
  if (options === void 0) {
7769
7831
  options = this._options;
7770
7832
  }
7771
7833
 
7772
- if (!xml2jsonrequestURL) {
7773
- // eslint-disable-next-line no-param-reassign
7774
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7775
- }
7776
-
7777
7834
  if (isDefined(this._flatLayerObject) && forceReload !== true) {
7778
7835
  succes(this._flatLayerObject);
7779
7836
  return;
@@ -7798,7 +7855,7 @@
7798
7855
  succes(_this._flatLayerObject);
7799
7856
  };
7800
7857
 
7801
- this.getNodes(callback, failure, forceReload, xml2jsonrequestURL, options);
7858
+ this.getNodes(callback, failure, forceReload, options);
7802
7859
  };
7803
7860
 
7804
7861
  return WMJSService;
@@ -7821,20 +7878,15 @@
7821
7878
  * Copyright 2020 - Finnish Meteorological Institute (FMI)
7822
7879
  * */
7823
7880
 
7824
- var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName, xml2jsonrequestURL) {
7881
+ var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName) {
7825
7882
  for (var j = 0; j < WMServiceStore.length; j += 1) {
7826
7883
  if (WMServiceStore[j].service === serviceName) {
7827
7884
  return WMServiceStore[j];
7828
7885
  }
7829
7886
  }
7830
7887
 
7831
- if (xml2jsonrequestURL) {
7832
- WMServiceStoreXML2JSONRequest.proxy = xml2jsonrequestURL;
7833
- }
7834
-
7835
7888
  var service = new WMJSService({
7836
- service: serviceName,
7837
- xml2jsonrequestURL: WMServiceStoreXML2JSONRequest.proxy
7889
+ service: serviceName
7838
7890
  });
7839
7891
  WMServiceStore.push(service);
7840
7892
  return service;
@@ -7863,55 +7915,6 @@
7863
7915
  LayerType["baseLayer"] = "baseLayer";
7864
7916
  LayerType["overLayer"] = "overLayer";
7865
7917
  })(exports.LayerType || (exports.LayerType = {}));
7866
- /**
7867
- * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
7868
- * @param layerStyles The layer styles object from the WMS GetCapabilities
7869
- * @param layer The WMLayer to configure
7870
- */
7871
-
7872
-
7873
- var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS, layer) {
7874
- /* Get the Style object */
7875
- if (!layerObjectFromWMS.Style) return;
7876
- var layerStyles = toArray(layerObjectFromWMS.Style);
7877
- /* 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 */
7878
-
7879
- for (var k = 0; k < layerStyles.length; k += 1) {
7880
- var layerStyle = layerStyles[k];
7881
- var style = {
7882
- title: 'default',
7883
- name: 'default',
7884
- legendURL: '',
7885
- "abstract": 'No abstract available'
7886
- };
7887
-
7888
- try {
7889
- style.title = layerStyle.Title.value;
7890
- } catch (e) {
7891
- /* Do nothing */
7892
- }
7893
-
7894
- try {
7895
- style.name = layerStyle.Name.value;
7896
- } catch (e) {
7897
- /* Do nothing */
7898
- }
7899
-
7900
- try {
7901
- style.legendURL = layerStyle.LegendURL.OnlineResource.attr['xlink:href'];
7902
- } catch (e) {
7903
- /* Do nothing */
7904
- }
7905
-
7906
- try {
7907
- style["abstract"] = layerStyle.Abstract.value;
7908
- } catch (e) {
7909
- /* Do nothing */
7910
- }
7911
-
7912
- layer.styles.push(style);
7913
- }
7914
- };
7915
7918
  /**
7916
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.
7917
7920
  * @param layerObjectFromWMS The corresponding layer object from the WMS GetCapabilities.
@@ -7919,6 +7922,7 @@
7919
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.
7920
7923
  */
7921
7924
 
7925
+
7922
7926
  var addDimsForLayer = function addDimsForLayer(layerObjectFromWMS, layer, layerDimNamesToRemove) {
7923
7927
  /* Information from the WMS GetCapabilities document */
7924
7928
  var layerDims = toArray(layerObjectFromWMS.Dimension);
@@ -7991,8 +7995,8 @@
7991
7995
  });
7992
7996
  /* Check if the dimension should take the value from the map */
7993
7997
 
7994
- if (layer.parentMaps.length > 0) {
7995
- var mapDim = layer.parentMaps[0].getDimension(layerDim.name);
7998
+ if (layer.parentMap) {
7999
+ var mapDim = layer.parentMap.getDimension(layerDim.name);
7996
8000
 
7997
8001
  if (mapDim && mapDim.linked && isDefined(mapDim.currentValue)) {
7998
8002
  var dimensionCurrentValue = dimension.getClosestValue(mapDim.currentValue);
@@ -8027,13 +8031,17 @@
8027
8031
  */
8028
8032
 
8029
8033
  var configureStyles = function configureStyles(nestedLayerPath, wmLayer) {
8034
+ var _a;
8030
8035
  /* Now add the previous parent layer objects style info (inherit) and end with the Style info from this layer */
8036
+
8037
+
8031
8038
  try {
8032
8039
  for (var o = 0; o < nestedLayerPath.length; o += 1) {
8033
- addStylesForLayer(nestedLayerPath[o], wmLayer);
8040
+ // eslint-disable-next-line no-param-reassign
8041
+ (_a = wmLayer.styles).push.apply(_a, __spreadArray([], __read(addStylesForLayer(nestedLayerPath[o]))));
8034
8042
  } // eslint-disable-next-line no-empty
8035
8043
 
8036
- } catch (_a) {}
8044
+ } catch (_b) {}
8037
8045
  /* Set the default style */
8038
8046
 
8039
8047
 
@@ -8099,8 +8107,8 @@
8099
8107
  wmLayer.handleReferenceTime('reference_time', refTimeDimension.getValue());
8100
8108
  }
8101
8109
 
8102
- if (wmLayer.parentMaps && wmLayer.parentMaps.length > 0) {
8103
- wmLayer.parentMaps[0].configureMapDimensions(wmLayer);
8110
+ if (wmLayer.parentMap) {
8111
+ wmLayer.parentMap.configureMapDimensions(wmLayer);
8104
8112
  }
8105
8113
  };
8106
8114
 
@@ -8200,8 +8208,8 @@
8200
8208
  this.type = options.type;
8201
8209
  }
8202
8210
 
8203
- if (options.parentMaps) {
8204
- this.parentMaps = options.parentMaps;
8211
+ if (options.parentMap) {
8212
+ this.parentMap = options.parentMap;
8205
8213
  }
8206
8214
 
8207
8215
  if (options.headers) {
@@ -8215,8 +8223,6 @@
8215
8223
  this.timer = undefined;
8216
8224
  this.service = undefined; // URL of the WMS Service
8217
8225
 
8218
- this.WMJSService = undefined; // Corresponding WMJSService
8219
-
8220
8226
  this.getmapURL = undefined;
8221
8227
  this.getfeatureinfoURL = undefined;
8222
8228
  this.getlegendgraphicURL = undefined;
@@ -8247,9 +8253,8 @@
8247
8253
  this.id = '-1';
8248
8254
  this.opacity = 1.0; // Ranges from 0.0-1.0
8249
8255
 
8250
- this.getCapabilitiesDoc = undefined;
8251
8256
  this.serviceTitle = 'not defined';
8252
- this.parentMaps = [];
8257
+ this.parentMap = null;
8253
8258
  this.sldURL = null;
8254
8259
  this.isConfigured = false;
8255
8260
  };
@@ -8266,7 +8271,7 @@
8266
8271
  if (this.autoupdate) {
8267
8272
  var numDeltaMS = 60000;
8268
8273
  this.timer = setInterval(function () {
8269
- _this.parseLayer(undefined, true, undefined);
8274
+ _this.parseLayer(undefined, true, 'WMLayer toggleAutoUpdate');
8270
8275
  }, numDeltaMS);
8271
8276
  } else {
8272
8277
  clearInterval(this.timer);
@@ -8283,7 +8288,7 @@
8283
8288
  clearInterval(this.timer);
8284
8289
  } else {
8285
8290
  this.timer = setInterval(function () {
8286
- _this.parseLayer(callback, true, undefined);
8291
+ _this.parseLayer(callback, true, 'WMLayer setAutoUpdate');
8287
8292
  }, interval);
8288
8293
  }
8289
8294
  }
@@ -8291,10 +8296,7 @@
8291
8296
 
8292
8297
  WMLayer.prototype.setOpacity = function (opacityValue) {
8293
8298
  this.opacity = parseFloat(opacityValue);
8294
-
8295
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8296
- this.parentMaps[j].redrawBuffer();
8297
- }
8299
+ this.parentMap && this.parentMap.redrawBuffer();
8298
8300
  };
8299
8301
 
8300
8302
  WMLayer.prototype.getOpacity = function () {
@@ -8302,37 +8304,37 @@
8302
8304
  };
8303
8305
 
8304
8306
  WMLayer.prototype.remove = function () {
8305
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8306
- this.parentMaps[j].deleteLayer(this);
8307
- this.parentMaps[j].draw('WMLayer::remove');
8307
+ if (this.parentMap) {
8308
+ this.parentMap.deleteLayer(this);
8309
+ this.parentMap.draw('WMLayer::remove');
8308
8310
  }
8309
8311
 
8310
8312
  clearInterval(this.timer);
8311
8313
  };
8312
8314
 
8313
8315
  WMLayer.prototype.moveUp = function () {
8314
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8315
- this.parentMaps[j].moveLayerUp(this);
8316
- this.parentMaps[j].draw('WMLayer::moveUp');
8316
+ if (this.parentMap) {
8317
+ this.parentMap.moveLayerUp(this);
8318
+ this.parentMap.draw('WMLayer::moveUp');
8317
8319
  }
8318
8320
  };
8319
8321
 
8320
8322
  WMLayer.prototype.moveDown = function () {
8321
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8322
- this.parentMaps[j].moveLayerDown(this);
8323
- this.parentMaps[j].draw('WMLayer::moveDown');
8323
+ if (this.parentMap) {
8324
+ this.parentMap.moveLayerDown(this);
8325
+ this.parentMap.draw('WMLayer::moveDown');
8324
8326
  }
8325
8327
  };
8326
8328
 
8327
8329
  WMLayer.prototype.zoomToLayer = function () {
8328
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8329
- this.parentMaps[j].zoomToLayer(this);
8330
+ if (this.parentMap) {
8331
+ this.parentMap.zoomToLayer(this);
8330
8332
  }
8331
8333
  };
8332
8334
 
8333
8335
  WMLayer.prototype.draw = function (e) {
8334
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8335
- this.parentMaps[j].draw("WMLayer::draw::" + e);
8336
+ if (this.parentMap) {
8337
+ this.parentMap.draw("WMLayer::draw::" + e);
8336
8338
  }
8337
8339
  };
8338
8340
 
@@ -8349,9 +8351,9 @@
8349
8351
  timeDim.setTimeValuesForReferenceTime(value, referenceTimeDim);
8350
8352
 
8351
8353
  if (updateMapDimensions) {
8352
- if (this.parentMaps && this.parentMaps.length > 0) {
8354
+ if (this.parentMap) {
8353
8355
  if (this.enabled !== false) {
8354
- this.parentMaps[0].getListener().triggerEvent('ondimchange', 'time');
8356
+ this.parentMap.getListener().triggerEvent('ondimchange', 'time');
8355
8357
  }
8356
8358
  }
8357
8359
  }
@@ -8379,42 +8381,40 @@
8379
8381
 
8380
8382
  if (updateMapDimensions) {
8381
8383
  if (dim.linked === true) {
8382
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8383
- this.parentMaps[j].setDimension(name, dim.getValue());
8384
+ if (this.parentMap) {
8385
+ this.parentMap.setDimension(name, dim.getValue());
8384
8386
  }
8385
8387
  }
8386
8388
  }
8387
8389
  };
8388
8390
 
8389
- WMLayer.prototype.__parseGetCapForLayer = function (layer, getcapabilitiesjson, layerDoneCallback, fail) {
8391
+ WMLayer.prototype.__parseGetCapForLayer = function (getcapabilitiesjson, layerDoneCallback, fail) {
8390
8392
  var _this = this;
8391
8393
 
8392
- var jsondata = getcapabilitiesjson;
8393
-
8394
- if (!jsondata) {
8394
+ if (!getcapabilitiesjson) {
8395
8395
  this.title = I18n.service_has_error.text;
8396
8396
  this["abstract"] = I18n.not_available_message.text;
8397
- fail(layer, I18n.unable_to_connect_server.text);
8397
+ fail(this, I18n.unable_to_connect_server.text);
8398
8398
  return;
8399
8399
  }
8400
8400
 
8401
- var j = 0; // Get the capability object
8401
+ var wmjsService = WMGetServiceFromStore(this.service); // Get the capability object
8402
8402
 
8403
8403
  var capabilityObject;
8404
8404
 
8405
8405
  try {
8406
- capabilityObject = layer.WMJSService.getCapabilityElement(getcapabilitiesjson);
8406
+ capabilityObject = wmjsService.getCapabilityElement(getcapabilitiesjson);
8407
8407
  } catch (_a) {
8408
- fail(layer, 'No capability element in service');
8408
+ fail(this, 'No capability element in service');
8409
8409
  return;
8410
8410
  }
8411
8411
 
8412
- this.version = layer.WMJSService.version; // Get the rootLayer
8412
+ this.version = wmjsService.version; // Get the rootLayer
8413
8413
 
8414
8414
  var rootLayer = capabilityObject.Layer;
8415
8415
 
8416
8416
  if (!isDefined(rootLayer)) {
8417
- fail(layer, 'No Layer element in service');
8417
+ fail(this, 'No Layer element in service');
8418
8418
  return;
8419
8419
  }
8420
8420
 
@@ -8444,52 +8444,58 @@
8444
8444
  return;
8445
8445
  }
8446
8446
 
8447
- var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8447
+ this.getmapURL = undefined;
8448
8448
 
8449
- var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8450
- _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
+ }
8451
8454
 
8452
- try {
8453
- _this.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8454
- } catch (e) {
8455
- /* Do nothing */
8456
- }
8455
+ if (!isDefined(this.getmapURL)) {
8456
+ this.getmapURL = this.service;
8457
+ debug(exports.DebugType.Error, 'GetMap OnlineResource is not specified. Using default.');
8458
+ }
8457
8459
 
8458
- if (!isDefined(_this.getmapURL)) {
8459
- _this.getmapURL = _this.service;
8460
- debug(exports.DebugType.Error, 'GetMap OnlineResource is not specified. Using default.');
8461
- }
8460
+ this.getfeatureinfoURL = undefined;
8462
8461
 
8463
- _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
+ }
8464
8467
 
8465
- try {
8466
- _this.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8467
- } catch (e) {
8468
- /* Do nothing */
8469
- }
8468
+ if (!isDefined(this.getfeatureinfoURL)) {
8469
+ this.getfeatureinfoURL = this.service;
8470
+ debug(exports.DebugType.Error, 'GetFeatureInfo OnlineResource is not specified. Using default.');
8471
+ }
8470
8472
 
8471
- if (!isDefined(_this.getfeatureinfoURL)) {
8472
- _this.getfeatureinfoURL = _this.service;
8473
- debug(exports.DebugType.Error, 'GetFeatureInfo OnlineResource is not specified. Using default.');
8474
- }
8473
+ this.getlegendgraphicURL = undefined;
8475
8474
 
8476
- _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
+ }
8477
8480
 
8478
- try {
8479
- _this.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8480
- } catch (e) {
8481
- /* Do nothing */
8482
- }
8481
+ if (!isDefined(this.getlegendgraphicURL)) {
8482
+ this.getlegendgraphicURL = this.service;
8483
+ } // TODO Should be arranged also for the other services:
8483
8484
 
8484
- if (!isDefined(_this.getlegendgraphicURL)) {
8485
- _this.getlegendgraphicURL = _this.service;
8486
- } // TODO Should be arranged also for the other services:
8487
8485
 
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 */
8488
8492
 
8489
- _this.getmapURL = WMJScheckURL(layer.getmapURL);
8490
- _this.getfeatureinfoURL = WMJScheckURL(layer.getfeatureinfoURL);
8491
- _this.getlegendgraphicURL = WMJScheckURL(layer.getlegendgraphicURL);
8492
- _this.getCapabilitiesDoc = jsondata;
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
8497
+
8498
+ var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8493
8499
  _this.title = jsonlayer.Title.value;
8494
8500
 
8495
8501
  try {
@@ -8499,7 +8505,6 @@
8499
8505
  }
8500
8506
 
8501
8507
  _this.path = path;
8502
- _this.styles = [];
8503
8508
  /** ***************** Go through styles **************** */
8504
8509
 
8505
8510
  configureStyles(nestedLayerPath, _this);
@@ -8512,7 +8517,6 @@
8512
8517
  gp = toArray(jsonlayer.CRS);
8513
8518
  }
8514
8519
 
8515
- _this.projectionProperties = [];
8516
8520
  var tempSRS = [];
8517
8521
 
8518
8522
  var getgpbbox = function getgpbbox(data) {
@@ -8520,7 +8524,7 @@
8520
8524
  // Fill in SRS and BBOX on basis of BoundingBox attribute
8521
8525
  var gpbbox = toArray(data.BoundingBox);
8522
8526
 
8523
- for (j = 0; j < gpbbox.length; j += 1) {
8527
+ for (var j = 0; j < gpbbox.length; j += 1) {
8524
8528
  var srs = void 0;
8525
8529
  srs = gpbbox[j].attr.SRS;
8526
8530
 
@@ -8548,8 +8552,8 @@
8548
8552
  geoProperty.srs = srs;
8549
8553
  var swapBBOX = false;
8550
8554
 
8551
- if (layer.version === WMSVersion.version130) {
8552
- if (geoProperty.srs === 'EPSG:4326' && layer.wms130bboxcompatibilitymode === false) {
8555
+ if (_this.version === WMSVersion.version130) {
8556
+ if (geoProperty.srs === 'EPSG:4326' && _this.wms130bboxcompatibilitymode === false) {
8553
8557
  swapBBOX = true;
8554
8558
  }
8555
8559
  }
@@ -8577,7 +8581,7 @@
8577
8581
  getgpbbox(jsonlayer);
8578
8582
  getgpbbox(rootLayer); // Fill in SRS on basis of SRS attribute
8579
8583
 
8580
- for (j = 0; j < gp.length; j += 1) {
8584
+ for (var j = 0; j < gp.length; j += 1) {
8581
8585
  if (tempSRS.indexOf(gp[j].value) === -1) {
8582
8586
  var geoProperty = new WMProjection();
8583
8587
  debug(exports.DebugType.Error, "Warning: BoundingBOX missing for SRS " + gp[j].value);
@@ -8586,7 +8590,8 @@
8586
8590
  geoProperty.bbox.right = 180;
8587
8591
  geoProperty.bbox.top = 90;
8588
8592
  geoProperty.srs = gp[j].value;
8589
- layer.projectionProperties.push(geoProperty);
8593
+
8594
+ _this.projectionProperties.push(geoProperty);
8590
8595
  }
8591
8596
  }
8592
8597
 
@@ -8598,13 +8603,13 @@
8598
8603
  try {
8599
8604
  if (parseInt(jsonlayer.attr.queryable, 10) === 1) _this.queryable = true;else _this.queryable = false;
8600
8605
  } catch (e) {
8601
- debug(exports.DebugType.Error, "Unable to detect whether this layer is queryable (for layer " + layer.title + ")");
8606
+ debug(exports.DebugType.Error, "Unable to detect whether this layer is queryable (for layer " + _this.title + ")");
8602
8607
  }
8603
8608
 
8604
8609
  foundLayer = 1;
8605
8610
  };
8606
8611
 
8607
- function recursivelyFindLayer(JSONLayers, path, _prevNestedLayerPath) {
8612
+ function recursivelyFindLayer(thisLayer, JSONLayers, path, _prevNestedLayerPath) {
8608
8613
  for (var k = 0; k < JSONLayers.length; k += 1) {
8609
8614
  var nestedLayerPath_1 = [];
8610
8615
 
@@ -8623,9 +8628,9 @@
8623
8628
  /* Do nothing */
8624
8629
  }
8625
8630
 
8626
- recursivelyFindLayer(toArray(JSONLayers[k].Layer), pathnew, nestedLayerPath_1);
8631
+ recursivelyFindLayer(thisLayer, toArray(JSONLayers[k].Layer), pathnew, nestedLayerPath_1);
8627
8632
  } else if (JSONLayers[k].Name) {
8628
- if (JSONLayers[k].Name.value === layer.name) {
8633
+ if (JSONLayers[k].Name.value === thisLayer.name) {
8629
8634
  foundLayerFunction(JSONLayers[k], path, nestedLayerPath_1);
8630
8635
  return;
8631
8636
  }
@@ -8637,13 +8642,13 @@
8637
8642
  var JSONLayers = toArray(rootLayer.Layer);
8638
8643
  var path = '';
8639
8644
  var nestedLayerPath = [rootLayer];
8640
- recursivelyFindLayer(JSONLayers, path, nestedLayerPath);
8645
+ recursivelyFindLayer(this, JSONLayers, path, nestedLayerPath);
8641
8646
 
8642
8647
  if (foundLayer === 0) {
8643
8648
  // Layer was not found...
8644
8649
  var message = '';
8645
8650
 
8646
- if (layer.name) {
8651
+ if (this.name) {
8647
8652
  message = "Unable to find layer '" + this.name + "' in service '" + this.service + "'";
8648
8653
  } else {
8649
8654
  message = "Unable to find layer '" + this.title + "' in service '" + this.service + "'";
@@ -8671,7 +8676,8 @@
8671
8676
  */
8672
8677
 
8673
8678
 
8674
- WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload, xml2jsonrequest) {
8679
+ WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload, // eslint-disable-next-line no-unused-vars
8680
+ origin) {
8675
8681
  var _this = this;
8676
8682
 
8677
8683
  this.hasError = false;
@@ -8679,7 +8685,10 @@
8679
8685
  var layerDoneCallback = function layerDoneCallback(__layer) {
8680
8686
  if (isDefined(_layerDoneCallback)) {
8681
8687
  try {
8682
- _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
+
8683
8692
  } catch (e) {
8684
8693
  debug(exports.DebugType.Error, e);
8685
8694
  }
@@ -8698,20 +8707,13 @@
8698
8707
  };
8699
8708
 
8700
8709
  var callback = function callback(data) {
8701
- _this.__parseGetCapForLayer(_this, data, layerDoneCallback, fail);
8710
+ _this.__parseGetCapForLayer(data, layerDoneCallback, fail);
8702
8711
  };
8703
8712
 
8704
8713
  var requestfail = function requestfail() {
8705
8714
  fail(_this, I18n.no_capability_element_found.text);
8706
8715
  };
8707
8716
 
8708
- var newXml2jsonrequest = xml2jsonrequest;
8709
-
8710
- if (!xml2jsonrequest) {
8711
- newXml2jsonrequest = this.parentMaps && this.parentMaps.length > 0 ? this.parentMaps[0].xml2jsonrequest : undefined;
8712
- }
8713
-
8714
- this.WMJSService = WMGetServiceFromStore(this.service, newXml2jsonrequest);
8715
8717
  var options = {
8716
8718
  headers: {}
8717
8719
  };
@@ -8720,10 +8722,12 @@
8720
8722
  options.headers = this.headers;
8721
8723
  }
8722
8724
 
8723
- if (this.WMJSService.service !== undefined) {
8724
- this.WMJSService.getCapabilities(function (data) {
8725
+ var wmjsService = WMGetServiceFromStore(this.service);
8726
+
8727
+ if (wmjsService.service !== undefined) {
8728
+ wmjsService.getCapabilities(function (data) {
8725
8729
  callback(data);
8726
- }, requestfail, forceReload, xml2jsonrequest, options);
8730
+ }, requestfail, forceReload, options);
8727
8731
  }
8728
8732
  };
8729
8733
  /**
@@ -8748,7 +8752,7 @@
8748
8752
  } else {
8749
8753
  resolve(layer);
8750
8754
  }
8751
- }, forceReload);
8755
+ }, forceReload, 'WMLayer parseLayerPromise');
8752
8756
  });
8753
8757
  };
8754
8758
 
@@ -8798,7 +8802,8 @@
8798
8802
  success(layerObjects[currentLayerIndex], currentLayerIndex, layerObjects.length);
8799
8803
  };
8800
8804
 
8801
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8805
+ var wmjsService = WMGetServiceFromStore(this.service);
8806
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8802
8807
  };
8803
8808
 
8804
8809
  WMLayer.prototype.autoSelectLayer = function (success, failure) {
@@ -8815,7 +8820,8 @@
8815
8820
  }
8816
8821
  };
8817
8822
 
8818
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8823
+ var wmjsService = WMGetServiceFromStore(this.service);
8824
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8819
8825
  };
8820
8826
 
8821
8827
  WMLayer.prototype.getNextLayer = function (success, failure) {
@@ -8979,8 +8985,8 @@
8979
8985
  WMLayer.prototype.display = function (displayornot) {
8980
8986
  this.enabled = displayornot;
8981
8987
 
8982
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8983
- this.parentMaps[j].displayLayer(this, this.enabled);
8988
+ if (this.parentMap) {
8989
+ this.parentMap.displayLayer(this, this.enabled);
8984
8990
  }
8985
8991
  };
8986
8992