@kepler.gl/reducers 3.3.0-alpha.2 → 3.3.0-alpha.21
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/dist/cjs/column-edit-reconcile.js +100 -0
- package/dist/cjs/column-edit-reconcile.js.map +1 -0
- package/dist/cjs/combined-updaters.js +676 -0
- package/dist/cjs/combined-updaters.js.map +1 -0
- package/dist/cjs/composer-helpers.js +101 -0
- package/dist/cjs/composer-helpers.js.map +1 -0
- package/dist/cjs/composers.js +21 -0
- package/dist/cjs/composers.js.map +1 -0
- package/dist/cjs/core.js +105 -0
- package/dist/cjs/core.js.map +1 -0
- package/dist/cjs/data-utils.js +53 -0
- package/dist/cjs/data-utils.js.map +1 -0
- package/dist/cjs/dataset-ops-updaters.js +375 -0
- package/dist/cjs/dataset-ops-updaters.js.map +1 -0
- package/dist/cjs/export-utils.js +163 -0
- package/dist/cjs/export-utils.js.map +1 -0
- package/dist/cjs/index.js +348 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interaction-utils.js +275 -0
- package/dist/cjs/interaction-utils.js.map +1 -0
- package/dist/cjs/layer-utils.js +797 -0
- package/dist/cjs/layer-utils.js.map +1 -0
- package/dist/cjs/map-state-updaters.js +709 -0
- package/dist/cjs/map-state-updaters.js.map +1 -0
- package/dist/cjs/map-state.js +35 -0
- package/dist/cjs/map-state.js.map +1 -0
- package/dist/cjs/map-style-updaters.js +659 -0
- package/dist/cjs/map-style-updaters.js.map +1 -0
- package/dist/cjs/map-style.js +33 -0
- package/dist/cjs/map-style.js.map +1 -0
- package/dist/cjs/merger-handler.js +105 -0
- package/dist/cjs/merger-handler.js.map +1 -0
- package/dist/cjs/middleware.js +25 -0
- package/dist/cjs/middleware.js.map +1 -0
- package/dist/cjs/provider-state-updaters.js +464 -0
- package/dist/cjs/provider-state-updaters.js.map +1 -0
- package/dist/cjs/provider-state.js +34 -0
- package/dist/cjs/provider-state.js.map +1 -0
- package/dist/cjs/root.js +207 -0
- package/dist/cjs/root.js.map +1 -0
- package/dist/cjs/ui-state-updaters.js +1096 -0
- package/dist/cjs/ui-state-updaters.js.map +1 -0
- package/dist/cjs/ui-state.js +36 -0
- package/dist/cjs/ui-state.js.map +1 -0
- package/dist/cjs/vis-state-merger.js +1439 -0
- package/dist/cjs/vis-state-merger.js.map +1 -0
- package/dist/cjs/vis-state-selectors.js +50 -0
- package/dist/cjs/vis-state-selectors.js.map +1 -0
- package/dist/cjs/vis-state-updaters.js +6749 -0
- package/dist/cjs/vis-state-updaters.js.map +1 -0
- package/dist/cjs/vis-state.js +35 -0
- package/dist/cjs/vis-state.js.map +1 -0
- package/dist/column-edit-reconcile.d.ts +4 -0
- package/dist/combined-updaters.d.ts +61 -15
- package/dist/composers.d.ts +17 -2
- package/dist/dataset-ops-updaters.d.ts +21 -0
- package/dist/esm/column-edit-reconcile.js +95 -0
- package/dist/esm/column-edit-reconcile.js.map +1 -0
- package/dist/esm/combined-updaters.js +669 -0
- package/dist/esm/combined-updaters.js.map +1 -0
- package/dist/esm/composer-helpers.js +85 -0
- package/dist/esm/composer-helpers.js.map +1 -0
- package/dist/esm/composers.js +15 -0
- package/dist/esm/composers.js.map +1 -0
- package/dist/esm/core.js +101 -0
- package/dist/esm/core.js.map +1 -0
- package/dist/esm/data-utils.js +47 -0
- package/dist/esm/data-utils.js.map +1 -0
- package/dist/esm/dataset-ops-updaters.js +357 -0
- package/dist/esm/dataset-ops-updaters.js.map +1 -0
- package/dist/esm/export-utils.js +158 -0
- package/dist/esm/export-utils.js.map +1 -0
- package/dist/esm/index.js +62 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interaction-utils.js +262 -0
- package/dist/esm/interaction-utils.js.map +1 -0
- package/dist/esm/layer-utils.js +762 -0
- package/dist/esm/layer-utils.js.map +1 -0
- package/dist/esm/map-state-updaters.js +701 -0
- package/dist/esm/map-state-updaters.js.map +1 -0
- package/dist/esm/map-state.js +29 -0
- package/dist/esm/map-state.js.map +1 -0
- package/dist/esm/map-style-updaters.js +652 -0
- package/dist/esm/map-style-updaters.js.map +1 -0
- package/dist/esm/map-style.js +27 -0
- package/dist/esm/map-style.js.map +1 -0
- package/dist/esm/merger-handler.js +96 -0
- package/dist/esm/merger-handler.js.map +1 -0
- package/dist/esm/middleware.js +17 -0
- package/dist/esm/middleware.js.map +1 -0
- package/dist/esm/provider-state-updaters.js +458 -0
- package/dist/esm/provider-state-updaters.js.map +1 -0
- package/dist/esm/provider-state.js +28 -0
- package/dist/esm/provider-state.js.map +1 -0
- package/dist/esm/root.js +201 -0
- package/dist/esm/root.js.map +1 -0
- package/dist/esm/ui-state-updaters.js +1091 -0
- package/dist/esm/ui-state-updaters.js.map +1 -0
- package/dist/esm/ui-state.js +30 -0
- package/dist/esm/ui-state.js.map +1 -0
- package/dist/esm/vis-state-merger.js +1403 -0
- package/dist/esm/vis-state-merger.js.map +1 -0
- package/dist/esm/vis-state-selectors.js +44 -0
- package/dist/esm/vis-state-selectors.js.map +1 -0
- package/dist/esm/vis-state-updaters.js +6586 -0
- package/dist/esm/vis-state-updaters.js.map +1 -0
- package/dist/esm/vis-state.js +29 -0
- package/dist/esm/vis-state.js.map +1 -0
- package/dist/export-utils.d.ts +2 -2
- package/dist/interaction-utils.d.ts +26 -3
- package/dist/layer-utils.d.ts +18 -0
- package/dist/map-state-updaters.d.ts +13 -0
- package/dist/map-style-updaters.d.ts +1 -3
- package/dist/middleware.d.ts +2 -2
- package/dist/root.d.ts +1 -1
- package/dist/ui-state-updaters.d.ts +62 -2
- package/dist/vis-state-merger.d.ts +23 -5
- package/dist/vis-state-selectors.d.ts +53 -6
- package/dist/vis-state-updaters.d.ts +196 -15
- package/dist/vis-state.d.ts +56 -0
- package/package.json +37 -32
- package/dist/combined-updaters.js +0 -412
- package/dist/composer-helpers.js +0 -101
- package/dist/composers.js +0 -23
- package/dist/core.js +0 -105
- package/dist/data-utils.js +0 -53
- package/dist/export-utils.js +0 -91
- package/dist/index.js +0 -349
- package/dist/interaction-utils.js +0 -105
- package/dist/layer-utils.js +0 -633
- package/dist/map-state-updaters.js +0 -516
- package/dist/map-state.js +0 -35
- package/dist/map-style-updaters.js +0 -661
- package/dist/map-style.js +0 -34
- package/dist/merger-handler.js +0 -105
- package/dist/middleware.js +0 -27
- package/dist/provider-state-updaters.js +0 -466
- package/dist/provider-state.js +0 -35
- package/dist/root.js +0 -207
- package/dist/ui-state-updaters.js +0 -890
- package/dist/ui-state.js +0 -37
- package/dist/vis-state-merger.js +0 -1193
- package/dist/vis-state-selectors.js +0 -30
- package/dist/vis-state-updaters.js +0 -4115
- package/dist/vis-state.js +0 -36
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _toArray from "@babel/runtime/helpers/esm/toArray";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
+
var _excluded = ["deleteOriginalDataset"];
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
// SPDX-License-Identifier: MIT
|
|
10
|
+
// Copyright contributors to the kepler.gl project
|
|
11
|
+
|
|
12
|
+
import { toggleModalUpdater, loadFilesSuccessUpdater as uiStateLoadFilesSuccessUpdater, toggleMapControlUpdater, toggleSplitMapUpdater as uiStateToggleSplitMapUpdater, receiveMapConfigUpdater as uiStateReceiveMapConfigUpdater } from './ui-state-updaters';
|
|
13
|
+
import { updateVisDataUpdater as visStateUpdateVisDataUpdater, setMapInfoUpdater, layerTypeChangeUpdater, toggleSplitMapUpdater as visStateToggleSplitMapUpdater } from './vis-state-updaters';
|
|
14
|
+
import { receiveMapConfigUpdater as stateMapConfigUpdater, toggleSplitMapUpdater as mapStateToggleSplitMapUpdater, setMapSplitModeUpdater as mapStateSetMapSplitModeUpdater, setMapViewModeUpdater } from './map-state-updaters';
|
|
15
|
+
import { mapStyleChangeUpdater, receiveMapConfigUpdater as styleMapConfigUpdater } from './map-style-updaters';
|
|
16
|
+
import { fileCacheToProgressiveSteps, filesToDataPayload } from '@kepler.gl/processors';
|
|
17
|
+
import { payload_, apply_, with_, if_, compose_, merge_, pick_ } from './composer-helpers';
|
|
18
|
+
import { loadFilesSuccess } from '@kepler.gl/actions';
|
|
19
|
+
import { isPlainObject, computeSplitMapLayers } from '@kepler.gl/utils';
|
|
20
|
+
import { findMapBounds } from './data-utils';
|
|
21
|
+
import { BASE_MAP_COLOR_MODES, OVERLAY_BLENDINGS, NO_MAP_ID, MapSplitMode, ADD_DATA_ID } from '@kepler.gl/constants';
|
|
22
|
+
import { getBasemapColorsForStyle, DEFAULT_BASEMAP_COLOR } from '@kepler.gl/deckgl-layers';
|
|
23
|
+
// compose action to apply result multiple reducers, with the output of one
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Some actions will affect the entire kepler.lg instance state.
|
|
27
|
+
* The updaters for these actions is exported as `combinedUpdaters`. These updater take the entire instance state
|
|
28
|
+
* as the first argument. Read more about [Using updaters](../advanced-usage/using-updaters.md)
|
|
29
|
+
* @public
|
|
30
|
+
* @example
|
|
31
|
+
*
|
|
32
|
+
* import keplerGlReducer, {combinedUpdaters} from '@kepler.gl/reducers';
|
|
33
|
+
* // Root Reducer
|
|
34
|
+
* const reducers = combineReducers({
|
|
35
|
+
* keplerGl: keplerGlReducer,
|
|
36
|
+
* app: appReducer
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const composedReducer = (state, action) => {
|
|
40
|
+
* switch (action.type) {
|
|
41
|
+
* // add data to map after receiving data from remote sources
|
|
42
|
+
* case 'LOAD_REMOTE_RESOURCE_SUCCESS':
|
|
43
|
+
* return {
|
|
44
|
+
* ...state,
|
|
45
|
+
* keplerGl: {
|
|
46
|
+
* ...state.keplerGl,
|
|
47
|
+
* // pass in kepler.gl instance state to combinedUpdaters
|
|
48
|
+
* map: combinedUpdaters.addDataToMapUpdater(
|
|
49
|
+
* state.keplerGl.map,
|
|
50
|
+
* {
|
|
51
|
+
* payload: {
|
|
52
|
+
* datasets: action.datasets,
|
|
53
|
+
* options: {readOnly: true},
|
|
54
|
+
* config: action.config
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* )
|
|
58
|
+
* }
|
|
59
|
+
* };
|
|
60
|
+
* }
|
|
61
|
+
* return reducers(state, action);
|
|
62
|
+
* };
|
|
63
|
+
*
|
|
64
|
+
* export default composedReducer;
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
var combinedUpdaters = null;
|
|
70
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
71
|
+
|
|
72
|
+
export var isValidConfig = function isValidConfig(config) {
|
|
73
|
+
return isPlainObject(config) && isPlainObject(config.config) && config.version;
|
|
74
|
+
};
|
|
75
|
+
export var defaultAddDataToMapOptions = {
|
|
76
|
+
centerMap: true,
|
|
77
|
+
keepExistingConfig: false,
|
|
78
|
+
autoCreateLayers: true,
|
|
79
|
+
autoCreateTooltips: true
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @typedef {Object} Dataset
|
|
84
|
+
* @memberof combinedUpdaters
|
|
85
|
+
* @property info -info of a dataset
|
|
86
|
+
* @property info.id - id of this dataset. If config is defined, `id` should matches the `dataId` in config.
|
|
87
|
+
* @property info.label - A display name of this dataset
|
|
88
|
+
* @property data - ***required** The data object, in a tabular format with 2 properties `fields` and `rows`
|
|
89
|
+
* @property data.fields - ***required** Array of fields,
|
|
90
|
+
* @property data.fields.name - ***required** Name of the field,
|
|
91
|
+
* @property data.rows - ***required** Array of rows, in a tabular format with `fields` and `rows`
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Combine data and full configuration update in a single action
|
|
98
|
+
*
|
|
99
|
+
* @memberof combinedUpdaters
|
|
100
|
+
* @param {Object} state kepler.gl instance state, containing all subreducer state
|
|
101
|
+
* @param {Object} action
|
|
102
|
+
* @param {Object} action.payload `{datasets, options, config}`
|
|
103
|
+
* @param action.payload.datasets - ***required** datasets can be a dataset or an array of datasets
|
|
104
|
+
* Each dataset object needs to have `info` and `data` property.
|
|
105
|
+
* @param [action.payload.options] option object `{centerMap: true, padding: {left: 300}}`
|
|
106
|
+
* @param [action.payload.config] map config
|
|
107
|
+
* @param [action.payload.info] map info contains title and description
|
|
108
|
+
* @returns nextState
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export var addDataToMapUpdater = function addDataToMapUpdater(state, action) {
|
|
112
|
+
var _datasets$, _datasets$2, _datasets$3;
|
|
113
|
+
var payload = action.payload,
|
|
114
|
+
onFinish = action.onFinish;
|
|
115
|
+
// Internal context carried only by replaceDataInMapUpdater.
|
|
116
|
+
var _ref = action,
|
|
117
|
+
replacement = _ref.replacement;
|
|
118
|
+
var datasets = payload.datasets,
|
|
119
|
+
config = payload.config,
|
|
120
|
+
info = payload.info;
|
|
121
|
+
var options = _objectSpread(_objectSpread({}, defaultAddDataToMapOptions), payload.options);
|
|
122
|
+
|
|
123
|
+
// check if progressive loading dataset by batches, and update visState directly
|
|
124
|
+
var isProgressiveLoading = Array.isArray(datasets) && ((_datasets$ = datasets[0]) === null || _datasets$ === void 0 ? void 0 : _datasets$.info.format) === 'arrow' && ((_datasets$2 = datasets[0]) === null || _datasets$2 === void 0 ? void 0 : _datasets$2.info.id) && ((_datasets$3 = datasets[0]) === null || _datasets$3 === void 0 ? void 0 : _datasets$3.info.id) in state.visState.datasets;
|
|
125
|
+
if (isProgressiveLoading) {
|
|
126
|
+
return compose_([pick_('visState')(apply_(visStateUpdateVisDataUpdater, {
|
|
127
|
+
datasets: datasets,
|
|
128
|
+
options: options,
|
|
129
|
+
config: config,
|
|
130
|
+
onFinish: onFinish
|
|
131
|
+
}))])(state);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// @ts-expect-error
|
|
135
|
+
var parsedConfig = config;
|
|
136
|
+
if (isValidConfig(config)) {
|
|
137
|
+
// if passed in saved config
|
|
138
|
+
// @ts-expect-error
|
|
139
|
+
parsedConfig = state.visState.schema.parseSavedConfig(config);
|
|
140
|
+
}
|
|
141
|
+
var oldLayers = state.visState.layers;
|
|
142
|
+
var filterNewlyAddedLayers = function filterNewlyAddedLayers(layers) {
|
|
143
|
+
return layers.filter(function (nl) {
|
|
144
|
+
return !oldLayers.find(function (ol) {
|
|
145
|
+
return ol === nl;
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Returns undefined if not found, to make typescript happy
|
|
151
|
+
var findMapBoundsIfCentered = function findMapBoundsIfCentered(layers) {
|
|
152
|
+
var bounds = options.centerMap && findMapBounds(layers);
|
|
153
|
+
return bounds ? bounds : undefined;
|
|
154
|
+
};
|
|
155
|
+
return compose_([pick_('visState')(
|
|
156
|
+
// this part can be async
|
|
157
|
+
apply_(visStateUpdateVisDataUpdater, {
|
|
158
|
+
datasets: datasets,
|
|
159
|
+
options: options,
|
|
160
|
+
config: parsedConfig,
|
|
161
|
+
onFinish: onFinish,
|
|
162
|
+
replacement: replacement
|
|
163
|
+
})), if_(Boolean(info), pick_('visState')(apply_(setMapInfoUpdater, {
|
|
164
|
+
info: info
|
|
165
|
+
}))),
|
|
166
|
+
// Note that fit bounds here won't be called in case datasets are created in Tasks.
|
|
167
|
+
// A separate Task to update bounds is created once the datasets are ready.
|
|
168
|
+
with_(function (_ref2) {
|
|
169
|
+
var visState = _ref2.visState;
|
|
170
|
+
return pick_('mapState')(apply_(stateMapConfigUpdater, payload_({
|
|
171
|
+
config: parsedConfig,
|
|
172
|
+
options: options,
|
|
173
|
+
bounds: findMapBoundsIfCentered(filterNewlyAddedLayers(visState.layers))
|
|
174
|
+
})));
|
|
175
|
+
}), pick_('mapStyle')(apply_(styleMapConfigUpdater, payload_({
|
|
176
|
+
config: parsedConfig,
|
|
177
|
+
options: options
|
|
178
|
+
}))), pick_('uiState')(apply_(uiStateReceiveMapConfigUpdater, payload_({
|
|
179
|
+
config: parsedConfig,
|
|
180
|
+
options: options
|
|
181
|
+
}))), pick_('uiState')(apply_(uiStateLoadFilesSuccessUpdater, payload_(null))), pick_('uiState')(apply_(toggleModalUpdater, payload_(null))), pick_('uiState')(merge_(Object.prototype.hasOwnProperty.call(options, 'readOnly') ? {
|
|
182
|
+
readOnly: options.readOnly
|
|
183
|
+
} : {}))])(state);
|
|
184
|
+
};
|
|
185
|
+
export var loadFilesSuccessUpdater = function loadFilesSuccessUpdater(state, action) {
|
|
186
|
+
if (isStaleFileLoadFinish(state.visState.fileLoading, action.loadId)) {
|
|
187
|
+
return state;
|
|
188
|
+
}
|
|
189
|
+
var progressiveSteps = Object.prototype.hasOwnProperty.call(action, 'progressiveSteps') ? [action.result].concat(_toConsumableArray(action.progressiveSteps || [])) : fileCacheToProgressiveSteps(action.result);
|
|
190
|
+
var _progressiveSteps = _toArray(progressiveSteps),
|
|
191
|
+
_progressiveSteps$ = _progressiveSteps[0],
|
|
192
|
+
currentStep = _progressiveSteps$ === void 0 ? action.result : _progressiveSteps$,
|
|
193
|
+
remainingSteps = _progressiveSteps.slice(1);
|
|
194
|
+
var payloads = filesToDataPayload(currentStep, action.options);
|
|
195
|
+
// The first progressive snapshot may fit the map to the newly created layer.
|
|
196
|
+
// Later snapshots only replace that layer's data and must not keep moving the viewport.
|
|
197
|
+
var continuationOptions = _objectSpread(_objectSpread({}, action.options), {}, {
|
|
198
|
+
centerMap: false
|
|
199
|
+
});
|
|
200
|
+
var onFinish = remainingSteps.length ? _objectSpread(_objectSpread({}, loadFilesSuccess(remainingSteps[0], continuationOptions)), {}, {
|
|
201
|
+
progressiveSteps: remainingSteps.slice(1)
|
|
202
|
+
}) : undefined;
|
|
203
|
+
var nextState = compose_([pick_('visState')(merge_({
|
|
204
|
+
fileLoading: false,
|
|
205
|
+
fileLoadingProgress: {},
|
|
206
|
+
stagedToAdd: null
|
|
207
|
+
}))])(state);
|
|
208
|
+
// make multiple add data to map calls
|
|
209
|
+
var stateWithData = compose_(payloads.map(function (p, index) {
|
|
210
|
+
return apply_(addDataToMapUpdater, _objectSpread(_objectSpread({}, payload_(p)), onFinish && index === payloads.length - 1 ? {
|
|
211
|
+
onFinish: onFinish
|
|
212
|
+
} : {}));
|
|
213
|
+
}))(nextState);
|
|
214
|
+
return stateWithData;
|
|
215
|
+
};
|
|
216
|
+
function keptLoadErrors() {
|
|
217
|
+
var progress = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
218
|
+
return Object.fromEntries(Object.entries(progress).filter(function (_ref3) {
|
|
219
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
220
|
+
value = _ref4[1];
|
|
221
|
+
return value === null || value === void 0 ? void 0 : value.error;
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** A finish from the 200ms pause is stale once that load was canceled or replaced. */
|
|
226
|
+
function isStaleFileLoadFinish(fileLoading, loadId) {
|
|
227
|
+
if (loadId == null) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
return !fileLoading || fileLoading.loadId !== loadId;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Finish a deferred file load: keep the parsed cache, clear the loading flag,
|
|
235
|
+
* and leave the Add Data modal open until the user confirms.
|
|
236
|
+
* @memberof combinedUpdaters
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
239
|
+
export var stageLoadedFilesUpdater = function stageLoadedFilesUpdater(state, action) {
|
|
240
|
+
if (isStaleFileLoadFinish(state.visState.fileLoading, action.loadId)) {
|
|
241
|
+
return state;
|
|
242
|
+
}
|
|
243
|
+
var modalOpen = state.uiState.currentModal === ADD_DATA_ID;
|
|
244
|
+
var result = action.result || [];
|
|
245
|
+
var previous = modalOpen && Array.isArray(state.visState.stagedToAdd) ? state.visState.stagedToAdd : [];
|
|
246
|
+
var stagedToAdd = [].concat(_toConsumableArray(previous), _toConsumableArray(result));
|
|
247
|
+
return compose_([pick_('visState')(merge_({
|
|
248
|
+
fileLoading: false,
|
|
249
|
+
fileLoadingProgress: modalOpen ? keptLoadErrors(state.visState.fileLoadingProgress) : {},
|
|
250
|
+
stagedToAdd: modalOpen && stagedToAdd.length ? stagedToAdd : null
|
|
251
|
+
})), pick_('uiState')(apply_(uiStateLoadFilesSuccessUpdater, payload_(null)))])(state);
|
|
252
|
+
};
|
|
253
|
+
function stagedItemKey(item) {
|
|
254
|
+
var _item$metadata, _item$info;
|
|
255
|
+
return (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.source) || (item === null || item === void 0 || (_item$info = item.info) === null || _item$info === void 0 ? void 0 : _item$info.id) || '';
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Add datasets to the Add Data list without interrupting a file that is still parsing.
|
|
260
|
+
* @memberof combinedUpdaters
|
|
261
|
+
* @public
|
|
262
|
+
*/
|
|
263
|
+
export var appendStagedLoadedFilesUpdater = function appendStagedLoadedFilesUpdater(state, action) {
|
|
264
|
+
if (state.uiState.currentModal !== ADD_DATA_ID) {
|
|
265
|
+
return state;
|
|
266
|
+
}
|
|
267
|
+
var previous = Array.isArray(state.visState.stagedToAdd) ? state.visState.stagedToAdd : [];
|
|
268
|
+
var seen = new Set(previous.map(stagedItemKey).filter(Boolean));
|
|
269
|
+
var next = (action.result || []).filter(function (item) {
|
|
270
|
+
var key = stagedItemKey(item);
|
|
271
|
+
if (!key || seen.has(key)) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
seen.add(key);
|
|
275
|
+
return true;
|
|
276
|
+
});
|
|
277
|
+
if (!next.length) {
|
|
278
|
+
return state;
|
|
279
|
+
}
|
|
280
|
+
return compose_([pick_('visState')(merge_({
|
|
281
|
+
stagedToAdd: [].concat(_toConsumableArray(previous), _toConsumableArray(next))
|
|
282
|
+
}))])(state);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The first plain dataset in a confirmed upload replaces the selected table.
|
|
287
|
+
* A kepler.gl map json is added as a map. Further tables are added after the replacement.
|
|
288
|
+
*/
|
|
289
|
+
function splitReplacementUpload(payloads) {
|
|
290
|
+
var datasets = [];
|
|
291
|
+
var maps = [];
|
|
292
|
+
payloads.forEach(function (payload) {
|
|
293
|
+
if (payload.config) {
|
|
294
|
+
maps.push(payload);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
var list = (Array.isArray(payload.datasets) ? payload.datasets : [payload.datasets]).filter(function (dataset) {
|
|
298
|
+
return Boolean(dataset);
|
|
299
|
+
});
|
|
300
|
+
datasets.push.apply(datasets, _toConsumableArray(list));
|
|
301
|
+
});
|
|
302
|
+
var datasetToUse = datasets[0],
|
|
303
|
+
more = datasets.slice(1);
|
|
304
|
+
return {
|
|
305
|
+
datasetToUse: datasetToUse !== null && datasetToUse !== void 0 ? datasetToUse : null,
|
|
306
|
+
remainder: [].concat(maps, _toConsumableArray(more.length ? [{
|
|
307
|
+
datasets: more,
|
|
308
|
+
options: {
|
|
309
|
+
keepExistingConfig: true,
|
|
310
|
+
centerMap: false,
|
|
311
|
+
autoCreateLayers: false
|
|
312
|
+
}
|
|
313
|
+
}] : []))
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Turn a confirmed Add Data selection into a dataset replacement.
|
|
319
|
+
* Layers and filters move onto the new table. The original table is dropped unless asked to stay.
|
|
320
|
+
* @memberof combinedUpdaters
|
|
321
|
+
* @public
|
|
322
|
+
*/
|
|
323
|
+
export var confirmReplaceDatasetUpdater = function confirmReplaceDatasetUpdater(state, action) {
|
|
324
|
+
var _datasetToUse$info;
|
|
325
|
+
var payloads = filesToDataPayload(action.result, {
|
|
326
|
+
keepExistingConfig: true,
|
|
327
|
+
centerMap: true,
|
|
328
|
+
autoCreateLayers: false
|
|
329
|
+
});
|
|
330
|
+
var cleared = compose_([pick_('visState')(merge_({
|
|
331
|
+
fileLoading: false,
|
|
332
|
+
fileLoadingProgress: {},
|
|
333
|
+
stagedToAdd: null
|
|
334
|
+
}))])(state);
|
|
335
|
+
var _splitReplacementUplo = splitReplacementUpload(payloads),
|
|
336
|
+
datasetToUse = _splitReplacementUplo.datasetToUse,
|
|
337
|
+
remainder = _splitReplacementUplo.remainder;
|
|
338
|
+
if (datasetToUse !== null && datasetToUse !== void 0 && (_datasetToUse$info = datasetToUse.info) !== null && _datasetToUse$info !== void 0 && _datasetToUse$info.id && action.datasetToReplaceId) {
|
|
339
|
+
var replaced = replaceDataInMapUpdater(cleared, {
|
|
340
|
+
payload: {
|
|
341
|
+
datasetToReplaceId: action.datasetToReplaceId,
|
|
342
|
+
datasetToUse: datasetToUse,
|
|
343
|
+
options: {
|
|
344
|
+
deleteOriginalDataset: action.deleteOriginalDataset !== false
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
if (replaced !== cleared) {
|
|
349
|
+
if (!remainder.length) {
|
|
350
|
+
return replaced;
|
|
351
|
+
}
|
|
352
|
+
return compose_(remainder.map(function (p) {
|
|
353
|
+
return apply_(addDataToMapUpdater, payload_(p));
|
|
354
|
+
}))(replaced);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return compose_(payloads.map(function (p) {
|
|
358
|
+
return apply_(addDataToMapUpdater, payload_(p));
|
|
359
|
+
}))(cleared);
|
|
360
|
+
};
|
|
361
|
+
export var addDataToMapComposed = addDataToMapUpdater;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Helper which updates map overlay blending mode in visState,
|
|
365
|
+
* but only if it's not currently in the `normal` mode.
|
|
366
|
+
*/
|
|
367
|
+
var updateOverlayBlending = function updateOverlayBlending(overlayBlending) {
|
|
368
|
+
return function (visState) {
|
|
369
|
+
if (visState.overlayBlending !== OVERLAY_BLENDINGS.normal.value) {
|
|
370
|
+
return _objectSpread(_objectSpread({}, visState), {}, {
|
|
371
|
+
overlayBlending: overlayBlending
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
return visState;
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Helper which updates `darkBaseMapEnabled` in all the layers in visState which
|
|
380
|
+
* have this config setting (or in one specific layer if the `layerId` param is provided).
|
|
381
|
+
*/
|
|
382
|
+
var updateDarkBaseMapLayers = function updateDarkBaseMapLayers(darkBaseMapEnabled) {
|
|
383
|
+
var layerId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
384
|
+
return function (visState) {
|
|
385
|
+
return _objectSpread(_objectSpread({}, visState), {}, {
|
|
386
|
+
layers: visState.layers.map(function (layer) {
|
|
387
|
+
if (!layerId || layer.id === layerId) {
|
|
388
|
+
if (Object.prototype.hasOwnProperty.call(layer.visConfigSettings, 'darkBaseMapEnabled')) {
|
|
389
|
+
var visConfig = layer.config.visConfig;
|
|
390
|
+
return layer.updateLayerConfig({
|
|
391
|
+
visConfig: _objectSpread(_objectSpread({}, visConfig), {}, {
|
|
392
|
+
darkBaseMapEnabled: darkBaseMapEnabled
|
|
393
|
+
})
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return layer;
|
|
398
|
+
})
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Updater that changes the map style by calling mapStyleChangeUpdater on visState.
|
|
405
|
+
* In addition to that, it does the following:
|
|
406
|
+
*
|
|
407
|
+
* 1. Update map overlay blending mode in accordance with the colorMode of the
|
|
408
|
+
* base map, but only if it's not in the `normal` mode.
|
|
409
|
+
*
|
|
410
|
+
* 2. Update all the layers which have the `darkBaseMapEnabled` config setting
|
|
411
|
+
* adjusting it in accordance with the colorMode of the base map.
|
|
412
|
+
*
|
|
413
|
+
*/
|
|
414
|
+
export var combinedMapStyleChangeUpdater = function combinedMapStyleChangeUpdater(state, action) {
|
|
415
|
+
var _mapState$globe;
|
|
416
|
+
var payload = action.payload;
|
|
417
|
+
var mapStyle = state.mapStyle;
|
|
418
|
+
var getColorMode = function getColorMode(key) {
|
|
419
|
+
var _mapStyle$mapStyles$k;
|
|
420
|
+
return (_mapStyle$mapStyles$k = mapStyle.mapStyles[key]) === null || _mapStyle$mapStyles$k === void 0 ? void 0 : _mapStyle$mapStyles$k.colorMode;
|
|
421
|
+
};
|
|
422
|
+
var prevColorMode = getColorMode(mapStyle.styleType);
|
|
423
|
+
var nextColorMode = getColorMode(payload.styleType);
|
|
424
|
+
var visState = state.visState,
|
|
425
|
+
mapState = state.mapState;
|
|
426
|
+
if (nextColorMode !== prevColorMode) {
|
|
427
|
+
switch (nextColorMode) {
|
|
428
|
+
case BASE_MAP_COLOR_MODES.DARK:
|
|
429
|
+
visState = compose_([updateOverlayBlending(OVERLAY_BLENDINGS.screen.value), updateDarkBaseMapLayers(true)])(visState);
|
|
430
|
+
break;
|
|
431
|
+
case BASE_MAP_COLOR_MODES.LIGHT:
|
|
432
|
+
visState = compose_([updateOverlayBlending(OVERLAY_BLENDINGS.darken.value), updateDarkBaseMapLayers(false)])(visState);
|
|
433
|
+
break;
|
|
434
|
+
default:
|
|
435
|
+
// do nothing
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Update globe config colors when style changes and globe is enabled
|
|
440
|
+
if ((_mapState$globe = mapState.globe) !== null && _mapState$globe !== void 0 && _mapState$globe.enabled) {
|
|
441
|
+
// Switching from "No Basemap" to a basemap - restore basemap sub-toggles
|
|
442
|
+
if (payload.styleType !== NO_MAP_ID && mapStyle.styleType === NO_MAP_ID) {
|
|
443
|
+
mapState = _objectSpread(_objectSpread({}, mapState), {}, {
|
|
444
|
+
globe: _objectSpread(_objectSpread({}, mapState.globe), {}, {
|
|
445
|
+
config: _objectSpread(_objectSpread({}, mapState.globe.config), {}, {
|
|
446
|
+
basemap: true,
|
|
447
|
+
labels: true,
|
|
448
|
+
adminLines: true,
|
|
449
|
+
water: true
|
|
450
|
+
})
|
|
451
|
+
})
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
mapState = syncGlobeConfigColorsToStyle(mapState, mapStyle, payload.styleType);
|
|
455
|
+
}
|
|
456
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
457
|
+
visState: visState,
|
|
458
|
+
mapState: mapState,
|
|
459
|
+
mapStyle: mapStyleChangeUpdater(mapStyle, {
|
|
460
|
+
payload: _objectSpread({}, payload)
|
|
461
|
+
})
|
|
462
|
+
});
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Derive globe basemap colors (surface / water / admin lines) from a map style and
|
|
467
|
+
* return an updated mapState with those colors written into `globe.config`. Used both
|
|
468
|
+
* when the base map style changes and when entering globe mode, so the globe always
|
|
469
|
+
* reflects the currently selected basemap instead of the static DEFAULT_GLOBE_CONFIG.
|
|
470
|
+
*/
|
|
471
|
+
export function syncGlobeConfigColorsToStyle(mapState, mapStyle, styleType) {
|
|
472
|
+
var _mapState$globe2;
|
|
473
|
+
if (!((_mapState$globe2 = mapState.globe) !== null && _mapState$globe2 !== void 0 && _mapState$globe2.enabled)) {
|
|
474
|
+
return mapState;
|
|
475
|
+
}
|
|
476
|
+
var nextStyleObj = mapStyle.mapStyles[styleType];
|
|
477
|
+
var nextGlobeConfig = _objectSpread({}, mapState.globe.config);
|
|
478
|
+
if (styleType === NO_MAP_ID) {
|
|
479
|
+
nextGlobeConfig.basemap = false;
|
|
480
|
+
nextGlobeConfig.labels = false;
|
|
481
|
+
nextGlobeConfig.adminLines = false;
|
|
482
|
+
nextGlobeConfig.water = false;
|
|
483
|
+
nextGlobeConfig.surfaceColor = DEFAULT_BASEMAP_COLOR.backgroundFillColor;
|
|
484
|
+
nextGlobeConfig.waterColor = DEFAULT_BASEMAP_COLOR.basemapWaterFillColor;
|
|
485
|
+
nextGlobeConfig.adminLinesColor = DEFAULT_BASEMAP_COLOR.basemapAdminLineColor;
|
|
486
|
+
} else {
|
|
487
|
+
var basemapColors = nextStyleObj ? getBasemapColorsForStyle(styleType, {
|
|
488
|
+
style: nextStyleObj.style,
|
|
489
|
+
layerGroups: nextStyleObj.layerGroups
|
|
490
|
+
}) :
|
|
491
|
+
// Style object not yet loaded - use known presets by style type
|
|
492
|
+
getBasemapColorsForStyle(styleType);
|
|
493
|
+
nextGlobeConfig.surfaceColor = basemapColors.backgroundFillColor;
|
|
494
|
+
nextGlobeConfig.waterColor = basemapColors.basemapWaterFillColor;
|
|
495
|
+
nextGlobeConfig.adminLinesColor = basemapColors.basemapAdminLineColor;
|
|
496
|
+
}
|
|
497
|
+
return _objectSpread(_objectSpread({}, mapState), {}, {
|
|
498
|
+
globe: _objectSpread(_objectSpread({}, mapState.globe), {}, {
|
|
499
|
+
config: nextGlobeConfig
|
|
500
|
+
})
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Updater that switches the map view mode (2D / 3D / Globe). Runs the base map-state
|
|
506
|
+
* updater and, when entering globe mode, syncs the globe basemap colors to the
|
|
507
|
+
* currently selected map style so the globe doesn't show stale default colors.
|
|
508
|
+
*/
|
|
509
|
+
export var combinedSetMapViewModeUpdater = function combinedSetMapViewModeUpdater(state, action) {
|
|
510
|
+
var _mapState$globe3;
|
|
511
|
+
var mapState = setMapViewModeUpdater(state.mapState, action);
|
|
512
|
+
if ((_mapState$globe3 = mapState.globe) !== null && _mapState$globe3 !== void 0 && _mapState$globe3.enabled) {
|
|
513
|
+
mapState = syncGlobeConfigColorsToStyle(mapState, state.mapStyle, state.mapStyle.styleType);
|
|
514
|
+
}
|
|
515
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
516
|
+
mapState: mapState
|
|
517
|
+
});
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Updater that changes the layer type by calling `layerTypeChangeUpdater` on visState.
|
|
522
|
+
* In addition to that, if the new layer type has the `darkBaseMapEnabled` config
|
|
523
|
+
* setting, we adjust it in accordance with the colorMode of the base map.s
|
|
524
|
+
*/
|
|
525
|
+
export var combinedLayerTypeChangeUpdater = function combinedLayerTypeChangeUpdater(state, action) {
|
|
526
|
+
var visState = state.visState;
|
|
527
|
+
var oldLayerIndex = visState.layers.findIndex(function (layer) {
|
|
528
|
+
return layer === action.oldLayer;
|
|
529
|
+
});
|
|
530
|
+
visState = layerTypeChangeUpdater(visState, action);
|
|
531
|
+
var newLayer = visState.layers[oldLayerIndex];
|
|
532
|
+
if (Object.prototype.hasOwnProperty.call(newLayer === null || newLayer === void 0 ? void 0 : newLayer.visConfigSettings, 'darkBaseMapEnabled')) {
|
|
533
|
+
var mapStyle = state.mapStyle;
|
|
534
|
+
var colorMode = mapStyle.mapStyles[mapStyle.styleType].colorMode;
|
|
535
|
+
var darkBaseMapEnabled = newLayer.config.visConfig.darkBaseMapEnabled;
|
|
536
|
+
switch (colorMode) {
|
|
537
|
+
case BASE_MAP_COLOR_MODES.DARK:
|
|
538
|
+
if (!darkBaseMapEnabled) {
|
|
539
|
+
visState = updateDarkBaseMapLayers(true, newLayer.id)(visState);
|
|
540
|
+
}
|
|
541
|
+
break;
|
|
542
|
+
case BASE_MAP_COLOR_MODES.LIGHT:
|
|
543
|
+
if (darkBaseMapEnabled) {
|
|
544
|
+
visState = updateDarkBaseMapLayers(false, newLayer.id)(visState);
|
|
545
|
+
}
|
|
546
|
+
break;
|
|
547
|
+
default:
|
|
548
|
+
// do nothing
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
552
|
+
visState: visState
|
|
553
|
+
});
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Make mapLegend active when toggleSplitMap action is called
|
|
558
|
+
*/
|
|
559
|
+
export var toggleSplitMapUpdater = function toggleSplitMapUpdater(state, action) {
|
|
560
|
+
var _newState$uiState$map;
|
|
561
|
+
var newState = _objectSpread(_objectSpread({}, state), {}, {
|
|
562
|
+
visState: visStateToggleSplitMapUpdater(state.visState, action),
|
|
563
|
+
uiState: uiStateToggleSplitMapUpdater(state.uiState),
|
|
564
|
+
mapState: mapStateToggleSplitMapUpdater(state.mapState)
|
|
565
|
+
});
|
|
566
|
+
var isSplit = newState.visState.splitMaps.length !== 0;
|
|
567
|
+
var isLegendActive = (_newState$uiState$map = newState.uiState.mapControls) === null || _newState$uiState$map === void 0 || (_newState$uiState$map = _newState$uiState$map.mapLegend) === null || _newState$uiState$map === void 0 ? void 0 : _newState$uiState$map.active;
|
|
568
|
+
if (isSplit && !isLegendActive) {
|
|
569
|
+
newState.uiState = toggleMapControlUpdater(newState.uiState, {
|
|
570
|
+
payload: {
|
|
571
|
+
panelId: 'mapLegend',
|
|
572
|
+
index: action.payload
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
return newState;
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Set map split mode updater - coordinates state changes across visState, mapState, and uiState
|
|
581
|
+
*/
|
|
582
|
+
export var setMapSplitModeUpdater = function setMapSplitModeUpdater(state, action) {
|
|
583
|
+
var _newUiState$mapContro;
|
|
584
|
+
var mapSplitMode = action.payload.mapSplitMode;
|
|
585
|
+
var prevMode = state.mapState.mapSplitMode;
|
|
586
|
+
if (mapSplitMode === prevMode) {
|
|
587
|
+
return state;
|
|
588
|
+
}
|
|
589
|
+
var newMapState = mapStateSetMapSplitModeUpdater(state.mapState, action);
|
|
590
|
+
var newVisState = _objectSpread({}, state.visState);
|
|
591
|
+
switch (mapSplitMode) {
|
|
592
|
+
case MapSplitMode.SINGLE_MAP:
|
|
593
|
+
newVisState = _objectSpread(_objectSpread({}, newVisState), {}, {
|
|
594
|
+
splitMaps: []
|
|
595
|
+
});
|
|
596
|
+
break;
|
|
597
|
+
case MapSplitMode.DUAL_MAP:
|
|
598
|
+
case MapSplitMode.SWIPE_COMPARE:
|
|
599
|
+
if (prevMode === MapSplitMode.SINGLE_MAP) {
|
|
600
|
+
newVisState = _objectSpread(_objectSpread({}, newVisState), {}, {
|
|
601
|
+
splitMaps: computeSplitMapLayers(newVisState.layers, {
|
|
602
|
+
duplicate: mapSplitMode === MapSplitMode.SWIPE_COMPARE
|
|
603
|
+
})
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
break;
|
|
607
|
+
default:
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
var newUiState = uiStateToggleSplitMapUpdater(state.uiState);
|
|
611
|
+
var isSplit = newVisState.splitMaps.length !== 0;
|
|
612
|
+
var isLegendActive = (_newUiState$mapContro = newUiState.mapControls) === null || _newUiState$mapContro === void 0 || (_newUiState$mapContro = _newUiState$mapContro.mapLegend) === null || _newUiState$mapContro === void 0 ? void 0 : _newUiState$mapContro.active;
|
|
613
|
+
if (isSplit && !isLegendActive) {
|
|
614
|
+
newUiState = toggleMapControlUpdater(newUiState, {
|
|
615
|
+
payload: {
|
|
616
|
+
panelId: 'mapLegend',
|
|
617
|
+
index: 0
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
622
|
+
mapState: newMapState,
|
|
623
|
+
visState: newVisState,
|
|
624
|
+
uiState: newUiState
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
var defaultReplaceDataToMapOptions = {
|
|
628
|
+
keepExistingConfig: true,
|
|
629
|
+
centerMap: true,
|
|
630
|
+
autoCreateLayers: false
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Updater replace a dataset in state
|
|
635
|
+
*/
|
|
636
|
+
export var replaceDataInMapUpdater = function replaceDataInMapUpdater(state, _ref5) {
|
|
637
|
+
var payload = _ref5.payload;
|
|
638
|
+
var datasetToReplaceId = payload.datasetToReplaceId,
|
|
639
|
+
datasetToUse = payload.datasetToUse,
|
|
640
|
+
_payload$options = payload.options,
|
|
641
|
+
options = _payload$options === void 0 ? {} : _payload$options;
|
|
642
|
+
var _options$deleteOrigin = options.deleteOriginalDataset,
|
|
643
|
+
deleteOriginalDataset = _options$deleteOrigin === void 0 ? true : _options$deleteOrigin,
|
|
644
|
+
replaceOptions = _objectWithoutProperties(options, _excluded);
|
|
645
|
+
var addDataToMapOptions = _objectSpread(_objectSpread({}, defaultReplaceDataToMapOptions), replaceOptions);
|
|
646
|
+
|
|
647
|
+
// check if dataset is there
|
|
648
|
+
if (!state.visState.datasets[datasetToReplaceId]) {
|
|
649
|
+
return state;
|
|
650
|
+
}
|
|
651
|
+
// datasetToUse is ProtoDataset
|
|
652
|
+
var dataIdToUse = datasetToUse.info.id;
|
|
653
|
+
if (!dataIdToUse) {
|
|
654
|
+
return state;
|
|
655
|
+
}
|
|
656
|
+
// Keep the original and its dependencies visible until creation succeeds.
|
|
657
|
+
var action = {
|
|
658
|
+
payload: {
|
|
659
|
+
datasets: datasetToUse,
|
|
660
|
+
options: addDataToMapOptions
|
|
661
|
+
},
|
|
662
|
+
replacement: {
|
|
663
|
+
datasetToReplaceId: datasetToReplaceId,
|
|
664
|
+
deleteOriginalDataset: deleteOriginalDataset
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
return addDataToMapUpdater(state, action);
|
|
668
|
+
};
|
|
669
|
+
//# sourceMappingURL=combined-updaters.js.map
|