@opengeoweb/store 9.20.2 → 9.22.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,4 +1,4 @@
1
- import { webmapUtils, LayerType, getWMJSMapById, WMLayer, webmapTestSettings, handleDateUtilsISOString, getCapabilities } from '@opengeoweb/webmap';
1
+ import { webmapUtils, LayerType, getWMJSMapById, WMLayer, webmapTestSettings, getWMSRequests, isProjectionSupported, handleDateUtilsISOString, getCapabilities } from '@opengeoweb/webmap';
2
2
  import { createAction, createSlice, createSelector, createEntityAdapter, createListenerMiddleware } from '@reduxjs/toolkit';
3
3
  import { getGeoJson, moveFeature, createInterSections, getLastEmptyFeatureIndex, defaultLayers, emptyGeoJSON, addSelectionTypeToGeoJSON, getFeatureCollection, defaultIntersectionStyleProperties } from '@opengeoweb/webmap-react';
4
4
  export { defaultLayers } from '@opengeoweb/webmap-react';
@@ -3911,6 +3911,7 @@ const slice$5 = createSlice({
3911
3911
  return;
3912
3912
  }
3913
3913
  draft.byId[mapId].animationStartTime = animationStartTime;
3914
+ draft.byId[mapId].isAnimationLengthAuto = false;
3914
3915
  },
3915
3916
  setAnimationEndTime: (draft, action) => {
3916
3917
  const {
@@ -3921,6 +3922,7 @@ const slice$5 = createSlice({
3921
3922
  return;
3922
3923
  }
3923
3924
  draft.byId[mapId].animationEndTime = animationEndTime;
3925
+ draft.byId[mapId].isAnimationLengthAuto = false;
3924
3926
  },
3925
3927
  setAnimationDelay: (draft, action) => {
3926
3928
  const {
@@ -4057,6 +4059,16 @@ const slice$5 = createSlice({
4057
4059
  }
4058
4060
  draft.byId[mapId].isTimeSpanAuto = timeSpanAuto;
4059
4061
  },
4062
+ toggleAnimationLengthAuto: (draft, action) => {
4063
+ const {
4064
+ mapId,
4065
+ autoAnimationLength
4066
+ } = action.payload;
4067
+ if (!draft.byId[mapId]) {
4068
+ return;
4069
+ }
4070
+ draft.byId[mapId].isAnimationLengthAuto = autoAnimationLength;
4071
+ },
4060
4072
  toggleTimeSliderHover: (draft, action) => {
4061
4073
  const {
4062
4074
  mapId,
@@ -5825,6 +5837,13 @@ const getMapTimeSliderSecondsPerPx = createSelector(getMapById, store => store ?
5825
5837
  * @returns {boolean} returnType: boolean
5826
5838
  */
5827
5839
  const isTimestepAuto = createSelector(getMapById, store => store ? store.isTimestepAuto : false, selectorMemoizationOptions);
5840
+ /**
5841
+ * Returns map is animation auto
5842
+ * @param {object} store store: object - store object
5843
+ * @param {string} mapId mapId: string - Id of the map
5844
+ * @returns {boolean} returnType: boolean
5845
+ */
5846
+ const isAnimationLengthAuto = createSelector(getMapById, store => (store === null || store === void 0 ? void 0 : store.isAnimationLengthAuto) || false, selectorMemoizationOptions);
5828
5847
  /**
5829
5848
  * Returns map is timespan auto
5830
5849
  *
@@ -6089,6 +6108,25 @@ const getAnimationList = createSelector(getMapById, getAnimationStartTime, getAn
6089
6108
  }
6090
6109
  return timeList;
6091
6110
  }, selectorMemoizationOptions);
6111
+ /**
6112
+ * @param {object} store store: object - store object
6113
+ * @param {string} mapId mapId: string - Id of the map
6114
+ * @returns {object} Returns min and max value of time dimension of autoTimeStep-layer. If no autoTimeStep-layer it returns default start/end time from store.
6115
+ */
6116
+ const getAnimationRange = createSelector(store => store, getAutoTimeStepLayerId, getAnimationStartTime, getAnimationEndTime, isAnimationLengthAuto, getLayerTimeDimension, (store, autoTimeStepLayerId, startTime, endTime, isAnimationLengthAuto) => {
6117
+ const layerTimeDimension = getLayerTimeDimension(store, autoTimeStepLayerId);
6118
+ const {
6119
+ minValue,
6120
+ maxValue
6121
+ } = layerTimeDimension || {};
6122
+ const hasTimeDimension = minValue && maxValue;
6123
+ const animationStartTime = isAnimationLengthAuto && autoTimeStepLayerId && hasTimeDimension ? minValue : startTime;
6124
+ const animationEndTime = isAnimationLengthAuto && autoTimeStepLayerId && hasTimeDimension ? maxValue : endTime;
6125
+ return {
6126
+ animationStartTime,
6127
+ animationEndTime
6128
+ };
6129
+ });
6092
6130
 
6093
6131
  var selectors$2 = /*#__PURE__*/Object.freeze({
6094
6132
  __proto__: null,
@@ -6098,6 +6136,7 @@ var selectors$2 = /*#__PURE__*/Object.freeze({
6098
6136
  getAllUniqueDimensions: getAllUniqueDimensions,
6099
6137
  getAnimationEndTime: getAnimationEndTime,
6100
6138
  getAnimationList: getAnimationList,
6139
+ getAnimationRange: getAnimationRange,
6101
6140
  getAnimationStartTime: getAnimationStartTime,
6102
6141
  getAutoTimeStepLayerId: getAutoTimeStepLayerId,
6103
6142
  getAutoUpdateLayerId: getAutoUpdateLayerId,
@@ -6140,6 +6179,7 @@ var selectors$2 = /*#__PURE__*/Object.freeze({
6140
6179
  getSelectedTime: getSelectedTime,
6141
6180
  getSrs: getSrs,
6142
6181
  isAnimating: isAnimating,
6182
+ isAnimationLengthAuto: isAnimationLengthAuto,
6143
6183
  isAutoUpdating: isAutoUpdating,
6144
6184
  isTimeSliderHoverOn: isTimeSliderHoverOn,
6145
6185
  isTimeSliderVisible: isTimeSliderVisible,
@@ -7592,6 +7632,8 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
7592
7632
 
7593
7633
  /* A map with all the timerIds and their current step */
7594
7634
  const stepMap = new Map();
7635
+ /* A map with a list of timers and their dwell */
7636
+ const timerDwellMap = new Map();
7595
7637
  /**
7596
7638
  * Returns the next step for given timerId.
7597
7639
  * @param timerId The timer id
@@ -7605,6 +7647,30 @@ const getNextStep = (timerId, numberOfStepsInAnimation, numStepsToGoForward = 1)
7605
7647
  const nextStepClipped = (nextStep % numberOfStepsInAnimation + numberOfStepsInAnimation) % numberOfStepsInAnimation;
7606
7648
  return nextStepClipped;
7607
7649
  };
7650
+ /**
7651
+ * Handles dwell at the end of the animation loop sequence. The number of steps to wait till proceed can be set by the dwell parameter.
7652
+ * @param timerId The timer id
7653
+ * @param numberOfStepsInAnimation Number of steps in the animation
7654
+ * @param dwell The number of steps to wait at the end of the animation sequence before to continue
7655
+ * @returns
7656
+ */
7657
+ const handleTimerDwell = (timerId, numberOfStepsInAnimation, dwell = 8) => {
7658
+ if (dwell > 0) {
7659
+ const currentStep = getCurrentStep(timerId);
7660
+ // Reset the dwell if we are not at the last animation step
7661
+ if (currentStep < numberOfStepsInAnimation - 1) {
7662
+ timerDwellMap.set(timerId, dwell);
7663
+ return false;
7664
+ }
7665
+ // We are at the last animation step, check the dwell
7666
+ const timerDwell = timerDwellMap.has(timerId) && timerDwellMap.get(timerId) || 0;
7667
+ if (currentStep === numberOfStepsInAnimation - 1 && timerDwell > 0) {
7668
+ timerDwellMap.set(timerId, timerDwell - 1);
7669
+ return true;
7670
+ }
7671
+ }
7672
+ return false;
7673
+ };
7608
7674
  /**
7609
7675
  * Set step for the timerId
7610
7676
  * @param timerId
@@ -7640,7 +7706,7 @@ const prefetchAnimationTargetsForMetronome = (timerId, animationListValues, targ
7640
7706
  const targetMapId = target.targetId;
7641
7707
  const wmMap = getWMJSMapById(targetMapId);
7642
7708
  if (wmMap) {
7643
- const layersImageUrls = wmMap.getWMSRequests([{
7709
+ const layersImageUrls = getWMSRequests(wmMap, [{
7644
7710
  name: 'time',
7645
7711
  currentValue: nextTimeValueStepToCheck
7646
7712
  }]);
@@ -7959,8 +8025,8 @@ function* setMapPresetSaga({
7959
8025
  }));
7960
8026
  yield call$e(handleBaseLayersSaga, mapId, allBaseLayers);
7961
8027
  if (proj) {
7962
- const isProjectionSupported = webmapUtils.getWMJSMapById(mapId).isProjectionSupported(proj.srs);
7963
- if (!isProjectionSupported) {
8028
+ const checkIsprojectionSupported = isProjectionSupported(proj.srs);
8029
+ if (!checkIsprojectionSupported) {
7964
8030
  throw new Error(`Projection ${proj.srs} is not supported`);
7965
8031
  }
7966
8032
  // set bbox
@@ -8192,7 +8258,7 @@ function* setStepBackwardOrForwardSaga({
8192
8258
  }
8193
8259
  }
8194
8260
  function* rootSaga$4() {
8195
- // resets WMJSMap state
8261
+ // resets IWMJSMap state
8196
8262
  yield takeLatest(mapActions.mapStopAnimation.type, stopAnimationSaga);
8197
8263
  yield takeLatest(mapActions.mapStartAnimation.type, startAnimationSaga);
8198
8264
  yield takeLatest(layerActions.layerDelete.type, deleteLayerSaga);
@@ -8256,7 +8322,8 @@ const metronomeHandler = (timerIds, listenerApi) => {
8256
8322
  value: ''
8257
8323
  });
8258
8324
  }
8259
- const timerShouldStepForward = prefetchAnimationTargetsForMetronome(timerId, animationListValues, targets);
8325
+ const timerIsInDwell = handleTimerDwell(timerId, animationListValues.length);
8326
+ const timerShouldStepForward = prefetchAnimationTargetsForMetronome(timerId, animationListValues, targets) && !timerIsInDwell;
8260
8327
  // Determine the next step
8261
8328
  const timerStep = timerShouldStepForward ? getNextStep(timerId, animationListValues.length) : getCurrentStep(timerId);
8262
8329
  setStep(timerId, timerStep);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/store",
3
- "version": "9.20.2",
3
+ "version": "9.22.0",
4
4
  "description": "GeoWeb Store library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -37,6 +37,7 @@ export declare const mapStoreActions: {
37
37
  setEndTimeOverriding: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").SetEndTimeOverriding, "mapReducer/setEndTimeOverriding">;
38
38
  toggleTimestepAuto: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").ToggleTimestepAutoPayload, "mapReducer/toggleTimestepAuto">;
39
39
  toggleTimeSpanAuto: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").ToggleTimeSpanAutoPayload, "mapReducer/toggleTimeSpanAuto">;
40
+ toggleAnimationLengthAuto: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").ToggleAnimationLengthAutoPayload, "mapReducer/toggleAnimationLengthAuto">;
40
41
  toggleTimeSliderHover: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").ToggleTimeSliderHoverPayload, "mapReducer/toggleTimeSliderHover">;
41
42
  toggleTimeSliderIsVisible: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").ToggleTimeSliderIsVisiblePayload, "mapReducer/toggleTimeSliderIsVisible">;
42
43
  toggleZoomControls: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").ToggleZoomControlsPayload, "mapReducer/toggleZoomControls">;
@@ -7,6 +7,14 @@ import { SetTimeSyncPayload } from '../../generic/synchronizationActions/types';
7
7
  * @returns
8
8
  */
9
9
  export declare const getNextStep: (timerId: string, numberOfStepsInAnimation: number, numStepsToGoForward?: number) => number;
10
+ /**
11
+ * Handles dwell at the end of the animation loop sequence. The number of steps to wait till proceed can be set by the dwell parameter.
12
+ * @param timerId The timer id
13
+ * @param numberOfStepsInAnimation Number of steps in the animation
14
+ * @param dwell The number of steps to wait at the end of the animation sequence before to continue
15
+ * @returns
16
+ */
17
+ export declare const handleTimerDwell: (timerId: string, numberOfStepsInAnimation: number, dwell?: number) => boolean;
10
18
  /**
11
19
  * Set step for the timerId
12
20
  * @param timerId
@@ -1,6 +1,6 @@
1
1
  import { PayloadAction, Draft } from '@reduxjs/toolkit';
2
2
  import { MapPinLocationPayload, SetBboxPayload, SetStepBackWardOrForward, UpdateAllMapDimensionsPayload } from '@opengeoweb/webmap-react';
3
- import type { WebMapState, SetAutoLayerIdPayload, SetMapAnimationStartPayload, SetMapAnimationStopPayload, SetTimeSliderSpanPayload, SetTimeStepPayload, SetAnimationStartTimePayload, SetAnimationEndTimePayload, SetAnimationDelayPayload, MoveLayerPayload, SetTimeSliderWidthPayload, SetTimeSliderCenterTimePayload, SetEndTimeOverriding, ToggleAutoUpdatePayload, ToggleTimestepAutoPayload, ToggleTimeSpanAutoPayload, ToggleTimeSliderHoverPayload, DisableMapPinPayload, SetTimeSliderSecondsPerPxPayload, ToggleTimeSliderIsVisiblePayload, SetDockedLayerManagerSize } from './types';
3
+ import type { WebMapState, SetAutoLayerIdPayload, SetMapAnimationStartPayload, SetMapAnimationStopPayload, SetTimeSliderSpanPayload, SetTimeStepPayload, SetAnimationStartTimePayload, SetAnimationEndTimePayload, SetAnimationDelayPayload, MoveLayerPayload, SetTimeSliderWidthPayload, SetTimeSliderCenterTimePayload, SetEndTimeOverriding, ToggleAutoUpdatePayload, ToggleTimestepAutoPayload, ToggleTimeSpanAutoPayload, ToggleTimeSliderHoverPayload, DisableMapPinPayload, SetTimeSliderSecondsPerPxPayload, ToggleTimeSliderIsVisiblePayload, SetDockedLayerManagerSize, ToggleAnimationLengthAutoPayload } from './types';
4
4
  import { ToggleMapPinIsVisiblePayload, ToggleZoomControlsPayload } from '../types';
5
5
  /**
6
6
  * Checks if the layer id is already taken in one of the maps.
@@ -44,6 +44,7 @@ export declare const slice: import("@reduxjs/toolkit").Slice<WebMapState, {
44
44
  setEndTimeOverriding: (draft: Draft<WebMapState>, action: PayloadAction<SetEndTimeOverriding>) => void;
45
45
  toggleTimestepAuto: (draft: Draft<WebMapState>, action: PayloadAction<ToggleTimestepAutoPayload>) => void;
46
46
  toggleTimeSpanAuto: (draft: Draft<WebMapState>, action: PayloadAction<ToggleTimeSpanAutoPayload>) => void;
47
+ toggleAnimationLengthAuto: (draft: Draft<WebMapState>, action: PayloadAction<ToggleAnimationLengthAutoPayload>) => void;
47
48
  toggleTimeSliderHover: (draft: Draft<WebMapState>, action: PayloadAction<ToggleTimeSliderHoverPayload>) => void;
48
49
  toggleTimeSliderIsVisible: (draft: Draft<WebMapState>, action: PayloadAction<ToggleTimeSliderIsVisiblePayload>) => void;
49
50
  toggleZoomControls: (draft: Draft<WebMapState>, action: PayloadAction<ToggleZoomControlsPayload>) => void;
@@ -92,6 +93,7 @@ export declare const mapActions: {
92
93
  setEndTimeOverriding: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetEndTimeOverriding, "mapReducer/setEndTimeOverriding">;
93
94
  toggleTimestepAuto: import("@reduxjs/toolkit").ActionCreatorWithPayload<ToggleTimestepAutoPayload, "mapReducer/toggleTimestepAuto">;
94
95
  toggleTimeSpanAuto: import("@reduxjs/toolkit").ActionCreatorWithPayload<ToggleTimeSpanAutoPayload, "mapReducer/toggleTimeSpanAuto">;
96
+ toggleAnimationLengthAuto: import("@reduxjs/toolkit").ActionCreatorWithPayload<ToggleAnimationLengthAutoPayload, "mapReducer/toggleAnimationLengthAuto">;
95
97
  toggleTimeSliderHover: import("@reduxjs/toolkit").ActionCreatorWithPayload<ToggleTimeSliderHoverPayload, "mapReducer/toggleTimeSliderHover">;
96
98
  toggleTimeSliderIsVisible: import("@reduxjs/toolkit").ActionCreatorWithPayload<ToggleTimeSliderIsVisiblePayload, "mapReducer/toggleTimeSliderIsVisible">;
97
99
  toggleZoomControls: import("@reduxjs/toolkit").ActionCreatorWithPayload<ToggleZoomControlsPayload, "mapReducer/toggleZoomControls">;
@@ -455,6 +455,17 @@ export declare const isTimestepAuto: ((state: any, mapId: any) => boolean | unde
455
455
  }> & {
456
456
  clearCache: () => void;
457
457
  };
458
+ /**
459
+ * Returns map is animation auto
460
+ * @param {object} store store: object - store object
461
+ * @param {string} mapId mapId: string - Id of the map
462
+ * @returns {boolean} returnType: boolean
463
+ */
464
+ export declare const isAnimationLengthAuto: ((state: any, mapId: any) => boolean) & import("reselect").OutputSelectorFields<(args_0: WebMap | undefined) => boolean, {
465
+ clearCache: () => void;
466
+ }> & {
467
+ clearCache: () => void;
468
+ };
458
469
  /**
459
470
  * Returns map is timespan auto
460
471
  *
@@ -704,3 +715,19 @@ export declare const getAnimationList: ((state: any, mapId: any) => WebMapAnimat
704
715
  }> & {
705
716
  clearCache: () => void;
706
717
  };
718
+ /**
719
+ * @param {object} store store: object - store object
720
+ * @param {string} mapId mapId: string - Id of the map
721
+ * @returns {object} Returns min and max value of time dimension of autoTimeStep-layer. If no autoTimeStep-layer it returns default start/end time from store.
722
+ */
723
+ export declare const getAnimationRange: ((state: any, mapId: any) => {
724
+ animationStartTime: string | undefined;
725
+ animationEndTime: string | undefined;
726
+ }) & import("reselect").OutputSelectorFields<(args_0: CoreAppStore, args_1: string | undefined, args_2: string | undefined, args_3: string | undefined, args_4: boolean, args_5: Dimension | undefined) => {
727
+ animationStartTime: string | undefined;
728
+ animationEndTime: string | undefined;
729
+ }, {
730
+ clearCache: () => void;
731
+ }> & {
732
+ clearCache: () => void;
733
+ };
@@ -43,6 +43,7 @@ export interface WebMap {
43
43
  timeSliderSecondsPerPx?: number;
44
44
  isTimestepAuto?: boolean;
45
45
  isTimeSpanAuto?: boolean;
46
+ isAnimationLengthAuto?: boolean;
46
47
  isTimeSliderHoverOn?: boolean;
47
48
  isTimeSliderVisible?: boolean;
48
49
  shouldShowZoomControls?: boolean;
@@ -179,6 +180,11 @@ export interface ToggleTimeSpanAutoPayload {
179
180
  timeSpanAuto: boolean;
180
181
  origin?: MapActionOrigin;
181
182
  }
183
+ export interface ToggleAnimationLengthAutoPayload {
184
+ mapId: string;
185
+ autoAnimationLength: boolean;
186
+ origin?: MapActionOrigin;
187
+ }
182
188
  export interface ToggleTimeSliderHoverPayload {
183
189
  mapId: string;
184
190
  isTimeSliderHoverOn: boolean;