@vcmap/core 5.0.0-rc.23 → 5.0.0-rc.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +824 -200
- package/index.js +24 -10
- package/package.json +2 -2
- package/src/category/category.js +1 -1
- package/src/featureProvider/abstractFeatureProvider.js +1 -18
- package/src/interaction/eventHandler.js +14 -0
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +4 -19
- package/src/layer/cesium/clusterContext.js +18 -0
- package/src/layer/cesium/vectorCesiumImpl.js +17 -2
- package/src/layer/cesium/vectorContext.js +187 -11
- package/src/layer/cesium/vectorRasterTileCesiumImpl.js +0 -1
- package/src/layer/cesiumTilesetLayer.js +1 -63
- package/src/layer/czmlLayer.js +1 -1
- package/src/layer/dataSourceLayer.js +1 -53
- package/src/layer/featureLayer.js +42 -38
- package/src/layer/featureStoreLayer.js +0 -15
- package/src/layer/layer.js +6 -11
- package/src/layer/layerSymbols.js +2 -1
- package/src/layer/oblique/vectorObliqueImpl.js +6 -0
- package/src/layer/openStreetMapLayer.js +6 -0
- package/src/layer/openlayers/layerOpenlayersImpl.js +69 -4
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +0 -80
- package/src/layer/rasterLayer.js +1 -1
- package/src/layer/vectorHelpers.js +0 -85
- package/src/layer/vectorLayer.js +1 -9
- package/src/layer/vectorProperties.js +150 -8
- package/src/layer/vectorTileLayer.js +0 -9
- package/src/map/baseOLMap.js +17 -0
- package/src/map/cesiumMap.js +46 -8
- package/src/map/vcsMap.js +23 -5
- package/src/style/arcStyle.js +316 -0
- package/src/style/arrowStyle.js +269 -0
- package/src/util/editor/createFeatureSession.js +3 -1
- package/src/util/editor/editFeaturesSession.js +315 -0
- package/src/util/editor/editGeometrySession.js +5 -1
- package/src/util/editor/editorHelpers.js +118 -14
- package/src/util/editor/editorSessionHelpers.js +12 -0
- package/src/util/editor/editorSymbols.js +6 -0
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +120 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +1 -3
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +48 -0
- package/src/util/editor/interactions/mapInteractionController.js +5 -2
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +146 -0
- package/src/util/editor/interactions/translateVertexInteraction.js +2 -2
- package/src/util/editor/transformation/create2DHandlers.js +294 -0
- package/src/util/editor/transformation/create3DHandlers.js +575 -0
- package/src/util/editor/transformation/extrudeInteraction.js +91 -0
- package/src/util/editor/transformation/rotateInteraction.js +188 -0
- package/src/util/editor/transformation/scaleInteraction.js +185 -0
- package/src/util/editor/transformation/transformationHandler.js +168 -0
- package/src/util/editor/transformation/transformationTypes.js +83 -0
- package/src/util/editor/transformation/translateInteraction.js +209 -0
- package/src/util/featureconverter/arcToCesium.js +87 -0
- package/src/util/featureconverter/convert.js +7 -1
- package/src/util/featureconverter/extent3D.js +64 -1
- package/src/util/featureconverter/lineStringToCesium.js +103 -2
- package/src/util/featureconverter/pointHelpers.js +341 -0
- package/src/util/featureconverter/pointToCesium.js +27 -76
- package/src/util/geometryHelpers.js +11 -8
- package/src/util/mapCollection.js +30 -24
- package/src/util/math.js +99 -2
- package/tests/unit/helpers/cesiumHelpers.js +14 -4
- package/tests/unit/helpers/helpers.js +13 -0
- package/src/featureProvider/featureProviderHelpers.js +0 -50
- package/src/util/splitScreen.js +0 -233
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
PrimitiveCollection,
|
|
3
|
+
BillboardCollection,
|
|
4
|
+
LabelCollection,
|
|
5
|
+
Matrix4,
|
|
6
|
+
Cartesian3,
|
|
7
|
+
Math as CesiumMath,
|
|
8
|
+
Model,
|
|
9
|
+
} from '@vcmap/cesium';
|
|
10
|
+
import Viewpoint from '../../util/viewpoint.js';
|
|
2
11
|
|
|
3
12
|
/**
|
|
4
13
|
* @typedef {Object} VectorContextFeatureCache
|
|
5
14
|
* @property {Array<import("@vcmap/cesium").Primitive|import("@vcmap/cesium").GroundPrimitive|import("@vcmap/cesium").GroundPolylinePrimitive|import("@vcmap/cesium").ClassificationPrimitive|import("@vcmap/cesium").Model>|undefined} primitives
|
|
15
|
+
* @property {Array<import("@vcmap/cesium").Primitive|import("@vcmap/cesium").GroundPrimitive|import("@vcmap/cesium").GroundPolylinePrimitive|import("@vcmap/cesium").ClassificationPrimitive|import("@vcmap/cesium").Model>|undefined} scaledPrimitives
|
|
6
16
|
* @property {Array<import("@vcmap/cesium").Billboard|import("@vcmap/cesium").Entity>|undefined} billboards
|
|
7
17
|
* @property {Array<import("@vcmap/cesium").Label|import("@vcmap/cesium").Entity>|undefined} labels
|
|
8
18
|
*/
|
|
@@ -31,10 +41,11 @@ export function removeArrayFromCollection(collection, array) {
|
|
|
31
41
|
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
32
42
|
* @param {Map<import("ol").Feature<import("ol/geom/Geometry").default>, Array<import("@vcmap/cesium").Primitive|import("@vcmap/cesium").GroundPrimitive|import("@vcmap/cesium").GroundPolylinePrimitive|import("@vcmap/cesium").ClassificationPrimitive|import("@vcmap/cesium").Billboard|import("@vcmap/cesium").Label|import("@vcmap/cesium").Entity|import("@vcmap/cesium").Model>>} featuresMap
|
|
33
43
|
* @param {import("@vcmap/cesium").PrimitiveCollection|import("@vcmap/cesium").BillboardCollection|import("@vcmap/cesium").LabelCollection|import("@vcmap/cesium").EntityCollection} primitiveCollection
|
|
44
|
+
* @returns {boolean} - if a feature was removed from the map
|
|
34
45
|
*/
|
|
35
46
|
export function removeFeatureFromMap(feature, featuresMap, primitiveCollection) {
|
|
36
47
|
removeArrayFromCollection(primitiveCollection, featuresMap.get(feature));
|
|
37
|
-
featuresMap.delete(feature);
|
|
48
|
+
return featuresMap.delete(feature);
|
|
38
49
|
}
|
|
39
50
|
|
|
40
51
|
/**
|
|
@@ -43,14 +54,26 @@ export function removeFeatureFromMap(feature, featuresMap, primitiveCollection)
|
|
|
43
54
|
* @param {boolean} allowPicking
|
|
44
55
|
* @param {import("@vcmap/cesium").BillboardCollection|import("@vcmap/cesium").LabelCollection|import("@vcmap/cesium").PrimitiveCollection|import("@vcmap/cesium").EntityCollection} primitiveCollection
|
|
45
56
|
* @param {Map<import("ol").Feature<import("ol/geom/Geometry").default>, Array<import("@vcmap/cesium").Billboard|import("@vcmap/cesium").Label|import("@vcmap/cesium").Primitive|import("@vcmap/cesium").GroundPrimitive|import("@vcmap/cesium").GroundPolylinePrimitive|import("@vcmap/cesium").ClassificationPrimitive|import("@vcmap/cesium").Entity|import("@vcmap/cesium").Model>>} featureMap
|
|
57
|
+
* @param {import("@vcmap/cesium").SplitDirection} [splitDirection]
|
|
46
58
|
*/
|
|
47
|
-
export function addPrimitiveToContext(
|
|
59
|
+
export function addPrimitiveToContext(
|
|
60
|
+
primitives,
|
|
61
|
+
feature,
|
|
62
|
+
allowPicking,
|
|
63
|
+
primitiveCollection,
|
|
64
|
+
featureMap,
|
|
65
|
+
splitDirection = undefined,
|
|
66
|
+
) {
|
|
48
67
|
if (primitives.length) {
|
|
49
68
|
const cesiumPrimitives = primitives.map((primitiveOptions) => {
|
|
50
69
|
const primitive = primitiveCollection.add(primitiveOptions);
|
|
51
70
|
if (allowPicking) {
|
|
52
71
|
setReferenceForPicking(feature, primitive);
|
|
53
72
|
}
|
|
73
|
+
if (splitDirection && primitive instanceof Model) {
|
|
74
|
+
// Cesium currently only supports splitDirection on Model primitives
|
|
75
|
+
primitive.splitDirection = splitDirection;
|
|
76
|
+
}
|
|
54
77
|
return primitive;
|
|
55
78
|
});
|
|
56
79
|
if (!featureMap.has(feature)) {
|
|
@@ -61,31 +84,111 @@ export function addPrimitiveToContext(primitives, feature, allowPicking, primiti
|
|
|
61
84
|
}
|
|
62
85
|
}
|
|
63
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Sets splitDirection on primitives. Currently only Model primitives support splitting.
|
|
89
|
+
* @param {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
90
|
+
* @param {import("@vcmap/cesium").PrimitiveCollection} primitives
|
|
91
|
+
*/
|
|
92
|
+
export function setSplitDirectionOnPrimitives(splitDirection, primitives) {
|
|
93
|
+
for (let i = 0; i < primitives.length; i++) {
|
|
94
|
+
const p = primitives.get(i);
|
|
95
|
+
if (p instanceof Model) {
|
|
96
|
+
p.splitDirection = splitDirection;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Symbol used in self scaling
|
|
103
|
+
* @type {symbol}
|
|
104
|
+
*/
|
|
105
|
+
const scaleSymbol = Symbol('Scale');
|
|
106
|
+
/**
|
|
107
|
+
* self scaling scratch
|
|
108
|
+
* @type {import("@vcmap/cesium").Cartesian3}
|
|
109
|
+
*/
|
|
110
|
+
const scratchCenter = new Cartesian3();
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Creates a self scaling primitive collection. It will scale a primitive of model in the collection
|
|
114
|
+
* in such a fashion, that the cartesian unit of 1 equals 1 pixel.
|
|
115
|
+
* @param {import("@vcmap/core").CesiumMap} map
|
|
116
|
+
* @param {import("@vcmap/cesium").PrimitiveCollection} primitiveCollection
|
|
117
|
+
* @param {{value: boolean}}dirtyRef
|
|
118
|
+
* @returns {function():void}
|
|
119
|
+
*/
|
|
120
|
+
export function setupScalingPrimitiveCollection(map, primitiveCollection, dirtyRef) {
|
|
121
|
+
let cachedVP = new Viewpoint({});
|
|
122
|
+
return map.getScene().postRender.addEventListener(() => {
|
|
123
|
+
const { length } = primitiveCollection;
|
|
124
|
+
if (length === 0) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const vp = map.getViewpointSync();
|
|
129
|
+
if (!dirtyRef.value && cachedVP.equals(vp, CesiumMath.EPSILON5)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
for (let i = 0; i < length; i++) {
|
|
134
|
+
const primitive = primitiveCollection.get(i);
|
|
135
|
+
if (!primitive.isDestroyed()) {
|
|
136
|
+
const { modelMatrix } = primitive;
|
|
137
|
+
const center = Matrix4.getTranslation(modelMatrix, scratchCenter);
|
|
138
|
+
const res = map.getCurrentResolutionFromCartesian(center);
|
|
139
|
+
if (primitive[scaleSymbol] !== res) {
|
|
140
|
+
primitive.modelMatrix = Matrix4.setScale(modelMatrix, new Cartesian3(res, res, res), new Matrix4());
|
|
141
|
+
primitive[scaleSymbol] = res;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
dirtyRef.value = false;
|
|
146
|
+
cachedVP = vp;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
64
150
|
/**
|
|
65
151
|
* @class
|
|
66
152
|
*/
|
|
67
153
|
class VectorContext {
|
|
68
154
|
/**
|
|
69
|
-
* @param {import("@vcmap/
|
|
155
|
+
* @param {import("@vcmap/core").CesiumMap} map
|
|
70
156
|
* @param {import("@vcmap/cesium").PrimitiveCollection} rootCollection
|
|
157
|
+
* @param {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
71
158
|
*/
|
|
72
|
-
constructor(
|
|
159
|
+
constructor(map, rootCollection, splitDirection) {
|
|
160
|
+
const scene = map.getScene();
|
|
73
161
|
/** @type {import("@vcmap/cesium").PrimitiveCollection} */
|
|
74
162
|
this.primitives = new PrimitiveCollection();
|
|
163
|
+
/** @type {import("@vcmap/cesium").PrimitiveCollection} */
|
|
164
|
+
this.scaledPrimitives = new PrimitiveCollection();
|
|
75
165
|
/** @type {import("@vcmap/cesium").BillboardCollection} */
|
|
76
166
|
this.billboards = new BillboardCollection({ scene });
|
|
77
167
|
/** @type {import("@vcmap/cesium").LabelCollection} */
|
|
78
168
|
this.labels = new LabelCollection({ scene });
|
|
79
169
|
/** @type {Map<import("ol").Feature<import("ol/geom/Geometry").default>, Array<import("@vcmap/cesium").Primitive|import("@vcmap/cesium").GroundPrimitive|import("@vcmap/cesium").GroundPolylinePrimitive|import("@vcmap/cesium").ClassificationPrimitive|import("@vcmap/cesium").Model>>} */
|
|
80
170
|
this.featureToPrimitiveMap = new Map();
|
|
171
|
+
/** @type {Map<import("ol").Feature<import("ol/geom/Geometry").default>, Array<import("@vcmap/cesium").Primitive|import("@vcmap/cesium").GroundPrimitive|import("@vcmap/cesium").GroundPolylinePrimitive|import("@vcmap/cesium").ClassificationPrimitive|import("@vcmap/cesium").Model>>} */
|
|
172
|
+
this.featureToScaledPrimitiveMap = new Map();
|
|
81
173
|
/** @type {Map<import("ol").Feature<import("ol/geom/Geometry").default>, Array<import("@vcmap/cesium").Billboard>>} */
|
|
82
174
|
this.featureToBillboardMap = new Map();
|
|
83
175
|
/** @type {Map<import("ol").Feature<import("ol/geom/Geometry").default>, Array<import("@vcmap/cesium").Label>>} */
|
|
84
176
|
this.featureToLabelMap = new Map();
|
|
177
|
+
/** @type {import("@vcmap/cesium").SplitDirection} */
|
|
178
|
+
this.splitDirection = splitDirection;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @type {import("@vcmap/cesium").PrimitiveCollection}
|
|
182
|
+
* @private
|
|
183
|
+
*/
|
|
184
|
+
this._rootCollection = rootCollection;
|
|
185
|
+
this._rootCollection.add(this.primitives);
|
|
186
|
+
this._rootCollection.add(this.scaledPrimitives);
|
|
187
|
+
this._rootCollection.add(this.billboards);
|
|
188
|
+
this._rootCollection.add(this.labels);
|
|
85
189
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
rootCollection.add(this.labels);
|
|
190
|
+
this._scaledDirty = { value: true };
|
|
191
|
+
this._postRenderListener = setupScalingPrimitiveCollection(map, this.scaledPrimitives, this._scaledDirty);
|
|
89
192
|
}
|
|
90
193
|
|
|
91
194
|
/**
|
|
@@ -94,7 +197,31 @@ class VectorContext {
|
|
|
94
197
|
* @param {boolean=} allowPicking
|
|
95
198
|
*/
|
|
96
199
|
addPrimitives(primitives, feature, allowPicking) {
|
|
97
|
-
addPrimitiveToContext(
|
|
200
|
+
addPrimitiveToContext(
|
|
201
|
+
primitives,
|
|
202
|
+
feature,
|
|
203
|
+
allowPicking,
|
|
204
|
+
this.primitives,
|
|
205
|
+
this.featureToPrimitiveMap,
|
|
206
|
+
this.splitDirection,
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @param {Array<import("@vcmap/cesium").Primitive|import("@vcmap/cesium").GroundPrimitive|import("@vcmap/cesium").GroundPolylinePrimitive|import("@vcmap/cesium").ClassificationPrimitive|import("@vcmap/cesium").Model>} primitives
|
|
212
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
213
|
+
* @param {boolean=} allowPicking
|
|
214
|
+
*/
|
|
215
|
+
addScaledPrimitives(primitives, feature, allowPicking) {
|
|
216
|
+
addPrimitiveToContext(
|
|
217
|
+
primitives,
|
|
218
|
+
feature,
|
|
219
|
+
allowPicking,
|
|
220
|
+
this.scaledPrimitives,
|
|
221
|
+
this.featureToScaledPrimitiveMap,
|
|
222
|
+
this.splitDirection,
|
|
223
|
+
);
|
|
224
|
+
this._scaledDirty.value = true;
|
|
98
225
|
}
|
|
99
226
|
|
|
100
227
|
/**
|
|
@@ -103,7 +230,14 @@ class VectorContext {
|
|
|
103
230
|
* @param {boolean=} allowPicking
|
|
104
231
|
*/
|
|
105
232
|
addBillboards(billboardOptions, feature, allowPicking) {
|
|
106
|
-
addPrimitiveToContext(
|
|
233
|
+
addPrimitiveToContext(
|
|
234
|
+
billboardOptions,
|
|
235
|
+
feature,
|
|
236
|
+
allowPicking,
|
|
237
|
+
this.billboards,
|
|
238
|
+
this.featureToBillboardMap,
|
|
239
|
+
this.splitDirection,
|
|
240
|
+
);
|
|
107
241
|
}
|
|
108
242
|
|
|
109
243
|
/**
|
|
@@ -112,7 +246,14 @@ class VectorContext {
|
|
|
112
246
|
* @param {boolean=} allowPicking
|
|
113
247
|
*/
|
|
114
248
|
addLabels(labelOptions, feature, allowPicking) {
|
|
115
|
-
addPrimitiveToContext(
|
|
249
|
+
addPrimitiveToContext(
|
|
250
|
+
labelOptions,
|
|
251
|
+
feature,
|
|
252
|
+
allowPicking,
|
|
253
|
+
this.labels,
|
|
254
|
+
this.featureToLabelMap,
|
|
255
|
+
this.splitDirection,
|
|
256
|
+
);
|
|
116
257
|
}
|
|
117
258
|
|
|
118
259
|
/**
|
|
@@ -120,6 +261,7 @@ class VectorContext {
|
|
|
120
261
|
*/
|
|
121
262
|
removeFeature(feature) {
|
|
122
263
|
removeFeatureFromMap(feature, this.featureToPrimitiveMap, this.primitives);
|
|
264
|
+
this._scaledDirty.value = removeFeatureFromMap(feature, this.featureToScaledPrimitiveMap, this.scaledPrimitives);
|
|
123
265
|
removeFeatureFromMap(feature, this.featureToBillboardMap, this.billboards);
|
|
124
266
|
removeFeatureFromMap(feature, this.featureToLabelMap, this.labels);
|
|
125
267
|
}
|
|
@@ -134,6 +276,8 @@ class VectorContext {
|
|
|
134
276
|
const cache = {};
|
|
135
277
|
cache.primitives = this.featureToPrimitiveMap.get(feature);
|
|
136
278
|
this.featureToPrimitiveMap.delete(feature);
|
|
279
|
+
cache.scaledPrimitives = this.featureToScaledPrimitiveMap.get(feature);
|
|
280
|
+
this.featureToScaledPrimitiveMap.delete(feature);
|
|
137
281
|
cache.billboards = this.featureToBillboardMap.get(feature);
|
|
138
282
|
this.featureToBillboardMap.delete(feature);
|
|
139
283
|
cache.labels = this.featureToLabelMap.get(feature);
|
|
@@ -146,21 +290,53 @@ class VectorContext {
|
|
|
146
290
|
*/
|
|
147
291
|
clearFeatureCache(cache) {
|
|
148
292
|
removeArrayFromCollection(this.primitives, cache.primitives);
|
|
293
|
+
removeArrayFromCollection(this.scaledPrimitives, cache.scaledPrimitives);
|
|
149
294
|
removeArrayFromCollection(this.billboards, cache.billboards);
|
|
150
295
|
removeArrayFromCollection(this.labels, cache.labels);
|
|
151
296
|
}
|
|
152
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Updates splitDirection on primitives. Currently only Model primitives support splitting.
|
|
300
|
+
* @param {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
301
|
+
*/
|
|
302
|
+
updateSplitDirection(splitDirection) {
|
|
303
|
+
this.splitDirection = splitDirection;
|
|
304
|
+
setSplitDirectionOnPrimitives(splitDirection, this.primitives);
|
|
305
|
+
setSplitDirectionOnPrimitives(splitDirection, this.scaledPrimitives);
|
|
306
|
+
}
|
|
307
|
+
|
|
153
308
|
/**
|
|
154
309
|
* Clears all collections and maps
|
|
155
310
|
* @api
|
|
156
311
|
*/
|
|
157
312
|
clear() {
|
|
158
313
|
this.primitives.removeAll();
|
|
314
|
+
this.scaledPrimitives.removeAll();
|
|
159
315
|
this.billboards.removeAll();
|
|
160
316
|
this.labels.removeAll();
|
|
161
317
|
this.featureToBillboardMap.clear();
|
|
162
318
|
this.featureToLabelMap.clear();
|
|
163
319
|
this.featureToPrimitiveMap.clear();
|
|
320
|
+
this._scaledDirty.value = this.featureToScaledPrimitiveMap.size > 0;
|
|
321
|
+
this.featureToScaledPrimitiveMap.clear();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Destroys this context and all its resources
|
|
326
|
+
*/
|
|
327
|
+
destroy() {
|
|
328
|
+
if (this._rootCollection) {
|
|
329
|
+
this._rootCollection.remove(this.primitives);
|
|
330
|
+
this._rootCollection.remove(this.scaledPrimitives);
|
|
331
|
+
this._rootCollection.remove(this.billboards);
|
|
332
|
+
this._rootCollection.remove(this.labels);
|
|
333
|
+
}
|
|
334
|
+
this._rootCollection = null;
|
|
335
|
+
this.featureToBillboardMap.clear();
|
|
336
|
+
this.featureToLabelMap.clear();
|
|
337
|
+
this.featureToPrimitiveMap.clear();
|
|
338
|
+
this.featureToScaledPrimitiveMap.clear();
|
|
339
|
+
this._postRenderListener();
|
|
164
340
|
}
|
|
165
341
|
}
|
|
166
342
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Matrix4 } from '@vcmap/cesium';
|
|
2
2
|
|
|
3
3
|
import { checkMaybe } from '@vcsuite/check';
|
|
4
4
|
import { parseInteger } from '@vcsuite/parsers';
|
|
@@ -7,7 +7,6 @@ import VectorStyleItem from '../style/vectorStyleItem.js';
|
|
|
7
7
|
import FeatureLayer from './featureLayer.js';
|
|
8
8
|
import CesiumTilesetCesiumImpl, { getExtentFromTileset } from './cesium/cesiumTilesetCesiumImpl.js';
|
|
9
9
|
import CesiumMap from '../map/cesiumMap.js';
|
|
10
|
-
import VcsEvent from '../vcsEvent.js';
|
|
11
10
|
import Extent from '../util/extent.js';
|
|
12
11
|
import { mercatorProjection } from '../util/projection.js';
|
|
13
12
|
import { isMobile } from '../util/isMobile.js';
|
|
@@ -21,7 +20,6 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
21
20
|
* @property {Object|undefined} tilesetOptions
|
|
22
21
|
* @property {import("@vcmap/core").VectorStyleItem|VectorStyleItemOptions|undefined} highlightStyle
|
|
23
22
|
* @property {import("@vcmap/core").FeatureVisibility|undefined} featureVisibility
|
|
24
|
-
* @property {string|undefined} splitDirection - either 'left' or 'right', if omitted none is applied
|
|
25
23
|
* @property {import("ol/coordinate").Coordinate|undefined} offset - an offset of x, y, z. x and y in degrees longitude/latitude respectively
|
|
26
24
|
* @api
|
|
27
25
|
*/
|
|
@@ -36,7 +34,6 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
36
34
|
/**
|
|
37
35
|
* @typedef {FeatureLayerImplementationOptions} CesiumTilesetImplementationOptions
|
|
38
36
|
* @property {Object|undefined} tilesetOptions
|
|
39
|
-
* @property {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
40
37
|
* @property {Array<CesiumTilesetTilesetProperties>|undefined} tilesetProperties
|
|
41
38
|
* @property {import("@vcmap/cesium").Matrix4|undefined} modelMatrix
|
|
42
39
|
* @property {import("ol/coordinate").Coordinate|undefined} offset
|
|
@@ -47,7 +44,6 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
47
44
|
* represents a specific Building layer for cesium.
|
|
48
45
|
* @class
|
|
49
46
|
* @extends {FeatureLayer}
|
|
50
|
-
* @implements {SplitLayer}
|
|
51
47
|
* @api stable
|
|
52
48
|
*/
|
|
53
49
|
class CesiumTilesetLayer extends FeatureLayer {
|
|
@@ -65,7 +61,6 @@ class CesiumTilesetLayer extends FeatureLayer {
|
|
|
65
61
|
screenSpaceErrorMobile: 32,
|
|
66
62
|
maximumMemoryUsage: 16,
|
|
67
63
|
tilesetOptions: {},
|
|
68
|
-
splitDirection: undefined,
|
|
69
64
|
offset: undefined,
|
|
70
65
|
};
|
|
71
66
|
}
|
|
@@ -109,22 +104,6 @@ class CesiumTilesetLayer extends FeatureLayer {
|
|
|
109
104
|
...tilesetOptions,
|
|
110
105
|
};
|
|
111
106
|
|
|
112
|
-
/** @type {import("@vcmap/cesium").SplitDirection} */
|
|
113
|
-
this._splitDirection = SplitDirection.NONE;
|
|
114
|
-
|
|
115
|
-
if (options.splitDirection) {
|
|
116
|
-
this._splitDirection = options.splitDirection === 'left' ?
|
|
117
|
-
SplitDirection.LEFT :
|
|
118
|
-
SplitDirection.RIGHT;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* raised if the split direction changes, is passed the split direction as its only argument
|
|
123
|
-
* @type {VcsEvent<import("@vcmap/cesium").SplitDirection>}
|
|
124
|
-
* @api
|
|
125
|
-
*/
|
|
126
|
-
this.splitDirectionChanged = new VcsEvent();
|
|
127
|
-
|
|
128
107
|
/**
|
|
129
108
|
* @type {import("@vcmap/cesium").Matrix4|undefined}
|
|
130
109
|
* @private
|
|
@@ -185,25 +164,6 @@ class CesiumTilesetLayer extends FeatureLayer {
|
|
|
185
164
|
});
|
|
186
165
|
}
|
|
187
166
|
|
|
188
|
-
/**
|
|
189
|
-
* @api
|
|
190
|
-
* @type {import("@vcmap/cesium").SplitDirection}
|
|
191
|
-
*/
|
|
192
|
-
get splitDirection() { return this._splitDirection; }
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* @param {import("@vcmap/cesium").SplitDirection} direction
|
|
196
|
-
*/
|
|
197
|
-
set splitDirection(direction) {
|
|
198
|
-
if (direction !== this._splitDirection) {
|
|
199
|
-
this.getImplementations().forEach((impl) => {
|
|
200
|
-
/** @type {CesiumTilesetCesiumImpl} */ (impl).updateSplitDirection(direction);
|
|
201
|
-
});
|
|
202
|
-
this._splitDirection = direction;
|
|
203
|
-
this.splitDirectionChanged.raiseEvent(this._splitDirection);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
167
|
/**
|
|
208
168
|
* @inheritDoc
|
|
209
169
|
* @returns {CesiumTilesetImplementationOptions}
|
|
@@ -212,7 +172,6 @@ class CesiumTilesetLayer extends FeatureLayer {
|
|
|
212
172
|
return {
|
|
213
173
|
...super.getImplementationOptions(),
|
|
214
174
|
tilesetOptions: this.tilesetOptions,
|
|
215
|
-
splitDirection: this.splitDirection,
|
|
216
175
|
modelMatrix: this.modelMatrix,
|
|
217
176
|
offset: this.offset,
|
|
218
177
|
};
|
|
@@ -276,20 +235,6 @@ class CesiumTilesetLayer extends FeatureLayer {
|
|
|
276
235
|
return null;
|
|
277
236
|
}
|
|
278
237
|
|
|
279
|
-
// TODO type params
|
|
280
|
-
getGenericFeatureFromClickedObject(object) {
|
|
281
|
-
const attributes = { ...this.genericFeatureProperties, ...object.attributes || object };
|
|
282
|
-
return {
|
|
283
|
-
layerName: this.name,
|
|
284
|
-
layerClass: this.className,
|
|
285
|
-
attributes,
|
|
286
|
-
longitude: object.clickedPosition.longitude,
|
|
287
|
-
latitude: object.clickedPosition.latitude,
|
|
288
|
-
height: object.clickedPosition.height + this.balloonHeightOffset,
|
|
289
|
-
relativeToGround: false,
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
|
|
293
238
|
/**
|
|
294
239
|
* set the maximum screenspace error of this layer
|
|
295
240
|
* @param {number} value
|
|
@@ -345,12 +290,6 @@ class CesiumTilesetLayer extends FeatureLayer {
|
|
|
345
290
|
config.tilesetOptions = tilesetOptions;
|
|
346
291
|
}
|
|
347
292
|
|
|
348
|
-
if (this._splitDirection !== SplitDirection.NONE) {
|
|
349
|
-
config.splitDirection = this._splitDirection === SplitDirection.RIGHT ?
|
|
350
|
-
'right' :
|
|
351
|
-
'left';
|
|
352
|
-
}
|
|
353
|
-
|
|
354
293
|
if (Array.isArray(this.offset)) {
|
|
355
294
|
config.offset = this.offset.slice();
|
|
356
295
|
}
|
|
@@ -364,7 +303,6 @@ class CesiumTilesetLayer extends FeatureLayer {
|
|
|
364
303
|
*/
|
|
365
304
|
destroy() {
|
|
366
305
|
super.destroy();
|
|
367
|
-
this.splitDirectionChanged.destroy();
|
|
368
306
|
}
|
|
369
307
|
}
|
|
370
308
|
|
package/src/layer/czmlLayer.js
CHANGED
|
@@ -6,12 +6,6 @@ import { vcsLayerName } from './layerSymbols.js';
|
|
|
6
6
|
import FeatureVisibility, { FeatureVisibilityAction } from './featureVisibility.js';
|
|
7
7
|
import { layerClassRegistry } from '../classRegistry.js';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {LayerOptions} DataSourceOptions
|
|
11
|
-
* @property {Object|undefined} genericFeatureProperties
|
|
12
|
-
* @api
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
9
|
/**
|
|
16
10
|
* @typedef {Object} DataSourcePickedObject
|
|
17
11
|
* @property {import("@vcmap/cesium").Entity} id
|
|
@@ -36,21 +30,10 @@ class DataSourceLayer extends Layer {
|
|
|
36
30
|
static get className() { return 'DataSourceLayer'; }
|
|
37
31
|
|
|
38
32
|
/**
|
|
39
|
-
* @
|
|
40
|
-
*/
|
|
41
|
-
static getDefaultOptions() {
|
|
42
|
-
return {
|
|
43
|
-
...Layer.getDefaultOptions(),
|
|
44
|
-
genericFeatureProperties: {},
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @param {DataSourceOptions} options
|
|
33
|
+
* @param {LayerOptions} options
|
|
50
34
|
*/
|
|
51
35
|
constructor(options) {
|
|
52
36
|
super(options);
|
|
53
|
-
const defaultOptions = DataSourceLayer.getDefaultOptions();
|
|
54
37
|
/**
|
|
55
38
|
* The entities of this layer. Use the `addEntity` API to add Enitities to ensure interoperability with vcm interfaces
|
|
56
39
|
* @type {import("@vcmap/cesium").EntityCollection}
|
|
@@ -61,12 +44,6 @@ class DataSourceLayer extends Layer {
|
|
|
61
44
|
* @type {import("@vcmap/cesium").DataSourceClock|undefined}
|
|
62
45
|
*/
|
|
63
46
|
this.clock = undefined;
|
|
64
|
-
/**
|
|
65
|
-
* @type {Object}
|
|
66
|
-
* @private
|
|
67
|
-
*/
|
|
68
|
-
this._genericFeatureProperties = options.genericFeatureProperties || defaultOptions.genericFeatureProperties;
|
|
69
|
-
|
|
70
47
|
/**
|
|
71
48
|
* The feature visibility of this layer. NOTE: Entities cannot be highlighted at this moment.
|
|
72
49
|
* @type {FeatureVisibility}
|
|
@@ -223,35 +200,6 @@ class DataSourceLayer extends Layer {
|
|
|
223
200
|
return null;
|
|
224
201
|
}
|
|
225
202
|
|
|
226
|
-
/**
|
|
227
|
-
* @param {DataSourcePickedObject} object
|
|
228
|
-
* @returns {GenericFeature}
|
|
229
|
-
*/
|
|
230
|
-
getGenericFeatureFromClickedObject(object) {
|
|
231
|
-
const attributes = { ...this._genericFeatureProperties, ...object.attributes || {} };
|
|
232
|
-
return {
|
|
233
|
-
layerName: this.name,
|
|
234
|
-
layerClass: this.className,
|
|
235
|
-
attributes,
|
|
236
|
-
longitude: object.clickedPosition.longitude,
|
|
237
|
-
latitude: object.clickedPosition.latitude,
|
|
238
|
-
height: object.clickedPosition.height,
|
|
239
|
-
relativeToGround: false,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* @inheritDoc
|
|
245
|
-
* @returns {DataSourceOptions}
|
|
246
|
-
*/
|
|
247
|
-
toJSON() {
|
|
248
|
-
const config = /** @type {DataSourceOptions} */ (super.toJSON());
|
|
249
|
-
if (Object.keys(this._genericFeatureProperties).length > 0) {
|
|
250
|
-
config.genericFeatureProperties = { ...this._genericFeatureProperties };
|
|
251
|
-
}
|
|
252
|
-
return config;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
203
|
/**
|
|
256
204
|
* @inheritDoc
|
|
257
205
|
*/
|