@vcmap/core 5.0.0-rc.3 → 5.0.0-rc.31
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 +1 -1
- package/README.md +12 -5
- package/build/postinstall.js +14 -3
- package/index.d.ts +3480 -2008
- package/index.js +169 -131
- package/package.json +25 -27
- package/src/category/category.js +483 -0
- package/src/category/categoryCollection.js +153 -0
- package/src/cesium/cesium3DTileFeature.js +2 -2
- package/src/cesium/cesium3DTilePointFeature.js +1 -1
- package/src/cesium/cesiumVcsCameraPrimitive.js +16 -8
- package/src/cesium/entity.js +29 -0
- package/src/cesium/wallpaperMaterial.js +5 -3
- package/src/classRegistry.js +169 -0
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/abstractFeatureProvider.js +49 -46
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/tileProviderFeatureProvider.js +13 -5
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/wmsFeatureProvider.js +56 -26
- package/src/{vcs/vcm/interaction → interaction}/abstractInteraction.js +33 -21
- package/src/{vcs/vcm/interaction → interaction}/coordinateAtPixel.js +40 -21
- package/src/{vcs/vcm/interaction → interaction}/eventHandler.js +131 -26
- package/src/{vcs/vcm/interaction → interaction}/featureAtPixelInteraction.js +108 -53
- package/src/interaction/featureProviderInteraction.js +58 -0
- package/src/{vcs/vcm/interaction → interaction}/interactionChain.js +40 -41
- package/src/{vcs/vcm/interaction → interaction}/interactionType.js +24 -31
- package/src/{vcs/vcm/layer/cesium/cesiumTilesetCesium.js → layer/cesium/cesiumTilesetCesiumImpl.js} +83 -70
- package/src/{vcs/vcm/layer → layer}/cesium/clusterContext.js +33 -8
- package/src/{vcs/vcm/layer/cesium/dataSourceCesium.js → layer/cesium/dataSourceCesiumImpl.js} +24 -13
- package/src/layer/cesium/openStreetMapCesiumImpl.js +32 -0
- package/src/{vcs/vcm/layer/cesium/rasterLayerCesium.js → layer/cesium/rasterLayerCesiumImpl.js} +12 -9
- package/src/{vcs/vcm/layer/cesium/singleImageCesium.js → layer/cesium/singleImageCesiumImpl.js} +19 -9
- package/src/{vcs/vcm/layer/cesium/terrainCesium.js → layer/cesium/terrainCesiumImpl.js} +8 -9
- package/src/{vcs/vcm/layer/cesium/tmsCesium.js → layer/cesium/tmsCesiumImpl.js} +21 -10
- package/src/{vcs/vcm/layer/cesium/vectorCesium.js → layer/cesium/vectorCesiumImpl.js} +93 -35
- package/src/layer/cesium/vectorContext.js +363 -0
- package/src/{vcs/vcm/layer/cesium/vectorRasterTileCesium.js → layer/cesium/vectorRasterTileCesiumImpl.js} +21 -13
- package/src/{vcs/vcm/layer → layer}/cesium/vectorTileImageryProvider.js +58 -21
- package/src/{vcs/vcm/layer/cesium/wmsCesium.js → layer/cesium/wmsCesiumImpl.js} +20 -9
- package/src/{vcs/vcm/layer/cesium/wmtsCesium.js → layer/cesium/wmtsCesiumImpl.js} +24 -13
- package/src/{vcs/vcm/layer → layer}/cesium/x3dmHelper.js +6 -3
- package/src/{vcs/vcm/layer/cesiumTileset.js → layer/cesiumTilesetLayer.js} +71 -112
- package/src/{vcs/vcm/layer/czml.js → layer/czmlLayer.js} +23 -20
- package/src/{vcs/vcm/layer/dataSource.js → layer/dataSourceLayer.js} +55 -90
- package/src/{vcs/vcm/layer → layer}/featureLayer.js +89 -74
- package/src/{vcs/vcm/layer/featureStore.js → layer/featureStoreLayer.js} +197 -150
- package/src/{vcs/vcm/layer/featureStoreChanges.js → layer/featureStoreLayerChanges.js} +150 -92
- package/src/{vcs/vcm/layer/featureStoreState.js → layer/featureStoreLayerState.js} +1 -2
- package/src/{vcs/vcm/layer → layer}/featureVisibility.js +114 -82
- package/src/{vcs/vcm/layer → layer}/geojsonHelpers.js +84 -69
- package/src/{vcs/vcm/layer/geojson.js → layer/geojsonLayer.js} +30 -27
- package/src/{vcs/vcm/layer → layer}/globalHider.js +25 -39
- package/src/{vcs/vcm/layer → layer}/layer.js +171 -96
- package/src/{vcs/vcm/layer → layer}/layerImplementation.js +13 -6
- package/src/{vcs/vcm/layer → layer}/layerState.js +0 -1
- package/src/{vcs/vcm/layer → layer}/layerSymbols.js +2 -1
- package/src/{vcs/vcm/layer/oblique/layerOblique.js → layer/oblique/layerObliqueImpl.js} +7 -5
- package/src/{vcs/vcm/layer → layer}/oblique/obliqueHelpers.js +76 -31
- package/src/{vcs/vcm/layer/oblique/vectorOblique.js → layer/oblique/vectorObliqueImpl.js} +198 -80
- package/src/{vcs/vcm/layer/openStreetMap.js → layer/openStreetMapLayer.js} +59 -40
- package/src/layer/openlayers/layerOpenlayersImpl.js +165 -0
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +28 -0
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +44 -0
- package/src/{vcs/vcm/layer/openlayers/singleImageOpenlayers.js → layer/openlayers/singleImageOpenlayersImpl.js} +8 -7
- package/src/{vcs/vcm/layer/openlayers/tileDebugOpenlayers.js → layer/openlayers/tileDebugOpenlayersImpl.js} +7 -6
- package/src/{vcs/vcm/layer/openlayers/tmsOpenlayers.js → layer/openlayers/tmsOpenlayersImpl.js} +12 -10
- package/src/{vcs/vcm/layer/openlayers/vectorOpenlayers.js → layer/openlayers/vectorOpenlayersImpl.js} +21 -12
- package/src/{vcs/vcm/layer/openlayers/vectorTileOpenlayers.js → layer/openlayers/vectorTileOpenlayersImpl.js} +18 -12
- package/src/{vcs/vcm/layer/openlayers/wmsOpenlayers.js → layer/openlayers/wmsOpenlayersImpl.js} +9 -8
- package/src/{vcs/vcm/layer/openlayers/wmtsOpenlayers.js → layer/openlayers/wmtsOpenlayersImpl.js} +19 -12
- package/src/{vcs/vcm/layer/pointCloud.js → layer/pointCloudLayer.js} +42 -39
- package/src/{vcs/vcm/layer → layer}/rasterLayer.js +86 -37
- package/src/{vcs/vcm/layer/singleImage.js → layer/singleImageLayer.js} +25 -22
- package/src/layer/terrainHelpers.js +95 -0
- package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +28 -21
- package/src/{vcs/vcm/layer → layer}/tileLoadedHelper.js +13 -8
- package/src/{vcs/vcm/layer → layer}/tileProvider/mvtTileProvider.js +51 -8
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +87 -0
- package/src/{vcs/vcm/layer → layer}/tileProvider/tileProvider.js +200 -89
- package/src/{vcs/vcm/layer → layer}/tileProvider/urlTemplateTileProvider.js +54 -13
- package/src/{vcs/vcm/layer/tms.js → layer/tmsLayer.js} +22 -22
- package/src/layer/vectorHelpers.js +129 -0
- package/src/{vcs/vcm/layer/vector.js → layer/vectorLayer.js} +124 -94
- package/src/{vcs/vcm/layer → layer}/vectorProperties.js +419 -107
- package/src/{vcs/vcm/layer → layer}/vectorSymbols.js +11 -1
- package/src/{vcs/vcm/layer/vectorTile.js → layer/vectorTileLayer.js} +181 -116
- package/src/{vcs/vcm/layer/wfs.js → layer/wfsLayer.js} +33 -23
- package/src/{vcs/vcm/layer → layer}/wmsHelpers.js +14 -7
- package/src/{vcs/vcm/layer/wms.js → layer/wmsLayer.js} +53 -32
- package/src/{vcs/vcm/layer/wmts.js → layer/wmtsLayer.js} +56 -42
- package/src/{vcs/vcm/maps → map}/baseOLMap.js +83 -35
- package/src/{vcs/vcm/maps → map}/cameraLimiter.js +64 -37
- package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +431 -277
- package/src/{vcs/vcm/maps → map}/mapState.js +0 -1
- package/src/{vcs/vcm/maps/oblique.js → map/obliqueMap.js} +132 -97
- package/src/{vcs/vcm/maps/openlayers.js → map/openlayersMap.js} +69 -45
- package/src/{vcs/vcm/maps/map.js → map/vcsMap.js} +118 -46
- package/src/oblique/defaultObliqueCollection.js +62 -0
- package/src/{vcs/vcm/oblique → oblique}/helpers.js +221 -78
- package/src/{vcs/vcm/oblique/ObliqueCollection.js → oblique/obliqueCollection.js} +151 -55
- package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +77 -46
- package/src/{vcs/vcm/oblique/ObliqueImage.js → oblique/obliqueImage.js} +58 -26
- package/src/{vcs/vcm/oblique/ObliqueImageMeta.js → oblique/obliqueImageMeta.js} +9 -9
- package/src/{vcs/vcm/oblique/ObliqueProvider.js → oblique/obliqueProvider.js} +85 -35
- package/src/{vcs/vcm/oblique/ObliqueView.js → oblique/obliqueView.js} +45 -5
- package/src/{vcs/vcm/oblique/ObliqueViewDirection.js → oblique/obliqueViewDirection.js} +3 -5
- package/src/{vcs/vcm/oblique → oblique}/parseImageJson.js +62 -28
- package/src/ol/feature.js +34 -1
- package/src/ol/geom/circle.js +14 -5
- package/src/ol/geom/geometryCollection.js +14 -8
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -10
- package/src/overrideClassRegistry.js +214 -0
- package/src/style/arcStyle.js +453 -0
- package/src/style/arrowStyle.js +304 -0
- package/src/{vcs/vcm/util/style → style}/declarativeStyleItem.js +147 -82
- package/src/{vcs/vcm/util/style → style}/shapesCategory.js +8 -8
- package/src/style/styleFactory.js +32 -0
- package/src/{vcs/vcm/util/style → style}/styleHelpers.js +24 -26
- package/src/style/styleItem.js +174 -0
- package/src/{vcs/vcm/util/style → style}/vectorStyleItem.js +230 -156
- package/src/{vcs/vcm/util/style → style}/writeStyle.js +7 -12
- package/src/{vcs/vcm/util → util}/clipping/clippingObject.js +79 -49
- package/src/{vcs/vcm/util → util}/clipping/clippingObjectManager.js +56 -23
- package/src/{vcs/vcm/util → util}/clipping/clippingPlaneHelper.js +149 -88
- package/src/{vcs/vcm/util → util}/collection.js +28 -10
- package/src/util/editor/createFeatureSession.js +195 -0
- package/src/util/editor/editFeaturesSession.js +325 -0
- package/src/util/editor/editGeometrySession.js +452 -0
- package/src/util/editor/editorHelpers.js +300 -0
- package/src/util/editor/editorSessionHelpers.js +132 -0
- package/src/util/editor/editorSymbols.js +21 -0
- package/src/util/editor/interactions/createBBoxInteraction.js +154 -0
- package/src/util/editor/interactions/createCircleInteraction.js +119 -0
- package/src/util/editor/interactions/createLineStringInteraction.js +119 -0
- package/src/util/editor/interactions/createPointInteraction.js +73 -0
- package/src/util/editor/interactions/createPolygonInteraction.js +136 -0
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +88 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +119 -0
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +50 -0
- package/src/util/editor/interactions/insertVertexInteraction.js +103 -0
- package/src/util/editor/interactions/mapInteractionController.js +119 -0
- package/src/util/editor/interactions/removeVertexInteraction.js +42 -0
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +152 -0
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +165 -0
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +120 -0
- package/src/util/editor/interactions/translateVertexInteraction.js +60 -0
- package/src/util/editor/selectFeaturesSession.js +303 -0
- package/src/util/editor/transformation/create2DHandlers.js +339 -0
- package/src/util/editor/transformation/create3DHandlers.js +678 -0
- package/src/util/editor/transformation/extrudeInteraction.js +106 -0
- package/src/util/editor/transformation/rotateInteraction.js +201 -0
- package/src/util/editor/transformation/scaleInteraction.js +201 -0
- package/src/util/editor/transformation/transformationHandler.js +178 -0
- package/src/util/editor/transformation/transformationTypes.js +88 -0
- package/src/util/editor/transformation/translateInteraction.js +263 -0
- package/src/util/editor/validateGeoemetry.js +24 -0
- package/src/{vcs/vcm/util → util}/exclusiveManager.js +6 -3
- package/src/{vcs/vcm/util → util}/extent.js +26 -20
- package/src/util/featureconverter/arcToCesium.js +121 -0
- package/src/{vcs/vcm/util → util}/featureconverter/circleToCesium.js +70 -37
- package/src/{vcs/vcm/util → util}/featureconverter/convert.js +94 -16
- package/src/util/featureconverter/extent3D.js +284 -0
- package/src/{vcs/vcm/util → util}/featureconverter/featureconverterHelper.js +253 -94
- package/src/util/featureconverter/lineStringToCesium.js +343 -0
- package/src/util/featureconverter/pointHelpers.js +413 -0
- package/src/{vcs/vcm/util → util}/featureconverter/pointToCesium.js +157 -107
- package/src/{vcs/vcm/util → util}/featureconverter/polygonToCesium.js +57 -24
- package/src/util/fetch.js +34 -0
- package/src/{vcs/vcm/util → util}/geometryHelpers.js +25 -17
- package/src/{vcs/vcm/util → util}/indexedCollection.js +27 -8
- package/src/{vcs/vcm/util → util}/isMobile.js +8 -2
- package/src/{vcs/vcm/util → util}/layerCollection.js +109 -19
- package/src/util/locale.js +12 -0
- package/src/{vcs/vcm/util → util}/mapCollection.js +170 -63
- package/src/util/math.js +193 -0
- package/src/util/overrideCollection.js +261 -0
- package/src/{vcs/vcm/util → util}/projection.js +23 -31
- package/src/{vcs/vcm/util → util}/urlHelpers.js +5 -3
- package/src/{vcs/vcm/util → util}/viewpoint.js +83 -57
- package/src/vcsApp.js +657 -0
- package/src/{vcs/vcm/event/vcsEvent.js → vcsEvent.js} +2 -3
- package/src/vcsModule.js +130 -0
- package/src/vcsModuleHelpers.js +136 -0
- package/src/{vcs/vcm/object.js → vcsObject.js} +3 -10
- package/tests/data/dynamicPointCzml.json +53 -0
- package/tests/data/oblique/imageData/imagev34.json +136 -0
- package/tests/data/oblique/imageData/imagev35.json +307 -0
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +333 -0
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -0
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -0
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -0
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -0
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -0
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -0
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -0
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -0
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -0
- package/tests/data/oblique/tiledImageData/image.json +70 -0
- package/tests/data/terrain/13/8800/6485.terrain +0 -0
- package/tests/data/terrain/13/8800/6486.terrain +0 -0
- package/tests/data/terrain/13/8801/6485.terrain +0 -0
- package/tests/data/terrain/13/8801/6486.terrain +0 -0
- package/tests/data/terrain/layer.json +127 -0
- package/tests/data/testGeoJSON.json +149 -0
- package/tests/data/tile.pbf +0 -0
- package/tests/unit/helpers/cesiumHelpers.js +326 -0
- package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
- package/tests/unit/helpers/helpers.js +32 -0
- package/tests/unit/helpers/imageHelpers.js +24 -0
- package/tests/unit/helpers/importJSON.js +15 -0
- package/tests/unit/helpers/obliqueData.js +102 -0
- package/tests/unit/helpers/obliqueHelpers.js +115 -0
- package/tests/unit/helpers/openlayersHelpers.js +25 -0
- package/tests/unit/helpers/terrain/terrainData.js +45 -0
- package/src/vcs/vcm/classRegistry.js +0 -106
- package/src/vcs/vcm/globalCollections.js +0 -11
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +0 -54
- package/src/vcs/vcm/layer/buildings.js +0 -17
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +0 -29
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +0 -58
- package/src/vcs/vcm/layer/cesium/vectorContext.js +0 -167
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +0 -79
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +0 -27
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +0 -121
- package/src/vcs/vcm/layer/terrainHelpers.js +0 -119
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +0 -67
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +0 -28
- package/src/vcs/vcm/layer/vectorHelpers.js +0 -206
- package/src/vcs/vcm/util/dateTime.js +0 -60
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +0 -51
- package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +0 -171
- package/src/vcs/vcm/util/locale.js +0 -53
- package/src/vcs/vcm/util/math.js +0 -71
- package/src/vcs/vcm/util/splitScreen.js +0 -233
- package/src/vcs/vcm/util/style/styleFactory.js +0 -48
- package/src/vcs/vcm/util/style/styleItem.js +0 -243
- /package/src/{vcs/vcm/util/featureProvider → featureProvider}/featureProviderSymbols.js +0 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
1
|
import { unByKey } from 'ol/Observable.js';
|
|
3
2
|
import Feature from 'ol/Feature.js';
|
|
4
3
|
import { check } from '@vcsuite/check';
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
FeatureStoreLayerState,
|
|
6
|
+
featureStoreStateSymbol,
|
|
7
|
+
} from './featureStoreLayerState.js';
|
|
6
8
|
import { parseGeoJSON, writeGeoJSONFeature } from './geojsonHelpers.js';
|
|
7
|
-
import VcsObject from '../
|
|
9
|
+
import VcsObject from '../vcsObject.js';
|
|
10
|
+
import { requestJson } from '../util/fetch.js';
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* @typedef {Object} FeatureStoreTrackResults
|
|
@@ -26,22 +29,83 @@ import VcsObject from '../object.js';
|
|
|
26
29
|
* @property {boolean} changed
|
|
27
30
|
*/
|
|
28
31
|
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {Object} CommitAction
|
|
34
|
+
* @property {string} action
|
|
35
|
+
* @property {import("ol/format/GeoJSON").GeoJSONFeature} feature
|
|
36
|
+
* @property {import("ol").Feature<import("ol/geom/Geometry").default>} original
|
|
37
|
+
* @property {function(string=):void} success
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} added
|
|
42
|
+
* @param {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} edited
|
|
43
|
+
* @param {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} removed
|
|
44
|
+
* @returns {Array<CommitAction>}
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
export function createCommitActions(added, edited, removed) {
|
|
48
|
+
const actions = [];
|
|
49
|
+
added.forEach((f) => {
|
|
50
|
+
const feature = writeGeoJSONFeature(f, { writeStyle: true });
|
|
51
|
+
actions.push({
|
|
52
|
+
action: 'add',
|
|
53
|
+
feature,
|
|
54
|
+
original: f,
|
|
55
|
+
success(data) {
|
|
56
|
+
f.setId(data);
|
|
57
|
+
f[featureStoreStateSymbol] = FeatureStoreLayerState.DYNAMIC;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
edited.forEach((f) => {
|
|
63
|
+
const feature = writeGeoJSONFeature(f, { writeStyle: true });
|
|
64
|
+
feature._id = f.getId();
|
|
65
|
+
feature.geomety = 'test'; // XXX why test???
|
|
66
|
+
actions.push({
|
|
67
|
+
action: 'edit',
|
|
68
|
+
original: f,
|
|
69
|
+
feature,
|
|
70
|
+
success() {
|
|
71
|
+
if (f[featureStoreStateSymbol] === FeatureStoreLayerState.STATIC) {
|
|
72
|
+
f[featureStoreStateSymbol] = FeatureStoreLayerState.EDITED;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
removed.forEach((f) => {
|
|
79
|
+
const _id = f.getId();
|
|
80
|
+
actions.push({
|
|
81
|
+
original: f,
|
|
82
|
+
action: 'remove',
|
|
83
|
+
feature: { _id },
|
|
84
|
+
success() {},
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return actions;
|
|
89
|
+
}
|
|
90
|
+
|
|
29
91
|
/**
|
|
30
92
|
* do not construct directly, use the layers .changeTracker instead
|
|
31
93
|
* @class
|
|
32
94
|
* @extends {VcsObject}
|
|
33
95
|
* @api
|
|
34
96
|
*/
|
|
35
|
-
class
|
|
36
|
-
static get className() {
|
|
97
|
+
class FeatureStoreLayerChanges extends VcsObject {
|
|
98
|
+
static get className() {
|
|
99
|
+
return 'FeatureStoreLayerChanges';
|
|
100
|
+
}
|
|
37
101
|
|
|
38
102
|
/**
|
|
39
|
-
* @param {import("@vcmap/core").
|
|
103
|
+
* @param {import("@vcmap/core").FeatureStoreLayer} layer
|
|
40
104
|
*/
|
|
41
105
|
constructor(layer) {
|
|
42
106
|
super({});
|
|
43
107
|
|
|
44
|
-
/** @type {import("@vcmap/core").
|
|
108
|
+
/** @type {import("@vcmap/core").FeatureStoreLayer} */
|
|
45
109
|
this.layer = layer;
|
|
46
110
|
/** @type {FeatureStoreChangesListeners} */
|
|
47
111
|
this._changesListeners = {
|
|
@@ -69,7 +133,9 @@ class FeatureStoreChanges extends VcsObject {
|
|
|
69
133
|
* @returns {boolean}
|
|
70
134
|
* @api
|
|
71
135
|
*/
|
|
72
|
-
get active() {
|
|
136
|
+
get active() {
|
|
137
|
+
return Object.values(this._changesListeners).some((c) => c !== null);
|
|
138
|
+
}
|
|
73
139
|
|
|
74
140
|
/**
|
|
75
141
|
* starts tracking changes on the layer
|
|
@@ -78,15 +144,24 @@ class FeatureStoreChanges extends VcsObject {
|
|
|
78
144
|
*/
|
|
79
145
|
track() {
|
|
80
146
|
if (this._changesListeners.addfeature === null) {
|
|
81
|
-
this._changesListeners.addfeature = this.layer.source.on(
|
|
147
|
+
this._changesListeners.addfeature = this.layer.source.on(
|
|
148
|
+
'addfeature',
|
|
149
|
+
this._featureAdded.bind(this),
|
|
150
|
+
);
|
|
82
151
|
}
|
|
83
152
|
|
|
84
153
|
if (this._changesListeners.changefeature === null) {
|
|
85
|
-
this._changesListeners.changefeature = this.layer.source.on(
|
|
154
|
+
this._changesListeners.changefeature = this.layer.source.on(
|
|
155
|
+
'changefeature',
|
|
156
|
+
this._featureChanged.bind(this),
|
|
157
|
+
);
|
|
86
158
|
}
|
|
87
159
|
|
|
88
160
|
if (this._changesListeners.removefeature === null) {
|
|
89
|
-
this._changesListeners.removefeature = this.layer.source.on(
|
|
161
|
+
this._changesListeners.removefeature = this.layer.source.on(
|
|
162
|
+
'removefeature',
|
|
163
|
+
this._featureRemoved.bind(this),
|
|
164
|
+
);
|
|
90
165
|
}
|
|
91
166
|
}
|
|
92
167
|
|
|
@@ -104,88 +179,57 @@ class FeatureStoreChanges extends VcsObject {
|
|
|
104
179
|
/**
|
|
105
180
|
* commits the changes to the provided url. url should contain accessTokens and point to a featureStore layers bulk operation endpoint
|
|
106
181
|
* @param {string} url
|
|
182
|
+
* @param {Object<string, string>=} headers
|
|
107
183
|
* @returns {Promise<void>}
|
|
108
184
|
* @api
|
|
109
185
|
*/
|
|
110
|
-
commitChanges(url) {
|
|
111
|
-
const actions =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
186
|
+
async commitChanges(url, headers = {}) {
|
|
187
|
+
const actions = createCommitActions(
|
|
188
|
+
this._addedFeatures,
|
|
189
|
+
this._editedFeatures,
|
|
190
|
+
this._removedFeatures,
|
|
191
|
+
);
|
|
192
|
+
if (actions.length > 0) {
|
|
193
|
+
const data = await requestJson(url.toString(), {
|
|
194
|
+
method: 'POST',
|
|
195
|
+
headers: {
|
|
196
|
+
...headers,
|
|
197
|
+
'Content-Type': 'application/json',
|
|
121
198
|
},
|
|
199
|
+
body: JSON.stringify(
|
|
200
|
+
actions.map((a) => ({ action: a.action, feature: a.feature })),
|
|
201
|
+
),
|
|
122
202
|
});
|
|
123
|
-
});
|
|
124
203
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
action: 'edit',
|
|
131
|
-
original: f,
|
|
132
|
-
feature,
|
|
133
|
-
success() {
|
|
134
|
-
if (f[featureStoreStateSymbol] === featureStoreState.STATIC) {
|
|
135
|
-
f[featureStoreStateSymbol] = featureStoreState.EDITED;
|
|
136
|
-
}
|
|
137
|
-
},
|
|
204
|
+
const failures = data.failedActions.map(({ index, error }) => {
|
|
205
|
+
const action = actions[index];
|
|
206
|
+
this.getLogger().log(`failed action ${action.action}: ${error}`);
|
|
207
|
+
actions[index] = null;
|
|
208
|
+
return this._resetFeature(action.original);
|
|
138
209
|
});
|
|
139
|
-
});
|
|
140
210
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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);
|
|
211
|
+
actions
|
|
212
|
+
.filter((a) => a)
|
|
213
|
+
.forEach(({ action, success }) => {
|
|
214
|
+
if (action === 'add') {
|
|
215
|
+
success(data.insertedIds.shift()._id); // XXX should this be shift or should we find the index?
|
|
216
|
+
} else {
|
|
217
|
+
success();
|
|
218
|
+
}
|
|
173
219
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this._resetValues();
|
|
184
|
-
})
|
|
185
|
-
.catch((err) => {
|
|
186
|
-
this._resetValues();
|
|
220
|
+
await Promise.all(failures);
|
|
221
|
+
} else {
|
|
222
|
+
try {
|
|
223
|
+
await Promise.all(
|
|
224
|
+
[...this._convertedFeatures].map(async (f) => {
|
|
225
|
+
await this._resetFeature(f);
|
|
226
|
+
}),
|
|
227
|
+
);
|
|
228
|
+
} catch (err) {
|
|
187
229
|
this.getLogger().error(err.message);
|
|
188
|
-
}
|
|
230
|
+
}
|
|
231
|
+
this._resetValues();
|
|
232
|
+
}
|
|
189
233
|
}
|
|
190
234
|
|
|
191
235
|
/**
|
|
@@ -195,10 +239,18 @@ class FeatureStoreChanges extends VcsObject {
|
|
|
195
239
|
*/
|
|
196
240
|
async reset() {
|
|
197
241
|
const promises = [];
|
|
198
|
-
this._addedFeatures.forEach((f) => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this.
|
|
242
|
+
this._addedFeatures.forEach((f) => {
|
|
243
|
+
promises.push(this._resetFeature(f));
|
|
244
|
+
});
|
|
245
|
+
this._editedFeatures.forEach((f) => {
|
|
246
|
+
promises.push(this._resetFeature(f));
|
|
247
|
+
});
|
|
248
|
+
this._removedFeatures.forEach((f) => {
|
|
249
|
+
promises.push(this._resetFeature(f));
|
|
250
|
+
});
|
|
251
|
+
this._convertedFeatures.forEach((f) => {
|
|
252
|
+
promises.push(this._resetFeature(f));
|
|
253
|
+
});
|
|
202
254
|
return Promise.all(promises)
|
|
203
255
|
.then(() => {
|
|
204
256
|
this._resetValues();
|
|
@@ -222,19 +274,23 @@ class FeatureStoreChanges extends VcsObject {
|
|
|
222
274
|
return Promise.resolve();
|
|
223
275
|
}
|
|
224
276
|
|
|
225
|
-
if (feature[featureStoreStateSymbol] ===
|
|
277
|
+
if (feature[featureStoreStateSymbol] === FeatureStoreLayerState.STATIC) {
|
|
226
278
|
this.layer.resetStaticFeature(featureId);
|
|
227
279
|
return Promise.resolve();
|
|
228
280
|
}
|
|
229
281
|
|
|
230
|
-
return this.layer
|
|
282
|
+
return this.layer
|
|
283
|
+
.injectedFetchDynamicFeatureFunc(featureId)
|
|
231
284
|
.then((data) => {
|
|
232
285
|
const { features } = parseGeoJSON(data);
|
|
233
286
|
this.layer.removeFeaturesById(idArray);
|
|
234
287
|
this.layer.addFeatures(features);
|
|
235
288
|
})
|
|
236
289
|
.catch((err) => {
|
|
237
|
-
this.getLogger().error(
|
|
290
|
+
this.getLogger().error(
|
|
291
|
+
'failed to reset feature, giving up',
|
|
292
|
+
err.message,
|
|
293
|
+
);
|
|
238
294
|
});
|
|
239
295
|
}
|
|
240
296
|
|
|
@@ -279,7 +335,9 @@ class FeatureStoreChanges extends VcsObject {
|
|
|
279
335
|
if (!feature[featureStoreStateSymbol]) {
|
|
280
336
|
this._addedFeatures.add(feature);
|
|
281
337
|
this.values.changed = true;
|
|
282
|
-
} else if (
|
|
338
|
+
} else if (
|
|
339
|
+
feature[featureStoreStateSymbol] === FeatureStoreLayerState.STATIC
|
|
340
|
+
) {
|
|
283
341
|
this._convertedFeatures.add(feature);
|
|
284
342
|
this.values.changed = true;
|
|
285
343
|
}
|
|
@@ -357,4 +415,4 @@ class FeatureStoreChanges extends VcsObject {
|
|
|
357
415
|
}
|
|
358
416
|
}
|
|
359
417
|
|
|
360
|
-
export default
|
|
418
|
+
export default FeatureStoreLayerChanges;
|
|
@@ -10,9 +10,8 @@ export const featureStoreStateSymbol = Symbol('vcsFeatureType');
|
|
|
10
10
|
* @property {string} STATIC
|
|
11
11
|
* @property {string} EDITED
|
|
12
12
|
* @api
|
|
13
|
-
* @export
|
|
14
13
|
*/
|
|
15
|
-
export const
|
|
14
|
+
export const FeatureStoreLayerState = {
|
|
16
15
|
DYNAMIC: 'dynamic',
|
|
17
16
|
STATIC: 'static',
|
|
18
17
|
EDITED: 'edited',
|