@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
|
@@ -6,10 +6,9 @@ import {
|
|
|
6
6
|
Cartesian2,
|
|
7
7
|
LabelStyle,
|
|
8
8
|
HorizontalOrigin,
|
|
9
|
-
type BillboardGraphics,
|
|
10
|
-
type LabelGraphics,
|
|
11
|
-
type PolylineGeometry,
|
|
12
9
|
type Scene,
|
|
10
|
+
Billboard,
|
|
11
|
+
Label,
|
|
13
12
|
} from '@vcmap-cesium/engine';
|
|
14
13
|
import { Icon, type Style } from 'ol/style.js';
|
|
15
14
|
import type { Coordinate } from 'ol/coordinate.js';
|
|
@@ -18,33 +17,28 @@ import type { Feature } from 'ol/index.js';
|
|
|
18
17
|
import type { Point } from 'ol/geom.js';
|
|
19
18
|
|
|
20
19
|
import { parseNumber } from '@vcsuite/parsers';
|
|
21
|
-
import {
|
|
22
|
-
createLinePrimitive,
|
|
23
|
-
getHeightInfo,
|
|
24
|
-
} from './featureconverterHelper.js';
|
|
25
|
-
import Projection from '../projection.js';
|
|
26
20
|
import { createLineGeometries } from './lineStringToCesium.js';
|
|
27
21
|
import { getCesiumColor } from '../../style/styleHelpers.js';
|
|
28
|
-
import {
|
|
22
|
+
import { getModelOrPointPrimitiveOptions } from './pointHelpers.js';
|
|
29
23
|
import VectorProperties from '../../layer/vectorProperties.js';
|
|
30
|
-
import type { VectorHeightInfo } from '../../layer/vectorLayer.js';
|
|
31
|
-
import { AsyncCesiumVectorContext } from '../../layer/cesium/vectorContext.js';
|
|
32
24
|
import type { ColorType } from '../../style/vectorStyleItem.js';
|
|
25
|
+
import { ConvertedItem } from './convert.js';
|
|
26
|
+
import {
|
|
27
|
+
isClampedHeightReference,
|
|
28
|
+
mercatorToWgs84TransformerForHeightInfo,
|
|
29
|
+
RelativeHeightReference,
|
|
30
|
+
VectorHeightInfo,
|
|
31
|
+
} from './vectorHeightInfo.js';
|
|
32
|
+
import { CesiumGeometryOption } from './vectorGeometryFactory.js';
|
|
33
33
|
|
|
34
|
-
export
|
|
35
|
-
return geometries.map((point) => {
|
|
36
|
-
return point.getCoordinates();
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type BillboardOptions = BillboardGraphics.ConstructorOptions;
|
|
34
|
+
export type BillboardOptions = Billboard.ConstructorOptions;
|
|
41
35
|
|
|
42
36
|
export function getBillboardOptions(
|
|
43
37
|
feature: Feature,
|
|
44
38
|
style: Style,
|
|
45
39
|
heightReference: HeightReference,
|
|
46
40
|
vectorProperties: VectorProperties,
|
|
47
|
-
): BillboardOptions | null {
|
|
41
|
+
): Partial<BillboardOptions> | null {
|
|
48
42
|
const imageStyle = style.getImage();
|
|
49
43
|
if (imageStyle) {
|
|
50
44
|
// ImageStyles should always have an opacity value between 0 and 1, default white Color
|
|
@@ -74,10 +68,7 @@ export function getBillboardOptions(
|
|
|
74
68
|
if (!image) {
|
|
75
69
|
image = imageStyle.getImage(1);
|
|
76
70
|
}
|
|
77
|
-
const options: BillboardOptions = {
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
79
|
-
// @ts-ignore
|
|
80
|
-
image,
|
|
71
|
+
const options: Partial<BillboardOptions> = {
|
|
81
72
|
color,
|
|
82
73
|
scale: imageStyle.getScaleArray()[0],
|
|
83
74
|
heightReference,
|
|
@@ -85,9 +76,12 @@ export function getBillboardOptions(
|
|
|
85
76
|
id: feature.getId(),
|
|
86
77
|
};
|
|
87
78
|
|
|
79
|
+
// @ts-expect-error: cesium types are wrong here
|
|
80
|
+
options.image = image;
|
|
81
|
+
|
|
88
82
|
options.eyeOffset = vectorProperties.getEyeOffset(feature);
|
|
89
83
|
options.scaleByDistance = vectorProperties.getScaleByDistance(feature);
|
|
90
|
-
if (heightReference
|
|
84
|
+
if (isClampedHeightReference(heightReference)) {
|
|
91
85
|
options.disableDepthTestDistance = Number.POSITIVE_INFINITY;
|
|
92
86
|
}
|
|
93
87
|
|
|
@@ -96,7 +90,7 @@ export function getBillboardOptions(
|
|
|
96
90
|
return null;
|
|
97
91
|
}
|
|
98
92
|
|
|
99
|
-
export type LabelOptions =
|
|
93
|
+
export type LabelOptions = Label.ConstructorOptions;
|
|
100
94
|
/**
|
|
101
95
|
* extracts cesium label options from a feature and style
|
|
102
96
|
* @param feature
|
|
@@ -110,11 +104,11 @@ export function getLabelOptions(
|
|
|
110
104
|
style: Style,
|
|
111
105
|
heightReference: HeightReference,
|
|
112
106
|
vectorProperties: VectorProperties,
|
|
113
|
-
): LabelOptions | null {
|
|
107
|
+
): Partial<LabelOptions> | null {
|
|
114
108
|
const textStyle = style.getText();
|
|
115
109
|
const text = textStyle ? textStyle.getText() : null;
|
|
116
110
|
if (text && textStyle) {
|
|
117
|
-
const options: LabelOptions = {};
|
|
111
|
+
const options: Partial<LabelOptions> = {};
|
|
118
112
|
|
|
119
113
|
options.text = text as string;
|
|
120
114
|
|
|
@@ -189,7 +183,7 @@ export function getLabelOptions(
|
|
|
189
183
|
options.eyeOffset = vectorProperties.getEyeOffset(feature);
|
|
190
184
|
options.scaleByDistance = vectorProperties.getScaleByDistance(feature);
|
|
191
185
|
|
|
192
|
-
if (heightReference
|
|
186
|
+
if (isClampedHeightReference(heightReference)) {
|
|
193
187
|
options.disableDepthTestDistance = Number.POSITIVE_INFINITY;
|
|
194
188
|
}
|
|
195
189
|
return options;
|
|
@@ -211,193 +205,135 @@ export function validatePoint(point: Point): boolean {
|
|
|
211
205
|
return false;
|
|
212
206
|
}
|
|
213
207
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
heightInfo.groundLevel +
|
|
208
|
+
export function getLineGeometries(
|
|
209
|
+
heightInfo: VectorHeightInfo<RelativeHeightReference | HeightReference.NONE>,
|
|
210
|
+
position: Cartesian3,
|
|
211
|
+
wgs84Coords: Coordinate,
|
|
212
|
+
style: Style,
|
|
213
|
+
): CesiumGeometryOption<'line'>[] {
|
|
214
|
+
const heightValueCorrection =
|
|
215
|
+
heightInfo.skirt +
|
|
216
|
+
heightInfo.storeyHeightsBelowGround.reduce(
|
|
217
|
+
(sum, currentValue) => sum + currentValue,
|
|
218
|
+
0,
|
|
219
|
+
) +
|
|
227
220
|
heightInfo.storeyHeightsAboveGround.reduce(
|
|
228
221
|
(sum, currentValue) => sum + currentValue,
|
|
229
222
|
0,
|
|
230
223
|
);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
};
|
|
224
|
+
|
|
225
|
+
const secondPoint = Cartesian3.fromDegrees(
|
|
226
|
+
wgs84Coords[0],
|
|
227
|
+
wgs84Coords[1],
|
|
228
|
+
wgs84Coords[2] - heightValueCorrection,
|
|
229
|
+
);
|
|
230
|
+
const linePositions = [position, secondPoint];
|
|
231
|
+
return createLineGeometries({ positions: linePositions }, heightInfo, style);
|
|
239
232
|
}
|
|
240
233
|
|
|
241
|
-
|
|
242
|
-
|
|
234
|
+
/**
|
|
235
|
+
* Sets the correct height on the wgs84Coords depending on the height info
|
|
236
|
+
* @param geometry
|
|
237
|
+
* @param heightInfo
|
|
238
|
+
*/
|
|
239
|
+
export function getWgs84CoordinatesForPoint(
|
|
240
|
+
geometry: Point,
|
|
243
241
|
heightInfo: VectorHeightInfo,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
242
|
+
): Coordinate {
|
|
243
|
+
const transformer = mercatorToWgs84TransformerForHeightInfo(heightInfo);
|
|
244
|
+
const wgs84Coords = transformer(geometry.getCoordinates());
|
|
245
|
+
if (!isClampedHeightReference(heightInfo.heightReference)) {
|
|
246
|
+
// points get rendered at the top of the extrusion. we must add this to the Z value
|
|
247
|
+
const extrusionHeight = (
|
|
248
|
+
heightInfo as VectorHeightInfo<
|
|
249
|
+
RelativeHeightReference | HeightReference.NONE
|
|
250
|
+
>
|
|
251
|
+
).storeyHeightsAboveGround.reduce(
|
|
251
252
|
(sum, currentValue) => sum + currentValue,
|
|
252
253
|
0,
|
|
253
254
|
);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
heightValue -= heightValueCorrection;
|
|
259
|
-
const secondPoint = Cartesian3.fromDegrees(
|
|
260
|
-
pointPosition[0],
|
|
261
|
-
pointPosition[1],
|
|
262
|
-
heightValue,
|
|
263
|
-
);
|
|
264
|
-
const linePositions = [positions[i], secondPoint];
|
|
265
|
-
lineGeometries.push(
|
|
266
|
-
...createLineGeometries({ positions: linePositions }, style),
|
|
267
|
-
);
|
|
255
|
+
|
|
256
|
+
if (extrusionHeight) {
|
|
257
|
+
wgs84Coords[2] += extrusionHeight;
|
|
258
|
+
}
|
|
268
259
|
}
|
|
269
|
-
|
|
260
|
+
|
|
261
|
+
return wgs84Coords;
|
|
270
262
|
}
|
|
271
263
|
|
|
272
|
-
export
|
|
264
|
+
export async function getPointPrimitives(
|
|
273
265
|
feature: Feature,
|
|
266
|
+
geometry: Point,
|
|
274
267
|
style: Style,
|
|
275
|
-
geometries: Point[],
|
|
276
268
|
vectorProperties: VectorProperties,
|
|
277
269
|
scene: Scene,
|
|
278
|
-
|
|
279
|
-
): Promise<
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
// no geometries, so early escape
|
|
286
|
-
if (!validGeometries.length) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const coordinates = getCoordinates(validGeometries);
|
|
291
|
-
const heightInfo = getHeightInfo(feature, vectorProperties, coordinates);
|
|
292
|
-
let { heightReference } = heightInfo;
|
|
293
|
-
const allowPicking = vectorProperties.getAllowPicking(feature);
|
|
294
|
-
|
|
295
|
-
const { positions, wgs84Positions } = getCartesian3AndWGS84FromCoordinates(
|
|
296
|
-
coordinates,
|
|
297
|
-
heightInfo,
|
|
270
|
+
heightInfo: VectorHeightInfo,
|
|
271
|
+
): Promise<(CesiumGeometryOption | ConvertedItem)[]> {
|
|
272
|
+
const wgs84Coords = getWgs84CoordinatesForPoint(geometry, heightInfo);
|
|
273
|
+
const position = Cartesian3.fromDegrees(
|
|
274
|
+
wgs84Coords[0],
|
|
275
|
+
wgs84Coords[1],
|
|
276
|
+
wgs84Coords[2],
|
|
298
277
|
);
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (feature.get('olcs_modelUrl')) {
|
|
302
|
-
modelOrPrimitiveOptions = await getModelOptions(
|
|
303
|
-
feature,
|
|
304
|
-
wgs84Positions,
|
|
305
|
-
positions,
|
|
306
|
-
vectorProperties,
|
|
307
|
-
scene,
|
|
308
|
-
style,
|
|
309
|
-
);
|
|
310
|
-
} else if (feature.get('olcs_primitiveOptions')) {
|
|
311
|
-
modelOrPrimitiveOptions = await getPrimitiveOptions(
|
|
278
|
+
const pointPrimitives: (CesiumGeometryOption | ConvertedItem)[] =
|
|
279
|
+
await getModelOrPointPrimitiveOptions(
|
|
312
280
|
feature,
|
|
313
281
|
style,
|
|
314
|
-
|
|
315
|
-
|
|
282
|
+
position,
|
|
283
|
+
wgs84Coords,
|
|
316
284
|
vectorProperties,
|
|
285
|
+
heightInfo,
|
|
317
286
|
scene,
|
|
318
287
|
);
|
|
319
|
-
} else {
|
|
320
|
-
modelOrPrimitiveOptions =
|
|
321
|
-
(await getModelOptions(
|
|
322
|
-
feature,
|
|
323
|
-
wgs84Positions,
|
|
324
|
-
positions,
|
|
325
|
-
vectorProperties,
|
|
326
|
-
scene,
|
|
327
|
-
style,
|
|
328
|
-
)) ??
|
|
329
|
-
(await getPrimitiveOptions(
|
|
330
|
-
feature,
|
|
331
|
-
style,
|
|
332
|
-
wgs84Positions,
|
|
333
|
-
positions,
|
|
334
|
-
vectorProperties,
|
|
335
|
-
scene,
|
|
336
|
-
));
|
|
337
|
-
}
|
|
338
288
|
|
|
339
|
-
if (
|
|
340
|
-
const lineGeometries = getLineGeometries(
|
|
341
|
-
wgs84Positions,
|
|
342
|
-
heightInfo,
|
|
343
|
-
positions,
|
|
344
|
-
style,
|
|
345
|
-
);
|
|
346
|
-
if (lineGeometries.length) {
|
|
347
|
-
heightReference = HeightReference.NONE;
|
|
348
|
-
const linePrimitive = createLinePrimitive(
|
|
349
|
-
scene,
|
|
350
|
-
vectorProperties,
|
|
351
|
-
allowPicking,
|
|
352
|
-
feature,
|
|
353
|
-
lineGeometries,
|
|
354
|
-
style,
|
|
355
|
-
false,
|
|
356
|
-
);
|
|
357
|
-
if (linePrimitive) {
|
|
358
|
-
context.addPrimitives([linePrimitive], feature, allowPicking);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
if (modelOrPrimitiveOptions) {
|
|
363
|
-
if (modelOrPrimitiveOptions.options.autoScale) {
|
|
364
|
-
context.addScaledPrimitives(
|
|
365
|
-
modelOrPrimitiveOptions.primitives,
|
|
366
|
-
feature,
|
|
367
|
-
allowPicking,
|
|
368
|
-
);
|
|
369
|
-
} else {
|
|
370
|
-
context.addPrimitives(
|
|
371
|
-
modelOrPrimitiveOptions.primitives,
|
|
372
|
-
feature,
|
|
373
|
-
allowPicking,
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
} else {
|
|
289
|
+
if (pointPrimitives.length === 0) {
|
|
377
290
|
const bbOptions = getBillboardOptions(
|
|
378
291
|
feature,
|
|
379
292
|
style,
|
|
380
|
-
heightReference,
|
|
293
|
+
heightInfo.heightReference,
|
|
381
294
|
vectorProperties,
|
|
382
295
|
);
|
|
383
296
|
if (bbOptions) {
|
|
384
|
-
|
|
385
|
-
|
|
297
|
+
pointPrimitives.push({
|
|
298
|
+
type: 'billboard',
|
|
299
|
+
item: { ...bbOptions, position },
|
|
386
300
|
});
|
|
387
|
-
context.addBillboards(bbOptionsperPosition, feature, allowPicking);
|
|
388
301
|
}
|
|
389
302
|
|
|
390
303
|
const labelOptions = getLabelOptions(
|
|
391
304
|
feature,
|
|
392
305
|
style,
|
|
393
|
-
heightReference,
|
|
306
|
+
heightInfo.heightReference,
|
|
394
307
|
vectorProperties,
|
|
395
308
|
);
|
|
396
309
|
if (labelOptions) {
|
|
397
|
-
|
|
398
|
-
|
|
310
|
+
pointPrimitives.push({
|
|
311
|
+
type: 'label',
|
|
312
|
+
item: { ...labelOptions, position },
|
|
399
313
|
});
|
|
400
|
-
context.addLabels(labelOptionsPerPosition, feature, allowPicking);
|
|
401
314
|
}
|
|
402
315
|
}
|
|
316
|
+
|
|
317
|
+
if (
|
|
318
|
+
!isClampedHeightReference(heightInfo.heightReference) &&
|
|
319
|
+
(
|
|
320
|
+
heightInfo as VectorHeightInfo<
|
|
321
|
+
RelativeHeightReference | HeightReference.NONE
|
|
322
|
+
>
|
|
323
|
+
).extruded &&
|
|
324
|
+
style.getStroke()
|
|
325
|
+
) {
|
|
326
|
+
pointPrimitives.push(
|
|
327
|
+
...getLineGeometries(
|
|
328
|
+
heightInfo as VectorHeightInfo<
|
|
329
|
+
RelativeHeightReference | HeightReference.NONE
|
|
330
|
+
>,
|
|
331
|
+
position,
|
|
332
|
+
wgs84Coords,
|
|
333
|
+
style,
|
|
334
|
+
),
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return pointPrimitives;
|
|
403
339
|
}
|
|
@@ -6,34 +6,27 @@ import {
|
|
|
6
6
|
GroundPolylineGeometry,
|
|
7
7
|
PolygonHierarchy,
|
|
8
8
|
PolylineGeometry,
|
|
9
|
-
type Scene,
|
|
10
9
|
} from '@vcmap-cesium/engine';
|
|
11
10
|
import type { Style } from 'ol/style.js';
|
|
12
11
|
import type { Polygon } from 'ol/geom.js';
|
|
13
|
-
import type { Coordinate } from 'ol/coordinate.js';
|
|
14
|
-
import type { Feature } from 'ol/index.js';
|
|
15
12
|
import { parseNumber } from '@vcsuite/parsers';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export type PolylineGeometryOptions = ConstructorParameters<
|
|
28
|
-
typeof PolylineGeometry
|
|
29
|
-
>[0];
|
|
13
|
+
import {
|
|
14
|
+
mercatorToCartesianTransformerForHeightInfo,
|
|
15
|
+
VectorHeightInfo,
|
|
16
|
+
} from './vectorHeightInfo.js';
|
|
17
|
+
import {
|
|
18
|
+
CesiumGeometryOption,
|
|
19
|
+
PolygonGeometryOptions,
|
|
20
|
+
PolylineGeometryOptions,
|
|
21
|
+
VectorGeometryFactory,
|
|
22
|
+
} from './vectorGeometryFactory.js';
|
|
30
23
|
|
|
31
|
-
|
|
24
|
+
function createPolygonGeometry(
|
|
32
25
|
options: PolygonGeometryOptions,
|
|
33
26
|
height: number,
|
|
34
27
|
perPositionHeight: boolean,
|
|
35
28
|
extrudedHeight?: number,
|
|
36
|
-
): PolygonGeometry
|
|
29
|
+
): PolygonGeometry {
|
|
37
30
|
const polygonOptions: PolygonGeometryOptions = {
|
|
38
31
|
...options,
|
|
39
32
|
perPositionHeight,
|
|
@@ -42,35 +35,69 @@ export function createSolidGeometries(
|
|
|
42
35
|
if (!perPositionHeight) {
|
|
43
36
|
polygonOptions.height = height;
|
|
44
37
|
}
|
|
45
|
-
|
|
38
|
+
|
|
39
|
+
return new PolygonGeometry(polygonOptions);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function createSolidGeometries(
|
|
43
|
+
options: PolygonGeometryOptions,
|
|
44
|
+
heightInfo: VectorHeightInfo,
|
|
45
|
+
height: number,
|
|
46
|
+
perPositionHeight: boolean,
|
|
47
|
+
extrudedHeight?: number,
|
|
48
|
+
): CesiumGeometryOption<'solid'>[] {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
type: 'solid',
|
|
52
|
+
geometry: createPolygonGeometry(
|
|
53
|
+
options,
|
|
54
|
+
height,
|
|
55
|
+
perPositionHeight,
|
|
56
|
+
extrudedHeight,
|
|
57
|
+
),
|
|
58
|
+
heightInfo,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
46
61
|
}
|
|
47
62
|
|
|
48
|
-
|
|
63
|
+
function createOutlineGeometries(
|
|
49
64
|
options: PolygonGeometryOptions,
|
|
65
|
+
heightInfo: VectorHeightInfo,
|
|
50
66
|
height: number,
|
|
51
67
|
perPositionHeight: boolean,
|
|
52
68
|
extrudedHeight?: number,
|
|
53
|
-
):
|
|
69
|
+
): CesiumGeometryOption<'outline'>[] {
|
|
54
70
|
return [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
{
|
|
72
|
+
type: 'outline',
|
|
73
|
+
geometry: new PolygonOutlineGeometry({
|
|
74
|
+
...options,
|
|
75
|
+
height: perPositionHeight ? undefined : height,
|
|
76
|
+
extrudedHeight,
|
|
77
|
+
perPositionHeight,
|
|
78
|
+
vertexFormat: PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
|
|
79
|
+
}),
|
|
80
|
+
heightInfo,
|
|
81
|
+
},
|
|
62
82
|
];
|
|
63
83
|
}
|
|
64
84
|
|
|
65
|
-
|
|
85
|
+
function createFillGeometries(
|
|
66
86
|
options: PolygonGeometryOptions,
|
|
87
|
+
heightInfo: VectorHeightInfo,
|
|
67
88
|
height: number,
|
|
68
89
|
perPositionHeight: boolean,
|
|
69
|
-
):
|
|
70
|
-
return
|
|
90
|
+
): CesiumGeometryOption<'fill'>[] {
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
type: 'fill',
|
|
94
|
+
geometry: createPolygonGeometry(options, height, perPositionHeight),
|
|
95
|
+
heightInfo,
|
|
96
|
+
},
|
|
97
|
+
];
|
|
71
98
|
}
|
|
72
99
|
|
|
73
|
-
|
|
100
|
+
function getLineGeometryOptions(
|
|
74
101
|
options: PolygonGeometryOptions,
|
|
75
102
|
style: Style,
|
|
76
103
|
): PolylineGeometryOptions[] {
|
|
@@ -91,47 +118,43 @@ export function getLineGeometryOptions(
|
|
|
91
118
|
return geometryOptions;
|
|
92
119
|
}
|
|
93
120
|
|
|
94
|
-
|
|
121
|
+
function createGroundLineGeometries(
|
|
95
122
|
options: PolygonGeometryOptions,
|
|
123
|
+
heightInfo: VectorHeightInfo,
|
|
96
124
|
style: Style,
|
|
97
|
-
):
|
|
98
|
-
return getLineGeometryOptions(options, style).map((option) => {
|
|
99
|
-
|
|
100
|
-
|
|
125
|
+
): CesiumGeometryOption<'groundLine'>[] {
|
|
126
|
+
return getLineGeometryOptions(options, style).map((option) => ({
|
|
127
|
+
type: 'groundLine',
|
|
128
|
+
geometry: new GroundPolylineGeometry(option),
|
|
129
|
+
heightInfo,
|
|
130
|
+
}));
|
|
101
131
|
}
|
|
102
|
-
|
|
132
|
+
|
|
133
|
+
function createLineGeometries(
|
|
103
134
|
options: PolygonGeometryOptions,
|
|
135
|
+
heightInfo: VectorHeightInfo,
|
|
104
136
|
style: Style,
|
|
105
|
-
):
|
|
106
|
-
return getLineGeometryOptions(options, style).map((option) => {
|
|
107
|
-
|
|
108
|
-
|
|
137
|
+
): CesiumGeometryOption<'line'>[] {
|
|
138
|
+
return getLineGeometryOptions(options, style).map((option) => ({
|
|
139
|
+
type: 'line',
|
|
140
|
+
geometry: new PolylineGeometry(option),
|
|
141
|
+
heightInfo,
|
|
142
|
+
}));
|
|
109
143
|
}
|
|
110
144
|
|
|
111
|
-
|
|
145
|
+
function getGeometryOptions(
|
|
112
146
|
geometry: Polygon,
|
|
113
|
-
|
|
114
|
-
perPositionHeight: boolean,
|
|
115
|
-
groundLevelOrMinHeight: number,
|
|
147
|
+
heightInfo: VectorHeightInfo,
|
|
116
148
|
): PolygonGeometryOptions {
|
|
117
149
|
let hieraryPositions;
|
|
118
150
|
const holes = [];
|
|
119
151
|
const rings = geometry.getLinearRings();
|
|
152
|
+
|
|
153
|
+
const coordinateTransformer =
|
|
154
|
+
mercatorToCartesianTransformerForHeightInfo(heightInfo);
|
|
120
155
|
for (let i = 0; i < rings.length; i++) {
|
|
121
156
|
const coords = rings[i].getCoordinates();
|
|
122
|
-
const positions = coords.map(
|
|
123
|
-
const wgs84Coords = Projection.mercatorToWgs84(coord);
|
|
124
|
-
if (!perPositionHeight && groundLevelOrMinHeight) {
|
|
125
|
-
wgs84Coords[2] = groundLevelOrMinHeight;
|
|
126
|
-
} else if (wgs84Coords[2] != null) {
|
|
127
|
-
wgs84Coords[2] += positionHeightAdjustment;
|
|
128
|
-
}
|
|
129
|
-
return Cartesian3.fromDegrees(
|
|
130
|
-
wgs84Coords[0],
|
|
131
|
-
wgs84Coords[1],
|
|
132
|
-
wgs84Coords[2],
|
|
133
|
-
);
|
|
134
|
-
});
|
|
157
|
+
const positions = coords.map(coordinateTransformer);
|
|
135
158
|
// make sure the last and first vertex is identical.
|
|
136
159
|
if (!Cartesian3.equals(positions[0], positions[positions.length - 1])) {
|
|
137
160
|
positions.push(positions[0]);
|
|
@@ -147,31 +170,6 @@ export function getGeometryOptions(
|
|
|
147
170
|
};
|
|
148
171
|
}
|
|
149
172
|
|
|
150
|
-
export function getCoordinates(geometries: Polygon[]): Coordinate[] {
|
|
151
|
-
const coordinates: Coordinate[] = [];
|
|
152
|
-
geometries.forEach((polygon) => {
|
|
153
|
-
coordinates.push(...getFlatCoordinatesFromSimpleGeometry(polygon));
|
|
154
|
-
});
|
|
155
|
-
return coordinates;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
let geometryFactory: VectorGeometryFactoryType | null = null;
|
|
159
|
-
|
|
160
|
-
function getGeometryFactory(): VectorGeometryFactoryType {
|
|
161
|
-
if (!geometryFactory) {
|
|
162
|
-
geometryFactory = {
|
|
163
|
-
getCoordinates,
|
|
164
|
-
getGeometryOptions,
|
|
165
|
-
createSolidGeometries,
|
|
166
|
-
createOutlineGeometries,
|
|
167
|
-
createFillGeometries,
|
|
168
|
-
createGroundLineGeometries,
|
|
169
|
-
createLineGeometries,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
return geometryFactory;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
173
|
/**
|
|
176
174
|
* TODO maybe add validation Functions to OpenlayersMap
|
|
177
175
|
* validates if a polygon is renderable
|
|
@@ -204,37 +202,20 @@ export function validatePolygon(polygon: Polygon): boolean {
|
|
|
204
202
|
return false;
|
|
205
203
|
}
|
|
206
204
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
scene: Scene,
|
|
222
|
-
context: AsyncCesiumVectorContext,
|
|
223
|
-
): void {
|
|
224
|
-
if (!style.getFill() && !style.getStroke()) {
|
|
225
|
-
return;
|
|
205
|
+
let geometryFactory: VectorGeometryFactory<'polygon'> | undefined;
|
|
206
|
+
|
|
207
|
+
export function getPolygonGeometryFactory(): VectorGeometryFactory<'polygon'> {
|
|
208
|
+
if (!geometryFactory) {
|
|
209
|
+
geometryFactory = {
|
|
210
|
+
type: 'polygon',
|
|
211
|
+
getGeometryOptions,
|
|
212
|
+
createSolidGeometries,
|
|
213
|
+
createOutlineGeometries,
|
|
214
|
+
createFillGeometries,
|
|
215
|
+
createGroundLineGeometries,
|
|
216
|
+
createLineGeometries,
|
|
217
|
+
validateGeometry: validatePolygon,
|
|
218
|
+
};
|
|
226
219
|
}
|
|
227
|
-
|
|
228
|
-
const validGeometries = geometries.filter((polygon) =>
|
|
229
|
-
validatePolygon(polygon),
|
|
230
|
-
);
|
|
231
|
-
addPrimitivesToContext(
|
|
232
|
-
feature,
|
|
233
|
-
style,
|
|
234
|
-
validGeometries,
|
|
235
|
-
vectorProperties,
|
|
236
|
-
scene,
|
|
237
|
-
polygonGeometryFactory,
|
|
238
|
-
context,
|
|
239
|
-
);
|
|
220
|
+
return geometryFactory;
|
|
240
221
|
}
|