@opengeoweb/store 9.7.0 → 9.9.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
@@ -1,9 +1,8 @@
1
1
  import { current, produce } from 'immer';
2
2
  import { webmapUtils, LayerType, webmapTestSettings, WMLayer, handleMomentISOString, getCapabilities } from '@opengeoweb/webmap';
3
- import { createAction, createSlice, createSelector, createEntityAdapter, current as current$1 } from '@reduxjs/toolkit';
4
- import { getGeoJson, moveFeature, createInterSections, defaultLayers, getFeatureCollection, emptyGeoJSON, defaultIntersectionStyleProperties } from '@opengeoweb/webmap-react';
3
+ import { createAction, createSlice, createSelector, createEntityAdapter } from '@reduxjs/toolkit';
4
+ import { getGeoJson, moveFeature, createInterSections, getLastEmptyFeatureIndex, defaultLayers, addSelectionTypeToGeoJSON, getFeatureCollection, emptyGeoJSON, defaultIntersectionStyleProperties } from '@opengeoweb/webmap-react';
5
5
  export { defaultLayers } from '@opengeoweb/webmap-react';
6
- import { differenceInMinutes, isValid, fromUnixTime } from 'date-fns';
7
6
  import { dateUtils, withEggs } from '@opengeoweb/shared';
8
7
  import { isEqual, compact } from 'lodash';
9
8
  import { createStore as createStore$1 } from '@redux-eggs/redux-toolkit';
@@ -403,6 +402,57 @@ function _nonIterableSpread() {
403
402
  function _nonIterableRest() {
404
403
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
405
404
  }
405
+ function _createForOfIteratorHelper(o, allowArrayLike) {
406
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
407
+ if (!it) {
408
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
409
+ if (it) o = it;
410
+ var i = 0;
411
+ var F = function () {};
412
+ return {
413
+ s: F,
414
+ n: function () {
415
+ if (i >= o.length) return {
416
+ done: true
417
+ };
418
+ return {
419
+ done: false,
420
+ value: o[i++]
421
+ };
422
+ },
423
+ e: function (e) {
424
+ throw e;
425
+ },
426
+ f: F
427
+ };
428
+ }
429
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
430
+ }
431
+ var normalCompletion = true,
432
+ didErr = false,
433
+ err;
434
+ return {
435
+ s: function () {
436
+ it = it.call(o);
437
+ },
438
+ n: function () {
439
+ var step = it.next();
440
+ normalCompletion = step.done;
441
+ return step;
442
+ },
443
+ e: function (e) {
444
+ didErr = true;
445
+ err = e;
446
+ },
447
+ f: function () {
448
+ try {
449
+ if (!normalCompletion && it.return != null) it.return();
450
+ } finally {
451
+ if (didErr) throw err;
452
+ }
453
+ }
454
+ };
455
+ }
406
456
 
407
457
  /******************************************************************************
408
458
  Copyright (c) Microsoft Corporation.
@@ -562,17 +612,17 @@ var createMap = function createMap(_ref) {
562
612
  _ref$isAnimating = _ref.isAnimating,
563
613
  isAnimating = _ref$isAnimating === void 0 ? false : _ref$isAnimating,
564
614
  _ref$animationStartTi = _ref.animationStartTime,
565
- animationStartTime = _ref$animationStartTi === void 0 ? dateUtils.dateToString(dateUtils.sub(dateUtils.fromUnix(dateUtils.unix(dateUtils.utc())), {
615
+ animationStartTime = _ref$animationStartTi === void 0 ? dateUtils.dateToString(dateUtils.sub(dateUtils.getNowUtc(), {
566
616
  hours: 5
567
617
  }), dateFormat) : _ref$animationStartTi,
568
618
  _ref$animationEndTime = _ref.animationEndTime,
569
- animationEndTime = _ref$animationEndTime === void 0 ? dateUtils.dateToString(dateUtils.sub(dateUtils.fromUnix(dateUtils.unix(dateUtils.utc())), {
619
+ animationEndTime = _ref$animationEndTime === void 0 ? dateUtils.dateToString(dateUtils.sub(dateUtils.getNowUtc(), {
570
620
  minutes: 10
571
621
  }), dateFormat) : _ref$animationEndTime,
572
622
  _ref$isAutoUpdating = _ref.isAutoUpdating,
573
623
  isAutoUpdating = _ref$isAutoUpdating === void 0 ? false : _ref$isAutoUpdating,
574
- _ref$isEndTimeOverrid = _ref.isEndTimeOverriding,
575
- isEndTimeOverriding = _ref$isEndTimeOverrid === void 0 ? false : _ref$isEndTimeOverrid,
624
+ _ref$shouldEndtimeOve = _ref.shouldEndtimeOverride,
625
+ shouldEndtimeOverride = _ref$shouldEndtimeOve === void 0 ? false : _ref$shouldEndtimeOve,
576
626
  _ref$bbox = _ref.bbox,
577
627
  bbox = _ref$bbox === void 0 ? {
578
628
  left: -19000000,
@@ -626,7 +676,7 @@ var createMap = function createMap(_ref) {
626
676
  animationStartTime: animationStartTime,
627
677
  animationEndTime: animationEndTime,
628
678
  isAutoUpdating: isAutoUpdating,
629
- isEndTimeOverriding: isEndTimeOverriding,
679
+ shouldEndtimeOverride: shouldEndtimeOverride,
630
680
  srs: srs,
631
681
  bbox: bbox,
632
682
  baseLayers: baseLayers,
@@ -654,19 +704,28 @@ var createMap = function createMap(_ref) {
654
704
  var checkValidLayersPayload = function checkValidLayersPayload(layers, mapId) {
655
705
  /* Check for duplicate ids */
656
706
  var layerIds = {};
657
- for (var i = 0; i < layers.length; i += 1) {
658
- if (layers[i].id) {
659
- /* Check if layer is already added to a different map */
660
- if (layers[i].mapId && mapId && layers[i].mapId !== mapId) {
661
- return false;
662
- }
663
- /* Check duplicate */
664
- if (!layerIds[layers[i].id]) {
665
- layerIds[layers[i].id] = true;
666
- } else {
667
- return false;
707
+ var _iterator = _createForOfIteratorHelper(layers),
708
+ _step;
709
+ try {
710
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
711
+ var layer = _step.value;
712
+ if (layer.id) {
713
+ /* Check if layer is already added to a different map */
714
+ if (layer.mapId && mapId && layer.mapId !== mapId) {
715
+ return false;
716
+ }
717
+ /* Check duplicate */
718
+ if (!layerIds[layer.id]) {
719
+ layerIds[layer.id] = true;
720
+ } else {
721
+ return false;
722
+ }
668
723
  }
669
724
  }
725
+ } catch (err) {
726
+ _iterator.e(err);
727
+ } finally {
728
+ _iterator.f();
670
729
  }
671
730
  return true;
672
731
  };
@@ -799,7 +858,7 @@ var getSpeedFactor = function getSpeedFactor(speedDelay) {
799
858
  return defaultDelay / speedDelay;
800
859
  };
801
860
  var getAnimationDuration = function getAnimationDuration(animationEndTime, animationStartTime) {
802
- return animationEndTime && animationStartTime ? differenceInMinutes(new Date(animationEndTime), new Date(animationStartTime)) : 0;
861
+ return animationEndTime && animationStartTime ? dateUtils.differenceInMinutes(new Date(animationEndTime), new Date(animationStartTime)) : 0;
803
862
  };
804
863
  /**
805
864
  * Returns speed delay for given speedFactor. For options, see defined above in "speedFactors"
@@ -1300,17 +1359,15 @@ var slice$7 = createSlice({
1300
1359
  }
1301
1360
  /*
1302
1361
  All layer id's for the specified mapId should be removed.
1303
- This is done by clearing the allId object, and then adding back the layer ids for the other maps we want to keep.
1362
+ This is done by filtering the allId array. Keeping only the layer id's which don't exist in the byId object
1304
1363
  At the same time the byId object is synchronized.
1305
1364
  */
1306
- var state = current(draft);
1307
- draft.allIds = [];
1308
- state.allIds.forEach(function (layerId) {
1309
- if (state.byId[layerId] && state.byId[layerId].layerType !== LayerType.baseLayer && state.byId[layerId].layerType !== LayerType.overLayer && state.byId[layerId].mapId === mapId) {
1365
+ draft.allIds = draft.allIds.filter(function (layerId) {
1366
+ if (draft.byId[layerId] && draft.byId[layerId].layerType !== LayerType.baseLayer && draft.byId[layerId].layerType !== LayerType.overLayer && draft.byId[layerId].mapId === mapId) {
1310
1367
  delete draft.byId[layerId];
1311
- } else {
1312
- draft.allIds.push(layerId);
1368
+ return false;
1313
1369
  }
1370
+ return true;
1314
1371
  });
1315
1372
  /*
1316
1373
  Here we set the layers for the mapId from the action. byId and allIds is updated.
@@ -1340,14 +1397,13 @@ var slice$7 = createSlice({
1340
1397
  layerTypes.push(layer.layerType);
1341
1398
  }
1342
1399
  });
1343
- var state = current(draft);
1344
1400
  // remove current layers with same type as one of the passed layers
1345
- state.allIds.forEach(function (layerId) {
1346
- if (state.byId[layerId] && layerTypes.includes(state.byId[layerId].layerType) && state.byId[layerId].mapId === mapId) {
1401
+ draft.allIds = draft.allIds.filter(function (layerId) {
1402
+ if (draft.byId[layerId] && layerTypes.includes(draft.byId[layerId].layerType) && draft.byId[layerId].mapId === mapId) {
1347
1403
  delete draft.byId[layerId];
1348
- var index = draft.allIds.indexOf(layerId);
1349
- draft.allIds.splice(index, 1);
1404
+ return false;
1350
1405
  }
1406
+ return true;
1351
1407
  });
1352
1408
  // set over and base layers
1353
1409
  filtererdBaseLayers.forEach(function (layer) {
@@ -1412,14 +1468,13 @@ var slice$7 = createSlice({
1412
1468
  var _action$payload13 = action.payload,
1413
1469
  layers = _action$payload13.layers,
1414
1470
  mapId = _action$payload13.mapId;
1415
- var state = current(draft);
1416
1471
  // remove current baselayers for passed map
1417
- state.availableBaseLayers.allIds.forEach(function (layerId) {
1418
- if (state.availableBaseLayers.byId[layerId] && state.availableBaseLayers.byId[layerId].mapId === mapId) {
1472
+ draft.availableBaseLayers.allIds = draft.availableBaseLayers.allIds.filter(function (layerId) {
1473
+ if (draft.availableBaseLayers.byId[layerId] && draft.availableBaseLayers.byId[layerId].mapId === mapId) {
1419
1474
  delete draft.availableBaseLayers.byId[layerId];
1420
- var index = draft.availableBaseLayers.allIds.indexOf(layerId);
1421
- draft.availableBaseLayers.allIds.splice(index, 1);
1475
+ return false;
1422
1476
  }
1477
+ return true;
1423
1478
  });
1424
1479
  // add new available baselayers
1425
1480
  layers.forEach(function (layer) {
@@ -1599,9 +1654,23 @@ var slice$7 = createSlice({
1599
1654
  if (!draft.byId[layerId]) {
1600
1655
  return;
1601
1656
  }
1602
- if (!shouldAllowMultipleShapes || shouldAllowMultipleShapes && reason === 'escaped') {
1657
+ var exitMultipleShapes = shouldAllowMultipleShapes && reason === 'escaped';
1658
+ if (!shouldAllowMultipleShapes || exitMultipleShapes) {
1603
1659
  draft.byId[layerId].isInEditMode = false;
1604
1660
  draft.byId[layerId].drawMode = '';
1661
+ if (exitMultipleShapes) {
1662
+ var currentGeoJSON = current(draft.byId[layerId].geojson);
1663
+ var lastFeatureIndex = currentGeoJSON !== undefined && getLastEmptyFeatureIndex(currentGeoJSON);
1664
+ if (currentGeoJSON && lastFeatureIndex !== undefined) {
1665
+ var newGeoJSON = Object.assign(Object.assign({}, currentGeoJSON), {
1666
+ features: currentGeoJSON.features.filter(function (_feature, index) {
1667
+ return index !== lastFeatureIndex;
1668
+ })
1669
+ });
1670
+ draft.byId[layerId].geojson = newGeoJSON;
1671
+ draft.byId[layerId].selectedFeatureIndex = newGeoJSON.features.length > 0 ? newGeoJSON.features.length - 1 : 0;
1672
+ }
1673
+ }
1605
1674
  }
1606
1675
  }
1607
1676
  },
@@ -1636,7 +1705,6 @@ var slice$7 = createSlice({
1636
1705
  var _action$payload22 = action.payload,
1637
1706
  targets = _action$payload22.targets,
1638
1707
  source = _action$payload22.source;
1639
- var state = current(draft);
1640
1708
  return targets.reduce(function (prevState, target) {
1641
1709
  var action = {
1642
1710
  payload: target,
@@ -1644,7 +1712,7 @@ var slice$7 = createSlice({
1644
1712
  };
1645
1713
  /* Handle the Layer action with the same logic, using the same reducer */
1646
1714
  return reducer$7(prevState, action);
1647
- }, state);
1715
+ }, draft);
1648
1716
  }).addCase(setMapPreset, function (draft, action) {
1649
1717
  var mapId = action.payload.mapId;
1650
1718
  var layers = draft.allIds.map(function (id) {
@@ -2402,14 +2470,22 @@ var createLayersWithIds = function createLayersWithIds(state, layers) {
2402
2470
  return layers;
2403
2471
  }
2404
2472
  return produce(layers, function (draft) {
2405
- for (var j = 0; j < draft.length; j += 1) {
2406
- var layer = draft[j];
2407
- if (!layer.id) {
2408
- layer.id = webmapUtils.generateLayerId();
2409
- } else if (checkIfMapLayerIdIsAlreadyTaken(state, layer.id)) {
2410
- console.warn("Warning: Layer id ".concat(layer.id, " was already taken: Generating new one."));
2411
- layer.id = webmapUtils.generateLayerId();
2473
+ var _iterator = _createForOfIteratorHelper(draft),
2474
+ _step;
2475
+ try {
2476
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2477
+ var layer = _step.value;
2478
+ if (!layer.id) {
2479
+ layer.id = webmapUtils.generateLayerId();
2480
+ } else if (checkIfMapLayerIdIsAlreadyTaken(state, layer.id)) {
2481
+ console.warn("Warning: Layer id ".concat(layer.id, " was already taken: Generating new one."));
2482
+ layer.id = webmapUtils.generateLayerId();
2483
+ }
2412
2484
  }
2485
+ } catch (err) {
2486
+ _iterator.e(err);
2487
+ } finally {
2488
+ _iterator.f();
2413
2489
  }
2414
2490
  });
2415
2491
  };
@@ -2639,7 +2715,7 @@ var slice$5 = createSlice({
2639
2715
  if (!draft.byId[mapId]) {
2640
2716
  return;
2641
2717
  }
2642
- draft.byId[mapId].isEndTimeOverriding = shouldEndtimeOverride;
2718
+ draft.byId[mapId].shouldEndtimeOverride = shouldEndtimeOverride;
2643
2719
  },
2644
2720
  toggleTimestepAuto: function toggleTimestepAuto(draft, action) {
2645
2721
  var _action$payload18 = action.payload,
@@ -2721,7 +2797,12 @@ var slice$5 = createSlice({
2721
2797
  return;
2722
2798
  }
2723
2799
  draft.byId[mapId].dockedLayerManagerSize = dockedLayerManagerSize;
2724
- }
2800
+ },
2801
+ setMapPresetError: function setMapPresetError(
2802
+ // eslint-disable-next-line no-unused-vars
2803
+ draft,
2804
+ // eslint-disable-next-line no-unused-vars
2805
+ action) {}
2725
2806
  },
2726
2807
  extraReducers: function extraReducers(builder) {
2727
2808
  builder.addCase(layerActions.addLayer, function (draft, action) {
@@ -3341,12 +3422,13 @@ var slice$4 = createSlice({
3341
3422
  }
3342
3423
  },
3343
3424
  syncGroupAddTarget: function syncGroupAddTarget(draft, action) {
3344
- var state = current(draft);
3425
+ var _a;
3345
3426
  var _action$payload2 = action.payload,
3346
3427
  groupId = _action$payload2.groupId,
3347
3428
  targetId = _action$payload2.targetId,
3348
3429
  linked = _action$payload2.linked;
3349
- if (!draft.groups.byId[groupId]) {
3430
+ var synchronizationGroup = draft.groups.byId[groupId];
3431
+ if (!synchronizationGroup) {
3350
3432
  console.warn("SYNCGROUPS_ADD_TARGET: Group ".concat(groupId, " does not exist."));
3351
3433
  return;
3352
3434
  }
@@ -3354,21 +3436,17 @@ var slice$4 = createSlice({
3354
3436
  console.warn("SYNCGROUPS_ADD_TARGET: targetId is not defined.");
3355
3437
  return;
3356
3438
  }
3357
- if (draft.groups.byId[groupId].targets.allIds.includes(targetId)) {
3439
+ if (synchronizationGroup.targets.allIds.includes(targetId)) {
3358
3440
  return;
3359
3441
  }
3360
- draft.groups.byId[groupId].targets.allIds.push(targetId);
3361
- draft.groups.byId[groupId].targets.byId[targetId] = {
3442
+ var isSourceLinked = (_a = synchronizationGroup.targets.byId[targetId]) === null || _a === void 0 ? void 0 : _a.linked;
3443
+ synchronizationGroup.targets.allIds.push(targetId);
3444
+ synchronizationGroup.targets.byId[targetId] = {
3362
3445
  linked: linked !== false
3363
3446
  };
3364
- /* Now try to initialize with the correct values from the state */
3365
- var syncronizationGroup = state.groups.byId[groupId];
3366
- /* Check if the source is in the target list of the synchonizationGroup */
3367
- var source = state.groups.byId[groupId].targets.byId[targetId];
3368
- /* If the source is part of the target list, and is linked, continue syncing the other targets */
3369
- if (source && source.linked) {
3370
- var type = syncronizationGroup.type;
3371
- draft.sources.byId[targetId].payloadByType[type] = syncronizationGroup.payloadByType[type];
3447
+ if (isSourceLinked) {
3448
+ var type = synchronizationGroup.type;
3449
+ draft.sources.byId[targetId].payloadByType[type] = synchronizationGroup.payloadByType[type];
3372
3450
  }
3373
3451
  },
3374
3452
  syncGroupRemoveTarget: function syncGroupRemoveTarget(draft, action) {
@@ -3444,48 +3522,46 @@ var slice$4 = createSlice({
3444
3522
  });
3445
3523
  }
3446
3524
  });
3447
- var setBboxOrTimeSync = function setBboxOrTimeSync(state, action) {
3448
- return produce(state, function (draft) {
3449
- var _action$payload6 = action.payload,
3450
- targets = _action$payload6.targets,
3451
- source = _action$payload6.source,
3452
- groups = _action$payload6.groups;
3453
- var getPayLoadKey = function getPayLoadKey(type) {
3454
- switch (type) {
3455
- case setTimeSync.type:
3456
- return SYNCGROUPS_TYPE_SETTIME;
3457
- case setBboxSync.type:
3458
- return SYNCGROUPS_TYPE_SETBBOX;
3459
- default:
3460
- return null;
3461
- }
3462
- };
3463
- var payloadKey = getPayLoadKey(action.type);
3464
- if (!source.payload || !payloadKey) {
3465
- console.warn('Wrong sync action: ', action);
3466
- return;
3525
+ var setBboxOrTimeSync = function setBboxOrTimeSync(draft, action) {
3526
+ var _action$payload6 = action.payload,
3527
+ targets = _action$payload6.targets,
3528
+ source = _action$payload6.source,
3529
+ groups = _action$payload6.groups;
3530
+ var getPayLoadKey = function getPayLoadKey(type) {
3531
+ switch (type) {
3532
+ case setTimeSync.type:
3533
+ return SYNCGROUPS_TYPE_SETTIME;
3534
+ case setBboxSync.type:
3535
+ return SYNCGROUPS_TYPE_SETBBOX;
3536
+ default:
3537
+ return null;
3467
3538
  }
3468
- if (draft.sources.byId[source.payload.sourceId]) {
3469
- if (!draft.sources.byId[source.payload.sourceId].payloadByType) {
3470
- draft.sources.byId[source.payload.sourceId].payloadByType = {};
3471
- }
3472
- draft.sources.byId[source.payload.sourceId].payloadByType[payloadKey] = source.payload;
3539
+ };
3540
+ var payloadKey = getPayLoadKey(action.type);
3541
+ if (!source.payload || !payloadKey) {
3542
+ console.warn('Wrong sync action: ', action);
3543
+ return;
3544
+ }
3545
+ if (draft.sources.byId[source.payload.sourceId]) {
3546
+ if (!draft.sources.byId[source.payload.sourceId].payloadByType) {
3547
+ draft.sources.byId[source.payload.sourceId].payloadByType = {};
3473
3548
  }
3474
- /* Update all targets */
3475
- targets.forEach(function (target) {
3476
- if (draft.sources.byId[target.targetId]) {
3477
- if (!draft.sources.byId[target.targetId].payloadByType) {
3478
- draft.sources.byId[target.targetId].payloadByType = {};
3479
- }
3480
- draft.sources.byId[target.targetId].payloadByType[payloadKey] = source.payload;
3481
- }
3482
- });
3483
- /* Set the value in the group */
3484
- groups.forEach(function (group) {
3485
- if (draft.groups.byId[group]) {
3486
- draft.groups.byId[group].payloadByType[payloadKey] = source.payload;
3549
+ draft.sources.byId[source.payload.sourceId].payloadByType[payloadKey] = source.payload;
3550
+ }
3551
+ /* Update all targets */
3552
+ targets.forEach(function (target) {
3553
+ if (draft.sources.byId[target.targetId]) {
3554
+ if (!draft.sources.byId[target.targetId].payloadByType) {
3555
+ draft.sources.byId[target.targetId].payloadByType = {};
3487
3556
  }
3488
- });
3557
+ draft.sources.byId[target.targetId].payloadByType[payloadKey] = source.payload;
3558
+ }
3559
+ });
3560
+ /* Set the value in the group */
3561
+ groups.forEach(function (group) {
3562
+ if (draft.groups.byId[group]) {
3563
+ draft.groups.byId[group].payloadByType[payloadKey] = source.payload;
3564
+ }
3489
3565
  });
3490
3566
  };
3491
3567
  var _slice$actions = slice$4.actions,
@@ -4065,7 +4141,7 @@ var getSelectedTime = createSelector(function (store, mapId) {
4065
4141
  return getMapDimension(store, mapId, 'time');
4066
4142
  }, function (timeDimension) {
4067
4143
  var now = dateUtils.unix(new Date());
4068
- if (!timeDimension) {
4144
+ if (!timeDimension || !timeDimension.currentValue) {
4069
4145
  return now;
4070
4146
  }
4071
4147
  var timeSliderTime = dateUtils.parseISO(timeDimension.currentValue);
@@ -4198,13 +4274,13 @@ var isAutoUpdating = createSelector(getMapById, function (store) {
4198
4274
  /**
4199
4275
  * Gets if endTime and duration of animationPayload are overriding maxValue and minValue of leading layer
4200
4276
  *
4201
- * Example: isEndTimeOverriding = isEndTimeOverriding(store, 'mapid_1')
4277
+ * Example: shouldEndtimeOverride = shouldEndtimeOverride(store, 'mapid_1')
4202
4278
  * @param {object} store store: object - store object
4203
4279
  * @param {string} mapId mapId: string - Id of the map
4204
4280
  * @returns {boolean} returnType: boolean
4205
4281
  */
4206
- var isEndTimeOverriding = createSelector(getMapById, function (store) {
4207
- return store ? store.isEndTimeOverriding : false;
4282
+ var shouldEndtimeOverride = createSelector(getMapById, function (store) {
4283
+ return store ? store.shouldEndtimeOverride : false;
4208
4284
  }, selectorMemoizationOptions);
4209
4285
  /**
4210
4286
  * Gets activeLayerId for map
@@ -4645,7 +4721,7 @@ var selectors$2 = /*#__PURE__*/Object.freeze({
4645
4721
  getAnimationStartTime: getAnimationStartTime,
4646
4722
  getAnimationEndTime: getAnimationEndTime$1,
4647
4723
  isAutoUpdating: isAutoUpdating,
4648
- isEndTimeOverriding: isEndTimeOverriding,
4724
+ shouldEndtimeOverride: shouldEndtimeOverride,
4649
4725
  getActiveLayerId: getActiveLayerId,
4650
4726
  getAutoUpdateLayerId: getAutoUpdateLayerId,
4651
4727
  getAutoTimeStepLayerId: getAutoTimeStepLayerId,
@@ -5150,6 +5226,10 @@ var generateTimeList = function generateTimeList(start, end, interval) {
5150
5226
  return timeList;
5151
5227
  };
5152
5228
  var getAnimationEndTime = function getAnimationEndTime(animationEndTime) {
5229
+ var ISOtime = dateUtils.parseISO(animationEndTime);
5230
+ if (dateUtils.isValid(ISOtime)) {
5231
+ return ISOtime.toISOString();
5232
+ }
5153
5233
  var calculateFromNow = animationEndTime.split(/[-+]/)[0] === 'NOW';
5154
5234
  var isAddingTime = animationEndTime.indexOf('+') !== -1;
5155
5235
  var duration = animationEndTime.substring(animationEndTime.indexOf('PT') + 2);
@@ -5170,7 +5250,11 @@ var isAnimationEndTimeValid = function isAnimationEndTimeValid(animationEndTime)
5170
5250
  var hasValidPrefix = animationEndTime.split(/[-+]/)[0] === 'NOW' || animationEndTime.split(/[-+]/)[0] === 'TODAY';
5171
5251
  var durationString = animationEndTime.substring(animationEndTime.indexOf('PT') + 2);
5172
5252
  var hasValidDate = /^(\d+H)?(\d+M)?$/.test(durationString);
5173
- return hasValidPrefix && hasValidDate;
5253
+ if (hasValidPrefix && hasValidDate) {
5254
+ return true;
5255
+ }
5256
+ var parsedDate = dateUtils.parseISO(animationEndTime);
5257
+ return dateUtils.isValid(parsedDate);
5174
5258
  };
5175
5259
  var validInitialAnimationStep = function validInitialAnimationStep(initialAnimationStep, draw) {
5176
5260
  return !!initialAnimationStep && !!(draw === null || draw === void 0 ? void 0 : draw.length) && initialAnimationStep >= 0 && draw.length > initialAnimationStep;
@@ -5260,56 +5344,72 @@ function deleteLayerSaga(_ref3) {
5260
5344
  })();
5261
5345
  }
5262
5346
  function updateAnimation(mapId, maxValue) {
5263
- var animationStart, animationStartUnix, animationEnd, animationEndUnix, t, deltaT, start, end, isAnimating$1, timeStep;
5347
+ var shouldEndtimeOverride$1, animationStart, animationStartUnix, animationEnd, animationEndUnix, t, deltaT, start, end, isAnimating$1, timeStep;
5264
5348
  return _regeneratorRuntime().wrap(function updateAnimation$(_context4) {
5265
5349
  while (1) switch (_context4.prev = _context4.next) {
5266
5350
  case 0:
5267
5351
  _context4.next = 2;
5268
- return select(getAnimationStartTime, mapId);
5352
+ return select(shouldEndtimeOverride, mapId);
5269
5353
  case 2:
5354
+ shouldEndtimeOverride$1 = _context4.sent;
5355
+ if (!(shouldEndtimeOverride$1 === true)) {
5356
+ _context4.next = 5;
5357
+ break;
5358
+ }
5359
+ return _context4.abrupt("return");
5360
+ case 5:
5361
+ _context4.next = 7;
5362
+ return select(getAnimationStartTime, mapId);
5363
+ case 7:
5270
5364
  animationStart = _context4.sent;
5271
5365
  animationStartUnix = dateUtils.unix(dateUtils.utc(animationStart));
5272
- _context4.next = 6;
5366
+ _context4.next = 11;
5273
5367
  return select(getAnimationEndTime$1, mapId);
5274
- case 6:
5368
+ case 11:
5275
5369
  animationEnd = _context4.sent;
5276
5370
  animationEndUnix = dateUtils.unix(dateUtils.utc(animationEnd));
5277
5371
  t = dateUtils.unix(dateUtils.utc(maxValue));
5278
5372
  deltaT = t - animationEndUnix;
5279
5373
  start = dateUtils.dateToString(dateUtils.fromUnix(animationStartUnix + deltaT), dateFormat);
5280
5374
  end = dateUtils.dateToString(dateUtils.fromUnix(animationEndUnix + deltaT), dateFormat);
5281
- _context4.next = 14;
5375
+ if (!(!start || !end)) {
5376
+ _context4.next = 19;
5377
+ break;
5378
+ }
5379
+ return _context4.abrupt("return");
5380
+ case 19:
5381
+ _context4.next = 21;
5282
5382
  return put(mapActions.setAnimationEndTime({
5283
5383
  mapId: mapId,
5284
5384
  animationEndTime: end
5285
5385
  }));
5286
- case 14:
5287
- _context4.next = 16;
5386
+ case 21:
5387
+ _context4.next = 23;
5288
5388
  return put(mapActions.setAnimationStartTime({
5289
5389
  mapId: mapId,
5290
5390
  animationStartTime: start
5291
5391
  }));
5292
- case 16:
5293
- _context4.next = 18;
5392
+ case 23:
5393
+ _context4.next = 25;
5294
5394
  return select(isAnimating, mapId);
5295
- case 18:
5395
+ case 25:
5296
5396
  isAnimating$1 = _context4.sent;
5297
5397
  if (!isAnimating$1) {
5298
- _context4.next = 25;
5398
+ _context4.next = 32;
5299
5399
  break;
5300
5400
  }
5301
- _context4.next = 22;
5401
+ _context4.next = 29;
5302
5402
  return select(getMapTimeStep, mapId);
5303
- case 22:
5403
+ case 29:
5304
5404
  timeStep = _context4.sent;
5305
- _context4.next = 25;
5405
+ _context4.next = 32;
5306
5406
  return put(mapActions.mapStartAnimation({
5307
5407
  mapId: mapId,
5308
5408
  start: start,
5309
5409
  end: end,
5310
5410
  interval: timeStep
5311
5411
  }));
5312
- case 25:
5412
+ case 32:
5313
5413
  case "end":
5314
5414
  return _context4.stop();
5315
5415
  }
@@ -5569,7 +5669,7 @@ function handleBaseLayersSaga(mapId, baseLayers) {
5569
5669
  function setMapPresetSaga(_ref6) {
5570
5670
  var payload = _ref6.payload;
5571
5671
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
5572
- var _a, _b, _c, mapId, initialProps, mapPreset, layers, activeLayerId, autoTimeStepLayerId, autoUpdateLayerId, proj, shouldAutoUpdate, shouldAnimate, animationPayload, toggleTimestepAuto, showTimeSlider, displayMapPin, shouldShowZoomControls, shouldShowLegend, dockedLayerManagerSize, _filterLayers, mapLayers, baseLayers, overLayers, autoTimeStepLayerIdNew, autoUpdateLayerIdNew, onlyActiveLayerIdIsSet, newLayerIds, firstLayerId, baseLayersWithDefaultLayer, overLayersWithDefaultLayer, allBaseLayers, animationLength, animationEndTime, shouldEndtimeOverride, interval, animationEnd, _animationEnd, duration, _animationEnd2, animationStart, shouldOpenLegend, legendId, fiveMinuteDelayForAnimation, _animationEnd3, _animationStart;
5672
+ var _a, _b, _c, mapId, initialProps, mapPreset, layers, activeLayerId, autoTimeStepLayerId, autoUpdateLayerId, proj, shouldAutoUpdate, shouldAnimate, animationPayload, toggleTimestepAuto, showTimeSlider, displayMapPin, shouldShowZoomControls, shouldShowLegend, dockedLayerManagerSize, _filterLayers, mapLayers, baseLayers, overLayers, autoTimeStepLayerIdNew, autoUpdateLayerIdNew, onlyActiveLayerIdIsSet, newLayerIds, firstLayerId, baseLayersWithDefaultLayer, overLayersWithDefaultLayer, allBaseLayers, isProjectionSupported, animationLength, animationEndTime, shouldEndtimeOverride, interval, animationEnd, _animationEnd, duration, _animationEnd2, animationStart, shouldOpenLegend, legendId, fiveMinuteDelayForAnimation, _animationEnd3, _animationStart;
5573
5673
  return _regeneratorRuntime().wrap(function _callee6$(_context8) {
5574
5674
  while (1) switch (_context8.prev = _context8.next) {
5575
5675
  case 0:
@@ -5577,7 +5677,7 @@ function setMapPresetSaga(_ref6) {
5577
5677
  mapId = payload.mapId, initialProps = payload.initialProps;
5578
5678
  mapPreset = initialProps.mapPreset;
5579
5679
  if (!mapPreset) {
5580
- _context8.next = 121;
5680
+ _context8.next = 124;
5581
5681
  break;
5582
5682
  }
5583
5683
  layers = mapPreset.layers, activeLayerId = mapPreset.activeLayerId, autoTimeStepLayerId = mapPreset.autoTimeStepLayerId, autoUpdateLayerId = mapPreset.autoUpdateLayerId, proj = mapPreset.proj, shouldAutoUpdate = mapPreset.shouldAutoUpdate, shouldAnimate = mapPreset.shouldAnimate, animationPayload = mapPreset.animationPayload, toggleTimestepAuto = mapPreset.toggleTimestepAuto, showTimeSlider = mapPreset.showTimeSlider, displayMapPin = mapPreset.displayMapPin, shouldShowZoomControls = mapPreset.shouldShowZoomControls, shouldShowLegend = mapPreset.shouldShowLegend, dockedLayerManagerSize = mapPreset.dockedLayerManagerSize;
@@ -5629,271 +5729,282 @@ function setMapPresetSaga(_ref6) {
5629
5729
  return call(handleBaseLayersSaga, mapId, allBaseLayers);
5630
5730
  case 24:
5631
5731
  if (!proj) {
5632
- _context8.next = 27;
5732
+ _context8.next = 30;
5733
+ break;
5734
+ }
5735
+ isProjectionSupported = webmapUtils.getWMJSMapById(mapId).isProjectionSupported(proj.srs);
5736
+ if (isProjectionSupported) {
5737
+ _context8.next = 28;
5633
5738
  break;
5634
5739
  }
5635
- _context8.next = 27;
5740
+ throw new Error("Projection ".concat(proj.srs, " is not supported"));
5741
+ case 28:
5742
+ _context8.next = 30;
5636
5743
  return put(mapActions.setBbox({
5637
5744
  mapId: mapId,
5638
- bbox: proj === null || proj === void 0 ? void 0 : proj.bbox,
5639
- srs: proj === null || proj === void 0 ? void 0 : proj.srs
5745
+ bbox: proj.bbox,
5746
+ srs: proj.srs
5640
5747
  }));
5641
- case 27:
5748
+ case 30:
5642
5749
  animationLength = animationPayload && animationPayload.duration;
5643
5750
  animationEndTime = animationPayload && animationPayload.endTime && isAnimationEndTimeValid(animationPayload.endTime) && animationPayload.endTime;
5644
5751
  shouldEndtimeOverride = animationPayload ? animationPayload.shouldEndtimeOverride : false;
5645
5752
  if (!shouldEndtimeOverride) {
5646
- _context8.next = 33;
5753
+ _context8.next = 36;
5647
5754
  break;
5648
5755
  }
5649
- _context8.next = 33;
5756
+ _context8.next = 36;
5650
5757
  return put(mapActions.setEndTimeOverriding({
5651
5758
  mapId: mapId,
5652
5759
  shouldEndtimeOverride: shouldEndtimeOverride
5653
5760
  }));
5654
- case 33:
5761
+ case 36:
5655
5762
  if (!(shouldAutoUpdate !== undefined && !animationEndTime)) {
5656
- _context8.next = 36;
5763
+ _context8.next = 39;
5657
5764
  break;
5658
5765
  }
5659
- _context8.next = 36;
5766
+ _context8.next = 39;
5660
5767
  return put(mapActions.toggleAutoUpdate({
5661
5768
  mapId: mapId,
5662
5769
  shouldAutoUpdate: shouldAutoUpdate
5663
5770
  }));
5664
- case 36:
5771
+ case 39:
5665
5772
  if (!(showTimeSlider !== undefined)) {
5666
- _context8.next = 39;
5773
+ _context8.next = 42;
5667
5774
  break;
5668
5775
  }
5669
- _context8.next = 39;
5776
+ _context8.next = 42;
5670
5777
  return put(mapActions.toggleTimeSliderIsVisible({
5671
5778
  mapId: mapId,
5672
5779
  isTimeSliderVisible: showTimeSlider
5673
5780
  }));
5674
- case 39:
5781
+ case 42:
5675
5782
  if (!(shouldShowZoomControls !== undefined)) {
5676
- _context8.next = 42;
5783
+ _context8.next = 45;
5677
5784
  break;
5678
5785
  }
5679
- _context8.next = 42;
5786
+ _context8.next = 45;
5680
5787
  return put(mapActions.toggleZoomControls({
5681
5788
  mapId: mapId,
5682
5789
  shouldShowZoomControls: shouldShowZoomControls
5683
5790
  }));
5684
- case 42:
5791
+ case 45:
5685
5792
  if (!(displayMapPin !== undefined)) {
5686
- _context8.next = 45;
5793
+ _context8.next = 48;
5687
5794
  break;
5688
5795
  }
5689
- _context8.next = 45;
5796
+ _context8.next = 48;
5690
5797
  return put(mapActions.toggleMapPinIsVisible({
5691
5798
  mapId: mapId,
5692
5799
  displayMapPin: displayMapPin
5693
5800
  }));
5694
- case 45:
5801
+ case 48:
5695
5802
  // sets timestep by interval of animationPayload
5696
5803
  interval = animationPayload && animationPayload.interval;
5697
5804
  if (!interval) {
5698
- _context8.next = 49;
5805
+ _context8.next = 52;
5699
5806
  break;
5700
5807
  }
5701
- _context8.next = 49;
5808
+ _context8.next = 52;
5702
5809
  return put(mapActions.setTimeStep({
5703
5810
  mapId: mapId,
5704
5811
  timeStep: interval
5705
5812
  }));
5706
- case 49:
5813
+ case 52:
5707
5814
  if (!animationEndTime) {
5708
- _context8.next = 58;
5815
+ _context8.next = 61;
5709
5816
  break;
5710
5817
  }
5711
- _context8.next = 52;
5818
+ _context8.next = 55;
5712
5819
  return put(mapActions.setAnimationEndTime({
5713
5820
  mapId: mapId,
5714
5821
  animationEndTime: getAnimationEndTime(animationEndTime)
5715
5822
  }));
5716
- case 52:
5823
+ case 55:
5717
5824
  if (animationLength) {
5718
- _context8.next = 58;
5825
+ _context8.next = 61;
5719
5826
  break;
5720
5827
  }
5721
- _context8.next = 55;
5828
+ _context8.next = 58;
5722
5829
  return select(getAnimationEndTime$1, mapId);
5723
- case 55:
5830
+ case 58:
5724
5831
  animationEnd = _context8.sent;
5725
- _context8.next = 58;
5832
+ _context8.next = 61;
5726
5833
  return put(mapActions.setAnimationStartTime({
5727
5834
  mapId: mapId,
5728
5835
  animationStartTime: dateUtils.sub(dateUtils.utc(animationEnd), {
5729
5836
  minutes: 5 * 60 // set to default of 5 hours
5730
5837
  }).toISOString()
5731
5838
  }));
5732
- case 58:
5839
+ case 61:
5733
5840
  if (!animationLength) {
5734
- _context8.next = 64;
5841
+ _context8.next = 67;
5735
5842
  break;
5736
5843
  }
5737
- _context8.next = 61;
5844
+ _context8.next = 64;
5738
5845
  return select(getAnimationEndTime$1, mapId);
5739
- case 61:
5846
+ case 64:
5740
5847
  _animationEnd = _context8.sent;
5741
- _context8.next = 64;
5848
+ _context8.next = 67;
5742
5849
  return put(mapActions.setAnimationStartTime({
5743
5850
  mapId: mapId,
5744
5851
  animationStartTime: dateUtils.sub(dateUtils.utc(_animationEnd), {
5745
5852
  minutes: animationLength
5746
5853
  }).toISOString()
5747
5854
  }));
5748
- case 64:
5855
+ case 67:
5749
5856
  if (!(animationPayload && animationPayload.speed)) {
5750
- _context8.next = 67;
5857
+ _context8.next = 70;
5751
5858
  break;
5752
5859
  }
5753
- _context8.next = 67;
5860
+ _context8.next = 70;
5754
5861
  return put(mapActions.setAnimationDelay({
5755
5862
  mapId: mapId,
5756
5863
  animationDelay: getSpeedDelay(animationPayload.speed)
5757
5864
  }));
5758
- case 67:
5865
+ case 70:
5759
5866
  if (!(shouldAnimate === true)) {
5760
- _context8.next = 92;
5867
+ _context8.next = 95;
5761
5868
  break;
5762
5869
  }
5763
5870
  duration = animationPayload && animationPayload.duration ? animationPayload.duration : 5 * 60; // set to default of 5 hours
5764
5871
  if (!(shouldEndtimeOverride && animationEndTime)) {
5765
- _context8.next = 75;
5872
+ _context8.next = 78;
5766
5873
  break;
5767
5874
  }
5768
- _context8.next = 72;
5875
+ _context8.next = 75;
5769
5876
  return select(getAnimationEndTime$1, mapId);
5770
- case 72:
5877
+ case 75:
5771
5878
  _context8.t0 = _context8.sent;
5772
- _context8.next = 76;
5879
+ _context8.next = 79;
5773
5880
  break;
5774
- case 75:
5881
+ case 78:
5775
5882
  _context8.t0 = dateUtils.dateToString(dateUtils.utc(), dateFormat);
5776
- case 76:
5883
+ case 79:
5777
5884
  _animationEnd2 = _context8.t0;
5778
5885
  if (!(shouldEndtimeOverride && animationLength)) {
5779
- _context8.next = 83;
5886
+ _context8.next = 86;
5780
5887
  break;
5781
5888
  }
5782
- _context8.next = 80;
5889
+ _context8.next = 83;
5783
5890
  return select(getAnimationStartTime, mapId);
5784
- case 80:
5891
+ case 83:
5785
5892
  _context8.t1 = _context8.sent;
5786
- _context8.next = 84;
5893
+ _context8.next = 87;
5787
5894
  break;
5788
- case 83:
5895
+ case 86:
5789
5896
  _context8.t1 = dateUtils.dateToString(dateUtils.sub(dateUtils.utc(_animationEnd2), {
5790
5897
  minutes: duration
5791
5898
  }), dateFormat);
5792
- case 84:
5899
+ case 87:
5793
5900
  animationStart = _context8.t1;
5794
- _context8.next = 87;
5901
+ _context8.next = 90;
5795
5902
  return put(mapActions.mapStartAnimation({
5796
5903
  mapId: mapId,
5797
5904
  start: animationStart,
5798
5905
  end: _animationEnd2,
5799
5906
  interval: interval || defaultTimeStep
5800
5907
  }));
5801
- case 87:
5908
+ case 90:
5802
5909
  if (!interval) {
5803
- _context8.next = 90;
5910
+ _context8.next = 93;
5804
5911
  break;
5805
5912
  }
5806
- _context8.next = 90;
5913
+ _context8.next = 93;
5807
5914
  return put(mapActions.toggleTimestepAuto({
5808
5915
  mapId: mapId,
5809
5916
  timestepAuto: false
5810
5917
  }));
5811
- case 90:
5812
- _context8.next = 95;
5918
+ case 93:
5919
+ _context8.next = 98;
5813
5920
  break;
5814
- case 92:
5921
+ case 95:
5815
5922
  if (!(toggleTimestepAuto !== undefined)) {
5816
- _context8.next = 95;
5923
+ _context8.next = 98;
5817
5924
  break;
5818
5925
  }
5819
- _context8.next = 95;
5926
+ _context8.next = 98;
5820
5927
  return put(mapActions.toggleTimestepAuto({
5821
5928
  mapId: mapId,
5822
5929
  timestepAuto: toggleTimestepAuto
5823
5930
  }));
5824
- case 95:
5931
+ case 98:
5825
5932
  // show legend
5826
5933
  shouldOpenLegend = shouldShowLegend !== undefined ? shouldShowLegend : IS_LEGEND_OPEN_BY_DEFAULT;
5827
- _context8.next = 98;
5934
+ _context8.next = 101;
5828
5935
  return select(getLegendId, mapId);
5829
- case 98:
5936
+ case 101:
5830
5937
  legendId = _context8.sent;
5831
5938
  if (!legendId) {
5832
- _context8.next = 102;
5939
+ _context8.next = 105;
5833
5940
  break;
5834
5941
  }
5835
- _context8.next = 102;
5942
+ _context8.next = 105;
5836
5943
  return put(uiActions.setToggleOpenDialog({
5837
5944
  type: legendId,
5838
5945
  setOpen: shouldOpenLegend
5839
5946
  }));
5840
- case 102:
5947
+ case 105:
5841
5948
  if (!dockedLayerManagerSize) {
5842
- _context8.next = 105;
5949
+ _context8.next = 108;
5843
5950
  break;
5844
5951
  }
5845
- _context8.next = 105;
5952
+ _context8.next = 108;
5846
5953
  return put(mapActions.setDockedLayerManagerSize({
5847
5954
  mapId: mapId,
5848
5955
  dockedLayerManagerSize: dockedLayerManagerSize
5849
5956
  }));
5850
- case 105:
5957
+ case 108:
5851
5958
  if (!(animationEndTime && (shouldEndtimeOverride || !(shouldAutoUpdate || shouldAnimate)))) {
5852
- _context8.next = 121;
5959
+ _context8.next = 124;
5853
5960
  break;
5854
5961
  }
5855
5962
  fiveMinuteDelayForAnimation = 1000 * 60 * 5;
5856
- _context8.next = 109;
5963
+ _context8.next = 112;
5857
5964
  return delay(fiveMinuteDelayForAnimation);
5858
- case 109:
5859
- _context8.next = 111;
5965
+ case 112:
5966
+ _context8.next = 114;
5860
5967
  return select(getAnimationEndTime$1, mapId);
5861
- case 111:
5968
+ case 114:
5862
5969
  _animationEnd3 = _context8.sent;
5863
- _context8.next = 114;
5970
+ _context8.next = 117;
5864
5971
  return put(mapActions.setAnimationEndTime({
5865
5972
  mapId: mapId,
5866
5973
  animationEndTime: dateUtils.add(dateUtils.utc(_animationEnd3), {
5867
5974
  minutes: 5
5868
5975
  }).toISOString()
5869
5976
  }));
5870
- case 114:
5871
- _context8.next = 116;
5977
+ case 117:
5978
+ _context8.next = 119;
5872
5979
  return select(getAnimationStartTime, mapId);
5873
- case 116:
5980
+ case 119:
5874
5981
  _animationStart = _context8.sent;
5875
- _context8.next = 119;
5982
+ _context8.next = 122;
5876
5983
  return put(mapActions.setAnimationStartTime({
5877
5984
  mapId: mapId,
5878
5985
  animationStartTime: dateUtils.add(dateUtils.utc(_animationStart), {
5879
5986
  minutes: 5
5880
5987
  }).toISOString()
5881
5988
  }));
5882
- case 119:
5883
- _context8.next = 105;
5989
+ case 122:
5990
+ _context8.next = 108;
5884
5991
  break;
5885
- case 121:
5886
- _context8.next = 126;
5992
+ case 124:
5993
+ _context8.next = 130;
5887
5994
  break;
5888
- case 123:
5889
- _context8.prev = 123;
5890
- _context8.t2 = _context8["catch"](0);
5891
- console.error(_context8.t2);
5892
5995
  case 126:
5996
+ _context8.prev = 126;
5997
+ _context8.t2 = _context8["catch"](0);
5998
+ _context8.next = 130;
5999
+ return put(mapActions.setMapPresetError({
6000
+ mapId: payload.mapId,
6001
+ error: _context8.t2.message
6002
+ }));
6003
+ case 130:
5893
6004
  case "end":
5894
6005
  return _context8.stop();
5895
6006
  }
5896
- }, _callee6, null, [[0, 123]]);
6007
+ }, _callee6, null, [[0, 126]]);
5897
6008
  })();
5898
6009
  }
5899
6010
  function unregisterMapSaga(_ref7) {
@@ -5947,7 +6058,7 @@ function setStepBackwardOrForwardSaga(_ref8) {
5947
6058
  _yield$select2 = _slicedToArray(_yield$select, 2);
5948
6059
  dataStartTime = _yield$select2[0];
5949
6060
  dataEndTime = _yield$select2[1];
5950
- if (!isValid(currentTime)) {
6061
+ if (!dateUtils.isValid(currentTime)) {
5951
6062
  _context10.next = 23;
5952
6063
  break;
5953
6064
  }
@@ -5955,13 +6066,13 @@ function setStepBackwardOrForwardSaga(_ref8) {
5955
6066
  var nextTime = currentTime + timeStep;
5956
6067
  var roundedTime = mapUtils.roundWithTimeStep(nextTime, timeStep, 'ceil');
5957
6068
  var newTime = Math.min(roundedTime, dataEndTime || roundedTime);
5958
- return fromUnixTime(newTime).toISOString();
6069
+ return dateUtils.fromUnix(newTime).toISOString();
5959
6070
  };
5960
6071
  makeBackwardStep = function makeBackwardStep() {
5961
6072
  var nextTime = currentTime - timeStep;
5962
6073
  var roundedTime = mapUtils.roundWithTimeStep(nextTime, timeStep, 'floor');
5963
6074
  var newTime = Math.max(roundedTime, dataStartTime || roundedTime);
5964
- return fromUnixTime(newTime).toISOString();
6075
+ return dateUtils.fromUnix(newTime).toISOString();
5965
6076
  };
5966
6077
  selectedTimeString = isForwardStep ? makeForwardStep() : makeBackwardStep();
5967
6078
  _context10.next = 19;
@@ -6828,9 +6939,8 @@ var drawAdapter = createEntityAdapter({
6828
6939
  }
6829
6940
  });
6830
6941
  var getDrawToolByLayerId = function getDrawToolByLayerId(draft, layerId) {
6831
- var state = current$1(draft);
6832
- var drawTool = state.ids.map(function (id) {
6833
- return state.entities[id];
6942
+ var drawTool = draft.ids.map(function (id) {
6943
+ return draft.entities[id];
6834
6944
  }).find(function (tool) {
6835
6945
  return (tool === null || tool === void 0 ? void 0 : tool.geoJSONLayerId) === layerId;
6836
6946
  });
@@ -7137,7 +7247,7 @@ function registerDrawToolSaga(_ref) {
7137
7247
  function changeDrawToolSaga(_ref2) {
7138
7248
  var payload = _ref2.payload;
7139
7249
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
7140
- var _a, _b, _c, _d, drawModeId, drawToolId, _payload$shouldUpdate, shouldUpdateShape, drawingTool, _drawingTool$shouldAl, shouldAllowMultipleShapes, geoJSONIntersectionLayerId, geoJSONIntersectionBoundsLayerId, newDrawMode, currentGeoJSONLayer, _ref3, currentGeoJSON, _ref3$selectedFeature, selectedFeatureIndex, currentSelectionType, newSelectionType, isNewToolSelected, shouldUpdateNewShape, geoJSONFeatureCollection, newGeoJSON;
7250
+ var _a, _b, _c, drawModeId, drawToolId, _payload$shouldUpdate, shouldUpdateShape, drawingTool, _drawingTool$shouldAl, shouldAllowMultipleShapes, geoJSONIntersectionLayerId, geoJSONIntersectionBoundsLayerId, newDrawMode, geoJSONLayer, geoJSON, lastFeatureIndex, newGeoJSON, currentGeoJSONLayer, _ref3, currentGeoJSON, _ref3$selectedFeature, selectedFeatureIndex, currentSelectionType, newSelectionType, isNewToolSelected, shouldUpdateNewShape, shapeWithSelectionType, geoJSONFeatureCollection, _newGeoJSON;
7141
7251
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7142
7252
  while (1) switch (_context2.prev = _context2.next) {
7143
7253
  case 0:
@@ -7153,7 +7263,7 @@ function changeDrawToolSaga(_ref2) {
7153
7263
  case 8:
7154
7264
  newDrawMode = _context2.sent;
7155
7265
  if (!(!newDrawMode || !drawingTool.activeDrawModeId && newDrawMode.isSelectable)) {
7156
- _context2.next = 13;
7266
+ _context2.next = 24;
7157
7267
  break;
7158
7268
  }
7159
7269
  _context2.next = 12;
@@ -7163,90 +7273,118 @@ function changeDrawToolSaga(_ref2) {
7163
7273
  drawMode: ''
7164
7274
  }));
7165
7275
  case 12:
7276
+ _context2.next = 14;
7277
+ return select(getLayerById, drawingTool.geoJSONLayerId);
7278
+ case 14:
7279
+ geoJSONLayer = _context2.sent;
7280
+ geoJSON = geoJSONLayer === null || geoJSONLayer === void 0 ? void 0 : geoJSONLayer.geojson;
7281
+ lastFeatureIndex = geoJSON !== undefined && getLastEmptyFeatureIndex(geoJSON) || undefined;
7282
+ if (!(lastFeatureIndex !== undefined)) {
7283
+ _context2.next = 23;
7284
+ break;
7285
+ }
7286
+ newGeoJSON = Object.assign(Object.assign({}, geoJSON), {
7287
+ features: geoJSON.features.filter(function (_feature, index) {
7288
+ return index !== lastFeatureIndex;
7289
+ })
7290
+ });
7291
+ _context2.next = 21;
7292
+ return put(layerActions.updateFeature({
7293
+ layerId: drawingTool.geoJSONLayerId,
7294
+ geojson: newGeoJSON
7295
+ }));
7296
+ case 21:
7297
+ _context2.next = 23;
7298
+ return put(layerActions.setSelectedFeature({
7299
+ layerId: drawingTool.geoJSONLayerId,
7300
+ selectedFeatureIndex: newGeoJSON.features.length > 0 ? newGeoJSON.features.length - 1 : 0
7301
+ }));
7302
+ case 23:
7166
7303
  return _context2.abrupt("return");
7167
- case 13:
7304
+ case 24:
7168
7305
  if (!(newDrawMode.value === 'DELETE')) {
7169
- _context2.next = 22;
7306
+ _context2.next = 33;
7170
7307
  break;
7171
7308
  }
7172
- _context2.next = 16;
7309
+ _context2.next = 27;
7173
7310
  return put(layerActions.layerChangeGeojson({
7174
7311
  layerId: drawingTool.geoJSONLayerId,
7175
7312
  geojson: emptyGeoJSON
7176
7313
  }));
7177
- case 16:
7314
+ case 27:
7178
7315
  if (!geoJSONIntersectionLayerId) {
7179
- _context2.next = 19;
7316
+ _context2.next = 30;
7180
7317
  break;
7181
7318
  }
7182
- _context2.next = 19;
7319
+ _context2.next = 30;
7183
7320
  return put(layerActions.layerChangeGeojson({
7184
7321
  layerId: geoJSONIntersectionLayerId,
7185
7322
  geojson: emptyGeoJSON
7186
7323
  }));
7187
- case 19:
7188
- _context2.next = 21;
7324
+ case 30:
7325
+ _context2.next = 32;
7189
7326
  return put(layerActions.toggleFeatureMode({
7190
7327
  layerId: drawingTool.geoJSONLayerId,
7191
7328
  isInEditMode: false,
7192
7329
  drawMode: ''
7193
7330
  }));
7194
- case 21:
7331
+ case 32:
7195
7332
  return _context2.abrupt("return");
7196
- case 22:
7197
- _context2.next = 24;
7333
+ case 33:
7334
+ _context2.next = 35;
7198
7335
  return select(getLayerById, drawingTool.geoJSONLayerId);
7199
- case 24:
7336
+ case 35:
7200
7337
  currentGeoJSONLayer = _context2.sent;
7201
7338
  _ref3 = currentGeoJSONLayer || {}, currentGeoJSON = _ref3.geojson, _ref3$selectedFeature = _ref3.selectedFeatureIndex, selectedFeatureIndex = _ref3$selectedFeature === void 0 ? 0 : _ref3$selectedFeature;
7202
7339
  currentSelectionType = (_b = (_a = currentGeoJSON === null || currentGeoJSON === void 0 ? void 0 : currentGeoJSON.features[selectedFeatureIndex]) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.selectionType;
7203
- newSelectionType = (_c = newDrawMode.shape.properties) === null || _c === void 0 ? void 0 : _c.selectionType;
7340
+ newSelectionType = newDrawMode.selectionType;
7204
7341
  isNewToolSelected = currentSelectionType !== newSelectionType;
7205
- shouldUpdateNewShape = !((_d = currentGeoJSON === null || currentGeoJSON === void 0 ? void 0 : currentGeoJSON.features) === null || _d === void 0 ? void 0 : _d.length) || shouldAllowMultipleShapes || isNewToolSelected; // don't change anything if same tool is selected again
7342
+ shouldUpdateNewShape = !((_c = currentGeoJSON === null || currentGeoJSON === void 0 ? void 0 : currentGeoJSON.features) === null || _c === void 0 ? void 0 : _c.length) || isNewToolSelected; // don't change anything if same tool is selected again
7206
7343
  if (!(shouldUpdateNewShape && shouldUpdateShape)) {
7207
- _context2.next = 38;
7344
+ _context2.next = 50;
7208
7345
  break;
7209
7346
  }
7210
- geoJSONFeatureCollection = getFeatureCollection(newDrawMode.shape, shouldAllowMultipleShapes, currentGeoJSON);
7211
- newGeoJSON = getGeoJson(geoJSONFeatureCollection, shouldAllowMultipleShapes);
7347
+ shapeWithSelectionType = addSelectionTypeToGeoJSON(newDrawMode.shape, newDrawMode.selectionType);
7348
+ geoJSONFeatureCollection = getFeatureCollection(shapeWithSelectionType, shouldAllowMultipleShapes, currentGeoJSON);
7349
+ _newGeoJSON = getGeoJson(geoJSONFeatureCollection, shouldAllowMultipleShapes);
7212
7350
  if (shouldAllowMultipleShapes) {
7213
- moveFeature(currentGeoJSON, newGeoJSON, selectedFeatureIndex, '');
7351
+ moveFeature(currentGeoJSON, _newGeoJSON, selectedFeatureIndex, '');
7214
7352
  }
7215
- _context2.next = 36;
7353
+ _context2.next = 48;
7216
7354
  return put(layerActions.setSelectedFeature({
7217
7355
  layerId: drawingTool.geoJSONLayerId,
7218
- selectedFeatureIndex: newGeoJSON.features.length - 1
7356
+ selectedFeatureIndex: _newGeoJSON.features.length - 1
7219
7357
  }));
7220
- case 36:
7221
- _context2.next = 38;
7358
+ case 48:
7359
+ _context2.next = 50;
7222
7360
  return put(layerActions.updateFeature(Object.assign(Object.assign({
7223
7361
  layerId: drawingTool.geoJSONLayerId,
7224
- geojson: newGeoJSON
7362
+ geojson: _newGeoJSON
7225
7363
  }, geoJSONIntersectionLayerId && {
7226
7364
  geoJSONIntersectionLayerId: geoJSONIntersectionLayerId
7227
7365
  }), geoJSONIntersectionBoundsLayerId && {
7228
7366
  geoJSONIntersectionBoundsLayerId: geoJSONIntersectionBoundsLayerId
7229
7367
  })));
7230
- case 38:
7231
- _context2.next = 40;
7368
+ case 50:
7369
+ _context2.next = 52;
7232
7370
  return put(layerActions.toggleFeatureMode({
7233
7371
  layerId: drawingTool.geoJSONLayerId,
7234
7372
  isInEditMode: newDrawMode.isSelectable,
7235
7373
  drawMode: newDrawMode.value
7236
7374
  }));
7237
- case 40:
7238
- _context2.next = 45;
7375
+ case 52:
7376
+ _context2.next = 57;
7239
7377
  break;
7240
- case 42:
7241
- _context2.prev = 42;
7378
+ case 54:
7379
+ _context2.prev = 54;
7242
7380
  _context2.t0 = _context2["catch"](0);
7243
7381
  // eslint-disable-next-line no-console
7244
7382
  console.log('error changeDrawToolSaga', _context2.t0);
7245
- case 45:
7383
+ case 57:
7246
7384
  case "end":
7247
7385
  return _context2.stop();
7248
7386
  }
7249
- }, _callee2, null, [[0, 42]]);
7387
+ }, _callee2, null, [[0, 54]]);
7250
7388
  })();
7251
7389
  }
7252
7390
  function changeIntersectionSaga(_ref4) {
@@ -7370,17 +7508,26 @@ var createMultipleLayersState = function createMultipleLayersState(layers, mapId
7370
7508
  byId: {}
7371
7509
  }
7372
7510
  };
7373
- for (var i = 0; i < layers.length; i += 1) {
7374
- var layerState = createLayer(Object.assign(Object.assign({}, layers[i]), {
7375
- id: layers[i].id,
7376
- mapId: mapId
7377
- }));
7378
- mockState.byId[layers[i].id] = Object.assign({}, layerState);
7379
- mockState.allIds.push(layers[i].id);
7380
- if (layers[i].layerType === LayerType.baseLayer) {
7381
- mockState.availableBaseLayers.byId[layers[i].id] = Object.assign({}, layerState);
7382
- mockState.availableBaseLayers.allIds.push(layers[i].id);
7511
+ var _iterator = _createForOfIteratorHelper(layers),
7512
+ _step;
7513
+ try {
7514
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
7515
+ var layer = _step.value;
7516
+ var layerState = createLayer(Object.assign(Object.assign({}, layer), {
7517
+ id: layer.id,
7518
+ mapId: mapId
7519
+ }));
7520
+ mockState.byId[layer.id] = Object.assign({}, layerState);
7521
+ mockState.allIds.push(layer.id);
7522
+ if (layer.layerType === LayerType.baseLayer) {
7523
+ mockState.availableBaseLayers.byId[layer.id] = Object.assign({}, layerState);
7524
+ mockState.availableBaseLayers.allIds.push(layer.id);
7525
+ }
7383
7526
  }
7527
+ } catch (err) {
7528
+ _iterator.e(err);
7529
+ } finally {
7530
+ _iterator.f();
7384
7531
  }
7385
7532
  return mockState;
7386
7533
  };
@@ -7392,12 +7539,13 @@ var createWebmapState = function createWebmapState() {
7392
7539
  for (var _len = arguments.length, mapIds = new Array(_len), _key = 0; _key < _len; _key++) {
7393
7540
  mapIds[_key] = arguments[_key];
7394
7541
  }
7395
- for (var i = 0; i < mapIds.length; i += 1) {
7542
+ for (var _i = 0, _mapIds = mapIds; _i < _mapIds.length; _i++) {
7543
+ var mapId = _mapIds[_i];
7396
7544
  var mapState = createMap({
7397
- id: mapIds[i]
7545
+ id: mapId
7398
7546
  });
7399
- mockState.byId[mapIds[i]] = Object.assign({}, mapState);
7400
- mockState.allIds.push(mapIds[i]);
7547
+ mockState.byId[mapId] = Object.assign({}, mapState);
7548
+ mockState.allIds.push(mapId);
7401
7549
  }
7402
7550
  return mockState;
7403
7551
  };
@@ -7409,13 +7557,14 @@ var createMapDimensionsState = function createMapDimensionsState(dimensions) {
7409
7557
  for (var _len2 = arguments.length, mapIds = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
7410
7558
  mapIds[_key2 - 1] = arguments[_key2];
7411
7559
  }
7412
- for (var i = 0; i < mapIds.length; i += 1) {
7560
+ for (var _i2 = 0, _mapIds2 = mapIds; _i2 < _mapIds2.length; _i2++) {
7561
+ var mapId = _mapIds2[_i2];
7413
7562
  var mapState = createMap({
7414
- id: mapIds[i]
7563
+ id: mapId
7415
7564
  });
7416
- mockState.byId[mapIds[i]] = Object.assign({}, mapState);
7417
- mockState.byId[mapIds[i]].dimensions = dimensions;
7418
- mockState.allIds.push(mapIds[i]);
7565
+ mockState.byId[mapId] = Object.assign({}, mapState);
7566
+ mockState.byId[mapId].dimensions = dimensions;
7567
+ mockState.allIds.push(mapId);
7419
7568
  }
7420
7569
  return mockState;
7421
7570
  };