@opengeoweb/webmap 6.0.3 → 6.1.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.
package/index.esm.js CHANGED
@@ -17870,14 +17870,14 @@ var getCorrectWMSDimName = function getCorrectWMSDimName(origDimName) {
17870
17870
  /* Returns all dimensions with its current values as URL */
17871
17871
  var getMapDimURL = function getMapDimURL(layer) {
17872
17872
  var request = '';
17873
- for (var j = 0; j < layer.dimensions.length; j += 1) {
17874
- var currentValue = layer.dimensions[j].getValue();
17875
- request += "&".concat(getCorrectWMSDimName(layer.dimensions[j].name));
17873
+ layer.dimensions.forEach(function (dimension) {
17874
+ var currentValue = dimension.getValue();
17875
+ request += "&".concat(getCorrectWMSDimName(dimension.name));
17876
17876
  request += "=".concat(URLEncode(currentValue));
17877
17877
  if (currentValue === WMDateOutSideRange || currentValue === WMDateTooEarlyString || currentValue === WMDateTooLateString) {
17878
17878
  throw new Error(WMDateOutSideRange);
17879
17879
  }
17880
- }
17880
+ });
17881
17881
  return request;
17882
17882
  };
17883
17883
  /**
@@ -18262,6 +18262,11 @@ var WMImage = /*#__PURE__*/function () {
18262
18262
  }
18263
18263
  return this._isLoaded;
18264
18264
  }
18265
+ }, {
18266
+ key: "isLoadedWithoutErrors",
18267
+ value: function isLoadedWithoutErrors() {
18268
+ return this.isLoaded() && !this.hasError();
18269
+ }
18265
18270
  /**
18266
18271
  * Returns true if the image is still loading
18267
18272
  */
@@ -18393,6 +18398,7 @@ var WMImage = /*#__PURE__*/function () {
18393
18398
  }, {
18394
18399
  key: "_load",
18395
18400
  value: function _load() {
18401
+ var _a;
18396
18402
  this._hasError = false;
18397
18403
  if (this._isLoaded === true) {
18398
18404
  this._loadEvent(false);
@@ -18418,7 +18424,7 @@ var WMImage = /*#__PURE__*/function () {
18418
18424
  this._loadEvent(false);
18419
18425
  return;
18420
18426
  }
18421
- if (this.headers && this.headers.length > 0) {
18427
+ if ((_a = this.headers) === null || _a === void 0 ? void 0 : _a.length) {
18422
18428
  /* Get an image which needs headers */
18423
18429
  this._getImageWithHeaders(this.srcToLoad, this.headers);
18424
18430
  } else if (this.randomize) {
@@ -18430,19 +18436,19 @@ var WMImage = /*#__PURE__*/function () {
18430
18436
  newSrc += "random=".concat(Math.random());
18431
18437
  this.getElement().src = newSrc;
18432
18438
  } else {
18439
+ // setting src loads the image and the 'load' callback is called when its finished loading
18433
18440
  this.getElement().src = this.srcToLoad;
18434
18441
  }
18435
18442
  }
18436
18443
  }, {
18437
18444
  key: "_loadEvent",
18438
18445
  value: function _loadEvent(hasError) {
18446
+ var _a;
18439
18447
  this._hasError = hasError;
18440
18448
  this._isLoading = false;
18441
18449
  this._isLoaded = true;
18442
18450
  this._srcLoaded = this.srcToLoad;
18443
- if (isDefined(this.loadEventCallback)) {
18444
- this.loadEventCallback(this);
18445
- }
18451
+ (_a = this.loadEventCallback) === null || _a === void 0 ? void 0 : _a.call(this, this);
18446
18452
  }
18447
18453
  /**
18448
18454
  * Get the width of the current image
@@ -18954,20 +18960,19 @@ var makeQueryStringWithoutGeoInfo = function makeQueryStringWithoutGeoInfo(image
18954
18960
  * @param newLayer A canvaslayer object to add.
18955
18961
  */
18956
18962
  var addAlternativeImage = function addAlternativeImage(newLayer) {
18963
+ var _a;
18957
18964
  /* Get a signature for images which belong to each other */
18958
18965
  var sigImageUrl = makeQueryStringWithoutGeoInfo(newLayer.imageSource);
18959
18966
  /* Make an entry for these images in the sharedImagesList */
18960
- if (!sharedImagesList[sigImageUrl]) {
18961
- sharedImagesList[sigImageUrl] = [];
18962
- }
18967
+ (_a = sharedImagesList[sigImageUrl]) !== null && _a !== void 0 ? _a : sharedImagesList[sigImageUrl] = [];
18963
18968
  /* Get the images for this signature */
18964
18969
  var imagesForUrl = sharedImagesList[sigImageUrl];
18965
18970
  /* Check if the image is not already in the sharedImagesList */
18966
- var imageIsAlreadyIndex = imagesForUrl.findIndex(function (i) {
18971
+ var imageIsAlreadyIndex = imagesForUrl.find(function (i) {
18967
18972
  return i.imageSource === newLayer.imageSource;
18968
18973
  });
18969
18974
  /* It is not in the list, so add it */
18970
- if (imageIsAlreadyIndex === -1) {
18975
+ if (!imageIsAlreadyIndex) {
18971
18976
  /* Ensure that the oldest images are removed, keep a maximum of 10 images per signature url */
18972
18977
  while (sharedImagesList[sigImageUrl].length >= 10) {
18973
18978
  sharedImagesList[sigImageUrl].pop();
@@ -19019,18 +19024,14 @@ var getAlternativeImage = function getAlternativeImage(imageUrl, imageStore,
19019
19024
  _bbox) {
19020
19025
  var sigImageUrl = makeQueryStringWithoutGeoInfo(imageUrl);
19021
19026
  var imagesForUrl = sharedImagesList[sigImageUrl];
19022
- if (imagesForUrl && imagesForUrl.length > 0) {
19027
+ if (imagesForUrl === null || imagesForUrl === void 0 ? void 0 : imagesForUrl.length) {
19023
19028
  var sortedImagesForUrl = sortByImageDate(imagesForUrl);
19024
- /* Find the first image in this list which is also loaded and has no error */
19025
- var index = sortedImagesForUrl.findIndex(function (altImage) {
19029
+ return sortedImagesForUrl.find(function (altImage) {
19026
19030
  var cachedImage = imageStore.getImageForSrc(altImage.imageSource);
19027
- return cachedImage && cachedImage.isLoaded() && !cachedImage.isLoading() && !cachedImage.hasError();
19031
+ return cachedImage === null || cachedImage === void 0 ? void 0 : cachedImage.isLoadedWithoutErrors();
19028
19032
  });
19029
- if (index !== -1) {
19030
- return sortedImagesForUrl[index];
19031
- }
19032
19033
  }
19033
- return null;
19034
+ return undefined;
19034
19035
  };
19035
19036
  var WMCanvasBuffer = /*#__PURE__*/function () {
19036
19037
  function WMCanvasBuffer(webmapJSCallback, _imageStore, w, h, internalCallbacks) {
@@ -19148,6 +19149,8 @@ var WMCanvasBuffer = /*#__PURE__*/function () {
19148
19149
  }, {
19149
19150
  key: "display",
19150
19151
  value: function display() {
19152
+ var _this2 = this;
19153
+ var _a, _b, _c, _d, _e, _f;
19151
19154
  this._ctx.globalAlpha = 1;
19152
19155
  this._ctx.fillStyle = 'white';
19153
19156
  this._ctx.beginPath();
@@ -19159,47 +19162,37 @@ var WMCanvasBuffer = /*#__PURE__*/function () {
19159
19162
  }
19160
19163
  /* Reset errors */
19161
19164
  this._errorList.length = 0;
19162
- for (var j = 0; j < this.layers.length; j += 1) {
19163
- var imageToDisplay = this._imageStore.getImageForSrc(this.layers[j].imageSource);
19164
- if (imageToDisplay && imageToDisplay.isLoaded() && !imageToDisplay.isLoading() && !imageToDisplay.hasError()) {
19165
+ this.layers.forEach(function (layer) {
19166
+ var imageToDisplay = _this2._imageStore.getImageForSrc(layer.imageSource);
19167
+ if (imageToDisplay === null || imageToDisplay === void 0 ? void 0 : imageToDisplay.isLoadedWithoutErrors()) {
19165
19168
  // Draw this image, it is loaded and OK
19166
- this._drawImage(this.layers[j]);
19167
- } else {
19168
- /**
19169
- * Check if this image has an error.
19170
- * If the error has occured some time ago, and the amount of retries is low, just retry to load the image.
19171
- */
19172
- if (imageToDisplay.hasError()) {
19173
- if (imageToDisplay.isLoading() === false && imageToDisplay.getLastErrorMSecondsAgo() > 5000) {
19174
- if (imageToDisplay.getNumFailedAttempts() < 10) {
19175
- imageToDisplay.forceReload();
19176
- }
19177
- }
19178
- }
19179
- /* Find closest alternative and display instead image */
19180
- var im = getAlternativeImage(this.layers[j].imageSource, this._imageStore, this._currentnewbbox);
19181
- if (im) {
19182
- this._drawImage(im);
19183
- }
19169
+ _this2._drawImage(layer);
19170
+ return;
19184
19171
  }
19185
- }
19172
+ /**
19173
+ * Check if this image has an error.
19174
+ * If the error has occured some time ago, and the amount of retries is low, just retry to load the image.
19175
+ */
19176
+ if (imageToDisplay.hasError() && imageToDisplay.isLoading() === false && imageToDisplay.getLastErrorMSecondsAgo() > 5000 && imageToDisplay.getNumFailedAttempts() < 10) {
19177
+ imageToDisplay.forceReload();
19178
+ }
19179
+ /* Find closest alternative and display instead image */
19180
+ var im = getAlternativeImage(layer.imageSource, _this2._imageStore, _this2._currentnewbbox);
19181
+ if (im) {
19182
+ _this2._drawImage(im);
19183
+ }
19184
+ });
19186
19185
  this._ctx.globalAlpha = 1;
19187
19186
  /* Display errors */
19188
19187
  if (this._errorList.length > 0) {
19189
19188
  this._webmapJSCallback.triggerEvent('canvasonerror', this._errorList);
19190
- if (this._internalCallbacks && this._internalCallbacks.canvasonerror) {
19191
- this._internalCallbacks.canvasonerror(this._errorList);
19192
- }
19189
+ (_b = (_a = this._internalCallbacks) === null || _a === void 0 ? void 0 : _a.canvasonerror) === null || _b === void 0 ? void 0 : _b.call(_a, this._errorList);
19193
19190
  }
19194
19191
  this._webmapJSCallback.triggerEvent('beforecanvasdisplay', this._ctx);
19195
- if (this._internalCallbacks && this._internalCallbacks.beforecanvasdisplay) {
19196
- this._internalCallbacks.beforecanvasdisplay(this._ctx);
19197
- }
19192
+ (_d = (_c = this._internalCallbacks) === null || _c === void 0 ? void 0 : _c.beforecanvasdisplay) === null || _d === void 0 ? void 0 : _d.call(_c, this._ctx);
19198
19193
  this.canvas.style.display = 'inline-block';
19199
19194
  this._webmapJSCallback.triggerEvent('aftercanvasdisplay', this._ctx);
19200
- if (this._internalCallbacks && this._internalCallbacks.aftercanvasdisplay) {
19201
- this._internalCallbacks.aftercanvasdisplay(this._ctx);
19202
- }
19195
+ (_f = (_e = this._internalCallbacks) === null || _e === void 0 ? void 0 : _e.aftercanvasdisplay) === null || _f === void 0 ? void 0 : _f.call(_e, this._ctx);
19203
19196
  }
19204
19197
  }, {
19205
19198
  key: "finishedLoading",
@@ -19250,12 +19243,13 @@ var WMCanvasBuffer = /*#__PURE__*/function () {
19250
19243
  }, {
19251
19244
  key: "setSrc",
19252
19245
  value: function setSrc(layerIndex, imageSource, linkedInfo, opacity, bbox) {
19246
+ var _a, _b;
19253
19247
  if (!isDefined(imageSource)) {
19254
19248
  debug(DebugType.Warning);
19255
19249
  return;
19256
19250
  }
19257
19251
  /* HTTP Headers for the image, necessary in case of certain authentication forms */
19258
- var headers = linkedInfo && linkedInfo.layer && linkedInfo.layer.headers ? linkedInfo.layer.headers : [];
19252
+ var headers = (_b = (_a = linkedInfo === null || linkedInfo === void 0 ? void 0 : linkedInfo.layer) === null || _a === void 0 ? void 0 : _a.headers) !== null && _b !== void 0 ? _b : [];
19259
19253
  /* Make a new CanvasLayer */
19260
19254
  var newLayer = {
19261
19255
  imageSource: imageSource,
@@ -19318,24 +19312,24 @@ var WMCanvasBuffer = /*#__PURE__*/function () {
19318
19312
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19319
19313
  var prefetch = function prefetch(requests) {
19320
19314
  var prefetching = [];
19321
- for (var j = 0; j < requests.length; j += 1) {
19322
- var image = getMapImageStore.getImage(requests[j].url, {
19323
- headers: requests[j].headers
19315
+ requests.forEach(function (request) {
19316
+ var image = getMapImageStore.getImage(request.url, {
19317
+ headers: request.headers
19324
19318
  });
19325
19319
  if (image.isLoaded() === false && image.isLoading() === false) {
19326
19320
  prefetching.push(image);
19327
19321
  image.load();
19328
19322
  }
19329
- }
19323
+ });
19330
19324
  return prefetching;
19331
19325
  };
19332
19326
  var WMJSAnimate = /*#__PURE__*/function () {
19333
19327
  function WMJSAnimate(_map) {
19334
19328
  _classCallCheck(this, WMJSAnimate);
19329
+ this._imageStore = getMapImageStore;
19335
19330
  this.isNextTimeCloseToWallClockTime = false;
19336
19331
  _map.animationDelay = 100;
19337
19332
  this._callBack = _map.getListener();
19338
- this._imageStore = getMapImageStore;
19339
19333
  this._divAnimationInfo = document.createElement('div');
19340
19334
  _map.currentAnimationStep = 0;
19341
19335
  _map.animationList = undefined;
@@ -19362,10 +19356,10 @@ var WMJSAnimate = /*#__PURE__*/function () {
19362
19356
  /* Bind */
19363
19357
  this._animate = this._animate.bind(this);
19364
19358
  this._animateLoop = this._animateLoop.bind(this);
19365
- this.checkAnimation = this.checkAnimation.bind(this);
19359
+ this.prefetchImagesForAnimationSteps = this.prefetchImagesForAnimationSteps.bind(this);
19366
19360
  this.stopAnimating = this.stopAnimating.bind(this);
19367
19361
  _map.stopAnimating = this.stopAnimating;
19368
- _map.checkAnimation = this.checkAnimation;
19362
+ _map.checkAnimation = this.prefetchImagesForAnimationSteps;
19369
19363
  }
19370
19364
  _createClass(WMJSAnimate, [{
19371
19365
  key: "isCurrentAnimationTimeCloseToWallClockTime",
@@ -19409,67 +19403,70 @@ var WMJSAnimate = /*#__PURE__*/function () {
19409
19403
  this._map.setDimension(animationStep.name, animationStep.value, false);
19410
19404
  this._callBack.triggerEvent('ondimchange');
19411
19405
  this._callBack.triggerEvent('onnextanimationstep', this._map);
19412
- this._map._pdraw();
19406
+ this._map.addLayersToCanvasAndDisplayThem();
19413
19407
  this._map.animateBusy = false;
19414
19408
  }
19415
19409
  }, {
19416
19410
  key: "_animateLoop",
19417
19411
  value: function _animateLoop() {
19412
+ var _this = this;
19418
19413
  if (this._map.isAnimating === false) {
19419
19414
  this._map.isAnimatingLoopRunning = false;
19420
19415
  return;
19421
19416
  }
19422
19417
  var animationDelay = this._map.animationDelay;
19418
+ var animationSteps = this._map.animationList;
19423
19419
  if (this._map.currentAnimationStep === 0) {
19424
19420
  animationDelay *= 3;
19425
- } else if (this._map.currentAnimationStep === this._map.animationList.length - 1) {
19421
+ } else if (this._map.currentAnimationStep === animationSteps.length - 1) {
19426
19422
  animationDelay *= 5;
19427
19423
  } else if (this.isCurrentAnimationTimeCloseToWallClockTime()) {
19428
19424
  animationDelay *= 5;
19429
19425
  }
19426
+ // set up timer for next animation step
19430
19427
  this._map.animationTimer.init(animationDelay, this._animateLoop);
19431
- this.checkAnimation();
19432
- if (this._map.mouseHoverAnimationBox === false) {
19433
- this._animate();
19434
- var nextStep = this._map.currentAnimationStep + 1;
19435
- if (nextStep >= this._map.animationList.length) {
19436
- nextStep = 0;
19437
- }
19438
- var continueAnimation = false;
19439
- var numReady = 0;
19440
- var animationStep = this._map.animationList[nextStep];
19441
- this._map.setDimension(animationStep.name, animationStep.value, false);
19442
- this._map.animationList[nextStep].requests = this._map.getWMSRequests();
19443
- animationStep = this._map.animationList[this._map.currentAnimationStep];
19444
- this._map.setDimension(animationStep.name, animationStep.value, false);
19445
- for (var i = 0; i < this._map.animationList[nextStep].requests.length; i += 1) {
19446
- var url = this._map.animationList[nextStep].requests[i].url;
19447
- var image = getMapImageStore.getImageForSrc(url);
19448
- /* Get a loaded image which has no error */
19449
- if (image && image.isLoaded() && !image.isLoading() && !image.hasError()) {
19450
- numReady += 1;
19451
- } else {
19452
- /* Check if a similar image is available instead, then we can continue with the smoother animation */
19453
- var im = getAlternativeImage(url, getMapImageStore, this._map.getDrawBBOX());
19454
- if (im) {
19455
- numReady += 1;
19456
- } else if (!(image && image.isLoading())) {
19457
- /* No alternatives and current image is not loading, so lets continue the animation */
19458
- numReady += 1;
19459
- }
19460
- }
19428
+ this.prefetchImagesForAnimationSteps();
19429
+ if (this._map.mouseHoverAnimationBox !== false) {
19430
+ return;
19431
+ }
19432
+ this._animate();
19433
+ var nextAnimationStepIndex = this._map.currentAnimationStep + 1;
19434
+ if (nextAnimationStepIndex >= animationSteps.length) {
19435
+ nextAnimationStepIndex = 0;
19436
+ }
19437
+ // get urls for images in next animation step
19438
+ var nextAnimationStep = animationSteps[nextAnimationStepIndex];
19439
+ nextAnimationStep.requests = this.getRequestsForAnimationStep(animationSteps, nextAnimationStepIndex);
19440
+ // if images for next animation step is ready or haven't started loading
19441
+ // change map animation step to next step
19442
+ var numberOfImagesReadyForNextAnimationStep = 0;
19443
+ nextAnimationStep.requests.forEach(function (request) {
19444
+ var url = request.url;
19445
+ var image = getMapImageStore.getImageForSrc(url);
19446
+ /* Get a loaded image which has no error */
19447
+ if (image === null || image === void 0 ? void 0 : image.isLoadedWithoutErrors()) {
19448
+ numberOfImagesReadyForNextAnimationStep += 1;
19449
+ return;
19461
19450
  }
19462
- if (numReady >= this._map.animationList[nextStep].requests.length) {
19463
- continueAnimation = true;
19451
+ /* Check if a similar image is available instead, then we can continue with the smoother animation */
19452
+ var alternativeImage = getAlternativeImage(url, getMapImageStore, _this._map.getDrawBBOX());
19453
+ if (alternativeImage) {
19454
+ numberOfImagesReadyForNextAnimationStep += 1;
19455
+ return;
19464
19456
  }
19465
- if (continueAnimation) {
19466
- this._map.currentAnimationStep = nextStep;
19457
+ var imageHasntStartedLoading = !(image === null || image === void 0 ? void 0 : image.isLoading());
19458
+ if (imageHasntStartedLoading) {
19459
+ /* No alternatives and current image is not loading, so lets continue the animation */
19460
+ numberOfImagesReadyForNextAnimationStep += 1;
19467
19461
  }
19462
+ });
19463
+ if (numberOfImagesReadyForNextAnimationStep >= nextAnimationStep.requests.length) {
19464
+ this._map.currentAnimationStep = nextAnimationStepIndex;
19468
19465
  }
19469
19466
  }
19470
19467
  }, {
19471
- key: "checkAnimation",
19472
- value: function checkAnimation() {
19468
+ key: "prefetchImagesForAnimationSteps",
19469
+ value: function prefetchImagesForAnimationSteps() {
19473
19470
  if (this._map.isAnimating === false) {
19474
19471
  this._map.isAnimatingLoopRunning = false;
19475
19472
  return;
@@ -19477,37 +19474,32 @@ var WMJSAnimate = /*#__PURE__*/function () {
19477
19474
  if (!this._map.animationTimer) {
19478
19475
  this._map.animationTimer = new WMTimer();
19479
19476
  }
19480
- if (this._map.mouseHoverAnimationBox === false) {
19481
- var maxSimultaneousLoads = 4;
19482
- var getNumImagesLoading = this._imageStore.getNumImagesLoading();
19483
- if (getNumImagesLoading < maxSimultaneousLoads) {
19484
- var numberPreCacheSteps = this._map.animationList.length;
19485
- if (this._map.animationList.length > 0) {
19486
- for (var j = 0; j < numberPreCacheSteps; j += 1) {
19487
- var index = j + this._map.currentAnimationStep;
19488
- while (index < 0) {
19489
- index += this._map.animationList.length;
19490
- }
19491
- while (index >= this._map.animationList.length) {
19492
- index -= this._map.animationList.length;
19493
- }
19494
- if (index < 0) {
19495
- index = 0;
19496
- }
19497
- if (index >= 0) {
19498
- var animationStep = this._map.animationList[index];
19499
- this._map.setDimension(animationStep.name, animationStep.value, false);
19500
- this._map.animationList[index].requests = this._map.getWMSRequests();
19501
- animationStep = this._map.animationList[this._map.currentAnimationStep];
19502
- this._map.setDimension(animationStep.name, animationStep.value, false);
19503
- this._map.animationList[index].imagesInPrefetch = prefetch(this._map.animationList[index].requests);
19504
- getNumImagesLoading = this._imageStore.getNumImagesLoading();
19505
- if (getNumImagesLoading > maxSimultaneousLoads - 1) {
19506
- break;
19507
- }
19508
- }
19509
- }
19477
+ var animationSteps = this._map.animationList;
19478
+ var countAnimationSteps = animationSteps === null || animationSteps === void 0 ? void 0 : animationSteps.length;
19479
+ if (countAnimationSteps && this._map.mouseHoverAnimationBox === false) {
19480
+ for (var j = 0; j < countAnimationSteps; j += 1) {
19481
+ // dont prefetch if already prefetching too many images
19482
+ var maxSimultaneousLoads = 4;
19483
+ var countImagesLoading = this._imageStore.getNumImagesLoading();
19484
+ if (countImagesLoading > maxSimultaneousLoads - 1) {
19485
+ break;
19486
+ }
19487
+ // start prefecthing images for the next animation step first
19488
+ var index = j + this._map.currentAnimationStep;
19489
+ while (index < 0) {
19490
+ index += countAnimationSteps;
19491
+ }
19492
+ while (index >= countAnimationSteps) {
19493
+ index -= countAnimationSteps;
19510
19494
  }
19495
+ if (index < 0) {
19496
+ index = 0;
19497
+ }
19498
+ // get urls for animation step
19499
+ var animationStep = animationSteps[index];
19500
+ animationStep.requests = this.getRequestsForAnimationStep(animationSteps, index);
19501
+ // prefetch images for animation step
19502
+ animationStep.imagesInPrefetch = prefetch(animationStep.requests);
19511
19503
  }
19512
19504
  }
19513
19505
  if (this._map.isAnimatingLoopRunning === false) {
@@ -19528,6 +19520,18 @@ var WMJSAnimate = /*#__PURE__*/function () {
19528
19520
  this._map.rebuildMapDimensions();
19529
19521
  this._callBack.triggerEvent('onstopanimation', this._map);
19530
19522
  }
19523
+ }, {
19524
+ key: "getRequestsForAnimationStep",
19525
+ value: function getRequestsForAnimationStep(animationSteps, index) {
19526
+ // get urls for animation step
19527
+ var animationStep = animationSteps[index];
19528
+ this._map.setDimension(animationStep.name, animationStep.value, false);
19529
+ var requests = this._map.getWMSRequests();
19530
+ // set map back to correct dimension
19531
+ var animationStepShownOnMap = animationSteps[this._map.currentAnimationStep];
19532
+ this._map.setDimension(animationStepShownOnMap.name, animationStepShownOnMap.value, false);
19533
+ return requests;
19534
+ }
19531
19535
  }]);
19532
19536
  return WMJSAnimate;
19533
19537
  }();
@@ -19818,10 +19822,6 @@ var getLegendGraphicURLForLayer = function getLegendGraphicURLForLayer(layer) {
19818
19822
  if (!legendURL) {
19819
19823
  return undefined;
19820
19824
  }
19821
- // For THREDDS WMS we need to add layers=
19822
- if (!legendURL.includes('&layers=')) {
19823
- legendURL += "&layers=".concat(URLEncode(layer.name), "&");
19824
- }
19825
19825
  try {
19826
19826
  if (layer.legendIsDimensionDependent === true) {
19827
19827
  legendURL += "".concat(getMapDimURL(layer), "&");
@@ -26973,11 +26973,9 @@ var getBBOXandProjString = function getBBOXandProjString(map, layer) {
26973
26973
  };
26974
26974
  // Build a valid WMS request for a certain layer
26975
26975
  var buildWMSGetMapRequest = function buildWMSGetMapRequest(map, layer) {
26976
- if (!isDefined(layer.name)) {
26977
- return {
26978
- url: undefined,
26979
- headers: null
26980
- };
26976
+ var _a;
26977
+ if (!isDefined(layer.name) || layer.name.length < 1) {
26978
+ return undefined;
26981
26979
  }
26982
26980
  var _map$getProjection2 = map.getProjection(),
26983
26981
  srs = _map$getProjection2.srs;
@@ -26985,15 +26983,7 @@ var buildWMSGetMapRequest = function buildWMSGetMapRequest(map, layer) {
26985
26983
  var _map$getSize = map.getSize(),
26986
26984
  width = _map$getSize.width,
26987
26985
  height = _map$getSize.height;
26988
- if (!layer.format) {
26989
- layer.format = 'image/png';
26990
- }
26991
- if (layer.name.length < 1) {
26992
- return {
26993
- url: undefined,
26994
- headers: null
26995
- };
26996
- }
26986
+ (_a = layer.format) !== null && _a !== void 0 ? _a : layer.format = 'image/png';
26997
26987
  // GetFeatureInfo timeseries in the mapview
26998
26988
  if (srs === 'GFI:TIME_ELEVATION') {
26999
26989
  var x = 707;
@@ -27059,10 +27049,7 @@ var buildWMSGetMapRequest = function buildWMSGetMapRequest(map, layer) {
27059
27049
  try {
27060
27050
  request += getMapDimURL(layer);
27061
27051
  } catch (e) {
27062
- return {
27063
- url: null,
27064
- headers: null
27065
- };
27052
+ return undefined;
27066
27053
  }
27067
27054
  // Handle WMS extensions
27068
27055
  request += layer.wmsextensions.url;
@@ -27377,7 +27364,7 @@ var WMJSMap = /*#__PURE__*/function () {
27377
27364
  this._onResumeSuspendCallbackFunction = this._onResumeSuspendCallbackFunction.bind(this);
27378
27365
  this._animFrameRedraw = this._animFrameRedraw.bind(this);
27379
27366
  this.getWMSRequests = this.getWMSRequests.bind(this);
27380
- this._pdraw = this._pdraw.bind(this);
27367
+ this.addLayersToCanvasAndDisplayThem = this.addLayersToCanvasAndDisplayThem.bind(this);
27381
27368
  this._updateBoundingBox = this._updateBoundingBox.bind(this);
27382
27369
  this.redrawBuffer = this.redrawBuffer.bind(this);
27383
27370
  this.addBaseLayers = this.addBaseLayers.bind(this);
@@ -28451,7 +28438,7 @@ var WMJSMap = /*#__PURE__*/function () {
28451
28438
  debug(DebugType.Log);
28452
28439
  return;
28453
28440
  }
28454
- this._animFrameRedraw();
28441
+ this._draw(this._animationList);
28455
28442
  }
28456
28443
  /**
28457
28444
  * API Function called to draw the layers, fires getmap request and shows the layers on the screen
@@ -28475,46 +28462,41 @@ var WMJSMap = /*#__PURE__*/function () {
28475
28462
  }, {
28476
28463
  key: "_drawAndLoad",
28477
28464
  value: function _drawAndLoad(animationList) {
28465
+ var _this7 = this;
28478
28466
  if (this.width < 4 || this.height < 4) {
28479
28467
  this._drawReady();
28480
28468
  return;
28481
28469
  }
28482
28470
  this.callBack.triggerEvent('beforedraw');
28483
- if (this.isAnimating === false) {
28484
- if (animationList !== undefined) {
28485
- if (_typeof$1(animationList) === 'object') {
28486
- if (animationList.length > 0) {
28487
- // Ensure the time dimension has been loaded for the map before starting animation
28488
- var timeDim = this.getDimension('time');
28489
- if (!timeDim) {
28490
- return;
28491
- }
28492
- var selectedTime = timeDim.currentValue;
28493
- this.isAnimating = true;
28494
- this.callBack.triggerEvent('onstartanimation', this);
28495
- this.currentAnimationStep = this.initialAnimationStep;
28496
- this.animationList = [];
28497
- this.mouseHoverAnimationBox = false;
28498
- for (var j = 0; j < animationList.length; j += 1) {
28499
- if (selectedTime && animationList[j].value === selectedTime) {
28500
- this.currentAnimationStep = j;
28501
- }
28502
- var animationListObject = {
28503
- name: animationList[j].name,
28504
- value: animationList[j].value,
28505
- requests: []
28506
- };
28507
- this.setDimension(animationList[j].name, animationList[j].value, false);
28508
- animationListObject.requests = this.getWMSRequests();
28509
- this.animationList.push(animationListObject);
28510
- }
28511
- this.setDimension(this.animationList[this.currentAnimationStep].name, this.animationList[this.currentAnimationStep].value, false);
28512
- this.wmAnimate.checkAnimation();
28513
- }
28514
- }
28471
+ if (this.isAnimating === false && animationList !== undefined && _typeof$1(animationList) === 'object' && animationList.length > 0) {
28472
+ // Ensure the time dimension has been loaded for the map before starting animation
28473
+ var timeDim = this.getDimension('time');
28474
+ if (!timeDim) {
28475
+ return;
28515
28476
  }
28477
+ var selectedTime = timeDim.currentValue;
28478
+ this.isAnimating = true;
28479
+ this.callBack.triggerEvent('onstartanimation', this);
28480
+ this.currentAnimationStep = this.initialAnimationStep;
28481
+ this.animationList = [];
28482
+ this.mouseHoverAnimationBox = false;
28483
+ animationList.forEach(function (animationStepWithoutRequests, j) {
28484
+ if (selectedTime && animationStepWithoutRequests.value === selectedTime) {
28485
+ _this7.currentAnimationStep = j;
28486
+ }
28487
+ var animationStep = {
28488
+ name: animationStepWithoutRequests.name,
28489
+ value: animationStepWithoutRequests.value,
28490
+ requests: []
28491
+ };
28492
+ _this7.setDimension(animationStepWithoutRequests.name, animationStepWithoutRequests.value, false);
28493
+ animationStep.requests = _this7.getWMSRequests();
28494
+ _this7.animationList.push(animationStep);
28495
+ });
28496
+ this.setDimension(this.animationList[this.currentAnimationStep].name, this.animationList[this.currentAnimationStep].value, false);
28497
+ this.wmAnimate.prefetchImagesForAnimationSteps();
28516
28498
  }
28517
- this._pdraw();
28499
+ this.addLayersToCanvasAndDisplayThem();
28518
28500
  }
28519
28501
  }, {
28520
28502
  key: "_onLayersReadyCallbackFunction",
@@ -28535,70 +28517,65 @@ var WMJSMap = /*#__PURE__*/function () {
28535
28517
  }, {
28536
28518
  key: "getWMSRequests",
28537
28519
  value: function getWMSRequests() {
28520
+ var _this8 = this;
28538
28521
  var requests = [];
28539
- var n = this.getNumLayers();
28540
- for (var j = 0; j < n; j += 1) {
28541
- if (this.layers[j].service && this.layers[j].enabled) {
28542
- var request = buildWMSGetMapRequest(this, this.layers[j]);
28543
- if (request.url) {
28522
+ this.layers.forEach(function (layer) {
28523
+ if (layer.service && layer.enabled) {
28524
+ var request = buildWMSGetMapRequest(_this8, layer);
28525
+ if (request === null || request === void 0 ? void 0 : request.url) {
28544
28526
  requests.push(request);
28545
28527
  }
28546
28528
  }
28547
- }
28529
+ });
28548
28530
  return requests;
28549
28531
  }
28550
28532
  }, {
28551
- key: "_pdraw",
28552
- value: function _pdraw() {
28553
- var _this7 = this;
28554
- var loadLayers = function loadLayers() {
28555
- debug(DebugType.Log);
28556
- _this7.divBuffer.reset();
28557
- var currentLayerIndex = 0;
28558
- _this7.numBaseLayers = 0;
28559
- if (_this7.baseLayers) {
28560
- for (var l = 0; l < _this7.baseLayers.length; l += 1) {
28561
- if (_this7.baseLayers[l].enabled && _this7.baseLayers[l].keepOnTop === false && _this7.baseLayers[l].type && _this7.baseLayers[l].type !== 'twms') {
28562
- _this7.numBaseLayers += 1;
28563
- var requestURL = buildWMSGetMapRequest(_this7, _this7.baseLayers[l]).url;
28564
- if (requestURL) {
28565
- _this7.divBuffer.setSrc(currentLayerIndex, requestURL, {
28566
- layer: _this7.baseLayers[l]
28567
- }, _this7.baseLayers[l].opacity, _this7.getDrawBBOX());
28568
- currentLayerIndex += 1;
28569
- }
28570
- }
28533
+ key: "addLayersToCanvasAndDisplayThem",
28534
+ value: function addLayersToCanvasAndDisplayThem() {
28535
+ var _this9 = this;
28536
+ var _a, _b, _c;
28537
+ debug(DebugType.Log);
28538
+ this.divBuffer.reset();
28539
+ var currentLayerIndex = 0;
28540
+ this.numBaseLayers = 0;
28541
+ (_a = this.baseLayers) === null || _a === void 0 ? void 0 : _a.forEach(function (baseLayer) {
28542
+ var _a;
28543
+ if (baseLayer.enabled && baseLayer.keepOnTop === false && baseLayer.type && baseLayer.type !== 'twms') {
28544
+ _this9.numBaseLayers += 1;
28545
+ var requestURL = (_a = buildWMSGetMapRequest(_this9, baseLayer)) === null || _a === void 0 ? void 0 : _a.url;
28546
+ if (requestURL) {
28547
+ _this9.divBuffer.setSrc(currentLayerIndex, requestURL, {
28548
+ layer: baseLayer
28549
+ }, baseLayer.opacity, _this9.getDrawBBOX());
28550
+ currentLayerIndex += 1;
28571
28551
  }
28572
28552
  }
28573
- /* Loop through all layers */
28574
- for (var j = 0; j < _this7.getNumLayers(); j += 1) {
28575
- if (_this7.layers[j].service && _this7.layers[j].enabled && _this7.layers[j].isConfigured) {
28576
- var _requestURL = buildWMSGetMapRequest(_this7, _this7.layers[j]).url;
28577
- if (_requestURL) {
28578
- _this7.divBuffer.setSrc(currentLayerIndex, _requestURL, {
28579
- layer: _this7.layers[j]
28580
- }, _this7.layers[j].opacity, _this7.getDrawBBOX());
28581
- currentLayerIndex += 1;
28582
- }
28553
+ });
28554
+ /* Loop through all layers */
28555
+ (_b = this.layers) === null || _b === void 0 ? void 0 : _b.forEach(function (layer) {
28556
+ var _a;
28557
+ if (layer.service && layer.enabled && layer.isConfigured) {
28558
+ var requestURL = (_a = buildWMSGetMapRequest(_this9, layer)) === null || _a === void 0 ? void 0 : _a.url;
28559
+ if (requestURL) {
28560
+ _this9.divBuffer.setSrc(currentLayerIndex, requestURL, {
28561
+ layer: layer
28562
+ }, layer.opacity, _this9.getDrawBBOX());
28563
+ currentLayerIndex += 1;
28583
28564
  }
28584
28565
  }
28585
- if (_this7.baseLayers) {
28586
- for (var _l = 0; _l < _this7.baseLayers.length; _l += 1) {
28587
- if (_this7.baseLayers[_l].enabled) {
28588
- if (_this7.baseLayers[_l].keepOnTop === true) {
28589
- var _requestURL2 = buildWMSGetMapRequest(_this7, _this7.baseLayers[_l]).url;
28590
- if (_requestURL2) {
28591
- _this7.divBuffer.setSrc(currentLayerIndex, _requestURL2, {
28592
- layer: _this7.baseLayers[_l]
28593
- }, _this7.baseLayers[_l].opacity, _this7.getDrawBBOX());
28594
- currentLayerIndex += 1;
28595
- }
28596
- }
28597
- }
28566
+ });
28567
+ (_c = this.baseLayers) === null || _c === void 0 ? void 0 : _c.forEach(function (baseLayer) {
28568
+ var _a;
28569
+ if (baseLayer.enabled && baseLayer.keepOnTop === true) {
28570
+ var requestURL = (_a = buildWMSGetMapRequest(_this9, baseLayer)) === null || _a === void 0 ? void 0 : _a.url;
28571
+ if (requestURL) {
28572
+ _this9.divBuffer.setSrc(currentLayerIndex, requestURL, {
28573
+ layer: baseLayer
28574
+ }, baseLayer.opacity, _this9.getDrawBBOX());
28575
+ currentLayerIndex += 1;
28598
28576
  }
28599
28577
  }
28600
- };
28601
- loadLayers();
28578
+ });
28602
28579
  this.divBuffer.display();
28603
28580
  this.callBack.triggerEvent('onmapready', this);
28604
28581
  }
@@ -28788,27 +28765,24 @@ var WMJSMap = /*#__PURE__*/function () {
28788
28765
  }, {
28789
28766
  key: "_buildLayerDims",
28790
28767
  value: function _buildLayerDims() {
28768
+ var _this10 = this;
28791
28769
  if (this.buildLayerDimsBusy === true) {
28792
28770
  return;
28793
28771
  }
28794
- for (var k = 0; k < this.mapdimensions.length; k += 1) {
28795
- var mapDim = this.mapdimensions[k];
28796
- for (var j = 0; j < this.layers.length; j += 1) {
28797
- for (var i = 0; i < this.layers[j].dimensions.length; i += 1) {
28798
- var layerDim = this.layers[j].dimensions[i];
28799
- if (layerDim.linked === true) {
28800
- if (layerDim.name === mapDim.name) {
28801
- if (mapDim.currentValue === 'current' || mapDim.currentValue === 'default' || mapDim.currentValue === '' || mapDim.currentValue === 'earliest' || mapDim.currentValue === 'middle' || mapDim.currentValue === 'latest') {
28802
- mapDim.currentValue = layerDim.getClosestValue(mapDim.currentValue);
28803
- }
28804
- this.buildLayerDimsBusy = true;
28805
- layerDim.setClosestValue(mapDim.currentValue);
28806
- this.buildLayerDimsBusy = false;
28772
+ this.mapdimensions.forEach(function (mapDim) {
28773
+ _this10.layers.forEach(function (layer) {
28774
+ layer.dimensions.forEach(function (layerDim) {
28775
+ if (layerDim.linked === true && layerDim.name === mapDim.name) {
28776
+ if (mapDim.currentValue === 'current' || mapDim.currentValue === 'default' || mapDim.currentValue === '' || mapDim.currentValue === 'earliest' || mapDim.currentValue === 'middle' || mapDim.currentValue === 'latest') {
28777
+ mapDim.currentValue = layerDim.getClosestValue(mapDim.currentValue);
28807
28778
  }
28779
+ _this10.buildLayerDimsBusy = true;
28780
+ layerDim.setClosestValue(mapDim.currentValue);
28781
+ _this10.buildLayerDimsBusy = false;
28808
28782
  }
28809
- }
28810
- }
28811
- }
28783
+ });
28784
+ });
28785
+ });
28812
28786
  }
28813
28787
  }, {
28814
28788
  key: "getMapMode",
@@ -29520,7 +29494,7 @@ var WMJSMap = /*#__PURE__*/function () {
29520
29494
  }, {
29521
29495
  key: "zoomTo",
29522
29496
  value: function zoomTo(_newbbox) {
29523
- var _this8 = this;
29497
+ var _this11 = this;
29524
29498
  debug(DebugType.Log);
29525
29499
  var setOrigBox = false;
29526
29500
  var newbbox = new WMBBOX(_newbbox);
@@ -29561,14 +29535,14 @@ var WMJSMap = /*#__PURE__*/function () {
29561
29535
  this._updateBoundingBox(this.bbox);
29562
29536
  this.drawnBBOX.setBBOX(this.bbox);
29563
29537
  var resetMapPinAndDialogs = function resetMapPinAndDialogs() {
29564
- for (var j = 0; j < _this8.gfiDialogList.length; j += 1) {
29565
- var newpos = _this8.getPixelCoordFromGeoCoord({
29566
- x: _this8.gfiDialogList[j].geoPosX,
29567
- y: _this8.gfiDialogList[j].geoPosY
29538
+ for (var j = 0; j < _this11.gfiDialogList.length; j += 1) {
29539
+ var newpos = _this11.getPixelCoordFromGeoCoord({
29540
+ x: _this11.gfiDialogList[j].geoPosX,
29541
+ y: _this11.gfiDialogList[j].geoPosY
29568
29542
  });
29569
- if (_this8.gfiDialogList[j].hasBeenDragged === false) {
29570
- if (_this8.gfiDialogList[j].moveToMouseCursor === true) {
29571
- _this8.gfiDialogList[j].setXY(_this8.gfiDialogList[j].origX + newpos.x, _this8.gfiDialogList[j].origY + newpos.y);
29543
+ if (_this11.gfiDialogList[j].hasBeenDragged === false) {
29544
+ if (_this11.gfiDialogList[j].moveToMouseCursor === true) {
29545
+ _this11.gfiDialogList[j].setXY(_this11.gfiDialogList[j].origX + newpos.x, _this11.gfiDialogList[j].origY + newpos.y);
29572
29546
  }
29573
29547
  }
29574
29548
  }
@@ -29721,10 +29695,13 @@ var WMJSMap = /*#__PURE__*/function () {
29721
29695
  // listeners:
29722
29696
  }, {
29723
29697
  key: "addListener",
29724
- value: function addListener(name, f) {
29698
+ value: function addListener(name,
29699
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29700
+ f) {
29725
29701
  var keep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
29726
29702
  return this.callBack.addToCallback(name, f, keep);
29727
29703
  }
29704
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29728
29705
  }, {
29729
29706
  key: "removeListener",
29730
29707
  value: function removeListener(name, f) {
@@ -29948,6 +29925,30 @@ var WMJSMap = /*#__PURE__*/function () {
29948
29925
  return WMJSMap;
29949
29926
  }();
29950
29927
 
29928
+ /* *
29929
+ * Licensed under the Apache License, Version 2.0 (the "License");
29930
+ * you may not use this file except in compliance with the License.
29931
+ * You may obtain a copy of the License at
29932
+ *
29933
+ * http://www.apache.org/licenses/LICENSE-2.0
29934
+ *
29935
+ * Unless required by applicable law or agreed to in writing, software
29936
+ * distributed under the License is distributed on an "AS IS" BASIS,
29937
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29938
+ * See the License for the specific language governing permissions and
29939
+ * limitations under the License.
29940
+ *
29941
+ * Copyright 2020 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
29942
+ * Copyright 2020 - Finnish Meteorological Institute (FMI)
29943
+ * */
29944
+ /**
29945
+ * Global service store for re-use of services
29946
+ */
29947
+ var WMServiceStore = [];
29948
+ var WMServiceStoreXML2JSONRequest = {
29949
+ proxy: 'Check WMJSGlobals WMJSServiceStoreXML2JSONRequest'
29950
+ };
29951
+
29951
29952
  /* *
29952
29953
  * Licensed under the Apache License, Version 2.0 (the "License");
29953
29954
  * you may not use this file except in compliance with the License.
@@ -30351,30 +30352,6 @@ var I18n = {
30351
30352
  }
30352
30353
  };
30353
30354
 
30354
- /* *
30355
- * Licensed under the Apache License, Version 2.0 (the "License");
30356
- * you may not use this file except in compliance with the License.
30357
- * You may obtain a copy of the License at
30358
- *
30359
- * http://www.apache.org/licenses/LICENSE-2.0
30360
- *
30361
- * Unless required by applicable law or agreed to in writing, software
30362
- * distributed under the License is distributed on an "AS IS" BASIS,
30363
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30364
- * See the License for the specific language governing permissions and
30365
- * limitations under the License.
30366
- *
30367
- * Copyright 2020 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
30368
- * Copyright 2020 - Finnish Meteorological Institute (FMI)
30369
- * */
30370
- /**
30371
- * Global service store for re-use of services
30372
- */
30373
- var WMServiceStore = [];
30374
- var WMServiceStoreXML2JSONRequest = {
30375
- proxy: 'Check WMJSGlobals WMJSServiceStoreXML2JSONRequest'
30376
- };
30377
-
30378
30355
  /* *
30379
30356
  * Licensed under the Apache License, Version 2.0 (the "License");
30380
30357
  * you may not use this file except in compliance with the License.
@@ -30918,6 +30895,7 @@ var LayerType;
30918
30895
  LayerType["mapLayer"] = "mapLayer";
30919
30896
  LayerType["baseLayer"] = "baseLayer";
30920
30897
  LayerType["overLayer"] = "overLayer";
30898
+ LayerType["featureLayer"] = "featureLayer";
30921
30899
  })(LayerType || (LayerType = {}));
30922
30900
  /**
30923
30901
  * 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.
@@ -31597,9 +31575,7 @@ var WMLayer = /*#__PURE__*/function () {
31597
31575
  this.legendGraphic = this.styles[0].legendURL;
31598
31576
  }
31599
31577
  /* Check if this legenURL has already a Layer Property set. If so set the Layer to the name of this layer */
31600
- this.legendGraphic = getUriWithParam(this.legendGraphic, {
31601
- layer: this.name
31602
- });
31578
+ this.legendGraphic = getUriWithParam(this.legendGraphic);
31603
31579
  }
31604
31580
  }, {
31605
31581
  key: "getStyles",
@@ -31746,6 +31722,269 @@ var WMLayer = /*#__PURE__*/function () {
31746
31722
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
31747
31723
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
31748
31724
  * */
31725
+ var generatedLayerIds = 0;
31726
+ var generateLayerId = function generateLayerId() {
31727
+ generatedLayerIds += 1;
31728
+ return "layerid_".concat(generatedLayerIds);
31729
+ };
31730
+ var generatedMapIds = 0;
31731
+ var generateMapId = function generateMapId() {
31732
+ generatedMapIds += 1;
31733
+ return "mapid_".concat(generatedMapIds);
31734
+ };
31735
+ var generatedTimesliderIds = 0;
31736
+ var generateTimesliderId = function generateTimesliderId() {
31737
+ generatedTimesliderIds += 1;
31738
+ return "timesliderid_".concat(generatedTimesliderIds);
31739
+ };
31740
+ /**
31741
+ * Map for registering wmlayers with their id's
31742
+ */
31743
+ var registeredWMLayersForReactLayerId = {};
31744
+ /**
31745
+ * Registers a WMJSLayer in a lookuptable with a layerId
31746
+ * @param {WMLayer} wmLayer
31747
+ * @param {string} layerId
31748
+ */
31749
+ var registerWMLayer = function registerWMLayer(wmLayer, layerId) {
31750
+ registeredWMLayersForReactLayerId[layerId] = wmLayer;
31751
+ };
31752
+ /**
31753
+ * Get the WMLayer from the lookuptable with layerId
31754
+ * @param {string} layerId
31755
+ */
31756
+ var getWMLayerById = function getWMLayerById(layerId) {
31757
+ return registeredWMLayersForReactLayerId[layerId];
31758
+ };
31759
+ var unRegisterWMJSLayer = function unRegisterWMJSLayer(layerId) {
31760
+ var layer = registeredWMLayersForReactLayerId[layerId];
31761
+ if (layer) {
31762
+ delete registeredWMLayersForReactLayerId[layerId];
31763
+ }
31764
+ };
31765
+ var unRegisterAllWMJSLayersAndMaps = function unRegisterAllWMJSLayersAndMaps() {
31766
+ var allLayerIds = Object.keys(registeredWMLayersForReactLayerId);
31767
+ allLayerIds.forEach(function (layerId) {
31768
+ unRegisterWMJSLayer(layerId);
31769
+ });
31770
+ var allMapIds = Object.keys(registeredWMMapForReactMapId);
31771
+ allMapIds.forEach(function (mapId) {
31772
+ unRegisterWMJSMap(mapId);
31773
+ });
31774
+ };
31775
+ /**
31776
+ * Map for registering wmlayers with their id's
31777
+ */
31778
+ var registeredWMMapForReactMapId = {};
31779
+ /**
31780
+ * Registers a WMJSMap in a lookuptable with a wmjsMapId
31781
+ * @param {WMJSMap} wmjsMap
31782
+ * @param {string} wmjsMapId
31783
+ */
31784
+ var registerWMJSMap = function registerWMJSMap(wmjsMap, wmjsMapId) {
31785
+ if (registeredWMMapForReactMapId[wmjsMapId]) {
31786
+ console.warn("Map with id ".concat(wmjsMapId, " already made"));
31787
+ }
31788
+ registeredWMMapForReactMapId[wmjsMapId] = wmjsMap;
31789
+ };
31790
+ var unRegisterWMJSMap = function unRegisterWMJSMap(wmjsMapId) {
31791
+ var wmjsMap = registeredWMMapForReactMapId[wmjsMapId];
31792
+ if (wmjsMap) {
31793
+ wmjsMap.getListener().suspendEvents();
31794
+ try {
31795
+ wmjsMap.stopAnimating && wmjsMap.stopAnimating();
31796
+ } catch (e) {
31797
+ console.warn(e);
31798
+ }
31799
+ Object.keys(registeredWMLayersForReactLayerId).forEach(function (layerId) {
31800
+ var wmLayer = getWMLayerById(layerId);
31801
+ if (wmLayer.parentMap === wmjsMap) {
31802
+ unRegisterWMJSLayer(layerId);
31803
+ }
31804
+ });
31805
+ wmjsMap.destroy();
31806
+ delete registeredWMMapForReactMapId[wmjsMapId];
31807
+ }
31808
+ };
31809
+ /**
31810
+ * Get the wmjsMap from the lookuptable with wmjsMapId
31811
+ * @param {string} wmjsMapId
31812
+ */
31813
+ var getWMJSMapById = function getWMJSMapById(wmjsMapId) {
31814
+ return registeredWMMapForReactMapId[wmjsMapId];
31815
+ };
31816
+ /**
31817
+ * Returns the WMJSDimension object for given layerId and dimension name
31818
+ * @param layerId The layerId
31819
+ * @param dimensionName The dimension to lookup
31820
+ */
31821
+ var getWMJSDimensionForLayerAndDimension = function getWMJSDimensionForLayerAndDimension(layerId, dimensionName) {
31822
+ var wmLayer = getWMLayerById(layerId);
31823
+ if (!wmLayer || !dimensionName) {
31824
+ return undefined;
31825
+ }
31826
+ var wmjsDimension = wmLayer.getDimension(dimensionName);
31827
+ if (!wmjsDimension) {
31828
+ return undefined;
31829
+ }
31830
+ return wmjsDimension;
31831
+ };
31832
+ /**
31833
+ * Gets the WMJSTimeDimension for given activeLayerId and dimensions list
31834
+ * @param layerId: The layer id to search the WMJSDimension for
31835
+ * @return: The WMJSDimension if found, otherwise null
31836
+ */
31837
+ var getWMJSTimeDimensionForLayerId = function getWMJSTimeDimensionForLayerId(layerId) {
31838
+ var wmLayer = getWMLayerById(layerId);
31839
+ if (!wmLayer) {
31840
+ return null;
31841
+ }
31842
+ return wmLayer.getDimension('time');
31843
+ };
31844
+
31845
+ var utils = /*#__PURE__*/Object.freeze({
31846
+ __proto__: null,
31847
+ generateLayerId: generateLayerId,
31848
+ generateMapId: generateMapId,
31849
+ generateTimesliderId: generateTimesliderId,
31850
+ registerWMLayer: registerWMLayer,
31851
+ getWMLayerById: getWMLayerById,
31852
+ unRegisterWMJSLayer: unRegisterWMJSLayer,
31853
+ unRegisterAllWMJSLayersAndMaps: unRegisterAllWMJSLayersAndMaps,
31854
+ registerWMJSMap: registerWMJSMap,
31855
+ unRegisterWMJSMap: unRegisterWMJSMap,
31856
+ getWMJSMapById: getWMJSMapById,
31857
+ getWMJSDimensionForLayerAndDimension: getWMJSDimensionForLayerAndDimension,
31858
+ getWMJSTimeDimensionForLayerId: getWMJSTimeDimensionForLayerId
31859
+ });
31860
+
31861
+ /* *
31862
+ * Licensed under the Apache License, Version 2.0 (the "License");
31863
+ * you may not use this file except in compliance with the License.
31864
+ * You may obtain a copy of the License at
31865
+ *
31866
+ * http://www.apache.org/licenses/LICENSE-2.0
31867
+ *
31868
+ * Unless required by applicable law or agreed to in writing, software
31869
+ * distributed under the License is distributed on an "AS IS" BASIS,
31870
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31871
+ * See the License for the specific language governing permissions and
31872
+ * limitations under the License.
31873
+ *
31874
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
31875
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
31876
+ * */
31877
+ var multiDimensionLayer = {
31878
+ service: 'https://testservice',
31879
+ id: 'multiDimensionLayerMock',
31880
+ name: 'MULTI_DIMENSION_LAYER',
31881
+ title: 'MULTI_DIMENSION_LAYER',
31882
+ layerType: LayerType.mapLayer,
31883
+ enabled: true,
31884
+ dimensions: [{
31885
+ name: 'flight level',
31886
+ units: 'hft',
31887
+ currentValue: '625',
31888
+ values: '25,325,625'
31889
+ }, {
31890
+ name: 'elevation',
31891
+ units: 'meters',
31892
+ currentValue: '9000',
31893
+ values: '1000,5000,9000'
31894
+ }, {
31895
+ name: 'time',
31896
+ units: 'ISO8601',
31897
+ currentValue: '2020-03-13T14:40:00Z'
31898
+ }]
31899
+ };
31900
+ var WmdefaultReduxLayerRadarKNMI = new WMLayer({
31901
+ service: 'https://testservice',
31902
+ name: 'RADNL_OPER_R___25PCPRR_L3_KNMI',
31903
+ title: 'RADNL_OPER_R___25PCPRR_L3_KNMI',
31904
+ format: 'image/png',
31905
+ style: 'knmiradar/nearest',
31906
+ enabled: true,
31907
+ layerType: LayerType.mapLayer,
31908
+ dimensions: [{
31909
+ name: 'time',
31910
+ units: 'ISO8601',
31911
+ currentValue: '2020-03-13T13:30:00Z'
31912
+ }],
31913
+ id: 'layerid_3'
31914
+ });
31915
+ var defaultReduxLayerRadarKNMI = {
31916
+ service: 'https://testservice',
31917
+ name: 'RADNL_OPER_R___25PCPRR_L3_KNMI',
31918
+ title: 'RADNL_OPER_R___25PCPRR_L3_KNMI',
31919
+ format: 'image/png',
31920
+ style: 'knmiradar/nearest',
31921
+ enabled: true,
31922
+ layerType: LayerType.mapLayer,
31923
+ dimensions: [{
31924
+ name: 'time',
31925
+ units: 'ISO8601',
31926
+ currentValue: '2020-03-13T13:30:00Z'
31927
+ }],
31928
+ styles: [{
31929
+ title: 'knmiradar/nearest',
31930
+ name: 'knmiradar/nearest',
31931
+ legendURL: 'https://geoservices.knmi.nl/wms?dataset=RADAR&SERVICE=WMS&&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=RADNL_OPER_R___25PCPRR_L3_KNMI&format=image/png&STYLE=knmiradar/nearest',
31932
+ "abstract": 'No abstract available'
31933
+ }, {
31934
+ title: 'precip/nearest',
31935
+ name: 'precip/nearest',
31936
+ legendURL: 'https://geoservices.knmi.nl/wms?dataset=RADAR&SERVICE=WMS&&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=RADNL_OPER_R___25PCPRR_L3_KNMI&format=image/png&STYLE=precip/nearest',
31937
+ "abstract": 'No abstract available'
31938
+ }, {
31939
+ title: 'precip-transparent/nearest',
31940
+ name: 'precip-transparent/nearest',
31941
+ legendURL: 'https://geoservices.knmi.nl/wms?dataset=RADAR&SERVICE=WMS&&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=RADNL_OPER_R___25PCPRR_L3_KNMI&format=image/png&STYLE=precip-transparent/nearest',
31942
+ "abstract": 'No abstract available'
31943
+ }, {
31944
+ title: 'precip-gray/nearest',
31945
+ name: 'precip-gray/nearest',
31946
+ legendURL: 'https://geoservices.knmi.nl/wms?dataset=RADAR&SERVICE=WMS&&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=RADNL_OPER_R___25PCPRR_L3_KNMI&format=image/png&STYLE=precip-gray/nearest',
31947
+ "abstract": 'No abstract available'
31948
+ }, {
31949
+ title: 'precip-rainbow/nearest',
31950
+ name: 'precip-rainbow/nearest',
31951
+ legendURL: 'https://geoservices.knmi.nl/wms?dataset=RADAR&SERVICE=WMS&&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=RADNL_OPER_R___25PCPRR_L3_KNMI&format=image/png&STYLE=precip-rainbow/nearest',
31952
+ "abstract": 'No abstract available'
31953
+ }, {
31954
+ title: 'precip-blue/nearest',
31955
+ name: 'precip-blue/nearest',
31956
+ legendURL: 'https://geoservices.knmi.nl/wms?dataset=RADAR&SERVICE=WMS&&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=RADNL_OPER_R___25PCPRR_L3_KNMI&format=image/png&STYLE=precip-blue/nearest',
31957
+ "abstract": 'No abstract available'
31958
+ }, {
31959
+ title: 'precip-blue-transparent/nearest',
31960
+ name: 'precip-blue-transparent/nearest',
31961
+ legendURL: 'https://geoservices.knmi.nl/wms?dataset=RADAR&SERVICE=WMS&&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=RADNL_OPER_R___25PCPRR_L3_KNMI&format=image/png&STYLE=precip-blue-transparent/nearest',
31962
+ "abstract": 'No abstract available'
31963
+ }, {
31964
+ title: 'pseudoradar/nearest',
31965
+ name: 'pseudoradar/nearest',
31966
+ legendURL: 'https://geoservices.knmi.nl/wms?dataset=RADAR&SERVICE=WMS&&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=RADNL_OPER_R___25PCPRR_L3_KNMI&format=image/png&STYLE=pseudoradar/nearest',
31967
+ "abstract": 'No abstract available'
31968
+ }],
31969
+ id: 'layerid_2'
31970
+ };
31971
+ var makeGeoservicesRadarLayer = function makeGeoservicesRadarLayer(dimensions) {
31972
+ return new WMLayer({
31973
+ service: 'https://geoservices.knmi.nl/wms?dataset=RADAR&',
31974
+ name: 'RAD_NL25_PCP_CM',
31975
+ format: 'image/png',
31976
+ enabled: true,
31977
+ style: 'radar/nearest',
31978
+ id: generateLayerId(),
31979
+ layerType: LayerType.mapLayer,
31980
+ title: 'RAD_NL25_PCP_CM',
31981
+ dimensions: dimensions !== null && dimensions !== void 0 ? dimensions : [{
31982
+ name: 'time',
31983
+ units: 'ISO8601',
31984
+ currentValue: '2021-04-15T00:00:00Z'
31985
+ }]
31986
+ });
31987
+ };
31749
31988
  var WmMultiDimensionLayer = new WMLayer({
31750
31989
  service: 'https://testservice',
31751
31990
  id: 'multiDimensionLayerMock',
@@ -31954,6 +32193,10 @@ var styleListForRADNL25PCPCMLayer = [{
31954
32193
 
31955
32194
  var testSettings = /*#__PURE__*/Object.freeze({
31956
32195
  __proto__: null,
32196
+ multiDimensionLayer: multiDimensionLayer,
32197
+ WmdefaultReduxLayerRadarKNMI: WmdefaultReduxLayerRadarKNMI,
32198
+ defaultReduxLayerRadarKNMI: defaultReduxLayerRadarKNMI,
32199
+ makeGeoservicesRadarLayer: makeGeoservicesRadarLayer,
31957
32200
  WmMultiDimensionLayer: WmMultiDimensionLayer,
31958
32201
  layerWithoutTimeDimension: layerWithoutTimeDimension,
31959
32202
  WmLayerWithoutTimeDimension: WmLayerWithoutTimeDimension,
@@ -31977,6 +32220,19 @@ var testSettings = /*#__PURE__*/Object.freeze({
31977
32220
  * Copyright 2020 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
31978
32221
  * Copyright 2020 - Finnish Meteorological Institute (FMI)
31979
32222
  * */
32223
+ var EPSGCode;
32224
+ (function (EPSGCode) {
32225
+ EPSGCode["EPSG3857"] = "EPSG:3857";
32226
+ EPSGCode["EPSG28992"] = "EPSG:28992";
32227
+ EPSGCode["TODO_EPSG4326"] = "TODO__EPSG:4326";
32228
+ EPSGCode["EPSG3411"] = "EPSG:3411";
32229
+ EPSGCode["EPSG32661"] = "EPSG:32661";
32230
+ EPSGCode["EPSG54030"] = "EPSG:54030";
32231
+ EPSGCode["EPSG4326"] = "EPSG:4326";
32232
+ EPSGCode["EPSG4258"] = "EPSG:4258";
32233
+ EPSGCode["EPSG3412"] = "EPSG:3412";
32234
+ EPSGCode["EPSG3575"] = "EPSG:3575";
32235
+ })(EPSGCode || (EPSGCode = {}));
31980
32236
  var tilesettings = {
31981
32237
  WorldMap_Light_Grey_Canvas: {
31982
32238
  'EPSG:3857': {
@@ -32312,158 +32568,6 @@ var tilesettings = {
32312
32568
  }
32313
32569
  };
32314
32570
 
32315
- /* *
32316
- * Licensed under the Apache License, Version 2.0 (the "License");
32317
- * you may not use this file except in compliance with the License.
32318
- * You may obtain a copy of the License at
32319
- *
32320
- * http://www.apache.org/licenses/LICENSE-2.0
32321
- *
32322
- * Unless required by applicable law or agreed to in writing, software
32323
- * distributed under the License is distributed on an "AS IS" BASIS,
32324
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32325
- * See the License for the specific language governing permissions and
32326
- * limitations under the License.
32327
- *
32328
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
32329
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
32330
- * */
32331
- var generatedLayerIds = 0;
32332
- var generateLayerId = function generateLayerId() {
32333
- generatedLayerIds += 1;
32334
- return "layerid_".concat(generatedLayerIds);
32335
- };
32336
- var generatedMapIds = 0;
32337
- var generateMapId = function generateMapId() {
32338
- generatedMapIds += 1;
32339
- return "mapid_".concat(generatedMapIds);
32340
- };
32341
- var generatedTimesliderIds = 0;
32342
- var generateTimesliderId = function generateTimesliderId() {
32343
- generatedTimesliderIds += 1;
32344
- return "timesliderid_".concat(generatedTimesliderIds);
32345
- };
32346
- /**
32347
- * Map for registering wmlayers with their id's
32348
- */
32349
- var registeredWMLayersForReactLayerId = {};
32350
- /**
32351
- * Registers a WMJSLayer in a lookuptable with a layerId
32352
- * @param {WMLayer} wmLayer
32353
- * @param {string} layerId
32354
- */
32355
- var registerWMLayer = function registerWMLayer(wmLayer, layerId) {
32356
- registeredWMLayersForReactLayerId[layerId] = wmLayer;
32357
- };
32358
- /**
32359
- * Get the WMLayer from the lookuptable with layerId
32360
- * @param {string} layerId
32361
- */
32362
- var getWMLayerById = function getWMLayerById(layerId) {
32363
- return registeredWMLayersForReactLayerId[layerId];
32364
- };
32365
- var unRegisterWMJSLayer = function unRegisterWMJSLayer(layerId) {
32366
- var layer = registeredWMLayersForReactLayerId[layerId];
32367
- if (layer) {
32368
- delete registeredWMLayersForReactLayerId[layerId];
32369
- }
32370
- };
32371
- var unRegisterAllWMJSLayersAndMaps = function unRegisterAllWMJSLayersAndMaps() {
32372
- var allLayerIds = Object.keys(registeredWMLayersForReactLayerId);
32373
- allLayerIds.forEach(function (layerId) {
32374
- unRegisterWMJSLayer(layerId);
32375
- });
32376
- var allMapIds = Object.keys(registeredWMMapForReactMapId);
32377
- allMapIds.forEach(function (mapId) {
32378
- unRegisterWMJSMap(mapId);
32379
- });
32380
- };
32381
- /**
32382
- * Map for registering wmlayers with their id's
32383
- */
32384
- var registeredWMMapForReactMapId = {};
32385
- /**
32386
- * Registers a WMJSMap in a lookuptable with a wmjsMapId
32387
- * @param {WMJSMap} wmjsMap
32388
- * @param {string} wmjsMapId
32389
- */
32390
- var registerWMJSMap = function registerWMJSMap(wmjsMap, wmjsMapId) {
32391
- if (registeredWMMapForReactMapId[wmjsMapId]) {
32392
- console.warn("Map with id ".concat(wmjsMapId, " already made"));
32393
- }
32394
- registeredWMMapForReactMapId[wmjsMapId] = wmjsMap;
32395
- };
32396
- var unRegisterWMJSMap = function unRegisterWMJSMap(wmjsMapId) {
32397
- var wmjsMap = registeredWMMapForReactMapId[wmjsMapId];
32398
- if (wmjsMap) {
32399
- wmjsMap.getListener().suspendEvents();
32400
- try {
32401
- wmjsMap.stopAnimating && wmjsMap.stopAnimating();
32402
- } catch (e) {
32403
- console.warn(e);
32404
- }
32405
- Object.keys(registeredWMLayersForReactLayerId).forEach(function (layerId) {
32406
- var wmLayer = getWMLayerById(layerId);
32407
- if (wmLayer.parentMap === wmjsMap) {
32408
- unRegisterWMJSLayer(layerId);
32409
- }
32410
- });
32411
- wmjsMap.destroy();
32412
- delete registeredWMMapForReactMapId[wmjsMapId];
32413
- }
32414
- };
32415
- /**
32416
- * Get the wmjsMap from the lookuptable with wmjsMapId
32417
- * @param {string} wmjsMapId
32418
- */
32419
- var getWMJSMapById = function getWMJSMapById(wmjsMapId) {
32420
- return registeredWMMapForReactMapId[wmjsMapId];
32421
- };
32422
- /**
32423
- * Returns the WMJSDimension object for given layerId and dimension name
32424
- * @param layerId The layerId
32425
- * @param dimensionName The dimension to lookup
32426
- */
32427
- var getWMJSDimensionForLayerAndDimension = function getWMJSDimensionForLayerAndDimension(layerId, dimensionName) {
32428
- var wmLayer = getWMLayerById(layerId);
32429
- if (!wmLayer || !dimensionName) {
32430
- return undefined;
32431
- }
32432
- var wmjsDimension = wmLayer.getDimension(dimensionName);
32433
- if (!wmjsDimension) {
32434
- return undefined;
32435
- }
32436
- return wmjsDimension;
32437
- };
32438
- /**
32439
- * Gets the WMJSTimeDimension for given activeLayerId and dimensions list
32440
- * @param layerId: The layer id to search the WMJSDimension for
32441
- * @return: The WMJSDimension if found, otherwise null
32442
- */
32443
- var getWMJSTimeDimensionForLayerId = function getWMJSTimeDimensionForLayerId(layerId) {
32444
- var wmLayer = getWMLayerById(layerId);
32445
- if (!wmLayer) {
32446
- return null;
32447
- }
32448
- return wmLayer.getDimension('time');
32449
- };
32450
-
32451
- var utils = /*#__PURE__*/Object.freeze({
32452
- __proto__: null,
32453
- generateLayerId: generateLayerId,
32454
- generateMapId: generateMapId,
32455
- generateTimesliderId: generateTimesliderId,
32456
- registerWMLayer: registerWMLayer,
32457
- getWMLayerById: getWMLayerById,
32458
- unRegisterWMJSLayer: unRegisterWMJSLayer,
32459
- unRegisterAllWMJSLayersAndMaps: unRegisterAllWMJSLayersAndMaps,
32460
- registerWMJSMap: registerWMJSMap,
32461
- unRegisterWMJSMap: unRegisterWMJSMap,
32462
- getWMJSMapById: getWMJSMapById,
32463
- getWMJSDimensionForLayerAndDimension: getWMJSDimensionForLayerAndDimension,
32464
- getWMJSTimeDimensionForLayerId: getWMJSTimeDimensionForLayerId
32465
- });
32466
-
32467
32571
  /* *
32468
32572
  * Licensed under the Apache License, Version 2.0 (the "License");
32469
32573
  * you may not use this file except in compliance with the License.
@@ -32804,4 +32908,4 @@ var getCapabilities = /*#__PURE__*/Object.freeze({
32804
32908
  getLayersFlattenedFromService: getLayersFlattenedFromService
32805
32909
  });
32806
32910
 
32807
- export { DateInterval, DebugType, I18n, LayerType, ParseISOTimeRangeDuration, URLDecode, URLEncode, WMBBOX, WMDateOutSideRange, WMDateTooEarlyString, WMDateTooLateString, WMEmptyLayerName, WMEmptyLayerTitle, WMGetServiceFromStore, WMImage, WMImageEventType, WMJSDimension, WMJSMap, WMJSService, WMJScheckURL, WMLayer, WMTimer, clearImageCache, debug, getCapabilities, getLegendGraphicURLForLayer, getMapImageStore, isDefined, legendImageStore, mockGetCapabilities, parseISO8601DateToDate, parseISO8601IntervalToDateInterval, tilesettings, toArray, testSettings as webmapTestSettings, utils as webmapUtils };
32911
+ export { DateInterval, DebugType, EPSGCode, I18n, LayerType, ParseISOTimeRangeDuration, URLDecode, URLEncode, WMBBOX, WMDateOutSideRange, WMDateTooEarlyString, WMDateTooLateString, WMEmptyLayerName, WMEmptyLayerTitle, WMGetServiceFromStore, WMImage, WMImageEventType, WMJSDimension, WMJSMap, WMJSService, WMJScheckURL, WMLayer, WMTimer, clearImageCache, debug, getCapabilities, getLegendGraphicURLForLayer, getMapImageStore, isDefined, legendImageStore, mockGetCapabilities, parseISO8601DateToDate, parseISO8601IntervalToDateInterval, tilesettings, toArray, testSettings as webmapTestSettings, utils as webmapUtils };