@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,647 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import Feature from 'ol/Feature.js';
|
|
3
|
+
import { Cesium3DTileFeature, Cesium3DTilePointFeature, ImagerySplitDirection } from '@vcmap/cesium';
|
|
4
|
+
import VectorSource from 'ol/source/Vector.js';
|
|
5
|
+
import { createEmpty, extend as extendExtent } from 'ol/extent.js';
|
|
6
|
+
|
|
7
|
+
import Vector from './vector.js';
|
|
8
|
+
import { featureStoreStateSymbol, featureStoreState } from './featureStoreState.js';
|
|
9
|
+
import { parseGeoJSON } from './geojsonHelpers.js';
|
|
10
|
+
import { mercatorProjection } from '../util/projection.js';
|
|
11
|
+
import FeatureStoreChanges from './featureStoreChanges.js';
|
|
12
|
+
import VectorStyleItem, { defaultVectorStyle, vectorStyleSymbol } from '../util/style/vectorStyleItem.js';
|
|
13
|
+
import FeatureVisibility, {
|
|
14
|
+
FeatureVisibilityAction,
|
|
15
|
+
originalStyle,
|
|
16
|
+
synchronizeFeatureVisibility,
|
|
17
|
+
updateOriginalStyle,
|
|
18
|
+
} from './featureVisibility.js';
|
|
19
|
+
import CesiumTilesetCesium, { getExtentFromTileset } from './cesium/cesiumTilesetCesium.js';
|
|
20
|
+
import CesiumMap from '../maps/cesium.js';
|
|
21
|
+
import Openlayers from '../maps/openlayers.js';
|
|
22
|
+
import Oblique from '../maps/oblique.js';
|
|
23
|
+
import CesiumTileset from './cesiumTileset.js';
|
|
24
|
+
import VectorProperties from './vectorProperties.js';
|
|
25
|
+
import VectorOpenlayers from './openlayers/vectorOpenlayers.js';
|
|
26
|
+
import Layer from './layer.js';
|
|
27
|
+
import DeclarativeStyleItem from '../util/style/declarativeStyleItem.js';
|
|
28
|
+
import VectorOblique from './oblique/vectorOblique.js';
|
|
29
|
+
import Extent from '../util/extent.js';
|
|
30
|
+
import { isMobile } from '../util/isMobile.js';
|
|
31
|
+
import { VcsClassRegistry } from '../classRegistry.js';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {Object} FeatureStoreStaticRepresentation
|
|
35
|
+
* @property {string|undefined} threeDim - 3D static representation of this layer
|
|
36
|
+
* @property {string|undefined} twoDim - 2D static representation for this layer
|
|
37
|
+
* @api
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {Object} FeatureStoreFeature
|
|
42
|
+
* @property {string} id - the mongo id
|
|
43
|
+
* @property {Object} properties - the properties bag
|
|
44
|
+
* @property {Object} geometry
|
|
45
|
+
* @property {Object|undefined} vcsMeta
|
|
46
|
+
* @property {featureStoreState} state
|
|
47
|
+
* @property {string} type - the featureType
|
|
48
|
+
* @todo write vcsMeta for features
|
|
49
|
+
* @todo set type to be one of an enum
|
|
50
|
+
* @api
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* For further details see: {@link http://gitlab/vcsuite/virtualcityMAP/wikis/featureStore/layerSchema}
|
|
55
|
+
* @typedef {VectorOptions} FeatureStoreLayerSchema
|
|
56
|
+
* @property {string} id - layer mongo id
|
|
57
|
+
* @property {string} type
|
|
58
|
+
* @property {string} featureType
|
|
59
|
+
* @property {FeatureStoreStaticRepresentation|undefined} staticRepresentation - URLs to static representations for 2D and 3D maps
|
|
60
|
+
* @property {Array<string|number>} hiddenStaticFeatureIds - an array of IDs of features to hide from the static representation
|
|
61
|
+
* @property {Array<FeatureStoreFeature>} features - the array of features to represent dynamic features
|
|
62
|
+
* @property {VcsMeta} vcsMeta - vector style implemented by the map and base64-encoded png icons used for custom styles
|
|
63
|
+
* @todo write type enum
|
|
64
|
+
* @api
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @typedef {FeatureStoreLayerSchema} FeatureStoreOptions
|
|
69
|
+
* @property {Function|undefined} injectedFetchDynamicFeatureFunc - injected function for fetching dynamic features from a remote FeatureStore server
|
|
70
|
+
* @api
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/** @type {symbol} */
|
|
74
|
+
export const isTiledFeature = Symbol('isTiledFeature');
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* FeatureStore Layer
|
|
78
|
+
* @class
|
|
79
|
+
* @export
|
|
80
|
+
* @extends {Vector}
|
|
81
|
+
* @api
|
|
82
|
+
*/
|
|
83
|
+
class FeatureStore extends Vector {
|
|
84
|
+
static get className() { return 'vcs.vcm.layer.FeatureStore'; }
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @returns {FeatureStoreOptions}
|
|
88
|
+
*/
|
|
89
|
+
static getDefaultOptions() {
|
|
90
|
+
return {
|
|
91
|
+
id: '',
|
|
92
|
+
type: 'vcs.vcm.layer.FeatureStore',
|
|
93
|
+
featureType: 'simple',
|
|
94
|
+
features: [],
|
|
95
|
+
...Vector.getDefaultOptions(),
|
|
96
|
+
projection: mercatorProjection.getConfigObject(),
|
|
97
|
+
staticRepresentation: {},
|
|
98
|
+
hiddenStaticFeatureIds: [],
|
|
99
|
+
vcsMeta: {
|
|
100
|
+
screenSpaceError: 4,
|
|
101
|
+
altitudeMode: 'clampToGround',
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// XXX cant implement getConfigOptions do to non layer options. this will most likely go away in 4.0
|
|
107
|
+
/**
|
|
108
|
+
* @param {FeatureStoreOptions} options
|
|
109
|
+
*/
|
|
110
|
+
constructor(options) {
|
|
111
|
+
const defaultOptions = FeatureStore.getDefaultOptions();
|
|
112
|
+
const vectorOptions = {
|
|
113
|
+
projection: defaultOptions.projection,
|
|
114
|
+
...options,
|
|
115
|
+
};
|
|
116
|
+
super(vectorOptions);
|
|
117
|
+
this._supportedMaps = [
|
|
118
|
+
CesiumMap.className,
|
|
119
|
+
Openlayers.className,
|
|
120
|
+
Oblique.className,
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Feature Store layers have feature UUIDs by design
|
|
125
|
+
* @type {boolean}
|
|
126
|
+
*/
|
|
127
|
+
this.hasFeatureUUID = true;
|
|
128
|
+
|
|
129
|
+
/** @type {string} */
|
|
130
|
+
this.layerId = options.id;
|
|
131
|
+
|
|
132
|
+
/** @type {FeatureStoreStaticRepresentation} */
|
|
133
|
+
this.staticRepresentation = options.staticRepresentation || defaultOptions.staticRepresentation;
|
|
134
|
+
|
|
135
|
+
/** @type {Set<string|number>} */
|
|
136
|
+
this.hiddenStaticFeatureIds = new Set(options.hiddenStaticFeatureIds || defaultOptions.hiddenStaticFeatureIds);
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @type {FeatureStoreChanges}
|
|
140
|
+
* @api
|
|
141
|
+
*/
|
|
142
|
+
this.changeTracker = new FeatureStoreChanges(this);
|
|
143
|
+
|
|
144
|
+
const { vcsMeta } = defaultOptions;
|
|
145
|
+
if (options.vcsMeta) {
|
|
146
|
+
Object.assign(vcsMeta, options.vcsMeta);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** @type {VcsMeta} */
|
|
150
|
+
this.vcsMeta = vcsMeta;
|
|
151
|
+
this.setVcsMeta(this.vcsMeta);
|
|
152
|
+
|
|
153
|
+
/** @type {number} */
|
|
154
|
+
this.screenSpaceErrorMobile = this.vcsMeta.screenSpaceError;
|
|
155
|
+
/** @type {number} */
|
|
156
|
+
this.screenSpaceError = this.vcsMeta.screenSpaceError;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @type {import("@vcmap/cesium").Event.RemoveCallback}
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
this._removeVectorPropertiesChangeHandler = this.vectorProperties.propertyChanged.addEventListener(() => {
|
|
163
|
+
this.changeTracker.values.changed = true;
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* a function to retrieve a single feature from the server
|
|
168
|
+
* @type {Function|undefined}
|
|
169
|
+
* @returns {Promise<string|Object>}
|
|
170
|
+
* @api
|
|
171
|
+
*/
|
|
172
|
+
this.injectedFetchDynamicFeatureFunc = options.injectedFetchDynamicFeatureFunc;
|
|
173
|
+
/**
|
|
174
|
+
* @type {FeatureVisibility}
|
|
175
|
+
* @private
|
|
176
|
+
*/
|
|
177
|
+
this._staticFeatureVisibility = new FeatureVisibility();
|
|
178
|
+
/**
|
|
179
|
+
* Synchronize featureVisibilities, while maintaining static features hidden.
|
|
180
|
+
* @type {Array<Function>}
|
|
181
|
+
* @private
|
|
182
|
+
*/
|
|
183
|
+
this._featureVisibilitySyncListeners = [
|
|
184
|
+
synchronizeFeatureVisibility(this.featureVisibility, this._staticFeatureVisibility),
|
|
185
|
+
this._staticFeatureVisibility.changed.addEventListener(({ action }) => {
|
|
186
|
+
if (action === FeatureVisibilityAction.SHOW) {
|
|
187
|
+
this._staticFeatureVisibility.hideObjects([...this.hiddenStaticFeatureIds]);
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @type {Object|null}
|
|
194
|
+
* @private
|
|
195
|
+
*/
|
|
196
|
+
this._setEditing = null;
|
|
197
|
+
/**
|
|
198
|
+
* @type {Promise<void>|null}
|
|
199
|
+
* @private
|
|
200
|
+
*/
|
|
201
|
+
this._twoDimLoaded = null;
|
|
202
|
+
/**
|
|
203
|
+
* @type {Function|null}
|
|
204
|
+
* @private
|
|
205
|
+
*/
|
|
206
|
+
this._twoDimStyleChanged = null;
|
|
207
|
+
/**
|
|
208
|
+
* @type {import("ol/source").Vector<import("ol/geom/Geometry").default>}
|
|
209
|
+
* @private
|
|
210
|
+
*/
|
|
211
|
+
this._twoDimStaticSource = new VectorSource();
|
|
212
|
+
|
|
213
|
+
if (options.features) {
|
|
214
|
+
const featureCollection = {
|
|
215
|
+
type: 'FeatureCollection',
|
|
216
|
+
features: options.features,
|
|
217
|
+
vcsMeta: options.vcsMeta,
|
|
218
|
+
};
|
|
219
|
+
const { style, features } = parseGeoJSON(
|
|
220
|
+
featureCollection,
|
|
221
|
+
{ targetProjection: mercatorProjection, dynamicStyle: true },
|
|
222
|
+
);
|
|
223
|
+
if (style) {
|
|
224
|
+
this._defaultStyle = style;
|
|
225
|
+
this.setStyle(style);
|
|
226
|
+
}
|
|
227
|
+
this.addFeatures(features);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @inheritDoc
|
|
233
|
+
* @returns {Promise<void>}
|
|
234
|
+
*/
|
|
235
|
+
initialize() {
|
|
236
|
+
if (!this.initialized) {
|
|
237
|
+
return super.initialize()
|
|
238
|
+
.then(() => {
|
|
239
|
+
this._staticFeatureVisibility.hideObjects([...this.hiddenStaticFeatureIds]);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return super.initialize();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @returns {Promise<void>}
|
|
247
|
+
* @private
|
|
248
|
+
*/
|
|
249
|
+
_loadTwoDim() {
|
|
250
|
+
if (!this._twoDimLoaded) {
|
|
251
|
+
this._twoDimLoaded = (async () => {
|
|
252
|
+
const { data } = await axios.get(this.staticRepresentation.twoDim);
|
|
253
|
+
const { features } = parseGeoJSON(data, {
|
|
254
|
+
targetProjection: mercatorProjection,
|
|
255
|
+
dynamicStyle: true,
|
|
256
|
+
});
|
|
257
|
+
const isDeclarative = this.style instanceof DeclarativeStyleItem;
|
|
258
|
+
features
|
|
259
|
+
.forEach((feature) => {
|
|
260
|
+
feature[Layer.vcsLayerNameSymbol] = this.name;
|
|
261
|
+
feature[isTiledFeature] = true;
|
|
262
|
+
if (isDeclarative && feature[vectorStyleSymbol]) {
|
|
263
|
+
feature.setStyle();
|
|
264
|
+
}
|
|
265
|
+
if (this._setEditing && this._setEditing.featureType != null) {
|
|
266
|
+
feature[this._setEditing.symbol] = this._setEditing.featureType;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
this._twoDimStaticSource.addFeatures(
|
|
270
|
+
/** @type {Array<import("ol").Feature<import("ol/geom/Geometry").default>>} */ (features),
|
|
271
|
+
);
|
|
272
|
+
})();
|
|
273
|
+
}
|
|
274
|
+
return this._twoDimLoaded;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @returns {VectorImplementationOptions}
|
|
279
|
+
* @private
|
|
280
|
+
*/
|
|
281
|
+
_getTwoDimStaticImplOptions() {
|
|
282
|
+
return {
|
|
283
|
+
...super.getImplementationOptions(),
|
|
284
|
+
source: this._twoDimStaticSource,
|
|
285
|
+
featureVisibility: this._staticFeatureVisibility,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @param {import("@vcmap/core").VcsMap} map
|
|
291
|
+
* @returns {Array<VectorOblique|import("@vcmap/core").VectorCesium|VectorOpenlayers|CesiumTilesetCesium>}
|
|
292
|
+
*/
|
|
293
|
+
// @ts-ignore
|
|
294
|
+
createImplementationsForMap(map) {
|
|
295
|
+
const impls = /** @type {Array<import("@vcmap/core").LayerImplementation>} */
|
|
296
|
+
(super.createImplementationsForMap(map));
|
|
297
|
+
if (map instanceof CesiumMap && this.staticRepresentation && this.staticRepresentation.threeDim) {
|
|
298
|
+
impls.push(new CesiumTilesetCesium(map, /** @type {CesiumTilesetImplementationOptions} */ ({
|
|
299
|
+
url: this.staticRepresentation.threeDim,
|
|
300
|
+
tilesetOptions: {
|
|
301
|
+
maximumScreenSpaceError: isMobile() ? this.screenSpaceErrorMobile : this.screenSpaceError,
|
|
302
|
+
url: this.staticRepresentation.threeDim,
|
|
303
|
+
},
|
|
304
|
+
tilesetProperties: [
|
|
305
|
+
{
|
|
306
|
+
key: isTiledFeature,
|
|
307
|
+
value: true,
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
name: this.name,
|
|
311
|
+
style: this.style,
|
|
312
|
+
featureVisibility: this._staticFeatureVisibility,
|
|
313
|
+
splitDirection: ImagerySplitDirection.NONE,
|
|
314
|
+
jumpToLocation: false,
|
|
315
|
+
})));
|
|
316
|
+
} else if (this.staticRepresentation && this.staticRepresentation.twoDim) {
|
|
317
|
+
this._loadTwoDim();
|
|
318
|
+
if (map instanceof Openlayers) {
|
|
319
|
+
impls.push(new VectorOpenlayers(map, this._getTwoDimStaticImplOptions()));
|
|
320
|
+
} else if (map instanceof Oblique) {
|
|
321
|
+
impls.push(new VectorOblique(map, this._getTwoDimStaticImplOptions()));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// eslint-disable-next-line max-len
|
|
325
|
+
return /** @type {Array<VectorOblique|import("@vcmap/core").VectorCesium|VectorOpenlayers|CesiumTilesetCesium>} */ (impls);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @inheritDoc
|
|
330
|
+
* @returns {Promise<void>}
|
|
331
|
+
*/
|
|
332
|
+
reload() {
|
|
333
|
+
this._twoDimLoaded = null;
|
|
334
|
+
this._twoDimStaticSource.clear();
|
|
335
|
+
return super.reload();
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* @inheritDoc
|
|
340
|
+
* @returns {Promise<void>}
|
|
341
|
+
* @api
|
|
342
|
+
*/
|
|
343
|
+
async activate() {
|
|
344
|
+
await super.activate();
|
|
345
|
+
if (this.active && this._setEditing) {
|
|
346
|
+
this.setEditing(this._setEditing.symbol, this._setEditing.featureType);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* @protected
|
|
352
|
+
*/
|
|
353
|
+
_trackStyleChanges() {
|
|
354
|
+
super._trackStyleChanges();
|
|
355
|
+
if (this.staticRepresentation.twoDim) {
|
|
356
|
+
if (this._twoDimStyleChanged) {
|
|
357
|
+
this._twoDimStyleChanged();
|
|
358
|
+
this._twoDimStyleChanged = null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const isDeclarative = this.style instanceof DeclarativeStyleItem;
|
|
362
|
+
this._twoDimStyleChanged = this.style.styleChanged.addEventListener(() => {
|
|
363
|
+
this._twoDimStaticSource.getFeatures().forEach((f) => {
|
|
364
|
+
if (isDeclarative || !f[vectorStyleSymbol]) {
|
|
365
|
+
f.changed();
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @inheritDoc
|
|
374
|
+
* @param {string|import("ol/style/Style").default|import("ol/style/Style").StyleFunction|import("@vcmap/core").StyleItem} style
|
|
375
|
+
* @param {boolean=} silent
|
|
376
|
+
* @api
|
|
377
|
+
*/
|
|
378
|
+
setStyle(style, silent) {
|
|
379
|
+
const changeTrackerActive = this.changeTracker.active;
|
|
380
|
+
if (changeTrackerActive) {
|
|
381
|
+
this.changeTracker.pauseTracking('changefeature');
|
|
382
|
+
}
|
|
383
|
+
super.setStyle(style, silent);
|
|
384
|
+
const isDeclarative = this.style instanceof DeclarativeStyleItem;
|
|
385
|
+
this._twoDimStaticSource.getFeatures().forEach((f) => {
|
|
386
|
+
if (f[vectorStyleSymbol]) {
|
|
387
|
+
let changed;
|
|
388
|
+
if (isDeclarative) {
|
|
389
|
+
changed = true;
|
|
390
|
+
f.setStyle(undefined);
|
|
391
|
+
} else if (f.getStyle() !== f[vectorStyleSymbol].style) {
|
|
392
|
+
changed = true;
|
|
393
|
+
f.setStyle(f[vectorStyleSymbol].style);
|
|
394
|
+
}
|
|
395
|
+
if (changed && Reflect.has(f, originalStyle)) {
|
|
396
|
+
updateOriginalStyle(f);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
if (changeTrackerActive) {
|
|
401
|
+
this.changeTracker.track();
|
|
402
|
+
this.changeTracker.values.changed = true;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @param {symbol} symbol
|
|
408
|
+
* @param {number=} featureType
|
|
409
|
+
*/
|
|
410
|
+
setEditing(symbol, featureType) {
|
|
411
|
+
this.getImplementations().forEach((impl) => {
|
|
412
|
+
if (impl instanceof CesiumTilesetCesium) {
|
|
413
|
+
if (impl.initialized) {
|
|
414
|
+
if (featureType != null) {
|
|
415
|
+
impl.cesium3DTileset[symbol] = featureType;
|
|
416
|
+
} else {
|
|
417
|
+
delete impl.cesium3DTileset[symbol];
|
|
418
|
+
}
|
|
419
|
+
this._setEditing = null;
|
|
420
|
+
} else {
|
|
421
|
+
this._setEditing = { symbol, featureType };
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
if (this.staticRepresentation.twoDim) {
|
|
427
|
+
if (this._twoDimLoaded) {
|
|
428
|
+
this._twoDimLoaded.then(() => {
|
|
429
|
+
this._twoDimStaticSource.getFeatures()
|
|
430
|
+
.forEach((f) => {
|
|
431
|
+
if (featureType != null) {
|
|
432
|
+
f[symbol] = featureType;
|
|
433
|
+
} else {
|
|
434
|
+
delete f[symbol];
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
} else {
|
|
439
|
+
this._setEditing = { symbol, featureType };
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* @param {Object|import("ol").Feature<import("ol/geom/Geometry").default>|import("@vcmap/cesium").Cesium3DTilePointFeature|import("@vcmap/cesium").Cesium3DTileFeature} feature
|
|
446
|
+
* @returns {?Object}
|
|
447
|
+
*/
|
|
448
|
+
objectClickedHandler(feature) {
|
|
449
|
+
if ((feature instanceof Cesium3DTileFeature || feature instanceof Cesium3DTilePointFeature)) {
|
|
450
|
+
return CesiumTileset.prototype.objectClickedHandler.call(this, feature);
|
|
451
|
+
} else if (feature instanceof Feature) {
|
|
452
|
+
return super.objectClickedHandler(feature);
|
|
453
|
+
}
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* @param {Object|VectorClickedObject} object
|
|
459
|
+
* @returns {GenericFeature}
|
|
460
|
+
*/
|
|
461
|
+
getGenericFeatureFromClickedObject(object) {
|
|
462
|
+
if (object instanceof Feature) {
|
|
463
|
+
// @ts-ignore
|
|
464
|
+
return super.getGenericFeatureFromClickedObject(/** @type {VectorClickedObject} */ (object));
|
|
465
|
+
}
|
|
466
|
+
const generic = CesiumTileset.prototype.getGenericFeatureFromClickedObject.call(this, object);
|
|
467
|
+
generic.layerName = this.name;
|
|
468
|
+
generic.layerClass = this.className;
|
|
469
|
+
return generic;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* @inheritDoc
|
|
474
|
+
* @returns {Extent|null}
|
|
475
|
+
* @api
|
|
476
|
+
*/
|
|
477
|
+
getZoomToExtent() {
|
|
478
|
+
if (this.extent && this.extent.isValid()) {
|
|
479
|
+
return this.extent;
|
|
480
|
+
}
|
|
481
|
+
const extent = super.getZoomToExtent();
|
|
482
|
+
const mercatorExtent = extent ? extent.getCoordinatesInProjection(mercatorProjection) : createEmpty();
|
|
483
|
+
if (this.staticRepresentation.threeDim) {
|
|
484
|
+
const threeDImpl = /** @type {CesiumTilesetCesium} */ (this.getImplementations()
|
|
485
|
+
.find((impl) => {
|
|
486
|
+
return impl instanceof CesiumTilesetCesium && impl.cesium3DTileset;
|
|
487
|
+
}));
|
|
488
|
+
|
|
489
|
+
if (threeDImpl) {
|
|
490
|
+
const threeDimExtent = getExtentFromTileset(threeDImpl.cesium3DTileset);
|
|
491
|
+
extendExtent(mercatorExtent, threeDimExtent);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (this.staticRepresentation.twoDim && this._twoDimLoaded) {
|
|
496
|
+
extendExtent(mercatorExtent, this._twoDimStaticSource.getExtent());
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const actualExtent = new Extent({
|
|
500
|
+
...mercatorProjection.getConfigObject(),
|
|
501
|
+
coordinates: mercatorExtent,
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
if (actualExtent.isValid()) {
|
|
505
|
+
return actualExtent;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* set the maximum screen space error of this layer
|
|
513
|
+
* @param {number} value
|
|
514
|
+
* @api stable
|
|
515
|
+
*/
|
|
516
|
+
setMaximumScreenSpaceError(value) {
|
|
517
|
+
if (isMobile()) {
|
|
518
|
+
this.screenSpaceErrorMobile = value;
|
|
519
|
+
} else {
|
|
520
|
+
this.screenSpaceError = value;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
this.getImplementations()
|
|
524
|
+
.forEach((impl) => {
|
|
525
|
+
if (impl instanceof CesiumTilesetCesium && impl.cesium3DTileset) {
|
|
526
|
+
impl.cesium3DTileset.maximumScreenSpaceError = value;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* switch an array of static features to dynamic features
|
|
533
|
+
* This is done by hiding the static features and adding their dynamic counterparts to the FeatureStore layer
|
|
534
|
+
* @param {string|number} [featureId] input static feature ID
|
|
535
|
+
* @returns {Promise<import("ol").Feature<import("ol/geom/Geometry").default>>}
|
|
536
|
+
* @api
|
|
537
|
+
*/
|
|
538
|
+
switchStaticFeatureToDynamic(featureId) {
|
|
539
|
+
if (this.hiddenStaticFeatureIds.has(featureId)) {
|
|
540
|
+
return Promise.resolve(this.getFeatureById(featureId));
|
|
541
|
+
}
|
|
542
|
+
if (this.injectedFetchDynamicFeatureFunc) {
|
|
543
|
+
return this.injectedFetchDynamicFeatureFunc(featureId)
|
|
544
|
+
.then((result) => {
|
|
545
|
+
const { features } = parseGeoJSON(
|
|
546
|
+
result,
|
|
547
|
+
{
|
|
548
|
+
targetProjection: mercatorProjection,
|
|
549
|
+
defaultStyle: this.defaultStyle instanceof VectorStyleItem ?
|
|
550
|
+
this.defaultStyle :
|
|
551
|
+
defaultVectorStyle,
|
|
552
|
+
},
|
|
553
|
+
);
|
|
554
|
+
this._staticFeatureVisibility.hideObjects([featureId]);
|
|
555
|
+
this.hiddenStaticFeatureIds.add(featureId);
|
|
556
|
+
this.addFeatures(features);
|
|
557
|
+
return features[0];
|
|
558
|
+
})
|
|
559
|
+
.catch((err) => {
|
|
560
|
+
this.getLogger().error(err.message);
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
return Promise.reject(new Error('no injected fetching function'));
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* removes a static feature from featureStore layer
|
|
568
|
+
* @param {string} featureId
|
|
569
|
+
* @api
|
|
570
|
+
*/
|
|
571
|
+
removeStaticFeature(featureId) {
|
|
572
|
+
this._staticFeatureVisibility.hideObjects([featureId]);
|
|
573
|
+
this.hiddenStaticFeatureIds.add(featureId);
|
|
574
|
+
const feature = new Feature();
|
|
575
|
+
feature.setId(featureId);
|
|
576
|
+
feature[featureStoreStateSymbol] = featureStoreState.STATIC;
|
|
577
|
+
this.changeTracker.removeFeature(feature);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Resets a feature which used to be static but is now dynamic. called from featureStoreChanges API.
|
|
582
|
+
* @param {string|number} featureId
|
|
583
|
+
*/
|
|
584
|
+
resetStaticFeature(featureId) {
|
|
585
|
+
if (this.hiddenStaticFeatureIds.has(featureId)) {
|
|
586
|
+
const idArray = [featureId];
|
|
587
|
+
this.removeFeaturesById(idArray);
|
|
588
|
+
this.hiddenStaticFeatureIds.delete(featureId);
|
|
589
|
+
if (!this.featureVisibility.hiddenObjects[featureId]) {
|
|
590
|
+
this._staticFeatureVisibility.showObjects(idArray);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* @inheritDoc
|
|
597
|
+
* @returns {FeatureStoreOptions}
|
|
598
|
+
*/
|
|
599
|
+
getConfigObject() {
|
|
600
|
+
const config = /** @type {FeatureStoreOptions} */ (super.getConfigObject());
|
|
601
|
+
const defaultOptions = FeatureStore.getDefaultOptions();
|
|
602
|
+
|
|
603
|
+
delete config.projection;
|
|
604
|
+
config.vcsMeta = this.vectorProperties
|
|
605
|
+
.getVcsMeta({ ...VectorProperties.getDefaultOptions(), ...defaultOptions.vcsMeta });
|
|
606
|
+
if (Object.keys(config.vcsMeta).length === 0) {
|
|
607
|
+
delete config.vcsMeta;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (this.vcsMeta.screenSpaceError !== defaultOptions.vcsMeta.screenSpaceError) {
|
|
611
|
+
config.vcsMeta = config.vcsMeta || {};
|
|
612
|
+
config.vcsMeta.screenSpaceError = this.vcsMeta.screenSpaceError;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (Object.keys(this.staticRepresentation).length > 0) {
|
|
616
|
+
config.staticRepresentation = { ...this.staticRepresentation };
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if (this.hiddenStaticFeatureIds.size > 0) {
|
|
620
|
+
config.hiddenStaticFeatureIds = [...this.hiddenStaticFeatureIds];
|
|
621
|
+
}
|
|
622
|
+
return config;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* @inheritDoc
|
|
627
|
+
*/
|
|
628
|
+
destroy() {
|
|
629
|
+
this.removeAllFeatures();
|
|
630
|
+
this._twoDimStaticSource.clear();
|
|
631
|
+
if (this._twoDimStyleChanged) {
|
|
632
|
+
this._twoDimStyleChanged();
|
|
633
|
+
this._twoDimStyleChanged = null;
|
|
634
|
+
}
|
|
635
|
+
this._featureVisibilitySyncListeners.forEach((cb) => { cb(); });
|
|
636
|
+
this._featureVisibilitySyncListeners = [];
|
|
637
|
+
this._staticFeatureVisibility.destroy();
|
|
638
|
+
this.changeTracker.destroy();
|
|
639
|
+
if (this._removeVectorPropertiesChangeHandler) {
|
|
640
|
+
this._removeVectorPropertiesChangeHandler();
|
|
641
|
+
}
|
|
642
|
+
super.destroy();
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
VcsClassRegistry.registerClass(FeatureStore.className, FeatureStore);
|
|
647
|
+
export default FeatureStore;
|