@vcmap/core 6.0.0-rc.4 → 6.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cesium.d.ts +11 -0
- package/dist/index.d.ts +23 -16
- package/dist/index.js +21 -14
- package/dist/index.js.map +1 -1
- package/dist/ol.d.ts +15 -2
- package/dist/src/layer/cesium/clusterContext.d.ts +8 -14
- package/dist/src/layer/cesium/clusterContext.js +62 -41
- package/dist/src/layer/cesium/clusterContext.js.map +1 -1
- package/dist/src/layer/cesium/vectorCesiumImpl.d.ts +2 -3
- package/dist/src/layer/cesium/vectorCesiumImpl.js +16 -10
- package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorContext.d.ts +10 -53
- package/dist/src/layer/cesium/vectorContext.js +88 -172
- package/dist/src/layer/cesium/vectorContext.js.map +1 -1
- package/dist/src/layer/geojsonHelpers.d.ts +1 -1
- package/dist/src/layer/geojsonHelpers.js +5 -10
- package/dist/src/layer/geojsonHelpers.js.map +1 -1
- package/dist/src/layer/oblique/obliqueHelpers.js +6 -6
- package/dist/src/layer/oblique/obliqueHelpers.js.map +1 -1
- package/dist/src/layer/vectorLayer.d.ts +0 -37
- package/dist/src/layer/vectorLayer.js.map +1 -1
- package/dist/src/layer/vectorProperties.d.ts +8 -3
- package/dist/src/layer/vectorProperties.js +30 -5
- package/dist/src/layer/vectorProperties.js.map +1 -1
- package/dist/src/map/baseOLMap.js +1 -1
- package/dist/src/map/baseOLMap.js.map +1 -1
- package/dist/src/map/obliqueMap.d.ts +3 -0
- package/dist/src/map/obliqueMap.js +27 -6
- package/dist/src/map/obliqueMap.js.map +1 -1
- package/dist/src/map/vcsMap.d.ts +8 -0
- package/dist/src/map/vcsMap.js +11 -0
- package/dist/src/map/vcsMap.js.map +1 -1
- package/dist/src/oblique/helpers.js +5 -5
- package/dist/src/oblique/helpers.js.map +1 -1
- package/dist/src/oblique/obliqueDataSet.js +4 -4
- package/dist/src/oblique/obliqueDataSet.js.map +1 -1
- package/dist/src/ol/geom/geometryCollection.js +19 -2
- package/dist/src/ol/geom/geometryCollection.js.map +1 -1
- package/dist/src/style/arcStyle.js +1 -0
- package/dist/src/style/arcStyle.js.map +1 -1
- package/dist/src/util/editor/createFeatureSession.d.ts +5 -1
- package/dist/src/util/editor/createFeatureSession.js +48 -4
- package/dist/src/util/editor/createFeatureSession.js.map +1 -1
- package/dist/src/util/editor/editFeaturesSession.d.ts +10 -4
- package/dist/src/util/editor/editFeaturesSession.js +74 -37
- package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
- package/dist/src/util/editor/editGeometrySession.d.ts +5 -1
- package/dist/src/util/editor/editGeometrySession.js +77 -55
- package/dist/src/util/editor/editGeometrySession.js.map +1 -1
- package/dist/src/util/editor/editorHelpers.d.ts +12 -6
- package/dist/src/util/editor/editorHelpers.js +47 -20
- package/dist/src/util/editor/editorHelpers.js.map +1 -1
- package/dist/src/util/editor/editorSessionHelpers.d.ts +5 -0
- package/dist/src/util/editor/editorSessionHelpers.js +1 -0
- package/dist/src/util/editor/editorSessionHelpers.js.map +1 -1
- package/dist/src/util/editor/editorSymbols.d.ts +1 -1
- package/dist/src/util/editor/editorSymbols.js +1 -1
- package/dist/src/util/editor/editorSymbols.js.map +1 -1
- package/dist/src/util/editor/interactions/createBBoxInteraction.d.ts +1 -0
- package/dist/src/util/editor/interactions/createBBoxInteraction.js +20 -16
- package/dist/src/util/editor/interactions/createBBoxInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createCircleInteraction.js +1 -1
- package/dist/src/util/editor/interactions/createCircleInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createLineStringInteraction.js +3 -3
- package/dist/src/util/editor/interactions/createLineStringInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createPointInteraction.js +1 -1
- package/dist/src/util/editor/interactions/createPointInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createPolygonInteraction.d.ts +4 -0
- package/dist/src/util/editor/interactions/createPolygonInteraction.js +9 -3
- package/dist/src/util/editor/interactions/createPolygonInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/creationSnapping.d.ts +26 -0
- package/dist/src/util/editor/interactions/creationSnapping.js +139 -0
- package/dist/src/util/editor/interactions/creationSnapping.js.map +1 -0
- package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js +3 -2
- package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/insertVertexInteraction.d.ts +3 -1
- package/dist/src/util/editor/interactions/insertVertexInteraction.js +14 -6
- package/dist/src/util/editor/interactions/insertVertexInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/layerSnapping.d.ts +19 -0
- package/dist/src/util/editor/interactions/layerSnapping.js +87 -0
- package/dist/src/util/editor/interactions/layerSnapping.js.map +1 -0
- package/dist/src/util/editor/interactions/translateVertexInteraction.js +2 -2
- package/dist/src/util/editor/interactions/translateVertexInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/translationSnapping.d.ts +25 -0
- package/dist/src/util/editor/interactions/translationSnapping.js +179 -0
- package/dist/src/util/editor/interactions/translationSnapping.js.map +1 -0
- package/dist/src/util/editor/snappingHelpers.d.ts +44 -0
- package/dist/src/util/editor/snappingHelpers.js +329 -0
- package/dist/src/util/editor/snappingHelpers.js.map +1 -0
- package/dist/src/util/editor/transformation/create2DHandlers.js +26 -26
- package/dist/src/util/editor/transformation/create2DHandlers.js.map +1 -1
- package/dist/src/util/editor/transformation/create3DHandlers.js +65 -14
- package/dist/src/util/editor/transformation/create3DHandlers.js.map +1 -1
- package/dist/src/util/editor/transformation/scaleInteraction.js +27 -5
- package/dist/src/util/editor/transformation/scaleInteraction.js.map +1 -1
- package/dist/src/util/editor/transformation/transformationHandler.js +56 -38
- package/dist/src/util/editor/transformation/transformationHandler.js.map +1 -1
- package/dist/src/util/editor/transformation/transformationTypes.d.ts +2 -0
- package/dist/src/util/editor/transformation/transformationTypes.js +4 -0
- package/dist/src/util/editor/transformation/transformationTypes.js.map +1 -1
- package/dist/src/util/featureconverter/arcToCesium.d.ts +5 -19
- package/dist/src/util/featureconverter/arcToCesium.js +15 -42
- package/dist/src/util/featureconverter/arcToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/circleToCesium.d.ts +2 -27
- package/dist/src/util/featureconverter/circleToCesium.js +84 -63
- package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/clampedPrimitive.d.ts +2 -0
- package/dist/src/util/featureconverter/clampedPrimitive.js +29 -0
- package/dist/src/util/featureconverter/clampedPrimitive.js.map +1 -0
- package/dist/src/util/featureconverter/convert.d.ts +26 -7
- package/dist/src/util/featureconverter/convert.js +221 -44
- package/dist/src/util/featureconverter/convert.js.map +1 -1
- package/dist/src/util/featureconverter/extent3D.d.ts +4 -3
- package/dist/src/util/featureconverter/extent3D.js +4 -3
- package/dist/src/util/featureconverter/extent3D.js.map +1 -1
- package/dist/src/util/featureconverter/lineStringToCesium.d.ts +12 -27
- package/dist/src/util/featureconverter/lineStringToCesium.js +85 -107
- package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/pointHelpers.d.ts +8 -11
- package/dist/src/util/featureconverter/pointHelpers.js +134 -120
- package/dist/src/util/featureconverter/pointHelpers.js.map +1 -1
- package/dist/src/util/featureconverter/pointToCesium.d.ts +14 -17
- package/dist/src/util/featureconverter/pointToCesium.js +47 -96
- package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/polygonToCesium.d.ts +2 -26
- package/dist/src/util/featureconverter/polygonToCesium.js +62 -72
- package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/storeyHelpers.d.ts +17 -0
- package/dist/src/util/featureconverter/storeyHelpers.js +78 -0
- package/dist/src/util/featureconverter/storeyHelpers.js.map +1 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.d.ts +54 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.js +278 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.js.map +1 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.d.ts +86 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.js +242 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.js.map +1 -0
- package/dist/src/util/geometryHelpers.d.ts +22 -1
- package/dist/src/util/geometryHelpers.js +65 -2
- package/dist/src/util/geometryHelpers.js.map +1 -1
- package/dist/src/util/mapCollection.js +8 -0
- package/dist/src/util/mapCollection.js.map +1 -1
- package/dist/src/util/math.d.ts +6 -2
- package/dist/src/util/math.js +34 -12
- package/dist/src/util/math.js.map +1 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js +3 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
- package/dist/tests/unit/helpers/helpers.d.ts +2 -9
- package/dist/tests/unit/helpers/helpers.js +2 -8
- package/dist/tests/unit/helpers/helpers.js.map +1 -1
- package/index.ts +74 -35
- package/package.json +3 -3
- package/src/cesium/cesium.d.ts +11 -0
- package/src/layer/cesium/clusterContext.ts +82 -91
- package/src/layer/cesium/vectorCesiumImpl.ts +17 -11
- package/src/layer/cesium/vectorContext.ts +120 -348
- package/src/layer/geojsonHelpers.ts +9 -12
- package/src/layer/oblique/obliqueHelpers.ts +6 -6
- package/src/layer/vectorLayer.ts +0 -71
- package/src/layer/vectorProperties.ts +46 -9
- package/src/map/baseOLMap.ts +1 -1
- package/src/map/obliqueMap.ts +46 -6
- package/src/map/vcsMap.ts +20 -2
- package/src/oblique/helpers.ts +11 -5
- package/src/oblique/obliqueDataSet.ts +4 -4
- package/src/ol/geom/geometryCollection.js +21 -2
- package/src/ol/ol.d.ts +15 -2
- package/src/style/arcStyle.ts +1 -0
- package/src/util/editor/createFeatureSession.ts +64 -6
- package/src/util/editor/editFeaturesSession.ts +105 -39
- package/src/util/editor/editGeometrySession.ts +118 -75
- package/src/util/editor/editorHelpers.ts +78 -30
- package/src/util/editor/editorSessionHelpers.ts +7 -0
- package/src/util/editor/editorSymbols.ts +1 -1
- package/src/util/editor/interactions/createBBoxInteraction.ts +25 -16
- package/src/util/editor/interactions/createCircleInteraction.ts +1 -1
- package/src/util/editor/interactions/createLineStringInteraction.ts +9 -3
- package/src/util/editor/interactions/createPointInteraction.ts +1 -1
- package/src/util/editor/interactions/createPolygonInteraction.ts +16 -3
- package/src/util/editor/interactions/creationSnapping.ts +226 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.ts +3 -2
- package/src/util/editor/interactions/insertVertexInteraction.ts +27 -7
- package/src/util/editor/interactions/layerSnapping.ts +136 -0
- package/src/util/editor/interactions/translateVertexInteraction.ts +8 -2
- package/src/util/editor/interactions/translationSnapping.ts +302 -0
- package/src/util/editor/snappingHelpers.ts +490 -0
- package/src/util/editor/transformation/create2DHandlers.ts +38 -26
- package/src/util/editor/transformation/create3DHandlers.ts +84 -22
- package/src/util/editor/transformation/scaleInteraction.ts +28 -5
- package/src/util/editor/transformation/transformationHandler.ts +72 -41
- package/src/util/editor/transformation/transformationTypes.ts +5 -0
- package/src/util/featureconverter/arcToCesium.ts +25 -95
- package/src/util/featureconverter/circleToCesium.ts +127 -113
- package/src/util/featureconverter/clampedPrimitive.ts +70 -0
- package/src/util/featureconverter/convert.ts +446 -114
- package/src/util/featureconverter/extent3D.ts +13 -6
- package/src/util/featureconverter/lineStringToCesium.ts +132 -179
- package/src/util/featureconverter/pointHelpers.ts +271 -214
- package/src/util/featureconverter/pointToCesium.ts +111 -175
- package/src/util/featureconverter/polygonToCesium.ts +98 -117
- package/src/util/featureconverter/storeyHelpers.ts +104 -0
- package/src/util/featureconverter/vectorGeometryFactory.ts +601 -0
- package/src/util/featureconverter/vectorHeightInfo.ts +393 -0
- package/src/util/geometryHelpers.ts +79 -5
- package/src/util/mapCollection.ts +8 -0
- package/src/util/math.ts +59 -12
- package/dist/src/util/featureconverter/featureconverterHelper.d.ts +0 -35
- package/dist/src/util/featureconverter/featureconverterHelper.js +0 -404
- package/dist/src/util/featureconverter/featureconverterHelper.js.map +0 -1
- package/src/util/featureconverter/featureconverterHelper.ts +0 -672
|
@@ -1,43 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
type Billboard,
|
|
3
3
|
BillboardCollection,
|
|
4
|
-
LabelCollection,
|
|
5
|
-
Matrix4,
|
|
6
4
|
Cartesian3,
|
|
7
|
-
Math as CesiumMath,
|
|
8
|
-
Model,
|
|
9
|
-
type Primitive,
|
|
10
|
-
type GroundPrimitive,
|
|
11
|
-
type GroundPolylinePrimitive,
|
|
12
|
-
type ClassificationPrimitive,
|
|
13
|
-
type Billboard,
|
|
14
5
|
type Entity,
|
|
15
6
|
type Label,
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
LabelCollection,
|
|
8
|
+
Math as CesiumMath,
|
|
9
|
+
Matrix4,
|
|
10
|
+
Model,
|
|
11
|
+
Primitive,
|
|
12
|
+
PrimitiveCollection,
|
|
18
13
|
Scene,
|
|
14
|
+
SplitDirection,
|
|
19
15
|
} from '@vcmap-cesium/engine';
|
|
20
|
-
import {
|
|
21
|
-
import { StyleFunction } from 'ol/style/Style.js';
|
|
16
|
+
import { StyleLike } from 'ol/style/Style.js';
|
|
22
17
|
import type { Feature } from 'ol/index.js';
|
|
18
|
+
|
|
23
19
|
import Viewpoint from '../../util/viewpoint.js';
|
|
24
20
|
import type CesiumMap from '../../map/cesiumMap.js';
|
|
25
21
|
import VectorProperties from '../vectorProperties.js';
|
|
26
|
-
import convert
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| GroundPrimitive
|
|
31
|
-
| GroundPolylinePrimitive
|
|
32
|
-
| ClassificationPrimitive
|
|
33
|
-
| Model;
|
|
34
|
-
|
|
35
|
-
export type VectorContextFeatureCache = {
|
|
36
|
-
primitives?: PrimitiveType[];
|
|
37
|
-
scaledPrimitives?: PrimitiveType[];
|
|
38
|
-
billboards?: (Billboard | Entity)[];
|
|
39
|
-
labels?: (Label | Entity)[];
|
|
40
|
-
};
|
|
22
|
+
import convert, {
|
|
23
|
+
ConvertedItem,
|
|
24
|
+
PrimitiveType,
|
|
25
|
+
} from '../../util/featureconverter/convert.js';
|
|
41
26
|
|
|
42
27
|
export function setReferenceForPicking(
|
|
43
28
|
feature: Feature,
|
|
@@ -46,71 +31,6 @@ export function setReferenceForPicking(
|
|
|
46
31
|
primitive.olFeature = feature;
|
|
47
32
|
}
|
|
48
33
|
|
|
49
|
-
export function removeArrayFromCollection(
|
|
50
|
-
collection:
|
|
51
|
-
| PrimitiveCollection
|
|
52
|
-
| BillboardCollection
|
|
53
|
-
| LabelCollection
|
|
54
|
-
| EntityCollection,
|
|
55
|
-
array?: (PrimitiveType | Billboard | Label | Entity)[],
|
|
56
|
-
): void {
|
|
57
|
-
if (array) {
|
|
58
|
-
array.forEach((primitive) => {
|
|
59
|
-
collection.remove(primitive);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function removeFeatureFromMap(
|
|
65
|
-
feature: Feature,
|
|
66
|
-
featuresMap: Map<Feature, (PrimitiveType | Billboard | Label | Entity)[]>,
|
|
67
|
-
primitiveCollection:
|
|
68
|
-
| PrimitiveCollection
|
|
69
|
-
| BillboardCollection
|
|
70
|
-
| LabelCollection
|
|
71
|
-
| EntityCollection,
|
|
72
|
-
): boolean {
|
|
73
|
-
removeArrayFromCollection(primitiveCollection, featuresMap.get(feature));
|
|
74
|
-
return featuresMap.delete(feature);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function addPrimitiveToContext(
|
|
78
|
-
primitives: (PrimitiveType | Entity.ConstructorOptions)[],
|
|
79
|
-
feature: Feature,
|
|
80
|
-
allowPicking: boolean,
|
|
81
|
-
primitiveCollection:
|
|
82
|
-
| BillboardCollection
|
|
83
|
-
| LabelCollection
|
|
84
|
-
| PrimitiveCollection
|
|
85
|
-
| EntityCollection,
|
|
86
|
-
featureMap: Map<Feature, (Billboard | Label | PrimitiveType | Entity)[]>,
|
|
87
|
-
splitDirection?: SplitDirection,
|
|
88
|
-
): void {
|
|
89
|
-
if (primitives.length) {
|
|
90
|
-
const cesiumPrimitives = primitives.map((primitiveOptions) => {
|
|
91
|
-
const primitive = primitiveCollection.add(primitiveOptions) as
|
|
92
|
-
| Billboard
|
|
93
|
-
| Label
|
|
94
|
-
| PrimitiveType
|
|
95
|
-
| Entity
|
|
96
|
-
| Model;
|
|
97
|
-
if (allowPicking) {
|
|
98
|
-
setReferenceForPicking(feature, primitive);
|
|
99
|
-
}
|
|
100
|
-
if (splitDirection && primitive instanceof Model) {
|
|
101
|
-
// Cesium currently only supports splitDirection on Model primitives
|
|
102
|
-
primitive.splitDirection = splitDirection;
|
|
103
|
-
}
|
|
104
|
-
return primitive;
|
|
105
|
-
});
|
|
106
|
-
if (!featureMap.has(feature)) {
|
|
107
|
-
featureMap.set(feature, cesiumPrimitives);
|
|
108
|
-
} else {
|
|
109
|
-
featureMap.get(feature)!.push(...cesiumPrimitives);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
34
|
/**
|
|
115
35
|
* Sets splitDirection on primitives. Currently only Model primitives support splitting.
|
|
116
36
|
*/
|
|
@@ -175,133 +95,19 @@ export function setupScalingPrimitiveCollection(
|
|
|
175
95
|
});
|
|
176
96
|
}
|
|
177
97
|
|
|
178
|
-
export interface
|
|
179
|
-
|
|
180
|
-
primitives: PrimitiveType[],
|
|
181
|
-
feature: Feature,
|
|
182
|
-
allowPicking: boolean,
|
|
183
|
-
): void;
|
|
184
|
-
addScaledPrimitives(
|
|
185
|
-
primitives: PrimitiveType[],
|
|
186
|
-
feature: Feature,
|
|
187
|
-
allowPicking: boolean,
|
|
188
|
-
): void;
|
|
189
|
-
addBillboards(
|
|
190
|
-
billboardOptions: object[],
|
|
98
|
+
export interface CesiumVectorContext {
|
|
99
|
+
addFeature(
|
|
191
100
|
feature: Feature,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
feature: Feature,
|
|
197
|
-
allowPicking: boolean,
|
|
198
|
-
): void;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export interface CesiumVectorContext extends AsyncCesiumVectorContext {
|
|
101
|
+
style: StyleLike,
|
|
102
|
+
vectorProperties: VectorProperties,
|
|
103
|
+
scene: Scene,
|
|
104
|
+
): Promise<void>;
|
|
202
105
|
removeFeature(feature: Feature): void;
|
|
203
|
-
createFeatureCache(feature: Feature): VectorContextFeatureCache;
|
|
204
|
-
clearFeatureCache(cache: VectorContextFeatureCache): void;
|
|
205
106
|
updateSplitDirection(splitDirection: SplitDirection): void;
|
|
206
107
|
clear(): void;
|
|
207
108
|
}
|
|
208
109
|
|
|
209
|
-
|
|
210
|
-
feature: Feature,
|
|
211
|
-
style: Style | StyleFunction,
|
|
212
|
-
vectorProperties: VectorProperties,
|
|
213
|
-
context: CesiumVectorContext,
|
|
214
|
-
scene: Scene,
|
|
215
|
-
): () => void {
|
|
216
|
-
let isDestroyed = false;
|
|
217
|
-
const primitivesArray: {
|
|
218
|
-
primitives: PrimitiveType[];
|
|
219
|
-
allowPicking: boolean;
|
|
220
|
-
}[] = [];
|
|
221
|
-
const scaledPrimitives: {
|
|
222
|
-
primitives: PrimitiveType[];
|
|
223
|
-
allowPicking: boolean;
|
|
224
|
-
}[] = [];
|
|
225
|
-
const billboards: { billboardOptions: object[]; allowPicking: boolean }[] =
|
|
226
|
-
[];
|
|
227
|
-
const labels: { labelOptions: object[]; allowPicking: boolean }[] = [];
|
|
228
|
-
|
|
229
|
-
const asyncContext: AsyncCesiumVectorContext = {
|
|
230
|
-
addPrimitives(
|
|
231
|
-
primitives: PrimitiveType[],
|
|
232
|
-
_feature: Feature,
|
|
233
|
-
allowPicking: boolean,
|
|
234
|
-
): void {
|
|
235
|
-
primitivesArray.push({ primitives, allowPicking });
|
|
236
|
-
},
|
|
237
|
-
addScaledPrimitives(
|
|
238
|
-
primitives: PrimitiveType[],
|
|
239
|
-
_feature: Feature,
|
|
240
|
-
allowPicking: boolean,
|
|
241
|
-
): void {
|
|
242
|
-
scaledPrimitives.push({ primitives, allowPicking });
|
|
243
|
-
},
|
|
244
|
-
addBillboards(
|
|
245
|
-
billboardOptions: object[],
|
|
246
|
-
_feature: Feature,
|
|
247
|
-
allowPicking: boolean,
|
|
248
|
-
): void {
|
|
249
|
-
billboards.push({ billboardOptions, allowPicking });
|
|
250
|
-
},
|
|
251
|
-
addLabels(
|
|
252
|
-
labelOptions: object[],
|
|
253
|
-
_feature: Feature,
|
|
254
|
-
allowPicking: boolean,
|
|
255
|
-
): void {
|
|
256
|
-
labels.push({ labelOptions, allowPicking });
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
convert(feature, style, vectorProperties, asyncContext, scene)
|
|
261
|
-
.then(() => {
|
|
262
|
-
if (!isDestroyed) {
|
|
263
|
-
primitivesArray.forEach(({ primitives, allowPicking }) => {
|
|
264
|
-
context.addPrimitives(primitives, feature, allowPicking);
|
|
265
|
-
});
|
|
266
|
-
scaledPrimitives.forEach(({ primitives, allowPicking }) => {
|
|
267
|
-
context.addScaledPrimitives(primitives, feature, allowPicking);
|
|
268
|
-
});
|
|
269
|
-
billboards.forEach(({ billboardOptions, allowPicking }) => {
|
|
270
|
-
context.addBillboards(billboardOptions, feature, allowPicking);
|
|
271
|
-
});
|
|
272
|
-
labels.forEach(({ labelOptions, allowPicking }) => {
|
|
273
|
-
context.addLabels(labelOptions, feature, allowPicking);
|
|
274
|
-
});
|
|
275
|
-
} else {
|
|
276
|
-
primitivesArray.forEach(({ primitives }) => {
|
|
277
|
-
primitives.forEach((p) => {
|
|
278
|
-
p.destroy();
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
scaledPrimitives.forEach(({ primitives }) => {
|
|
282
|
-
primitives.forEach((p) => {
|
|
283
|
-
p.destroy();
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
})
|
|
288
|
-
.catch((err) => {
|
|
289
|
-
console.error('feature conversion failed');
|
|
290
|
-
console.error(err);
|
|
291
|
-
})
|
|
292
|
-
.finally(() => {
|
|
293
|
-
primitivesArray.splice(0);
|
|
294
|
-
scaledPrimitives.splice(0);
|
|
295
|
-
billboards.splice(0);
|
|
296
|
-
labels.splice(0);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
return () => {
|
|
300
|
-
isDestroyed = true;
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
class VectorContext implements CesiumVectorContext {
|
|
110
|
+
export default class VectorContext implements CesiumVectorContext {
|
|
305
111
|
primitives = new PrimitiveCollection();
|
|
306
112
|
|
|
307
113
|
scaledPrimitives = new PrimitiveCollection();
|
|
@@ -310,15 +116,9 @@ class VectorContext implements CesiumVectorContext {
|
|
|
310
116
|
|
|
311
117
|
labels: LabelCollection;
|
|
312
118
|
|
|
313
|
-
|
|
119
|
+
private _featureItems = new Map<Feature, (() => void)[]>();
|
|
314
120
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
featureToBillboardMap: Map<Feature, Array<Billboard>> = new Map();
|
|
318
|
-
|
|
319
|
-
featureToLabelMap: Map<Feature, Array<Label>> = new Map();
|
|
320
|
-
|
|
321
|
-
_features: Map<Feature, () => void> = new Map();
|
|
121
|
+
private _convertingFeatures: Map<Feature, () => void> = new Map();
|
|
322
122
|
|
|
323
123
|
splitDirection: SplitDirection;
|
|
324
124
|
|
|
@@ -335,7 +135,7 @@ class VectorContext implements CesiumVectorContext {
|
|
|
335
135
|
rootCollection: PrimitiveCollection,
|
|
336
136
|
splitDirection: SplitDirection,
|
|
337
137
|
) {
|
|
338
|
-
const scene = map.getScene()
|
|
138
|
+
const scene = map.getScene()!;
|
|
339
139
|
this.billboards = new BillboardCollection({ scene });
|
|
340
140
|
this.labels = new LabelCollection({ scene });
|
|
341
141
|
this.splitDirection = splitDirection;
|
|
@@ -354,150 +154,127 @@ class VectorContext implements CesiumVectorContext {
|
|
|
354
154
|
);
|
|
355
155
|
}
|
|
356
156
|
|
|
357
|
-
|
|
358
|
-
primitives: PrimitiveType[],
|
|
157
|
+
private _addConvertedItems(
|
|
359
158
|
feature: Feature,
|
|
360
|
-
allowPicking
|
|
159
|
+
allowPicking: boolean,
|
|
160
|
+
items: ConvertedItem[],
|
|
361
161
|
): void {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
162
|
+
const removeItems = items
|
|
163
|
+
.map((item) => {
|
|
164
|
+
let instance: PrimitiveType | Label | Billboard | undefined;
|
|
165
|
+
let removeItem: (() => void) | undefined;
|
|
166
|
+
if (item.type === 'primitive') {
|
|
167
|
+
if (item.autoScale) {
|
|
168
|
+
instance = this.scaledPrimitives.add(item.item) as PrimitiveType;
|
|
169
|
+
if (instance) {
|
|
170
|
+
removeItem = (): void => {
|
|
171
|
+
this._scaledDirty.value =
|
|
172
|
+
this.scaledPrimitives.remove(instance);
|
|
173
|
+
};
|
|
174
|
+
this._scaledDirty.value = true;
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
instance = this.primitives.add(item.item) as PrimitiveType;
|
|
178
|
+
if (instance) {
|
|
179
|
+
removeItem = (): void => {
|
|
180
|
+
this.primitives.remove(instance);
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
} else if (item.type === 'billboard') {
|
|
185
|
+
instance = this.billboards.add(item.item);
|
|
186
|
+
if (instance) {
|
|
187
|
+
removeItem = (): void => {
|
|
188
|
+
this.billboards.remove(instance as Billboard);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
} else if (item.type === 'label') {
|
|
192
|
+
instance = this.labels.add(item.item);
|
|
193
|
+
if (instance) {
|
|
194
|
+
removeItem = (): void => {
|
|
195
|
+
this.labels.remove(instance as Label);
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
371
199
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
): void {
|
|
377
|
-
addPrimitiveToContext(
|
|
378
|
-
primitives,
|
|
379
|
-
feature,
|
|
380
|
-
allowPicking,
|
|
381
|
-
this.scaledPrimitives,
|
|
382
|
-
this.featureToScaledPrimitiveMap,
|
|
383
|
-
this.splitDirection,
|
|
384
|
-
);
|
|
385
|
-
this._scaledDirty.value = true;
|
|
386
|
-
}
|
|
200
|
+
if (instance) {
|
|
201
|
+
if (allowPicking) {
|
|
202
|
+
setReferenceForPicking(feature, instance);
|
|
203
|
+
}
|
|
387
204
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
this.featureToBillboardMap,
|
|
399
|
-
this.splitDirection,
|
|
400
|
-
);
|
|
205
|
+
if (this.splitDirection && instance instanceof Model) {
|
|
206
|
+
// Cesium currently only supports splitDirection on Model primitives // XXX this is no longer TRUE
|
|
207
|
+
instance.splitDirection = this.splitDirection;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return removeItem;
|
|
211
|
+
})
|
|
212
|
+
.filter((i): i is () => void => i != null);
|
|
213
|
+
|
|
214
|
+
this._featureItems.set(feature, removeItems);
|
|
401
215
|
}
|
|
402
216
|
|
|
403
|
-
|
|
404
|
-
labelOptions: object[],
|
|
217
|
+
async addFeature(
|
|
405
218
|
feature: Feature,
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
);
|
|
416
|
-
}
|
|
219
|
+
style: StyleLike,
|
|
220
|
+
vectorProperties: VectorProperties,
|
|
221
|
+
scene: Scene,
|
|
222
|
+
): Promise<void> {
|
|
223
|
+
this._convertingFeatures.get(feature)?.();
|
|
224
|
+
let deleted = false;
|
|
225
|
+
this._convertingFeatures.set(feature, () => {
|
|
226
|
+
deleted = true;
|
|
227
|
+
});
|
|
417
228
|
|
|
418
|
-
|
|
419
|
-
* @param feature
|
|
420
|
-
*/
|
|
421
|
-
removeFeature(feature: Feature): void {
|
|
422
|
-
this._features.get(feature)?.();
|
|
423
|
-
this._features.delete(feature);
|
|
424
|
-
removeFeatureFromMap(feature, this.featureToPrimitiveMap, this.primitives);
|
|
425
|
-
this._scaledDirty.value = removeFeatureFromMap(
|
|
229
|
+
const convertedItems = await convert(
|
|
426
230
|
feature,
|
|
427
|
-
|
|
428
|
-
|
|
231
|
+
style,
|
|
232
|
+
vectorProperties,
|
|
233
|
+
scene,
|
|
429
234
|
);
|
|
430
|
-
removeFeatureFromMap(feature, this.featureToBillboardMap, this.billboards);
|
|
431
|
-
removeFeatureFromMap(feature, this.featureToLabelMap, this.labels);
|
|
432
|
-
}
|
|
433
235
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
236
|
+
this._featureItems.get(feature)?.forEach((removeItem) => removeItem());
|
|
237
|
+
this._featureItems.delete(feature);
|
|
238
|
+
|
|
239
|
+
if (deleted) {
|
|
240
|
+
convertedItems.forEach((item) => {
|
|
241
|
+
if (item.type === 'primitive') {
|
|
242
|
+
item.item.destroy();
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
} else {
|
|
246
|
+
this._addConvertedItems(
|
|
247
|
+
feature,
|
|
248
|
+
vectorProperties.getAllowPicking(feature),
|
|
249
|
+
convertedItems,
|
|
250
|
+
);
|
|
251
|
+
}
|
|
449
252
|
}
|
|
450
253
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
removeArrayFromCollection(this.scaledPrimitives, cache.scaledPrimitives);
|
|
457
|
-
removeArrayFromCollection(this.billboards, cache.billboards);
|
|
458
|
-
removeArrayFromCollection(this.labels, cache.labels);
|
|
254
|
+
removeFeature(feature: Feature): void {
|
|
255
|
+
this._convertingFeatures.get(feature)?.();
|
|
256
|
+
this._convertingFeatures.delete(feature);
|
|
257
|
+
this._featureItems.get(feature)?.forEach((removeItem) => removeItem());
|
|
258
|
+
this._featureItems.delete(feature);
|
|
459
259
|
}
|
|
460
260
|
|
|
461
|
-
/**
|
|
462
|
-
* Updates splitDirection on primitives. Currently only Model primitives support splitting.
|
|
463
|
-
* @param splitDirection
|
|
464
|
-
*/
|
|
465
261
|
updateSplitDirection(splitDirection: SplitDirection): void {
|
|
466
262
|
this.splitDirection = splitDirection;
|
|
467
263
|
setSplitDirectionOnPrimitives(splitDirection, this.primitives);
|
|
468
264
|
setSplitDirectionOnPrimitives(splitDirection, this.scaledPrimitives);
|
|
469
265
|
}
|
|
470
266
|
|
|
471
|
-
/**
|
|
472
|
-
* Clears all collections and maps
|
|
473
|
-
*/
|
|
474
267
|
clear(): void {
|
|
475
268
|
this.primitives.removeAll();
|
|
269
|
+
this._scaledDirty.value = this.scaledPrimitives.length > 0;
|
|
476
270
|
this.scaledPrimitives.removeAll();
|
|
477
271
|
this.billboards.removeAll();
|
|
478
272
|
this.labels.removeAll();
|
|
479
|
-
this.
|
|
480
|
-
this.
|
|
481
|
-
this.featureToPrimitiveMap.clear();
|
|
482
|
-
this._scaledDirty.value = this.featureToScaledPrimitiveMap.size > 0;
|
|
483
|
-
this.featureToScaledPrimitiveMap.clear();
|
|
484
|
-
this._features.forEach((destroy) => {
|
|
273
|
+
this._featureItems.clear();
|
|
274
|
+
this._convertingFeatures.forEach((destroy) => {
|
|
485
275
|
destroy();
|
|
486
276
|
});
|
|
487
|
-
this.
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
convertFeature(
|
|
491
|
-
feature: Feature,
|
|
492
|
-
style: Style | StyleFunction,
|
|
493
|
-
vectorProperties: VectorProperties,
|
|
494
|
-
scene: Scene,
|
|
495
|
-
): void {
|
|
496
|
-
this._features.get(feature)?.();
|
|
497
|
-
this._features.set(
|
|
498
|
-
feature,
|
|
499
|
-
createAsyncFeatureConvert(feature, style, vectorProperties, this, scene),
|
|
500
|
-
);
|
|
277
|
+
this._convertingFeatures.clear();
|
|
501
278
|
}
|
|
502
279
|
|
|
503
280
|
/**
|
|
@@ -513,16 +290,11 @@ class VectorContext implements CesiumVectorContext {
|
|
|
513
290
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
514
291
|
// @ts-ignore
|
|
515
292
|
this._rootCollection = null;
|
|
516
|
-
this.
|
|
517
|
-
this.featureToLabelMap.clear();
|
|
518
|
-
this.featureToPrimitiveMap.clear();
|
|
519
|
-
this._features.forEach((destroy) => {
|
|
293
|
+
this._convertingFeatures.forEach((destroy) => {
|
|
520
294
|
destroy();
|
|
521
295
|
});
|
|
522
|
-
this.
|
|
523
|
-
this.
|
|
296
|
+
this._convertingFeatures.clear();
|
|
297
|
+
this._featureItems.clear();
|
|
524
298
|
this._postRenderListener();
|
|
525
299
|
}
|
|
526
300
|
}
|
|
527
|
-
|
|
528
|
-
export default VectorContext;
|
|
@@ -248,16 +248,10 @@ function readFeature(
|
|
|
248
248
|
|
|
249
249
|
if (featureObj.radius && geometry instanceof Point) {
|
|
250
250
|
const coordinates = geometry.getCoordinates();
|
|
251
|
-
|
|
252
|
-
coordinates.push(0);
|
|
253
|
-
}
|
|
254
|
-
geometry = new Circle(coordinates, featureObj.radius, 'XYZ');
|
|
251
|
+
geometry = new Circle(coordinates, featureObj.radius);
|
|
255
252
|
}
|
|
256
253
|
if (radius && geometry instanceof Point) {
|
|
257
254
|
const coordinates = geometry.getCoordinates();
|
|
258
|
-
if (coordinates.length === 2) {
|
|
259
|
-
coordinates.push(0);
|
|
260
|
-
}
|
|
261
255
|
geometry = circleFromCenterRadius(coordinates, radius);
|
|
262
256
|
}
|
|
263
257
|
if (String(options.formatOptions?.featureProjection) === 'EPSG:3857') {
|
|
@@ -467,23 +461,26 @@ export function writeGeoJSONFeature(
|
|
|
467
461
|
/**
|
|
468
462
|
* Writes all the features of the current layer to GeojsonLayer
|
|
469
463
|
*/
|
|
470
|
-
export function writeGeoJSON(
|
|
464
|
+
export function writeGeoJSON<O extends GeoJSONwriteOptions>(
|
|
471
465
|
data: GeoJSONData,
|
|
472
|
-
options
|
|
473
|
-
):
|
|
466
|
+
options?: O,
|
|
467
|
+
): O['asObject'] extends true ? FeatureCollection : string {
|
|
474
468
|
// how to handel embedded icons when they are not set on the vcsMeta but options is true?
|
|
475
469
|
const vcsMeta = data.vcsMeta || { version: vcsMetaVersion };
|
|
476
470
|
vcsMeta.version = vcsMetaVersion;
|
|
477
471
|
const featureObjs = data.features.map((feature) =>
|
|
478
472
|
writeGeoJSONFeature(feature, options, vcsMeta.embeddedIcons),
|
|
479
473
|
);
|
|
474
|
+
|
|
480
475
|
const obj: FeatureCollection = {
|
|
481
476
|
type: 'FeatureCollection',
|
|
482
477
|
features: featureObjs,
|
|
483
478
|
vcsMeta,
|
|
484
479
|
};
|
|
485
480
|
|
|
486
|
-
|
|
481
|
+
const returnValue = options?.asObject
|
|
487
482
|
? obj
|
|
488
|
-
: JSON.stringify(obj, undefined, options
|
|
483
|
+
: JSON.stringify(obj, undefined, options?.prettyPrint ? 2 : undefined);
|
|
484
|
+
|
|
485
|
+
return returnValue as O['asObject'] extends true ? FeatureCollection : string;
|
|
489
486
|
}
|
|
@@ -7,7 +7,7 @@ import type { Geometry } from 'ol/geom.js';
|
|
|
7
7
|
import type { Feature } from 'ol/index.js';
|
|
8
8
|
|
|
9
9
|
import { Cartographic, sampleTerrainMostDetailed } from '@vcmap-cesium/engine';
|
|
10
|
-
import {
|
|
10
|
+
import { cartesian2DDistanceSquared } from '../../util/math.js';
|
|
11
11
|
import Projection, {
|
|
12
12
|
mercatorProjection,
|
|
13
13
|
wgs84Projection,
|
|
@@ -25,7 +25,7 @@ import { transformFromImage } from '../../oblique/helpers.js';
|
|
|
25
25
|
import type ObliqueImage from '../../oblique/obliqueImage.js';
|
|
26
26
|
|
|
27
27
|
export function getLongestSide(coordinates: Coordinate[]): number {
|
|
28
|
-
let
|
|
28
|
+
let sideSquared = 0;
|
|
29
29
|
for (let i = 0; i < coordinates.length; i++) {
|
|
30
30
|
let j = i + 1;
|
|
31
31
|
if (j >= coordinates.length) {
|
|
@@ -33,12 +33,12 @@ export function getLongestSide(coordinates: Coordinate[]): number {
|
|
|
33
33
|
}
|
|
34
34
|
const point1 = coordinates[i];
|
|
35
35
|
const point2 = coordinates[j];
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
36
|
+
const currentSideSquared = cartesian2DDistanceSquared(point1, point2);
|
|
37
|
+
if (currentSideSquared > sideSquared) {
|
|
38
|
+
sideSquared = currentSideSquared;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return Math.sqrt(sideSquared);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export function getResolutionOptions(
|