@vcmap/core 5.0.0-rc.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/LICENSE.md +21 -0
- package/README.md +44 -0
- package/build/postinstall.js +44 -0
- package/index.js +139 -0
- package/package.json +92 -0
- package/src/cesium/cesium3DTileFeature.js +9 -0
- package/src/cesium/cesium3DTilePointFeature.js +9 -0
- package/src/cesium/cesiumVcsCameraPrimitive.js +146 -0
- package/src/cesium/wallpaperMaterial.js +64 -0
- package/src/ol/feature.js +47 -0
- package/src/ol/geom/circle.js +24 -0
- package/src/ol/geom/geometryCollection.js +33 -0
- package/src/ol/render/canvas/canvasTileRenderer.js +179 -0
- package/src/ol/source/ClusterEnhancedVectorSource.js +39 -0
- package/src/ol/source/VcsCluster.js +37 -0
- package/src/vcs/vcm/classRegistry.js +106 -0
- package/src/vcs/vcm/event/vcsEvent.js +89 -0
- package/src/vcs/vcm/globalCollections.js +11 -0
- package/src/vcs/vcm/interaction/abstractInteraction.js +149 -0
- package/src/vcs/vcm/interaction/coordinateAtPixel.js +102 -0
- package/src/vcs/vcm/interaction/eventHandler.js +425 -0
- package/src/vcs/vcm/interaction/featureAtPixelInteraction.js +286 -0
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +54 -0
- package/src/vcs/vcm/interaction/interactionChain.js +124 -0
- package/src/vcs/vcm/interaction/interactionType.js +114 -0
- package/src/vcs/vcm/layer/buildings.js +17 -0
- package/src/vcs/vcm/layer/cesium/cesiumTilesetCesium.js +359 -0
- package/src/vcs/vcm/layer/cesium/clusterContext.js +95 -0
- package/src/vcs/vcm/layer/cesium/dataSourceCesium.js +171 -0
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +29 -0
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +58 -0
- package/src/vcs/vcm/layer/cesium/rasterLayerCesium.js +110 -0
- package/src/vcs/vcm/layer/cesium/singleImageCesium.js +49 -0
- package/src/vcs/vcm/layer/cesium/terrainCesium.js +80 -0
- package/src/vcs/vcm/layer/cesium/tmsCesium.js +54 -0
- package/src/vcs/vcm/layer/cesium/vectorCesium.js +255 -0
- package/src/vcs/vcm/layer/cesium/vectorContext.js +167 -0
- package/src/vcs/vcm/layer/cesium/vectorRasterTileCesium.js +116 -0
- package/src/vcs/vcm/layer/cesium/vectorTileImageryProvider.js +246 -0
- package/src/vcs/vcm/layer/cesium/wmsCesium.js +71 -0
- package/src/vcs/vcm/layer/cesium/wmtsCesium.js +101 -0
- package/src/vcs/vcm/layer/cesium/x3dmHelper.js +22 -0
- package/src/vcs/vcm/layer/cesiumTileset.js +376 -0
- package/src/vcs/vcm/layer/czml.js +141 -0
- package/src/vcs/vcm/layer/dataSource.js +259 -0
- package/src/vcs/vcm/layer/featureLayer.js +261 -0
- package/src/vcs/vcm/layer/featureStore.js +647 -0
- package/src/vcs/vcm/layer/featureStoreChanges.js +360 -0
- package/src/vcs/vcm/layer/featureStoreState.js +19 -0
- package/src/vcs/vcm/layer/featureVisibility.js +435 -0
- package/src/vcs/vcm/layer/geojson.js +185 -0
- package/src/vcs/vcm/layer/geojsonHelpers.js +450 -0
- package/src/vcs/vcm/layer/globalHider.js +157 -0
- package/src/vcs/vcm/layer/layer.js +752 -0
- package/src/vcs/vcm/layer/layerImplementation.js +102 -0
- package/src/vcs/vcm/layer/layerState.js +17 -0
- package/src/vcs/vcm/layer/layerSymbols.js +6 -0
- package/src/vcs/vcm/layer/oblique/layerOblique.js +76 -0
- package/src/vcs/vcm/layer/oblique/obliqueHelpers.js +175 -0
- package/src/vcs/vcm/layer/oblique/vectorOblique.js +469 -0
- package/src/vcs/vcm/layer/openStreetMap.js +194 -0
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +79 -0
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +27 -0
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +121 -0
- package/src/vcs/vcm/layer/openlayers/singleImageOpenlayers.js +49 -0
- package/src/vcs/vcm/layer/openlayers/tileDebugOpenlayers.js +39 -0
- package/src/vcs/vcm/layer/openlayers/tmsOpenlayers.js +62 -0
- package/src/vcs/vcm/layer/openlayers/vectorOpenlayers.js +118 -0
- package/src/vcs/vcm/layer/openlayers/vectorTileOpenlayers.js +177 -0
- package/src/vcs/vcm/layer/openlayers/wmsOpenlayers.js +55 -0
- package/src/vcs/vcm/layer/openlayers/wmtsOpenlayers.js +141 -0
- package/src/vcs/vcm/layer/pointCloud.js +162 -0
- package/src/vcs/vcm/layer/rasterLayer.js +294 -0
- package/src/vcs/vcm/layer/singleImage.js +119 -0
- package/src/vcs/vcm/layer/terrain.js +122 -0
- package/src/vcs/vcm/layer/terrainHelpers.js +123 -0
- package/src/vcs/vcm/layer/tileLoadedHelper.js +72 -0
- package/src/vcs/vcm/layer/tileProvider/mvtTileProvider.js +104 -0
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +67 -0
- package/src/vcs/vcm/layer/tileProvider/tileProvider.js +584 -0
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +28 -0
- package/src/vcs/vcm/layer/tileProvider/urlTemplateTileProvider.js +106 -0
- package/src/vcs/vcm/layer/tms.js +121 -0
- package/src/vcs/vcm/layer/vector.js +632 -0
- package/src/vcs/vcm/layer/vectorHelpers.js +206 -0
- package/src/vcs/vcm/layer/vectorProperties.js +1391 -0
- package/src/vcs/vcm/layer/vectorSymbols.js +40 -0
- package/src/vcs/vcm/layer/vectorTile.js +480 -0
- package/src/vcs/vcm/layer/wfs.js +165 -0
- package/src/vcs/vcm/layer/wms.js +270 -0
- package/src/vcs/vcm/layer/wmsHelpers.js +65 -0
- package/src/vcs/vcm/layer/wmts.js +235 -0
- package/src/vcs/vcm/maps/baseOLMap.js +257 -0
- package/src/vcs/vcm/maps/cameraLimiter.js +219 -0
- package/src/vcs/vcm/maps/cesium.js +1192 -0
- package/src/vcs/vcm/maps/map.js +511 -0
- package/src/vcs/vcm/maps/mapState.js +17 -0
- package/src/vcs/vcm/maps/oblique.js +536 -0
- package/src/vcs/vcm/maps/openlayers.js +205 -0
- package/src/vcs/vcm/object.js +92 -0
- package/src/vcs/vcm/oblique/ObliqueCollection.js +572 -0
- package/src/vcs/vcm/oblique/ObliqueDataSet.js +357 -0
- package/src/vcs/vcm/oblique/ObliqueImage.js +247 -0
- package/src/vcs/vcm/oblique/ObliqueImageMeta.js +126 -0
- package/src/vcs/vcm/oblique/ObliqueProvider.js +433 -0
- package/src/vcs/vcm/oblique/ObliqueView.js +130 -0
- package/src/vcs/vcm/oblique/ObliqueViewDirection.js +40 -0
- package/src/vcs/vcm/oblique/helpers.js +483 -0
- package/src/vcs/vcm/oblique/parseImageJson.js +248 -0
- package/src/vcs/vcm/util/clipping/clippingObject.js +386 -0
- package/src/vcs/vcm/util/clipping/clippingObjectManager.js +312 -0
- package/src/vcs/vcm/util/clipping/clippingPlaneHelper.js +413 -0
- package/src/vcs/vcm/util/collection.js +193 -0
- package/src/vcs/vcm/util/dateTime.js +60 -0
- package/src/vcs/vcm/util/exclusiveManager.js +135 -0
- package/src/vcs/vcm/util/extent.js +124 -0
- package/src/vcs/vcm/util/featureProvider/abstractFeatureProvider.js +196 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +51 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderSymbols.js +11 -0
- package/src/vcs/vcm/util/featureProvider/tileProviderFeatureProvider.js +62 -0
- package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +280 -0
- package/src/vcs/vcm/util/featureconverter/circleToCesium.js +215 -0
- package/src/vcs/vcm/util/featureconverter/convert.js +83 -0
- package/src/vcs/vcm/util/featureconverter/extent3d.js +154 -0
- package/src/vcs/vcm/util/featureconverter/featureconverterHelper.js +591 -0
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +171 -0
- package/src/vcs/vcm/util/featureconverter/pointToCesium.js +359 -0
- package/src/vcs/vcm/util/featureconverter/polygonToCesium.js +229 -0
- package/src/vcs/vcm/util/geometryHelpers.js +172 -0
- package/src/vcs/vcm/util/indexedCollection.js +158 -0
- package/src/vcs/vcm/util/isMobile.js +12 -0
- package/src/vcs/vcm/util/layerCollection.js +216 -0
- package/src/vcs/vcm/util/locale.js +53 -0
- package/src/vcs/vcm/util/mapCollection.js +363 -0
- package/src/vcs/vcm/util/math.js +71 -0
- package/src/vcs/vcm/util/projection.js +348 -0
- package/src/vcs/vcm/util/splitScreen.js +233 -0
- package/src/vcs/vcm/util/style/declarativeStyleItem.js +631 -0
- package/src/vcs/vcm/util/style/shapesCategory.js +67 -0
- package/src/vcs/vcm/util/style/styleFactory.js +48 -0
- package/src/vcs/vcm/util/style/styleHelpers.js +555 -0
- package/src/vcs/vcm/util/style/styleItem.js +226 -0
- package/src/vcs/vcm/util/style/vectorStyleItem.js +927 -0
- package/src/vcs/vcm/util/style/writeStyle.js +48 -0
- package/src/vcs/vcm/util/urlHelpers.js +16 -0
- package/src/vcs/vcm/util/viewpoint.js +333 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { unByKey } from 'ol/Observable.js';
|
|
3
|
+
import Feature from 'ol/Feature.js';
|
|
4
|
+
import { check } from '@vcsuite/check';
|
|
5
|
+
import { featureStoreState, featureStoreStateSymbol } from './featureStoreState.js';
|
|
6
|
+
import { parseGeoJSON, writeGeoJSONFeature } from './geojsonHelpers.js';
|
|
7
|
+
import VcsObject from '../object.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} FeatureStoreTrackResults
|
|
11
|
+
* @property {Array<import("ol").Feature<import("ol/geom/Geometry").default>>} add
|
|
12
|
+
* @property {Array<import("ol").Feature<import("ol/geom/Geometry").default>>} edit
|
|
13
|
+
* @property {Array<import("ol").Feature<import("ol/geom/Geometry").default>>} remove
|
|
14
|
+
* @api
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {Object} FeatureStoreChangesListeners
|
|
19
|
+
* @property {import("ol/events").EventsKey|Array<import("ol/events").EventsKey>|null} addfeature
|
|
20
|
+
* @property {import("ol/events").EventsKey|Array<import("ol/events").EventsKey>|null} changefeature
|
|
21
|
+
* @property {import("ol/events").EventsKey|Array<import("ol/events").EventsKey>|null} removefeature
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {Object} FeatureStoreChangesValues
|
|
26
|
+
* @property {boolean} changed
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* do not construct directly, use the layers .changeTracker instead
|
|
31
|
+
* @class
|
|
32
|
+
* @extends {VcsObject}
|
|
33
|
+
* @api
|
|
34
|
+
*/
|
|
35
|
+
class FeatureStoreChanges extends VcsObject {
|
|
36
|
+
static get className() { return 'vcs.vcm.layer.FeatureStoreChanges'; }
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {import("@vcmap/core").FeatureStore} layer
|
|
40
|
+
*/
|
|
41
|
+
constructor(layer) {
|
|
42
|
+
super({});
|
|
43
|
+
|
|
44
|
+
/** @type {import("@vcmap/core").FeatureStore} */
|
|
45
|
+
this.layer = layer;
|
|
46
|
+
/** @type {FeatureStoreChangesListeners} */
|
|
47
|
+
this._changesListeners = {
|
|
48
|
+
addfeature: null,
|
|
49
|
+
changefeature: null,
|
|
50
|
+
removefeature: null,
|
|
51
|
+
};
|
|
52
|
+
/** @type {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} */
|
|
53
|
+
this._addedFeatures = new Set();
|
|
54
|
+
/** @type {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} */
|
|
55
|
+
this._editedFeatures = new Set();
|
|
56
|
+
/** @type {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} */
|
|
57
|
+
this._removedFeatures = new Set();
|
|
58
|
+
/** @type {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} */
|
|
59
|
+
this._convertedFeatures = new Set();
|
|
60
|
+
/** @type {FeatureStoreChangesValues} */
|
|
61
|
+
this.values = {
|
|
62
|
+
changed: false,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Whether changes are being tracked or not
|
|
68
|
+
* @readonly
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
* @api
|
|
71
|
+
*/
|
|
72
|
+
get active() { return Object.values(this._changesListeners).some(c => c !== null); }
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* starts tracking changes on the layer
|
|
76
|
+
* starts tracking changes on the feature store layer
|
|
77
|
+
* @api
|
|
78
|
+
*/
|
|
79
|
+
track() {
|
|
80
|
+
if (this._changesListeners.addfeature === null) {
|
|
81
|
+
this._changesListeners.addfeature = this.layer.source.on('addfeature', this._featureAdded.bind(this));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (this._changesListeners.changefeature === null) {
|
|
85
|
+
this._changesListeners.changefeature = this.layer.source.on('changefeature', this._featureChanged.bind(this));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (this._changesListeners.removefeature === null) {
|
|
89
|
+
this._changesListeners.removefeature = this.layer.source.on('removefeature', this._featureRemoved.bind(this));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @returns {FeatureStoreTrackResults}
|
|
95
|
+
*/
|
|
96
|
+
getChanges() {
|
|
97
|
+
return {
|
|
98
|
+
add: [...this._addedFeatures],
|
|
99
|
+
edit: [...this._editedFeatures],
|
|
100
|
+
remove: [...this._removedFeatures],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* commits the changes to the provided url. url should contain accessTokens and point to a featureStore layers bulk operation endpoint
|
|
106
|
+
* @param {string} url
|
|
107
|
+
* @returns {Promise<void>}
|
|
108
|
+
* @api
|
|
109
|
+
*/
|
|
110
|
+
commitChanges(url) {
|
|
111
|
+
const actions = [];
|
|
112
|
+
this._addedFeatures.forEach((f) => {
|
|
113
|
+
const feature = writeGeoJSONFeature(f, { writeStyle: true });
|
|
114
|
+
actions.push({
|
|
115
|
+
action: 'add',
|
|
116
|
+
feature,
|
|
117
|
+
original: f,
|
|
118
|
+
success(data) {
|
|
119
|
+
f.setId(data);
|
|
120
|
+
f[featureStoreStateSymbol] = featureStoreState.DYNAMIC;
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
this._editedFeatures.forEach((f) => {
|
|
126
|
+
const feature = writeGeoJSONFeature(f, { writeStyle: true });
|
|
127
|
+
feature._id = f.getId();
|
|
128
|
+
feature.geomety = 'test';
|
|
129
|
+
actions.push({
|
|
130
|
+
action: 'edit',
|
|
131
|
+
original: f,
|
|
132
|
+
feature,
|
|
133
|
+
success() {
|
|
134
|
+
if (f[featureStoreStateSymbol] === featureStoreState.STATIC) {
|
|
135
|
+
f[featureStoreStateSymbol] = featureStoreState.EDITED;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
this._removedFeatures.forEach((f) => {
|
|
142
|
+
const _id = f.getId();
|
|
143
|
+
actions.push({
|
|
144
|
+
original: f,
|
|
145
|
+
action: 'remove',
|
|
146
|
+
feature: { _id },
|
|
147
|
+
success() {},
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
/** @type {Promise<void>} */
|
|
151
|
+
let promise = Promise.resolve();
|
|
152
|
+
if (actions.length) {
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
promise = axios.post(url.toString(), actions.map(a => ({ action: a.action, feature: a.feature })))
|
|
155
|
+
.then(({ data }) => {
|
|
156
|
+
const failures = data.failedActions.map(({ index, error }) => {
|
|
157
|
+
const action = actions[index];
|
|
158
|
+
this.getLogger().log(`failed action ${action.action}: ${error}`);
|
|
159
|
+
actions[index] = null;
|
|
160
|
+
return this._resetFeature(action.original);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
actions
|
|
164
|
+
.filter(a => a)
|
|
165
|
+
.forEach(({ action, success }) => {
|
|
166
|
+
if (action === 'add') {
|
|
167
|
+
success(data.insertedIds.shift()._id); // XXX should this be shift or should we find the index?
|
|
168
|
+
} else {
|
|
169
|
+
success();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
return Promise.all(failures);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return promise
|
|
177
|
+
.then(() => {
|
|
178
|
+
const promises = [];
|
|
179
|
+
this._convertedFeatures.forEach((f) => { promises.push(this._resetFeature(f)); });
|
|
180
|
+
return Promise.all(promises);
|
|
181
|
+
})
|
|
182
|
+
.then(() => {
|
|
183
|
+
this._resetValues();
|
|
184
|
+
})
|
|
185
|
+
.catch((err) => {
|
|
186
|
+
this._resetValues();
|
|
187
|
+
this.getLogger().error(err.message);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* resets all changes since the last commit or the beginning of tracking
|
|
193
|
+
* @returns {Promise<void>}
|
|
194
|
+
* @api
|
|
195
|
+
*/
|
|
196
|
+
async reset() {
|
|
197
|
+
const promises = [];
|
|
198
|
+
this._addedFeatures.forEach((f) => { promises.push(this._resetFeature(f)); });
|
|
199
|
+
this._editedFeatures.forEach((f) => { promises.push(this._resetFeature(f)); });
|
|
200
|
+
this._removedFeatures.forEach((f) => { promises.push(this._resetFeature(f)); });
|
|
201
|
+
this._convertedFeatures.forEach((f) => { promises.push(this._resetFeature(f)); });
|
|
202
|
+
return Promise.all(promises)
|
|
203
|
+
.then(() => {
|
|
204
|
+
this._resetValues();
|
|
205
|
+
})
|
|
206
|
+
.catch((err) => {
|
|
207
|
+
this.getLogger().error(err);
|
|
208
|
+
this._resetValues();
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
214
|
+
* @returns {Promise<void>}
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
217
|
+
_resetFeature(feature) {
|
|
218
|
+
const featureId = feature.getId();
|
|
219
|
+
const idArray = [featureId];
|
|
220
|
+
if (!feature[featureStoreStateSymbol]) {
|
|
221
|
+
this.layer.removeFeaturesById(idArray);
|
|
222
|
+
return Promise.resolve();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (feature[featureStoreStateSymbol] === featureStoreState.STATIC) {
|
|
226
|
+
this.layer.resetStaticFeature(featureId);
|
|
227
|
+
return Promise.resolve();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return this.layer.injectedFetchDynamicFeatureFunc(featureId)
|
|
231
|
+
.then((data) => {
|
|
232
|
+
const { features } = parseGeoJSON(data);
|
|
233
|
+
this.layer.removeFeaturesById(idArray);
|
|
234
|
+
this.layer.addFeatures(features);
|
|
235
|
+
})
|
|
236
|
+
.catch((err) => {
|
|
237
|
+
this.getLogger().error('failed to reset feature, giving up', err.message);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
_resetValues() {
|
|
242
|
+
this._addedFeatures.clear();
|
|
243
|
+
this._editedFeatures.clear();
|
|
244
|
+
this._removedFeatures.clear();
|
|
245
|
+
this._convertedFeatures.clear();
|
|
246
|
+
this.values.changed = false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* stops tracking changes on the feature store layer
|
|
251
|
+
* @api
|
|
252
|
+
*/
|
|
253
|
+
unTrack() {
|
|
254
|
+
unByKey(Object.values(this._changesListeners));
|
|
255
|
+
this._changesListeners.addfeature = null;
|
|
256
|
+
this._changesListeners.changefeature = null;
|
|
257
|
+
this._changesListeners.removefeature = null;
|
|
258
|
+
this._resetValues();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* pauses the tracking of the given event, but does not reset features
|
|
263
|
+
* @param {string} event - one of: addfeature, changefeature or removefeature
|
|
264
|
+
* @api
|
|
265
|
+
*/
|
|
266
|
+
pauseTracking(event) {
|
|
267
|
+
if (this._changesListeners[event]) {
|
|
268
|
+
unByKey(this._changesListeners[event]);
|
|
269
|
+
this._changesListeners[event] = null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @param {{feature: import("ol").Feature<import("ol/geom/Geometry").default>}} event
|
|
275
|
+
* @private
|
|
276
|
+
*/
|
|
277
|
+
_featureAdded(event) {
|
|
278
|
+
const { feature } = event;
|
|
279
|
+
if (!feature[featureStoreStateSymbol]) {
|
|
280
|
+
this._addedFeatures.add(feature);
|
|
281
|
+
this.values.changed = true;
|
|
282
|
+
} else if (feature[featureStoreStateSymbol] === featureStoreState.STATIC) {
|
|
283
|
+
this._convertedFeatures.add(feature);
|
|
284
|
+
this.values.changed = true;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param {{feature: import("ol").Feature<import("ol/geom/Geometry").default>}} event
|
|
290
|
+
* @private
|
|
291
|
+
*/
|
|
292
|
+
_featureChanged(event) {
|
|
293
|
+
const { feature } = event;
|
|
294
|
+
if (feature[featureStoreStateSymbol]) {
|
|
295
|
+
this._convertedFeatures.delete(feature);
|
|
296
|
+
this._editedFeatures.add(feature);
|
|
297
|
+
this.values.changed = true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* @param {{feature: import("ol").Feature<import("ol/geom/Geometry").default>}} event
|
|
303
|
+
* @private
|
|
304
|
+
*/
|
|
305
|
+
_featureRemoved(event) {
|
|
306
|
+
const { feature } = event;
|
|
307
|
+
if (feature[featureStoreStateSymbol]) {
|
|
308
|
+
this._removedFeatures.add(feature);
|
|
309
|
+
this._editedFeatures.delete(feature);
|
|
310
|
+
this._convertedFeatures.delete(feature);
|
|
311
|
+
this.values.changed = true;
|
|
312
|
+
} else {
|
|
313
|
+
this._addedFeatures.delete(feature);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* tracks the change of removing a static feature
|
|
319
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
320
|
+
* @api
|
|
321
|
+
*/
|
|
322
|
+
removeFeature(feature) {
|
|
323
|
+
check(feature, Feature);
|
|
324
|
+
|
|
325
|
+
this._featureRemoved({ feature });
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* adds an addition to the tracker. prefer use of .track
|
|
330
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
331
|
+
* @api
|
|
332
|
+
*/
|
|
333
|
+
addFeature(feature) {
|
|
334
|
+
check(feature, Feature);
|
|
335
|
+
|
|
336
|
+
this._featureAdded({ feature });
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* adds an edit to the tracker. prefer use of .track
|
|
341
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
342
|
+
* @api
|
|
343
|
+
*/
|
|
344
|
+
editFeature(feature) {
|
|
345
|
+
check(feature, Feature);
|
|
346
|
+
|
|
347
|
+
this._featureChanged({ feature });
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* destroys the Changetracker
|
|
352
|
+
*/
|
|
353
|
+
destroy() {
|
|
354
|
+
this.unTrack();
|
|
355
|
+
this.layer = null;
|
|
356
|
+
super.destroy();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export default FeatureStoreChanges;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {symbol}
|
|
3
|
+
*/
|
|
4
|
+
export const featureStoreStateSymbol = Symbol('vcsFeatureType');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Enumeration of feature store item states
|
|
8
|
+
* @enum {string}
|
|
9
|
+
* @property {string} DYNAMIC
|
|
10
|
+
* @property {string} STATIC
|
|
11
|
+
* @property {string} EDITED
|
|
12
|
+
* @api
|
|
13
|
+
* @export
|
|
14
|
+
*/
|
|
15
|
+
export const featureStoreState = {
|
|
16
|
+
DYNAMIC: 'dynamic',
|
|
17
|
+
STATIC: 'static',
|
|
18
|
+
EDITED: 'edited',
|
|
19
|
+
};
|