@opengeoweb/store 9.21.0 → 9.23.1

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,5 +1,5 @@
1
- import { webmapUtils, LayerType, getWMJSMapById, WMLayer, webmapTestSettings, handleDateUtilsISOString, getCapabilities } from '@opengeoweb/webmap';
2
- import { createAction, createSlice, createSelector, createEntityAdapter, createListenerMiddleware } from '@reduxjs/toolkit';
1
+ import { webmapUtils, LayerType, getWMJSMapById, WMLayer, webmapTestSettings, getWMSRequests, isProjectionSupported, handleDateUtilsISOString, getCapabilities } from '@opengeoweb/webmap';
2
+ import { createAction, createSlice, createSelector, createEntityAdapter, createListenerMiddleware, isAnyOf } 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';
5
5
  import { dateUtils, defaultDelay, withEggs } from '@opengeoweb/shared';
@@ -4635,6 +4635,7 @@ var DialogTypes;
4635
4635
  DialogTypes["ObjectManager"] = "objectManager";
4636
4636
  DialogTypes["PublicWarnings"] = "publicWarnings";
4637
4637
  DialogTypes["Search"] = "search";
4638
+ DialogTypes["AreaObjectLoader"] = "areaObjectLoader";
4638
4639
  })(DialogTypes || (DialogTypes = {}));
4639
4640
 
4640
4641
  var types$3 = /*#__PURE__*/Object.freeze({
@@ -4999,17 +5000,7 @@ const setBboxOrTimeSync = (draft, action) => {
4999
5000
  });
5000
5001
  }
5001
5002
  };
5002
- const {
5003
- syncGroupAddGroup,
5004
- syncGroupAddSource,
5005
- syncGroupAddTarget,
5006
- syncGroupClear,
5007
- syncGroupLinkTarget,
5008
- syncGroupRemoveGroup,
5009
- syncGroupRemoveSource,
5010
- syncGroupRemoveTarget,
5011
- syncGroupSetViewState
5012
- } = slice$4.actions;
5003
+ slice$4.actions;
5013
5004
  const {
5014
5005
  actions,
5015
5006
  reducer: reducer$3
@@ -7632,6 +7623,8 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
7632
7623
 
7633
7624
  /* A map with all the timerIds and their current step */
7634
7625
  const stepMap = new Map();
7626
+ /* A map with a list of timers and their dwell */
7627
+ const timerDwellMap = new Map();
7635
7628
  /**
7636
7629
  * Returns the next step for given timerId.
7637
7630
  * @param timerId The timer id
@@ -7645,6 +7638,30 @@ const getNextStep = (timerId, numberOfStepsInAnimation, numStepsToGoForward = 1)
7645
7638
  const nextStepClipped = (nextStep % numberOfStepsInAnimation + numberOfStepsInAnimation) % numberOfStepsInAnimation;
7646
7639
  return nextStepClipped;
7647
7640
  };
7641
+ /**
7642
+ * 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.
7643
+ * @param timerId The timer id
7644
+ * @param numberOfStepsInAnimation Number of steps in the animation
7645
+ * @param dwell The number of steps to wait at the end of the animation sequence before to continue
7646
+ * @returns
7647
+ */
7648
+ const handleTimerDwell = (timerId, numberOfStepsInAnimation, dwell = 8) => {
7649
+ if (dwell > 0) {
7650
+ const currentStep = getCurrentStep(timerId);
7651
+ // Reset the dwell if we are not at the last animation step
7652
+ if (currentStep < numberOfStepsInAnimation - 1) {
7653
+ timerDwellMap.set(timerId, dwell);
7654
+ return false;
7655
+ }
7656
+ // We are at the last animation step, check the dwell
7657
+ const timerDwell = timerDwellMap.has(timerId) && timerDwellMap.get(timerId) || 0;
7658
+ if (currentStep === numberOfStepsInAnimation - 1 && timerDwell > 0) {
7659
+ timerDwellMap.set(timerId, timerDwell - 1);
7660
+ return true;
7661
+ }
7662
+ }
7663
+ return false;
7664
+ };
7648
7665
  /**
7649
7666
  * Set step for the timerId
7650
7667
  * @param timerId
@@ -7680,7 +7697,7 @@ const prefetchAnimationTargetsForMetronome = (timerId, animationListValues, targ
7680
7697
  const targetMapId = target.targetId;
7681
7698
  const wmMap = getWMJSMapById(targetMapId);
7682
7699
  if (wmMap) {
7683
- const layersImageUrls = wmMap.getWMSRequests([{
7700
+ const layersImageUrls = getWMSRequests(wmMap, [{
7684
7701
  name: 'time',
7685
7702
  currentValue: nextTimeValueStepToCheck
7686
7703
  }]);
@@ -7999,8 +8016,8 @@ function* setMapPresetSaga({
7999
8016
  }));
8000
8017
  yield call$e(handleBaseLayersSaga, mapId, allBaseLayers);
8001
8018
  if (proj) {
8002
- const isProjectionSupported = webmapUtils.getWMJSMapById(mapId).isProjectionSupported(proj.srs);
8003
- if (!isProjectionSupported) {
8019
+ const checkIsprojectionSupported = isProjectionSupported(proj.srs);
8020
+ if (!checkIsprojectionSupported) {
8004
8021
  throw new Error(`Projection ${proj.srs} is not supported`);
8005
8022
  }
8006
8023
  // set bbox
@@ -8231,8 +8248,8 @@ function* setStepBackwardOrForwardSaga({
8231
8248
  }));
8232
8249
  }
8233
8250
  }
8234
- function* rootSaga$4() {
8235
- // resets WMJSMap state
8251
+ function* rootSaga$2() {
8252
+ // resets IWMJSMap state
8236
8253
  yield takeLatest(mapActions.mapStopAnimation.type, stopAnimationSaga);
8237
8254
  yield takeLatest(mapActions.mapStartAnimation.type, startAnimationSaga);
8238
8255
  yield takeLatest(layerActions.layerDelete.type, deleteLayerSaga);
@@ -8269,7 +8286,7 @@ function* fetchInitialServicesSaga({
8269
8286
  }));
8270
8287
  }));
8271
8288
  }
8272
- function* rootSaga$3() {
8289
+ function* rootSaga$1() {
8273
8290
  yield takeEvery(serviceActions.fetchInitialServices, fetchInitialServicesSaga);
8274
8291
  }
8275
8292
 
@@ -8296,7 +8313,8 @@ const metronomeHandler = (timerIds, listenerApi) => {
8296
8313
  value: ''
8297
8314
  });
8298
8315
  }
8299
- const timerShouldStepForward = prefetchAnimationTargetsForMetronome(timerId, animationListValues, targets);
8316
+ const timerIsInDwell = handleTimerDwell(timerId, animationListValues.length);
8317
+ const timerShouldStepForward = prefetchAnimationTargetsForMetronome(timerId, animationListValues, targets) && !timerIsInDwell;
8300
8318
  // Determine the next step
8301
8319
  const timerStep = timerShouldStepForward ? getNextStep(timerId, animationListValues.length) : getCurrentStep(timerId);
8302
8320
  setStep(timerId, timerStep);
@@ -8446,7 +8464,7 @@ const mapStoreReducers = {
8446
8464
  const mapStoreModuleConfig = {
8447
8465
  id: 'webmap-module',
8448
8466
  reducersMap: mapStoreReducers,
8449
- sagas: [rootSaga$4, rootSaga$3],
8467
+ sagas: [rootSaga$2, rootSaga$1],
8450
8468
  middlewares: [metronomeListener.middleware, layersListener.middleware, mapUiListener.middleware]
8451
8469
  };
8452
8470
 
@@ -8757,7 +8775,7 @@ function* mapBaseLayerActionsSaga({
8757
8775
  yield put(setLayerActionSync(payload, targets, type));
8758
8776
  }
8759
8777
  }
8760
- function* rootSaga$2() {
8778
+ function* rootSaga() {
8761
8779
  yield takeLatest(setTime.type, setTimeSaga);
8762
8780
  yield takeLatest(setBbox.type, setBBoxSaga);
8763
8781
  yield takeLatest(layerActions.layerChangeName.type, layerActionsSaga);
@@ -8846,18 +8864,19 @@ var utils = /*#__PURE__*/Object.freeze({
8846
8864
  * See the License for the specific language governing permissions and
8847
8865
  * limitations under the License.
8848
8866
  *
8849
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
8850
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
8867
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
8868
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
8851
8869
  * */
8852
- function* navigateToUrlSaga(action) {
8853
- const {
8870
+ const routerListener = createListenerMiddleware();
8871
+ routerListener.startListening({
8872
+ actionCreator: routerActions.navigateToUrl,
8873
+ effect: ({
8854
8874
  payload
8855
- } = action;
8856
- yield call$e(historyDict.navigate, payload.url);
8857
- }
8858
- function* rootSaga$1() {
8859
- yield takeLatest(routerActions.navigateToUrl.type, navigateToUrlSaga);
8860
- }
8875
+ }, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
8876
+ listenerApi.cancelActiveListeners();
8877
+ historyDict.navigate(payload.url);
8878
+ })
8879
+ });
8861
8880
 
8862
8881
  /* *
8863
8882
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -8880,7 +8899,7 @@ const routerModuleConfig = {
8880
8899
  reducersMap: {
8881
8900
  router: reducer$1
8882
8901
  },
8883
- sagas: [rootSaga$1]
8902
+ middlewares: [routerListener.middleware]
8884
8903
  };
8885
8904
 
8886
8905
  // reducer utils
@@ -9106,195 +9125,212 @@ var selectors = /*#__PURE__*/Object.freeze({
9106
9125
  selectDrawToolById: selectDrawToolById
9107
9126
  });
9108
9127
 
9128
+ const drawingToolListener = createListenerMiddleware();
9109
9129
  const registerOrigin = 'drawings saga:registerDrawToolSaga';
9110
- function* registerDrawToolSaga({
9111
- payload
9112
- }) {
9113
- const {
9114
- mapId,
9115
- geoJSONLayerId,
9116
- geoJSONIntersectionLayerId,
9117
- geoJSONIntersectionBoundsLayerId,
9118
- defaultGeoJSON = emptyGeoJSON,
9119
- defaultGeoJSONIntersection = emptyGeoJSON,
9120
- defaultGeoJSONIntersectionBounds,
9121
- defaultGeoJSONIntersectionProperties = defaultIntersectionStyleProperties
9122
- } = payload;
9123
- // create for every drawTool a draw layer
9124
- if (geoJSONLayerId && mapId) {
9125
- yield put(mapStoreActions.addLayer({
9126
- mapId,
9127
- layer: {
9128
- // empty geoJSON
9129
- geojson: defaultGeoJSON,
9130
- layerType: LayerType.featureLayer
9131
- },
9132
- layerId: geoJSONLayerId,
9133
- origin: registerOrigin
9134
- }));
9135
- }
9136
- // create intersection layer
9137
- if (geoJSONIntersectionLayerId && mapId) {
9138
- yield put(mapStoreActions.addLayer({
9130
+ // register draw tool
9131
+ drawingToolListener.startListening({
9132
+ actionCreator: drawtoolActions.registerDrawTool,
9133
+ effect: ({
9134
+ payload
9135
+ }, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
9136
+ listenerApi.cancelActiveListeners();
9137
+ const {
9139
9138
  mapId,
9140
- layer: {
9141
- geojson: defaultGeoJSONIntersection,
9142
- layerType: LayerType.featureLayer,
9143
- defaultGeoJSONProperties: defaultGeoJSONIntersectionProperties
9144
- },
9145
- layerId: geoJSONIntersectionLayerId,
9146
- origin: registerOrigin
9147
- }));
9148
- }
9149
- // create intersection bounds layer
9150
- if (geoJSONIntersectionBoundsLayerId && mapId) {
9151
- const existingBoundsLayer = yield select(getLayerById, geoJSONIntersectionBoundsLayerId);
9152
- // don't add a new boundslayer when another drawtool using that same boundslayer
9153
- if (!existingBoundsLayer) {
9154
- yield put(mapStoreActions.addLayer({
9139
+ geoJSONLayerId,
9140
+ geoJSONIntersectionLayerId,
9141
+ geoJSONIntersectionBoundsLayerId,
9142
+ defaultGeoJSON = emptyGeoJSON,
9143
+ defaultGeoJSONIntersection = emptyGeoJSON,
9144
+ defaultGeoJSONIntersectionBounds,
9145
+ defaultGeoJSONIntersectionProperties = defaultIntersectionStyleProperties
9146
+ } = payload;
9147
+ // create for every drawTool a draw layer
9148
+ if (geoJSONLayerId && mapId) {
9149
+ listenerApi.dispatch(mapStoreActions.addLayer({
9155
9150
  mapId,
9156
9151
  layer: {
9157
- geojson: defaultGeoJSONIntersectionBounds,
9152
+ // empty geoJSON
9153
+ geojson: defaultGeoJSON,
9158
9154
  layerType: LayerType.featureLayer
9159
9155
  },
9160
- layerId: geoJSONIntersectionBoundsLayerId,
9156
+ layerId: geoJSONLayerId,
9161
9157
  origin: registerOrigin
9162
9158
  }));
9163
9159
  }
9164
- yield put(layerActions.orderLayerToFront({
9165
- layerId: geoJSONIntersectionBoundsLayerId
9166
- }));
9167
- }
9168
- }
9169
- function* changeDrawToolSaga({
9170
- payload
9171
- }) {
9172
- var _a, _b, _c;
9173
- try {
9174
- const {
9175
- drawModeId,
9176
- drawToolId,
9177
- shouldUpdateShape = true
9178
- } = payload;
9179
- const drawingTool = yield select(selectDrawToolById, drawToolId);
9180
- const {
9181
- shouldAllowMultipleShapes = false,
9182
- geoJSONIntersectionLayerId,
9183
- geoJSONIntersectionBoundsLayerId
9184
- } = drawingTool;
9185
- const newDrawMode = yield select(getDrawModeById, drawToolId, drawModeId);
9186
- // disable layer when no new drawmode or when selecting same tool and is selectable
9187
- if (!newDrawMode || !drawingTool.activeDrawModeId && newDrawMode.isSelectable) {
9188
- yield put(layerActions.toggleFeatureMode({
9189
- layerId: drawingTool.geoJSONLayerId,
9190
- isInEditMode: false,
9191
- drawMode: ''
9160
+ // create intersection layer
9161
+ if (geoJSONIntersectionLayerId && mapId) {
9162
+ listenerApi.dispatch(mapStoreActions.addLayer({
9163
+ mapId,
9164
+ layer: {
9165
+ geojson: defaultGeoJSONIntersection,
9166
+ layerType: LayerType.featureLayer,
9167
+ defaultGeoJSONProperties: defaultGeoJSONIntersectionProperties
9168
+ },
9169
+ layerId: geoJSONIntersectionLayerId,
9170
+ origin: registerOrigin
9192
9171
  }));
9193
- const geoJSONLayer = yield select(getLayerById, drawingTool.geoJSONLayerId);
9194
- const geoJSON = geoJSONLayer === null || geoJSONLayer === void 0 ? void 0 : geoJSONLayer.geojson;
9195
- const lastFeatureIndex = geoJSON !== undefined ? getLastEmptyFeatureIndex(geoJSON) : undefined;
9196
- if (lastFeatureIndex !== undefined) {
9197
- const newGeoJSON = Object.assign(Object.assign({}, geoJSON), {
9198
- features: geoJSON.features.filter((_feature, index) => index !== lastFeatureIndex)
9199
- });
9200
- yield put(layerActions.updateFeature({
9201
- layerId: drawingTool.geoJSONLayerId,
9202
- geojson: newGeoJSON
9172
+ }
9173
+ // create intersection bounds layer
9174
+ if (geoJSONIntersectionBoundsLayerId && mapId) {
9175
+ const existingBoundsLayer = getLayerById(listenerApi.getState(), geoJSONIntersectionBoundsLayerId);
9176
+ // don't add a new boundslayer when another drawtool using that same boundslayer
9177
+ if (!existingBoundsLayer) {
9178
+ listenerApi.dispatch(mapStoreActions.addLayer({
9179
+ mapId,
9180
+ layer: {
9181
+ geojson: defaultGeoJSONIntersectionBounds,
9182
+ layerType: LayerType.featureLayer
9183
+ },
9184
+ layerId: geoJSONIntersectionBoundsLayerId,
9185
+ origin: registerOrigin
9203
9186
  }));
9204
- yield put(layerActions.setSelectedFeature({
9187
+ }
9188
+ listenerApi.dispatch(layerActions.orderLayerToFront({
9189
+ layerId: geoJSONIntersectionBoundsLayerId
9190
+ }));
9191
+ }
9192
+ })
9193
+ });
9194
+ // change draw tool
9195
+ drawingToolListener.startListening({
9196
+ actionCreator: drawtoolActions.changeDrawToolMode,
9197
+ effect: ({
9198
+ payload
9199
+ }, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
9200
+ var _a, _b, _c;
9201
+ listenerApi.cancelActiveListeners();
9202
+ try {
9203
+ const {
9204
+ drawModeId,
9205
+ drawToolId,
9206
+ shouldUpdateShape = true
9207
+ } = payload;
9208
+ const drawingTool = selectDrawToolById(listenerApi.getState(), drawToolId);
9209
+ if (!drawingTool) {
9210
+ return;
9211
+ }
9212
+ const {
9213
+ shouldAllowMultipleShapes = false,
9214
+ geoJSONIntersectionLayerId,
9215
+ geoJSONIntersectionBoundsLayerId
9216
+ } = drawingTool;
9217
+ const newDrawMode = getDrawModeById(listenerApi.getState(), drawToolId, drawModeId);
9218
+ // disable layer when no new drawmode or when selecting same tool and is selectable
9219
+ if (!newDrawMode || !drawingTool.activeDrawModeId && newDrawMode.isSelectable) {
9220
+ listenerApi.dispatch(layerActions.toggleFeatureMode({
9205
9221
  layerId: drawingTool.geoJSONLayerId,
9206
- selectedFeatureIndex: newGeoJSON.features.length > 0 ? newGeoJSON.features.length - 1 : 0
9222
+ isInEditMode: false,
9223
+ drawMode: ''
9207
9224
  }));
9225
+ const geoJSONLayer = getLayerById(listenerApi.getState(), drawingTool.geoJSONLayerId);
9226
+ const geoJSON = geoJSONLayer === null || geoJSONLayer === void 0 ? void 0 : geoJSONLayer.geojson;
9227
+ const lastFeatureIndex = geoJSON !== undefined ? getLastEmptyFeatureIndex(geoJSON) : undefined;
9228
+ if (lastFeatureIndex !== undefined) {
9229
+ const newGeoJSON = Object.assign(Object.assign({}, geoJSON), {
9230
+ features: geoJSON.features.filter((_feature, index) => index !== lastFeatureIndex)
9231
+ });
9232
+ listenerApi.dispatch(layerActions.updateFeature({
9233
+ layerId: drawingTool.geoJSONLayerId,
9234
+ geojson: newGeoJSON
9235
+ }));
9236
+ listenerApi.dispatch(layerActions.setSelectedFeature({
9237
+ layerId: drawingTool.geoJSONLayerId,
9238
+ selectedFeatureIndex: newGeoJSON.features.length > 0 ? newGeoJSON.features.length - 1 : 0
9239
+ }));
9240
+ }
9241
+ return;
9208
9242
  }
9209
- return;
9210
- }
9211
- // delete shape
9212
- if (newDrawMode.value === 'DELETE') {
9213
- yield put(layerActions.layerChangeGeojson({
9214
- layerId: drawingTool.geoJSONLayerId,
9215
- geojson: emptyGeoJSON
9216
- }));
9217
- // clear intersection shape
9218
- if (geoJSONIntersectionLayerId) {
9219
- yield put(layerActions.layerChangeGeojson({
9220
- layerId: geoJSONIntersectionLayerId,
9243
+ // delete shape
9244
+ if (newDrawMode.value === 'DELETE') {
9245
+ listenerApi.dispatch(layerActions.layerChangeGeojson({
9246
+ layerId: drawingTool.geoJSONLayerId,
9221
9247
  geojson: emptyGeoJSON
9222
9248
  }));
9249
+ // clear intersection shape
9250
+ if (geoJSONIntersectionLayerId) {
9251
+ listenerApi.dispatch(layerActions.layerChangeGeojson({
9252
+ layerId: geoJSONIntersectionLayerId,
9253
+ geojson: emptyGeoJSON
9254
+ }));
9255
+ }
9256
+ listenerApi.dispatch(layerActions.toggleFeatureMode({
9257
+ layerId: drawingTool.geoJSONLayerId,
9258
+ isInEditMode: false,
9259
+ drawMode: ''
9260
+ }));
9261
+ return;
9223
9262
  }
9224
- yield put(layerActions.toggleFeatureMode({
9263
+ // check tool is selected of existing drawn shape
9264
+ const currentGeoJSONLayer = getLayerById(listenerApi.getState(), drawingTool.geoJSONLayerId);
9265
+ const {
9266
+ geojson: currentGeoJSON,
9267
+ selectedFeatureIndex = 0
9268
+ } = currentGeoJSONLayer || {};
9269
+ const 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;
9270
+ const newSelectionType = newDrawMode.selectionType;
9271
+ const isNewToolSelected = currentSelectionType !== newSelectionType;
9272
+ const shouldUpdateNewShape = !((_c = currentGeoJSON === null || currentGeoJSON === void 0 ? void 0 : currentGeoJSON.features) === null || _c === void 0 ? void 0 : _c.length) || isNewToolSelected || !newDrawMode.isSelectable && shouldAllowMultipleShapes;
9273
+ // don't change anything if same tool is selected again
9274
+ if (shouldUpdateNewShape && shouldUpdateShape) {
9275
+ const shapeWithSelectionType = addSelectionTypeToGeoJSON(newDrawMode.shape, newDrawMode.selectionType);
9276
+ const geoJSONFeatureCollection = getFeatureCollection(shapeWithSelectionType, shouldAllowMultipleShapes, currentGeoJSON);
9277
+ const newGeoJSON = getGeoJson(geoJSONFeatureCollection, shouldAllowMultipleShapes);
9278
+ if (shouldAllowMultipleShapes) {
9279
+ moveFeature(currentGeoJSON, newGeoJSON, selectedFeatureIndex, '');
9280
+ }
9281
+ listenerApi.dispatch(layerActions.setSelectedFeature({
9282
+ layerId: drawingTool.geoJSONLayerId,
9283
+ selectedFeatureIndex: newGeoJSON.features.length - 1
9284
+ }));
9285
+ listenerApi.dispatch(layerActions.updateFeature(Object.assign(Object.assign({
9286
+ layerId: drawingTool.geoJSONLayerId,
9287
+ geojson: newGeoJSON
9288
+ }, geoJSONIntersectionLayerId && {
9289
+ geoJSONIntersectionLayerId
9290
+ }), geoJSONIntersectionBoundsLayerId && {
9291
+ geoJSONIntersectionBoundsLayerId
9292
+ })));
9293
+ }
9294
+ listenerApi.dispatch(layerActions.toggleFeatureMode({
9225
9295
  layerId: drawingTool.geoJSONLayerId,
9226
- isInEditMode: false,
9227
- drawMode: ''
9296
+ isInEditMode: newDrawMode.isSelectable,
9297
+ drawMode: newDrawMode.value
9228
9298
  }));
9229
- return;
9299
+ } catch (error) {
9300
+ // eslint-disable-next-line no-console
9301
+ console.log('error changeDrawToolSaga', error);
9230
9302
  }
9231
- // check tool is selected of existing drawn shape
9232
- const currentGeoJSONLayer = yield select(getLayerById, drawingTool.geoJSONLayerId);
9303
+ })
9304
+ });
9305
+ // change intersection
9306
+ drawingToolListener.startListening({
9307
+ actionCreator: drawtoolActions.changeIntersectionBounds,
9308
+ effect: ({
9309
+ payload
9310
+ }, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
9311
+ listenerApi.cancelActiveListeners();
9233
9312
  const {
9234
- geojson: currentGeoJSON,
9235
- selectedFeatureIndex = 0
9236
- } = currentGeoJSONLayer || {};
9237
- const 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;
9238
- const newSelectionType = newDrawMode.selectionType;
9239
- const isNewToolSelected = currentSelectionType !== newSelectionType;
9240
- const shouldUpdateNewShape = !((_c = currentGeoJSON === null || currentGeoJSON === void 0 ? void 0 : currentGeoJSON.features) === null || _c === void 0 ? void 0 : _c.length) || isNewToolSelected || !newDrawMode.isSelectable && shouldAllowMultipleShapes;
9241
- // don't change anything if same tool is selected again
9242
- if (shouldUpdateNewShape && shouldUpdateShape) {
9243
- const shapeWithSelectionType = addSelectionTypeToGeoJSON(newDrawMode.shape, newDrawMode.selectionType);
9244
- const geoJSONFeatureCollection = getFeatureCollection(shapeWithSelectionType, shouldAllowMultipleShapes, currentGeoJSON);
9245
- const newGeoJSON = getGeoJson(geoJSONFeatureCollection, shouldAllowMultipleShapes);
9246
- if (shouldAllowMultipleShapes) {
9247
- moveFeature(currentGeoJSON, newGeoJSON, selectedFeatureIndex, '');
9248
- }
9249
- yield put(layerActions.setSelectedFeature({
9250
- layerId: drawingTool.geoJSONLayerId,
9251
- selectedFeatureIndex: newGeoJSON.features.length - 1
9252
- }));
9253
- yield put(layerActions.updateFeature(Object.assign(Object.assign({
9254
- layerId: drawingTool.geoJSONLayerId,
9255
- geojson: newGeoJSON
9256
- }, geoJSONIntersectionLayerId && {
9257
- geoJSONIntersectionLayerId
9258
- }), geoJSONIntersectionBoundsLayerId && {
9259
- geoJSONIntersectionBoundsLayerId
9260
- })));
9313
+ drawToolId,
9314
+ geoJSON
9315
+ } = payload;
9316
+ const drawtool = selectDrawToolById(listenerApi.getState(), drawToolId);
9317
+ if (!drawtool) {
9318
+ return;
9261
9319
  }
9262
- yield put(layerActions.toggleFeatureMode({
9263
- layerId: drawingTool.geoJSONLayerId,
9264
- isInEditMode: newDrawMode.isSelectable,
9265
- drawMode: newDrawMode.value
9320
+ listenerApi.dispatch(layerActions.layerChangeGeojson({
9321
+ layerId: drawtool.geoJSONIntersectionBoundsLayerId,
9322
+ geojson: geoJSON
9266
9323
  }));
9267
- } catch (error) {
9268
- // eslint-disable-next-line no-console
9269
- console.log('error changeDrawToolSaga', error);
9270
- }
9271
- }
9272
- function* changeIntersectionSaga({
9273
- payload
9274
- }) {
9275
- const {
9276
- drawToolId,
9277
- geoJSON
9278
- } = payload;
9279
- const drawtool = yield select(selectDrawToolById, drawToolId);
9280
- yield put(layerActions.layerChangeGeojson({
9281
- layerId: drawtool.geoJSONIntersectionBoundsLayerId,
9282
- geojson: geoJSON
9283
- }));
9284
- yield put(layerActions.layerChangeGeojson({
9285
- layerId: drawtool.geoJSONLayerId,
9286
- geojson: emptyGeoJSON
9287
- }));
9288
- yield put(layerActions.layerChangeGeojson({
9289
- layerId: drawtool.geoJSONIntersectionLayerId,
9290
- geojson: emptyGeoJSON
9291
- }));
9292
- }
9293
- function* drawingSaga() {
9294
- yield takeLatest(drawtoolActions.registerDrawTool, registerDrawToolSaga);
9295
- yield takeLatest(drawtoolActions.changeDrawToolMode, changeDrawToolSaga);
9296
- yield takeLatest(drawtoolActions.changeIntersectionBounds, changeIntersectionSaga);
9297
- }
9324
+ listenerApi.dispatch(layerActions.layerChangeGeojson({
9325
+ layerId: drawtool.geoJSONLayerId,
9326
+ geojson: emptyGeoJSON
9327
+ }));
9328
+ listenerApi.dispatch(layerActions.layerChangeGeojson({
9329
+ layerId: drawtool.geoJSONIntersectionLayerId,
9330
+ geojson: emptyGeoJSON
9331
+ }));
9332
+ })
9333
+ });
9298
9334
 
9299
9335
  /* *
9300
9336
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -9317,7 +9353,7 @@ const drawtoolModuleConfig = {
9317
9353
  reducersMap: {
9318
9354
  drawingtools: reducer
9319
9355
  },
9320
- sagas: [drawingSaga]
9356
+ middlewares: [drawingToolListener.middleware]
9321
9357
  };
9322
9358
 
9323
9359
  /* *
@@ -9618,77 +9654,57 @@ var storeTestUtils = /*#__PURE__*/Object.freeze({
9618
9654
  * See the License for the specific language governing permissions and
9619
9655
  * limitations under the License.
9620
9656
  *
9621
- * Copyright 2020 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
9622
- * Copyright 2020 - Finnish Meteorological Institute (FMI)
9657
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
9658
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
9623
9659
  * */
9624
- function* updateSourceValueWhenLinkingComponentToGroupSaga(groupId, targetToUpdate) {
9625
- const group = yield select(getSynchronizationGroup, groupId);
9626
- if (!group) {
9627
- return;
9628
- }
9629
- switch (group.type) {
9630
- case SYNCGROUPS_TYPE_SETTIME:
9631
- if (!group.payloadByType[SYNCGROUPS_TYPE_SETTIME]) {
9632
- return;
9633
- }
9634
- yield put(setTimeSync(group.payloadByType[SYNCGROUPS_TYPE_SETTIME], [{
9635
- targetId: targetToUpdate,
9636
- value: group.payloadByType[SYNCGROUPS_TYPE_SETTIME].value
9637
- }], [groupId]));
9638
- break;
9639
- case SYNCGROUPS_TYPE_SETBBOX:
9640
- if (!group.payloadByType[SYNCGROUPS_TYPE_SETBBOX]) {
9641
- return;
9660
+ const syncGroupsListener = createListenerMiddleware();
9661
+ syncGroupsListener.startListening({
9662
+ matcher: isAnyOf(actions.syncGroupAddTarget, actions.syncGroupLinkTarget),
9663
+ effect: ({
9664
+ payload
9665
+ }, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
9666
+ listenerApi.cancelActiveListeners();
9667
+ const {
9668
+ groupId,
9669
+ linked,
9670
+ targetId: targetToUpdate
9671
+ } = payload;
9672
+ const group = getSynchronizationGroup(listenerApi.getState(), groupId);
9673
+ if (!linked && group) {
9674
+ switch (group.type) {
9675
+ case SYNCGROUPS_TYPE_SETTIME:
9676
+ if (!group.payloadByType[SYNCGROUPS_TYPE_SETTIME]) {
9677
+ return;
9678
+ }
9679
+ listenerApi.dispatch(setTimeSync(group.payloadByType[SYNCGROUPS_TYPE_SETTIME], [{
9680
+ targetId: targetToUpdate,
9681
+ value: group.payloadByType[SYNCGROUPS_TYPE_SETTIME].value
9682
+ }], [groupId]));
9683
+ break;
9684
+ case SYNCGROUPS_TYPE_SETBBOX:
9685
+ if (!group.payloadByType[SYNCGROUPS_TYPE_SETBBOX]) {
9686
+ return;
9687
+ }
9688
+ listenerApi.dispatch(setBboxSync(group.payloadByType[SYNCGROUPS_TYPE_SETBBOX], [{
9689
+ targetId: targetToUpdate,
9690
+ bbox: group.payloadByType[SYNCGROUPS_TYPE_SETBBOX].bbox,
9691
+ srs: group.payloadByType[SYNCGROUPS_TYPE_SETBBOX].srs
9692
+ }], [groupId]));
9693
+ break;
9642
9694
  }
9643
- yield put(setBboxSync(group.payloadByType[SYNCGROUPS_TYPE_SETBBOX], [{
9644
- targetId: targetToUpdate,
9645
- bbox: group.payloadByType[SYNCGROUPS_TYPE_SETBBOX].bbox,
9646
- srs: group.payloadByType[SYNCGROUPS_TYPE_SETBBOX].srs
9647
- }], [groupId]));
9648
- break;
9649
- }
9650
- }
9651
- function* addGroupTargetSaga({
9652
- payload
9653
- }) {
9654
- const {
9655
- groupId,
9656
- linked,
9657
- targetId: targetToUpdate
9658
- } = payload;
9659
- if (!linked) {
9660
- yield call$e(updateSourceValueWhenLinkingComponentToGroupSaga, groupId, targetToUpdate);
9661
- }
9662
- }
9663
- function* linkGroupTargetSaga({
9664
- payload
9665
- }) {
9666
- const {
9667
- groupId,
9668
- linked,
9669
- targetId: targetToUpdate
9670
- } = payload;
9671
- if (!linked) {
9672
- yield call$e(updateSourceValueWhenLinkingComponentToGroupSaga, groupId, targetToUpdate);
9673
- }
9674
- }
9675
- function* updateViewStateSaga() {
9676
- const viewState = yield select(createSyncGroupViewStateSelector);
9677
- yield put(syncGroupSetViewState({
9678
- viewState
9679
- }));
9680
- }
9681
- function* rootSaga() {
9682
- yield takeLatest(syncGroupAddTarget.type, addGroupTargetSaga);
9683
- yield takeLatest(syncGroupLinkTarget.type, linkGroupTargetSaga);
9684
- yield takeLatest(syncGroupAddGroup.type, updateViewStateSaga);
9685
- yield takeLatest(syncGroupRemoveGroup.type, updateViewStateSaga);
9686
- yield takeLatest(syncGroupAddSource.type, updateViewStateSaga);
9687
- yield takeLatest(syncGroupRemoveSource.type, updateViewStateSaga);
9688
- yield takeLatest(syncGroupAddTarget.type, updateViewStateSaga);
9689
- yield takeLatest(syncGroupRemoveTarget.type, updateViewStateSaga);
9690
- yield takeLatest(syncGroupLinkTarget.type, updateViewStateSaga);
9691
- }
9695
+ }
9696
+ })
9697
+ });
9698
+ syncGroupsListener.startListening({
9699
+ matcher: isAnyOf(actions.syncGroupAddGroup, actions.syncGroupRemoveGroup, actions.syncGroupAddSource, actions.syncGroupRemoveSource, actions.syncGroupAddTarget, actions.syncGroupRemoveTarget, actions.syncGroupLinkTarget),
9700
+ effect: (_, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
9701
+ listenerApi.cancelActiveListeners();
9702
+ const viewState = createSyncGroupViewStateSelector(listenerApi.getState());
9703
+ listenerApi.dispatch(actions.syncGroupSetViewState({
9704
+ viewState
9705
+ }));
9706
+ })
9707
+ });
9692
9708
 
9693
9709
  const synchronizationGroupConfig = {
9694
9710
  id: 'syncronizationGroupStore-module',
@@ -9696,7 +9712,8 @@ const synchronizationGroupConfig = {
9696
9712
  syncronizationGroupStore: reducer$3,
9697
9713
  loadingIndicatorStore: loadingIndicatorReducer
9698
9714
  },
9699
- sagas: [rootSaga$2, rootSaga]
9715
+ sagas: [rootSaga],
9716
+ middlewares: [syncGroupsListener.middleware]
9700
9717
  };
9701
9718
 
9702
9719
  /* *
@@ -9765,4 +9782,4 @@ const StoreProvider = ({
9765
9782
  })
9766
9783
  }));
9767
9784
 
9768
- export { IS_LEGEND_OPEN_BY_DEFAULT, StoreProvider, coreModuleConfig, createStore, drawtoolActions, drawtoolModuleConfig, reducer as drawtoolReducer, selectors as drawtoolSelectors, filterLayers$1 as filterLayers, genericActions, rootSaga$2 as genericSaga, selectors$4 as genericSelectors, types$1 as genericTypes, getSingularDrawtoolDrawLayerId, getUserAddedServices, initialState$3 as initialState, layerActions, reducer$6 as layerReducer, selectors$7 as layerSelectors, types$5 as layerTypes, utils$2 as layerUtils, loadingIndicatorActions, constants as loadingIndicatorConstants, loadingIndicatorReducer, selectors$3 as loadingIndicatorSelectors, mapActions, enums as mapEnums, rootSaga$4 as mapSaga, selectors$2 as mapSelectors, mapStoreActions, mapStoreModuleConfig, mapStoreReducers, types$4 as mapTypes, mapUtils, routerActions, routerModuleConfig, utils as routerUtils, selectorMemoizationOptions, serviceActions, selectors$1 as serviceSelectors, types as serviceTypes, setUserAddedServices, storeTestSettings, storeTestUtils, utils$1 as storeUtils, constants$1 as syncConstants, actions as syncGroupsActions, reducer$3 as syncGroupsReducer, selector as syncGroupsSelector, selectors$5 as syncGroupsSelectors, types$2 as syncGroupsTypes, types$2 as types, uiActions, uiModuleConfig, reducer$5 as uiReducer, selectors$6 as uiSelectors, types$3 as uiTypes, useSetupDialog, reducer$4 as webmapReducer };
9785
+ export { IS_LEGEND_OPEN_BY_DEFAULT, StoreProvider, coreModuleConfig, createStore, drawtoolActions, drawtoolModuleConfig, reducer as drawtoolReducer, selectors as drawtoolSelectors, filterLayers$1 as filterLayers, genericActions, rootSaga as genericSaga, selectors$4 as genericSelectors, types$1 as genericTypes, getSingularDrawtoolDrawLayerId, getUserAddedServices, initialState$3 as initialState, layerActions, reducer$6 as layerReducer, selectors$7 as layerSelectors, types$5 as layerTypes, utils$2 as layerUtils, loadingIndicatorActions, constants as loadingIndicatorConstants, loadingIndicatorReducer, selectors$3 as loadingIndicatorSelectors, mapActions, enums as mapEnums, rootSaga$2 as mapSaga, selectors$2 as mapSelectors, mapStoreActions, mapStoreModuleConfig, mapStoreReducers, types$4 as mapTypes, mapUtils, routerActions, routerModuleConfig, utils as routerUtils, selectorMemoizationOptions, serviceActions, selectors$1 as serviceSelectors, types as serviceTypes, setUserAddedServices, storeTestSettings, storeTestUtils, utils$1 as storeUtils, constants$1 as syncConstants, actions as syncGroupsActions, reducer$3 as syncGroupsReducer, selector as syncGroupsSelector, selectors$5 as syncGroupsSelectors, types$2 as syncGroupsTypes, types$2 as types, uiActions, uiModuleConfig, reducer$5 as uiReducer, selectors$6 as uiSelectors, types$3 as uiTypes, useSetupDialog, reducer$4 as webmapReducer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/store",
3
- "version": "9.21.0",
3
+ "version": "9.23.1",
4
4
  "description": "GeoWeb Store library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -0,0 +1,3 @@
1
+ import { DrawtoolModuleStore } from './reducer';
2
+ import { WebMapStateModuleState } from '../mapStore';
3
+ export declare const drawingToolListener: import("@reduxjs/toolkit").ListenerMiddlewareInstance<DrawtoolModuleStore & WebMapStateModuleState, import("@reduxjs/toolkit").ThunkDispatch<DrawtoolModuleStore & WebMapStateModuleState, unknown, import("redux").AnyAction>, unknown>;
@@ -0,0 +1,2 @@
1
+ import { SynchronizationGroupModuleState } from './types';
2
+ export declare const syncGroupsListener: import("@reduxjs/toolkit").ListenerMiddlewareInstance<SynchronizationGroupModuleState, import("@reduxjs/toolkit").ThunkDispatch<SynchronizationGroupModuleState, unknown, import("redux").AnyAction>, unknown>;
@@ -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
@@ -0,0 +1,2 @@
1
+ import { RouterModuleStore } from './types';
2
+ export declare const routerListener: import("@reduxjs/toolkit").ListenerMiddlewareInstance<RouterModuleStore, import("@reduxjs/toolkit").ThunkDispatch<RouterModuleStore, unknown, import("redux").AnyAction>, unknown>;
@@ -1,7 +1,5 @@
1
- import { EntityState } from '@reduxjs/toolkit';
2
- export type RouterState = EntityState<undefined>;
3
1
  export interface RouterModuleStore {
4
- router?: RouterState;
2
+ router?: Record<string, never>;
5
3
  }
6
4
  export interface NavigateToUrlPayload {
7
5
  url: string;
@@ -16,7 +16,8 @@ export declare enum DialogTypes {
16
16
  DockedLayerManager = "dockedLayerManager",
17
17
  ObjectManager = "objectManager",
18
18
  PublicWarnings = "publicWarnings",
19
- Search = "search"
19
+ Search = "search",
20
+ AreaObjectLoader = "areaObjectLoader"
20
21
  }
21
22
  export type DialogType = DialogTypes | LegendDialogType | GetFeatureInfoDialogType;
22
23
  export type { Source };
@@ -1,7 +0,0 @@
1
- import { SagaIterator } from 'redux-saga';
2
- import { drawtoolActions } from './reducer';
3
- export declare function registerDrawToolSaga({ payload, }: ReturnType<typeof drawtoolActions.registerDrawTool>): SagaIterator;
4
- export declare function changeDrawToolSaga({ payload, }: ReturnType<typeof drawtoolActions.changeDrawToolMode>): SagaIterator;
5
- export declare function changeIntersectionSaga({ payload, }: ReturnType<typeof drawtoolActions.changeIntersectionBounds>): SagaIterator;
6
- declare function drawingSaga(): SagaIterator;
7
- export default drawingSaga;
@@ -1,8 +0,0 @@
1
- import { SagaIterator } from 'redux-saga';
2
- import * as synchronizationGroupActions from './reducer';
3
- export declare function updateSourceValueWhenLinkingComponentToGroupSaga(groupId: string, targetToUpdate: string): SagaIterator;
4
- export declare function addGroupTargetSaga({ payload, }: ReturnType<typeof synchronizationGroupActions.syncGroupAddTarget>): SagaIterator;
5
- export declare function linkGroupTargetSaga({ payload, }: ReturnType<typeof synchronizationGroupActions.syncGroupLinkTarget>): SagaIterator;
6
- export declare function updateViewStateSaga(): SagaIterator;
7
- declare function rootSaga(): SagaIterator;
8
- export default rootSaga;
@@ -1,5 +0,0 @@
1
- import { SagaIterator } from 'redux-saga';
2
- import { RouterActions } from './reducer';
3
- export declare function navigateToUrlSaga(action: RouterActions): SagaIterator;
4
- export declare function rootSaga(): SagaIterator;
5
- export default rootSaga;