@opengeoweb/store 9.15.0 → 9.17.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, getAlternativeImage, handleDateUtilsISOString, getCapabilities } from '@opengeoweb/webmap';
1
+ import { webmapUtils, LayerType, getWMJSMapById, WMLayer, webmapTestSettings, 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';
@@ -2003,7 +2003,7 @@ var types$5 = /*#__PURE__*/Object.freeze({
2003
2003
  get LayerActionOrigin () { return LayerActionOrigin; }
2004
2004
  });
2005
2005
 
2006
- const dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z";
2006
+ const dateFormat = dateUtils.DATE_FORMAT_UTC;
2007
2007
  const createMap = ({
2008
2008
  id,
2009
2009
  isAnimating: _isAnimating = false,
@@ -2632,6 +2632,16 @@ const slice$7 = createSlice({
2632
2632
  draft.byId[layerId].geojson = geojson;
2633
2633
  }
2634
2634
  },
2635
+ layerSetGeojsonFromLayer: (draft, action) => {
2636
+ var _a;
2637
+ const {
2638
+ layerId,
2639
+ sourceLayerId
2640
+ } = action.payload;
2641
+ if (draft.byId[layerId]) {
2642
+ draft.byId[layerId].geojson = (_a = draft.byId[sourceLayerId]) === null || _a === void 0 ? void 0 : _a.geojson;
2643
+ }
2644
+ },
2635
2645
  layerDelete: (draft, action) => {
2636
2646
  const {
2637
2647
  layerId
@@ -5712,7 +5722,7 @@ const getAnimationStartTime = createSelector(getMapById, store => (store === nul
5712
5722
  * @param {string} mapId mapId: string - Id of the map
5713
5723
  * @returns {string} returnType: string
5714
5724
  */
5715
- const getAnimationEndTime$1 = createSelector(getMapById, store => (store === null || store === void 0 ? void 0 : store.animationEndTime) ? store.animationEndTime : dateUtils.dateToString(dateUtils.sub(dateUtils.utc(), {
5725
+ const getAnimationEndTime = createSelector(getMapById, store => (store === null || store === void 0 ? void 0 : store.animationEndTime) ? store.animationEndTime : dateUtils.dateToString(dateUtils.sub(dateUtils.utc(), {
5716
5726
  minutes: 10
5717
5727
  }), dateFormat), selectorMemoizationOptions);
5718
5728
  /**
@@ -5990,7 +6000,7 @@ const getLegendId = createSelector(getMapById, store => store ? store.legendId :
5990
6000
  * @param {string} mapId mapId: string - Id of the map
5991
6001
  * @returns {MapPreset} returnType: MapPreset
5992
6002
  */
5993
- const getMapPreset = createSelector(getMapLayers, getMapBaseLayers, getMapOverLayers, getBbox, getSrs, getActiveLayerId, getAutoTimeStepLayerId, getAutoUpdateLayerId, isAnimating, isAutoUpdating, isTimeSliderVisible, getDisplayMapPin, isZoomControlsVisible, getMapTimeStep, getMapAnimationDelay, getAnimationStartTime, getAnimationEndTime$1, isTimestepAuto, getLegendId, getUiStore, (mapLayers, baseLayers, overLayers, bbox, srs, activeLayerId, autoUpdateLayerId, autoTimeStepLayerId, isAnimating, isAutoUpdating, isTimeSliderVisible, displayMapPin, isZoomControlsVisible, mapTimeStep, mapAnimationDelay, animationStartTime, animationEndTime, isTimestepAuto, legendId, uiStore) => {
6003
+ const getMapPreset = createSelector(getMapLayers, getMapBaseLayers, getMapOverLayers, getBbox, getSrs, getActiveLayerId, getAutoTimeStepLayerId, getAutoUpdateLayerId, isAnimating, isAutoUpdating, isTimeSliderVisible, getDisplayMapPin, isZoomControlsVisible, getMapTimeStep, getMapAnimationDelay, getAnimationStartTime, getAnimationEndTime, isTimestepAuto, getLegendId, getUiStore, (mapLayers, baseLayers, overLayers, bbox, srs, activeLayerId, autoUpdateLayerId, autoTimeStepLayerId, isAnimating, isAutoUpdating, isTimeSliderVisible, displayMapPin, isZoomControlsVisible, mapTimeStep, mapAnimationDelay, animationStartTime, animationEndTime, isTimestepAuto, legendId, uiStore) => {
5994
6004
  var _a;
5995
6005
  const allLayers = [...baseLayers, ...overLayers, ...mapLayers].map(_a => {
5996
6006
  var layer = __rest(_a, ["mapId"]);
@@ -6070,7 +6080,7 @@ const getDockedLayerManagerSize = createSelector(getMapById, store => store ? st
6070
6080
  * @param {string} mapId mapId: string - Id of the map
6071
6081
  * @returns {animationList} returnType: WebMapAnimationList, list of timesteps to animate for this map.
6072
6082
  */
6073
- const getAnimationList = createSelector(getMapById, getAnimationStartTime, getAnimationEndTime$1, getMapTimeStep, (mapStore, animationStart, animationEnd, animationInterval) => {
6083
+ const getAnimationList = createSelector(getMapById, getAnimationStartTime, getAnimationEndTime, getMapTimeStep, (mapStore, animationStart, animationEnd, animationInterval) => {
6074
6084
  // Animation is defined by one of the following:
6075
6085
  // - start, end and interval for a continuous animation loop with constant interval
6076
6086
  // - timeList, for a custom timeList
@@ -6119,7 +6129,7 @@ var selectors$2 = /*#__PURE__*/Object.freeze({
6119
6129
  isAnimating: isAnimating,
6120
6130
  linkedMapAnimationInfo: linkedMapAnimationInfo,
6121
6131
  getAnimationStartTime: getAnimationStartTime,
6122
- getAnimationEndTime: getAnimationEndTime$1,
6132
+ getAnimationEndTime: getAnimationEndTime,
6123
6133
  isAutoUpdating: isAutoUpdating,
6124
6134
  shouldEndtimeOverride: shouldEndtimeOverride,
6125
6135
  getActiveLayerId: getActiveLayerId,
@@ -7655,14 +7665,18 @@ const prefetchAnimationTargetsForMetronome = (timerId, animationListValues, targ
7655
7665
  image.load();
7656
7666
  }
7657
7667
  if (numPrefetch === 0) {
7658
- const altImage = getAlternativeImage(layersImageUrl.url, wmMap.getMapImageStore, wmMap.getBBOX());
7668
+ const altImage = wmMap.getAlternativeImage(layersImageUrl.url, wmMap.getBBOX(), true);
7659
7669
  // No alternative image available yet, so skipping animation.
7660
- if (!altImage) {
7670
+ if (altImage.length === 0) {
7661
7671
  // This is useful to indicate that the map is loading and has nothing yet to display.
7662
7672
  // console.warn('No data available: Not stepping forward');
7663
7673
  timerShouldStepForward = false;
7664
7674
  }
7665
7675
  }
7676
+ } else if (image.isStale()) {
7677
+ if (wmMap.getMapImageStore.getNumImagesLoading() < MAX_NUMBER_OF_PARALLEL_LOADING_IMAGES) {
7678
+ image.forceReload(true);
7679
+ }
7666
7680
  }
7667
7681
  }
7668
7682
  } else {
@@ -7673,25 +7687,6 @@ const prefetchAnimationTargetsForMetronome = (timerId, animationListValues, targ
7673
7687
  return timerShouldStepForward;
7674
7688
  };
7675
7689
 
7676
- // Expects start, end time as Date object and interval in minutes
7677
- const getAnimationEndTime = animationEndTime => {
7678
- const ISOtime = dateUtils.parseISO(animationEndTime);
7679
- if (dateUtils.isValid(ISOtime)) {
7680
- return ISOtime.toISOString();
7681
- }
7682
- const calculateFromNow = animationEndTime.split(/[-+]/)[0] === 'NOW';
7683
- const isAddingTime = animationEndTime.indexOf('+') !== -1;
7684
- const duration = animationEndTime.substring(animationEndTime.indexOf('PT') + 2);
7685
- const [hours, minutes] = duration.split('H');
7686
- const timeInMinutes = parseInt(hours, 10) * 60 + parseInt(minutes, 10);
7687
- const startingTime = calculateFromNow ? dateUtils.utc() : dateUtils.startOfDay(dateUtils.utc());
7688
- const newAnimationEndTime = isAddingTime ? dateUtils.add(startingTime, {
7689
- minutes: timeInMinutes
7690
- }).toISOString() : dateUtils.sub(startingTime, {
7691
- minutes: timeInMinutes
7692
- }).toISOString();
7693
- return newAnimationEndTime;
7694
- };
7695
7690
  const isAnimationEndTimeValid = animationEndTime => {
7696
7691
  const hasValidPrefix = animationEndTime.split(/[-+]/)[0] === 'NOW' || animationEndTime.split(/[-+]/)[0] === 'TODAY';
7697
7692
  const durationString = animationEndTime.substring(animationEndTime.indexOf('PT') + 2);
@@ -7753,7 +7748,7 @@ function* updateAnimation(mapId, maxValue) {
7753
7748
  }
7754
7749
  const animationStart = yield select(getAnimationStartTime, mapId);
7755
7750
  // Calculate how much time the animation start need to move forwards
7756
- const animationEnd = yield select(getAnimationEndTime$1, mapId);
7751
+ const animationEnd = yield select(getAnimationEndTime, mapId);
7757
7752
  const animationEndUnix = dateUtils.unix(dateUtils.utc(animationEnd));
7758
7753
  const maxTimeAsUnix = dateUtils.unix(dateUtils.utc(maxValue));
7759
7754
  const timeInSecondToShiftAnimationForwards = maxTimeAsUnix - animationEndUnix;
@@ -8037,28 +8032,43 @@ function* setMapPresetSaga({
8037
8032
  }
8038
8033
  // sets animationEndTime by endTime of animationPayload
8039
8034
  if (animationEndTime) {
8035
+ const endTime = animationEndTime.includes('NOW') || animationEndTime.includes('TODAY') ? dateUtils.convertNOWandTODAYFormatsToUTC(animationEndTime) : animationEndTime;
8040
8036
  yield put(mapActions.setAnimationEndTime({
8041
8037
  mapId,
8042
- animationEndTime: getAnimationEndTime(animationEndTime)
8038
+ animationEndTime: handleDateUtilsISOString(endTime)
8039
+ }));
8040
+ const startTime = handleDateUtilsISOString(dateUtils.sub(dateUtils.utc(endTime), {
8041
+ minutes: 5 * 60 // set to default of 5 hours
8042
+ }).toISOString());
8043
+ yield put(mapActions.setAnimationStartTime({
8044
+ mapId,
8045
+ animationStartTime: startTime
8046
+ }));
8047
+ yield put(genericActions.setTime({
8048
+ origin: '',
8049
+ sourceId: mapId,
8050
+ value: startTime
8051
+ }));
8052
+ const centerTimeInSeconds = new Date(handleDateUtilsISOString(endTime)).getTime();
8053
+ yield put(mapActions.setTimeSliderCenterTime({
8054
+ mapId,
8055
+ timeSliderCenterTime: centerTimeInSeconds
8043
8056
  }));
8044
- if (!animationLength) {
8045
- const animationEnd = yield select(getAnimationEndTime$1, mapId);
8046
- yield put(mapActions.setAnimationStartTime({
8047
- mapId,
8048
- animationStartTime: dateUtils.sub(dateUtils.utc(animationEnd), {
8049
- minutes: 5 * 60 // set to default of 5 hours
8050
- }).toISOString()
8051
- }));
8052
- }
8053
8057
  }
8054
8058
  // sets animationStartTime by duration of animationPayload
8055
8059
  if (animationLength) {
8056
- const animationEnd = yield select(getAnimationEndTime$1, mapId);
8060
+ const animationEnd = yield select(getAnimationEndTime, mapId);
8061
+ const startTime = handleDateUtilsISOString(dateUtils.sub(dateUtils.utc(animationEnd), {
8062
+ minutes: animationLength
8063
+ }).toISOString());
8057
8064
  yield put(mapActions.setAnimationStartTime({
8058
8065
  mapId,
8059
- animationStartTime: dateUtils.sub(dateUtils.utc(animationEnd), {
8060
- minutes: animationLength
8061
- }).toISOString()
8066
+ animationStartTime: startTime
8067
+ }));
8068
+ yield put(genericActions.setTime({
8069
+ origin: '',
8070
+ sourceId: mapId,
8071
+ value: startTime
8062
8072
  }));
8063
8073
  }
8064
8074
  // sets animationDelay by speed of animationPayload
@@ -8071,7 +8081,7 @@ function* setMapPresetSaga({
8071
8081
  // turn animation on
8072
8082
  if (shouldAnimate === true) {
8073
8083
  const duration = animationPayload && animationPayload.duration ? animationPayload.duration : 5 * 60; // set to default of 5 hours
8074
- const animationEnd = shouldEndtimeOverride && animationEndTime ? yield select(getAnimationEndTime$1, mapId) : dateUtils.dateToString(dateUtils.utc(), dateFormat);
8084
+ const animationEnd = shouldEndtimeOverride && animationEndTime ? yield select(getAnimationEndTime, mapId) : dateUtils.dateToString(dateUtils.utc(), dateFormat);
8075
8085
  const animationStart = shouldEndtimeOverride && animationLength ? yield select(getAnimationStartTime, mapId) : dateUtils.dateToString(dateUtils.sub(dateUtils.utc(animationEnd), {
8076
8086
  minutes: duration
8077
8087
  }), dateFormat);
@@ -8113,7 +8123,7 @@ function* setMapPresetSaga({
8113
8123
  while (animationEndTime && (shouldEndtimeOverride || !(shouldAutoUpdate || shouldAnimate))) {
8114
8124
  const fiveMinuteDelayForAnimation = 1000 * 60 * 5;
8115
8125
  yield delay(fiveMinuteDelayForAnimation);
8116
- const animationEnd = yield select(getAnimationEndTime$1, mapId);
8126
+ const animationEnd = yield select(getAnimationEndTime, mapId);
8117
8127
  yield put(mapActions.setAnimationEndTime({
8118
8128
  mapId,
8119
8129
  animationEndTime: dateUtils.add(dateUtils.utc(animationEnd), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/store",
3
- "version": "9.15.0",
3
+ "version": "9.17.0",
4
4
  "description": "GeoWeb Store library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -60,6 +60,7 @@ export declare const mapStoreActions: {
60
60
  }, "layerReducer/layerChangeAcceptanceTime">;
61
61
  layerChangeName: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").SetLayerNamePayload, "layerReducer/layerChangeName">;
62
62
  layerChangeGeojson: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").SetLayerGeojsonPayload, "layerReducer/layerChangeGeojson">;
63
+ layerSetGeojsonFromLayer: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").SetLayerGeojsonFromLayerPayload, "layerReducer/layerSetGeojsonFromLayer">;
63
64
  layerDelete: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").DeleteLayerPayload, "layerReducer/layerDelete">;
64
65
  layerError: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").ErrorLayerPayload, "layerReducer/layerError">;
65
66
  baseLayerDelete: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./types").DeleteLayerPayload, "layerReducer/baseLayerDelete">;
@@ -1,6 +1,6 @@
1
1
  import { Draft, PayloadAction } from '@reduxjs/toolkit';
2
2
  import { SetLayerDimensionsPayload, SetLayerStylePayload, UpdateLayerInfoPayload } from '@opengeoweb/webmap-react';
3
- import { LayerState, Layer, AddLayerPayload, SetLayerDimensionPayload, SetLayerEnabledPayload, SetLayerOpacityPayload, SetLayerNamePayload, SetLayerGeojsonPayload, DeleteLayerPayload, ErrorLayerPayload, SetLayersPayload, SetBaseLayersPayload, AddBaseLayerPayload, AddAvailableBaseLayerPayload, AddAvailableBaseLayersPayload, SetAvailableBaseLayersPayload, SetSelectedFeaturePayload, UpdateFeaturePayload, ExitFeatureDrawModePayload, ToggleFeatureModePayload, UpdateFeaturePropertiesPayload, DuplicateMapLayerPayload, ShowLayerInfoPayload } from './types';
3
+ import { LayerState, Layer, AddLayerPayload, SetLayerDimensionPayload, SetLayerEnabledPayload, SetLayerOpacityPayload, SetLayerNamePayload, SetLayerGeojsonPayload, DeleteLayerPayload, ErrorLayerPayload, SetLayersPayload, SetBaseLayersPayload, AddBaseLayerPayload, AddAvailableBaseLayerPayload, AddAvailableBaseLayersPayload, SetAvailableBaseLayersPayload, SetSelectedFeaturePayload, UpdateFeaturePayload, ExitFeatureDrawModePayload, ToggleFeatureModePayload, UpdateFeaturePropertiesPayload, DuplicateMapLayerPayload, ShowLayerInfoPayload, SetLayerGeojsonFromLayerPayload } from './types';
4
4
  export declare const createLayer: ({ id, opacity, acceptanceTimeInMinutes, enabled, layerType, status, useLatestReferenceTime, ...props }: Layer) => Layer;
5
5
  export declare const initialState: LayerState;
6
6
  export declare const slice: import("@reduxjs/toolkit").Slice<LayerState, {
@@ -16,6 +16,7 @@ export declare const slice: import("@reduxjs/toolkit").Slice<LayerState, {
16
16
  }>) => void;
17
17
  layerChangeName: (draft: Draft<LayerState>, action: PayloadAction<SetLayerNamePayload>) => void;
18
18
  layerChangeGeojson: (draft: Draft<LayerState>, action: PayloadAction<SetLayerGeojsonPayload>) => void;
19
+ layerSetGeojsonFromLayer: (draft: Draft<LayerState>, action: PayloadAction<SetLayerGeojsonFromLayerPayload>) => void;
19
20
  layerDelete: (draft: Draft<LayerState>, action: PayloadAction<DeleteLayerPayload>) => void;
20
21
  layerError: (draft: Draft<LayerState>, action: PayloadAction<ErrorLayerPayload>) => void;
21
22
  baseLayerDelete: (draft: Draft<LayerState>, action: PayloadAction<DeleteLayerPayload>) => void;
@@ -56,6 +57,7 @@ export declare const layerActions: import("@reduxjs/toolkit").CaseReducerActions
56
57
  }>) => void;
57
58
  layerChangeName: (draft: Draft<LayerState>, action: PayloadAction<SetLayerNamePayload>) => void;
58
59
  layerChangeGeojson: (draft: Draft<LayerState>, action: PayloadAction<SetLayerGeojsonPayload>) => void;
60
+ layerSetGeojsonFromLayer: (draft: Draft<LayerState>, action: PayloadAction<SetLayerGeojsonFromLayerPayload>) => void;
59
61
  layerDelete: (draft: Draft<LayerState>, action: PayloadAction<DeleteLayerPayload>) => void;
60
62
  layerError: (draft: Draft<LayerState>, action: PayloadAction<ErrorLayerPayload>) => void;
61
63
  baseLayerDelete: (draft: Draft<LayerState>, action: PayloadAction<DeleteLayerPayload>) => void;
@@ -91,6 +91,9 @@ export interface SetLayerDimensionPayload extends LayerPayload {
91
91
  export interface SetLayerGeojsonPayload extends LayerPayload {
92
92
  geojson: FeatureCollection;
93
93
  }
94
+ export interface SetLayerGeojsonFromLayerPayload extends LayerPayload {
95
+ sourceLayerId: string;
96
+ }
94
97
  export interface DeleteLayerPayload extends LayerPayload {
95
98
  mapId: string;
96
99
  layerIndex?: number;
@@ -3,7 +3,7 @@ import * as utils from './utils';
3
3
  export declare const mapUtils: {
4
4
  replaceLayerIdsToEnsureUniqueLayerIdsInStore: (layerIds: import("./replaceLayerIdsToEnsureUniqueLayerIdsInStore").LayersAndAutoLayerIds) => import("./replaceLayerIdsToEnsureUniqueLayerIdsInStore").LayersAndAutoLayerIds;
5
5
  moveArrayElements<T>(array: T[], oldIndex: number, newIndex: number): T[];
6
- dateFormat: "yyyy-MM-dd'T'HH:mm:ss'Z";
6
+ dateFormat: "yyyy-MM-dd'T'HH:mm:ss'Z'";
7
7
  createMap: ({ id, isAnimating, animationStartTime, animationEndTime, isAutoUpdating, shouldEndtimeOverride, bbox, srs, baseLayers, overLayers, mapLayers, featureLayers, dimensions, autoUpdateLayerId, autoTimeStepLayerId, timeSliderSpan, timeStep, animationDelay, timeSliderWidth, timeSliderCenterTime, timeSliderSecondsPerPx, isTimestepAuto, isTimeSpanAuto, isTimeSliderHoverOn, isTimeSliderVisible, displayMapPin, disableMapPin, shouldShowZoomControls, }: utils.CreateMapProps) => mapTypes.WebMap;
8
8
  checkValidLayersPayload: (layers: import("../types").Layer[], mapId: string) => boolean;
9
9
  getDraftMapById: (mapId: string, draft: mapTypes.WebMapState) => mapTypes.WebMap;
@@ -3,7 +3,7 @@ import { SpeedFactorType } from '@opengeoweb/timeslider';
3
3
  import { Bbox, Dimension } from './types';
4
4
  import type { WebMapState, WebMap } from '../types';
5
5
  import type { Layer } from '../layers/types';
6
- export declare const dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z";
6
+ export declare const dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'";
7
7
  export interface CreateMapProps {
8
8
  id: string;
9
9
  isAnimating?: boolean;
@@ -77,3 +77,6 @@ export interface UISetDialogFocusedPayload {
77
77
  type: DialogType;
78
78
  focused: boolean;
79
79
  }
80
+ export interface UIToggleShowSentryRecordButton {
81
+ type: DialogType;
82
+ }