@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,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WallGeometry, WallOutlineGeometry, GroundPolylineGeometry, PolylineGeometry, Math as CesiumMath, Cartesian3, } from '@vcmap-cesium/engine';
|
|
2
2
|
import { Feature } from 'ol';
|
|
3
3
|
import { Point } from 'ol/geom.js';
|
|
4
4
|
import { parseNumber } from '@vcsuite/parsers';
|
|
5
|
-
import
|
|
6
|
-
import { addPrimitivesToContext } from './featureconverterHelper.js';
|
|
7
|
-
import { getFlatCoordinatesFromSimpleGeometry } from '../geometryHelpers.js';
|
|
8
|
-
import ArrowStyle, { ArrowEnd } from '../../style/arrowStyle.js';
|
|
5
|
+
import { ArrowEnd } from '../../style/arrowStyle.js';
|
|
9
6
|
import { getCartesianBearing, getCartesianPitch } from '../math.js';
|
|
10
7
|
import { getPrimitiveOptions } from './pointHelpers.js';
|
|
8
|
+
import { getWgs84CoordinatesForPoint } from './pointToCesium.js';
|
|
9
|
+
import { getHeightInfo, mercatorToCartesianTransformerForHeightInfo, isAbsoluteHeightReference, } from './vectorHeightInfo.js';
|
|
11
10
|
function getArrowOptions(from, to, heightReference) {
|
|
12
|
-
let pitch = heightReference
|
|
11
|
+
let pitch = isAbsoluteHeightReference(heightReference)
|
|
12
|
+
? getCartesianPitch(to, from)
|
|
13
|
+
: 0;
|
|
13
14
|
pitch += 90;
|
|
14
15
|
return {
|
|
15
16
|
location: to,
|
|
@@ -17,128 +18,107 @@ function getArrowOptions(from, to, heightReference) {
|
|
|
17
18
|
heading: CesiumMath.toDegrees(getCartesianBearing(from, to) + CesiumMath.PI_OVER_TWO),
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
export
|
|
21
|
+
export function getArrowHeadPrimitives(feature, style, geometry, vectorProperties, scene, inputCoordinates) {
|
|
21
22
|
if (style.end === ArrowEnd.NONE || !style.primitiveOptions?.geometryOptions) {
|
|
22
|
-
return;
|
|
23
|
+
return [];
|
|
23
24
|
}
|
|
24
25
|
const arrowOptions = [];
|
|
25
26
|
const heightReference = vectorProperties.getAltitudeMode(feature);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
});
|
|
27
|
+
const coordinates = inputCoordinates ?? geometry.getCoordinates();
|
|
28
|
+
if (style.end === ArrowEnd.START || style.end === ArrowEnd.BOTH) {
|
|
29
|
+
arrowOptions.push(getArrowOptions(coordinates[1], coordinates[0], heightReference));
|
|
30
|
+
}
|
|
31
|
+
if (style.end === ArrowEnd.END || style.end === ArrowEnd.BOTH) {
|
|
32
|
+
arrowOptions.push(getArrowOptions(coordinates.at(-2), coordinates.at(-1), heightReference));
|
|
33
|
+
}
|
|
35
34
|
if (arrowOptions.length === 0) {
|
|
36
|
-
return;
|
|
35
|
+
return [];
|
|
37
36
|
}
|
|
38
37
|
const usedStyle = style.getOlcsStyle();
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
return arrowOptions
|
|
39
|
+
.map((arrowOption) => {
|
|
40
|
+
const arrowHeadGeometry = new Point(arrowOption.location);
|
|
41
41
|
const arrowFeature = new Feature({
|
|
42
42
|
...feature.getProperties(),
|
|
43
43
|
olcs_primitiveOptions: style.primitiveOptions,
|
|
44
44
|
olcs_modelHeading: arrowOption.heading,
|
|
45
45
|
olcs_modelPitch: arrowOption.pitch,
|
|
46
|
-
geometry:
|
|
46
|
+
geometry: arrowHeadGeometry,
|
|
47
47
|
olcs_modelAutoScale: true,
|
|
48
48
|
});
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}));
|
|
49
|
+
const heightInfo = getHeightInfo(arrowFeature, arrowHeadGeometry, vectorProperties);
|
|
50
|
+
const wgs84Coords = getWgs84CoordinatesForPoint(arrowHeadGeometry, heightInfo);
|
|
51
|
+
const position = Cartesian3.fromDegrees(wgs84Coords[0], wgs84Coords[1], wgs84Coords[2]);
|
|
52
|
+
return getPrimitiveOptions(arrowFeature, usedStyle, position, wgs84Coords, vectorProperties, scene, heightInfo);
|
|
53
|
+
})
|
|
54
|
+
.flat();
|
|
56
55
|
}
|
|
57
|
-
export function createSolidGeometries(options, height, perPositionHeight, extrudedHeight) {
|
|
56
|
+
export function createSolidGeometries(options, heightInfo, height, perPositionHeight, extrudedHeight) {
|
|
58
57
|
return [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
{
|
|
59
|
+
type: 'solid',
|
|
60
|
+
geometry: WallGeometry.fromConstantHeights({
|
|
61
|
+
...options,
|
|
62
|
+
maximumHeight: !perPositionHeight ? height : undefined,
|
|
63
|
+
minimumHeight: extrudedHeight,
|
|
64
|
+
}),
|
|
65
|
+
heightInfo,
|
|
66
|
+
},
|
|
64
67
|
];
|
|
65
68
|
}
|
|
66
|
-
export function createOutlineGeometries(options, height, perPositionHeight, extrudedHeight) {
|
|
69
|
+
export function createOutlineGeometries(options, heightInfo, height, perPositionHeight, extrudedHeight) {
|
|
67
70
|
// maxium and minimum are flipped, to create the same perPositionHeight behaviour as in polygons
|
|
68
71
|
// WallGeometries extrudes down instead of up, so we switch the behaviour and extrude in the other direction
|
|
69
72
|
return [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
{
|
|
74
|
+
type: 'outline',
|
|
75
|
+
geometry: WallOutlineGeometry.fromConstantHeights({
|
|
76
|
+
...options,
|
|
77
|
+
maximumHeight: !perPositionHeight ? height : undefined,
|
|
78
|
+
minimumHeight: extrudedHeight,
|
|
79
|
+
}),
|
|
80
|
+
heightInfo,
|
|
81
|
+
},
|
|
75
82
|
];
|
|
76
83
|
}
|
|
77
|
-
export function
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
|
-
export function createGroundLineGeometries(options, style) {
|
|
84
|
+
export function createGroundLineGeometries(options, heightInfo, style) {
|
|
81
85
|
const width = parseNumber(style.getStroke().getWidth(), 1.0);
|
|
82
86
|
return [
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
{
|
|
88
|
+
type: 'groundLine',
|
|
89
|
+
geometry: new GroundPolylineGeometry({
|
|
90
|
+
...options,
|
|
91
|
+
width,
|
|
92
|
+
}),
|
|
93
|
+
heightInfo,
|
|
94
|
+
},
|
|
87
95
|
];
|
|
88
96
|
}
|
|
89
|
-
export function createLineGeometries(options, style) {
|
|
97
|
+
export function createLineGeometries(options, heightInfo, style) {
|
|
90
98
|
const width = parseNumber(style.getStroke().getWidth(), 1.0);
|
|
91
99
|
return [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
{
|
|
101
|
+
type: 'line',
|
|
102
|
+
geometry: new PolylineGeometry({
|
|
103
|
+
...options,
|
|
104
|
+
width,
|
|
105
|
+
}),
|
|
106
|
+
heightInfo,
|
|
107
|
+
},
|
|
96
108
|
];
|
|
97
109
|
}
|
|
98
110
|
/**
|
|
99
111
|
* Creates the positions array for PolylineGeometry
|
|
100
112
|
* @param geometry
|
|
101
|
-
* @param
|
|
102
|
-
* @param perPositionHeight
|
|
103
|
-
* @param groundLevelOrMinHeight
|
|
113
|
+
* @param heightInfo
|
|
104
114
|
* @private
|
|
105
115
|
*/
|
|
106
|
-
export function getGeometryOptions(geometry,
|
|
116
|
+
export function getGeometryOptions(geometry, heightInfo) {
|
|
107
117
|
const coords = geometry.getCoordinates();
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
if (!perPositionHeight && groundLevelOrMinHeight) {
|
|
111
|
-
wgs84Coords[2] = groundLevelOrMinHeight;
|
|
112
|
-
}
|
|
113
|
-
else if (wgs84Coords[2] != null) {
|
|
114
|
-
wgs84Coords[2] += positionHeightAdjustment;
|
|
115
|
-
}
|
|
116
|
-
return Cartesian3.fromDegrees(wgs84Coords[0], wgs84Coords[1], wgs84Coords[2]);
|
|
117
|
-
});
|
|
118
|
+
const coordinateTransformer = mercatorToCartesianTransformerForHeightInfo(heightInfo);
|
|
119
|
+
const positions = coords.map(coordinateTransformer);
|
|
118
120
|
return { positions };
|
|
119
121
|
}
|
|
120
|
-
export function getCoordinates(geometries) {
|
|
121
|
-
const coordinates = [];
|
|
122
|
-
geometries.forEach((lineString) => {
|
|
123
|
-
coordinates.push(...getFlatCoordinatesFromSimpleGeometry(lineString));
|
|
124
|
-
});
|
|
125
|
-
return coordinates;
|
|
126
|
-
}
|
|
127
|
-
let geometryFactory = null;
|
|
128
|
-
function getGeometryFactory() {
|
|
129
|
-
if (!geometryFactory) {
|
|
130
|
-
geometryFactory = {
|
|
131
|
-
getCoordinates,
|
|
132
|
-
getGeometryOptions,
|
|
133
|
-
createSolidGeometries,
|
|
134
|
-
createOutlineGeometries,
|
|
135
|
-
createFillGeometries,
|
|
136
|
-
createGroundLineGeometries,
|
|
137
|
-
createLineGeometries,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
return geometryFactory;
|
|
141
|
-
}
|
|
142
122
|
/**
|
|
143
123
|
* validates if a lineString is renderable
|
|
144
124
|
* @param lineString
|
|
@@ -154,24 +134,22 @@ export function validateLineString(lineString) {
|
|
|
154
134
|
}
|
|
155
135
|
return false;
|
|
156
136
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
addPrimitivesToContext(feature, style, validGeometries, vectorProperties, scene, lineGeometryFactory, context);
|
|
173
|
-
if (style instanceof ArrowStyle) {
|
|
174
|
-
await addArrowsToContext(feature, style, validGeometries, vectorProperties, scene, lineGeometryFactory, context);
|
|
137
|
+
let geometryFactory;
|
|
138
|
+
export function getLineStringGeometryFactory() {
|
|
139
|
+
if (!geometryFactory) {
|
|
140
|
+
geometryFactory = {
|
|
141
|
+
type: 'lineString',
|
|
142
|
+
getGeometryOptions,
|
|
143
|
+
createSolidGeometries,
|
|
144
|
+
createOutlineGeometries,
|
|
145
|
+
createFillGeometries() {
|
|
146
|
+
return [];
|
|
147
|
+
},
|
|
148
|
+
createGroundLineGeometries,
|
|
149
|
+
createLineGeometries,
|
|
150
|
+
validateGeometry: validateLineString,
|
|
151
|
+
};
|
|
175
152
|
}
|
|
153
|
+
return geometryFactory;
|
|
176
154
|
}
|
|
177
155
|
//# sourceMappingURL=lineStringToCesium.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineStringToCesium.js","sourceRoot":"","sources":["../../../../src/util/featureconverter/lineStringToCesium.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"lineStringToCesium.js","sourceRoot":"","sources":["../../../../src/util/featureconverter/lineStringToCesium.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,IAAI,IAAI,UAAU,EAGlB,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAmB,KAAK,EAAE,MAAM,YAAY,CAAC;AAIpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAmB,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CA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zB,CAAC"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { Cartesian3,
|
|
1
|
+
import { Cartesian3, type Scene } from '@vcmap-cesium/engine';
|
|
2
2
|
import type { Feature } from 'ol/index.js';
|
|
3
|
-
import type { Coordinate } from 'ol/coordinate.js';
|
|
4
3
|
import { type Style } from 'ol/style.js';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare function getPrimitiveOptions(feature: Feature, style: Style,
|
|
11
|
-
|
|
12
|
-
options: VectorPropertiesPrimitive;
|
|
13
|
-
}>;
|
|
4
|
+
import { Coordinate } from 'ol/coordinate.js';
|
|
5
|
+
import VectorProperties from '../../layer/vectorProperties.js';
|
|
6
|
+
import { ConvertedItem } from './convert.js';
|
|
7
|
+
import { VectorHeightInfo } from './vectorHeightInfo.js';
|
|
8
|
+
export declare function getModelOptions(feature: Feature, position: Cartesian3, wgs84Coords: Coordinate, vectorProperties: VectorProperties, scene: Scene, heightInfo: VectorHeightInfo, style?: Style): Promise<null | ConvertedItem<'primitive'>>;
|
|
9
|
+
export declare function getPrimitiveOptions(feature: Feature, style: Style, position: Cartesian3, wgs84Coords: Coordinate, vectorProperties: VectorProperties, scene: Scene, heightInfo: VectorHeightInfo): ConvertedItem<'primitive'>[];
|
|
10
|
+
export declare function getModelOrPointPrimitiveOptions(feature: Feature, style: Style, position: Cartesian3, wgs84Coords: Coordinate, vectorProperties: VectorProperties, heightInfo: VectorHeightInfo, scene: Scene): Promise<ConvertedItem<'primitive'>[]>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { BoxGeometry, BoxOutlineGeometry, Cartesian3, Cartographic, Color, ColorGeometryInstanceAttribute, CylinderGeometry, CylinderOutlineGeometry, EllipsoidGeometry, EllipsoidOutlineGeometry, GeometryInstance, HeadingPitchRoll,
|
|
1
|
+
import { BoxGeometry, BoxOutlineGeometry, Cartesian3, Cartographic, Color, ColorGeometryInstanceAttribute, CylinderGeometry, CylinderOutlineGeometry, EllipsoidGeometry, EllipsoidOutlineGeometry, GeometryInstance, HeadingPitchRoll, Material, MaterialAppearance, Matrix4, Model, ModelAnimationLoop, PerInstanceColorAppearance, Primitive, SphereGeometry, SphereOutlineGeometry, Transforms, } from '@vcmap-cesium/engine';
|
|
2
2
|
import { RegularShape } from 'ol/style.js';
|
|
3
3
|
import { asColorLike } from 'ol/colorlike.js';
|
|
4
4
|
import { createSync } from '../../layer/vectorSymbols.js';
|
|
5
5
|
import { PrimitiveOptionsType, vectorPropertiesOfType, } from '../../layer/vectorProperties.js';
|
|
6
6
|
import { getCesiumColor } from '../../style/styleHelpers.js';
|
|
7
7
|
import ModelFill from '../../style/modelFill.js';
|
|
8
|
+
import { wgs84ToCartographic } from '../math.js';
|
|
9
|
+
import { isRelativeHeightReference, } from './vectorHeightInfo.js';
|
|
8
10
|
function makeOffsetAutoScalePrimitive(primitive, transform, scale, offset) {
|
|
9
11
|
const { modelMatrix } = primitive;
|
|
10
12
|
let currentScale = scale.clone();
|
|
@@ -43,23 +45,33 @@ function makeScaledAutoScalePrimitive(primitive, scale) {
|
|
|
43
45
|
},
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Cartesian3.add(newPosition, offset, newPosition);
|
|
56
|
-
}
|
|
57
|
-
primitive.modelMatrix = Matrix4.setTranslation(modelMatrix, newPosition, modelMatrix);
|
|
48
|
+
const scratchUpdateHeightCartesian = new Cartesian3();
|
|
49
|
+
function makeClampedPrimitive(primitive, scale, headingPitchRoll, heightReference, scene, wgs84Coords, offset) {
|
|
50
|
+
const originCartographic = wgs84ToCartographic(wgs84Coords);
|
|
51
|
+
const updatePrimitiveHeight = (clampedPosition) => {
|
|
52
|
+
clampedPosition.height += wgs84Coords[2];
|
|
53
|
+
Cartographic.toCartesian(clampedPosition, undefined, scratchUpdateHeightCartesian);
|
|
54
|
+
const geometryModelMatrix = Matrix4.fromScale(scale);
|
|
55
|
+
if (offset) {
|
|
56
|
+
Matrix4.setTranslation(geometryModelMatrix, Cartesian3.multiplyComponents(offset, scale, new Cartesian3()), geometryModelMatrix);
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
.
|
|
58
|
+
const transform = Transforms.headingPitchRollToFixedFrame(scratchUpdateHeightCartesian, headingPitchRoll);
|
|
59
|
+
primitive.modelMatrix = Matrix4.multiply(transform, geometryModelMatrix, new Matrix4());
|
|
60
|
+
};
|
|
61
|
+
const callbackHandler = scene.updateHeight(originCartographic, updatePrimitiveHeight, heightReference);
|
|
62
|
+
const height = scene.getHeight(originCartographic, heightReference);
|
|
63
|
+
if (height) {
|
|
64
|
+
const updatedHeightCarto = originCartographic.clone();
|
|
65
|
+
updatedHeightCarto.height = height;
|
|
66
|
+
updatePrimitiveHeight(updatedHeightCarto);
|
|
67
|
+
}
|
|
68
|
+
const destroy = primitive.destroy.bind(primitive);
|
|
69
|
+
primitive.destroy = () => {
|
|
70
|
+
callbackHandler();
|
|
71
|
+
destroy();
|
|
72
|
+
};
|
|
61
73
|
}
|
|
62
|
-
export async function getModelOptions(feature,
|
|
74
|
+
export async function getModelOptions(feature, position, wgs84Coords, vectorProperties, scene, heightInfo, style) {
|
|
63
75
|
const options = vectorProperties.getModel(feature);
|
|
64
76
|
if (!options) {
|
|
65
77
|
return null;
|
|
@@ -75,44 +87,42 @@ export async function getModelOptions(feature, wgs84Positions, positions, vector
|
|
|
75
87
|
color = Color.fromCssColorString(asColorLike(olColor));
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
const modelMatrix = Matrix4.multiply(Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll), Matrix4.fromScale(scale), new Matrix4());
|
|
91
|
+
const additionalModelOptions = vectorProperties.getModelOptions(feature);
|
|
92
|
+
const model = await Model.fromGltfAsync({
|
|
93
|
+
asynchronous: !feature[createSync],
|
|
94
|
+
url: options.url,
|
|
95
|
+
modelMatrix,
|
|
96
|
+
allowPicking,
|
|
97
|
+
color,
|
|
98
|
+
...additionalModelOptions,
|
|
99
|
+
});
|
|
100
|
+
const activateAnimations = () => {
|
|
101
|
+
model.activeAnimations.addAll({
|
|
102
|
+
loop: ModelAnimationLoop.REPEAT,
|
|
89
103
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
if (model.ready) {
|
|
104
|
+
};
|
|
105
|
+
if (model.ready) {
|
|
106
|
+
activateAnimations();
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const listener = model.readyEvent.addEventListener(() => {
|
|
110
|
+
listener();
|
|
100
111
|
activateAnimations();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return model;
|
|
112
|
-
}));
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (options.autoScale && !Cartesian3.ONE.equals(scale)) {
|
|
115
|
+
makeScaledAutoScalePrimitive(model, scale);
|
|
116
|
+
}
|
|
117
|
+
if (isRelativeHeightReference(heightInfo.heightReference) &&
|
|
118
|
+
heightInfo.groundLevel ==
|
|
119
|
+
null) {
|
|
120
|
+
makeClampedPrimitive(model, scale, headingPitchRoll, heightInfo.heightReference, scene, wgs84Coords);
|
|
121
|
+
}
|
|
113
122
|
return {
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
type: 'primitive',
|
|
124
|
+
item: model,
|
|
125
|
+
autoScale: options.autoScale,
|
|
116
126
|
};
|
|
117
127
|
}
|
|
118
128
|
function getGeometryInstanceFromOptions(options, color, outline) {
|
|
@@ -159,10 +169,10 @@ function getGeometryInstanceFromOptions(options, color, outline) {
|
|
|
159
169
|
}
|
|
160
170
|
return null;
|
|
161
171
|
}
|
|
162
|
-
export
|
|
172
|
+
export function getPrimitiveOptions(feature, style, position, wgs84Coords, vectorProperties, scene, heightInfo) {
|
|
163
173
|
const options = vectorProperties.getPrimitive(feature);
|
|
164
174
|
if (!options) {
|
|
165
|
-
return
|
|
175
|
+
return [];
|
|
166
176
|
}
|
|
167
177
|
const imageStyle = style.getImage();
|
|
168
178
|
let fill;
|
|
@@ -177,7 +187,7 @@ export async function getPrimitiveOptions(feature, style, wgs84Positions, positi
|
|
|
177
187
|
stroke = style.getStroke(); // XXX this makes it impossible to create an extruded un-stroked primitive with an icon in 2D or we add a new primitive option
|
|
178
188
|
}
|
|
179
189
|
if (!fill && !stroke) {
|
|
180
|
-
return
|
|
190
|
+
return [];
|
|
181
191
|
}
|
|
182
192
|
let fillColor;
|
|
183
193
|
if (fill) {
|
|
@@ -190,76 +200,80 @@ export async function getPrimitiveOptions(feature, style, wgs84Positions, positi
|
|
|
190
200
|
const scale = Cartesian3.fromArray(options.scale);
|
|
191
201
|
const headingPitchRoll = HeadingPitchRoll.fromDegrees(options.heading, options.pitch, options.roll);
|
|
192
202
|
const allowPicking = vectorProperties.getAllowPicking(feature);
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
heightReference === HeightReference.CLAMP_TO_GROUND) {
|
|
228
|
-
await placePrimitiveOnTerrain(primitive, position, scene, offset);
|
|
229
|
-
Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll, undefined, undefined, transform); // update transform for usage in offset auto scale
|
|
203
|
+
const geometryModelMatrix = Matrix4.fromScale(scale);
|
|
204
|
+
let offset;
|
|
205
|
+
if (options.primitiveOptions.offset?.length === 3) {
|
|
206
|
+
offset = Cartesian3.fromArray(options.primitiveOptions.offset);
|
|
207
|
+
Matrix4.setTranslation(geometryModelMatrix, Cartesian3.multiplyComponents(offset, scale, new Cartesian3()), geometryModelMatrix);
|
|
208
|
+
}
|
|
209
|
+
const transform = Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll);
|
|
210
|
+
const modelMatrix = Matrix4.multiply(transform, geometryModelMatrix, new Matrix4());
|
|
211
|
+
let depthFail;
|
|
212
|
+
if (options.primitiveOptions.depthFailColor) {
|
|
213
|
+
const depthFailColor = getCesiumColor(options.primitiveOptions.depthFailColor, [255, 255, 255, 0.4]);
|
|
214
|
+
depthFail = new MaterialAppearance({
|
|
215
|
+
translucent: depthFailColor.alpha < 1,
|
|
216
|
+
material: Material.fromType('Color', {
|
|
217
|
+
color: depthFailColor,
|
|
218
|
+
}),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const createPrimitive = (translucent, geometryInstances, depthFailAppearance) => {
|
|
222
|
+
const primitive = new Primitive({
|
|
223
|
+
asynchronous: !feature[createSync],
|
|
224
|
+
geometryInstances: geometryInstances.filter((g) => g),
|
|
225
|
+
modelMatrix,
|
|
226
|
+
appearance: new PerInstanceColorAppearance({
|
|
227
|
+
translucent,
|
|
228
|
+
flat: true,
|
|
229
|
+
}),
|
|
230
|
+
depthFailAppearance,
|
|
231
|
+
allowPicking,
|
|
232
|
+
...options.primitiveOptions.additionalOptions,
|
|
233
|
+
});
|
|
234
|
+
if (options.autoScale) {
|
|
235
|
+
if (offset) {
|
|
236
|
+
makeOffsetAutoScalePrimitive(primitive, transform, scale, offset);
|
|
230
237
|
}
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
makeOffsetAutoScalePrimitive(primitive, transform, scale, offset);
|
|
234
|
-
}
|
|
235
|
-
else if (!Cartesian3.ONE.equals(scale)) {
|
|
236
|
-
makeScaledAutoScalePrimitive(primitive, scale);
|
|
237
|
-
}
|
|
238
|
+
else if (!Cartesian3.ONE.equals(scale)) {
|
|
239
|
+
makeScaledAutoScalePrimitive(primitive, scale);
|
|
238
240
|
}
|
|
239
|
-
return primitive;
|
|
240
|
-
};
|
|
241
|
-
const fillAndOutline = [];
|
|
242
|
-
if (fillColor) {
|
|
243
|
-
fillAndOutline.push(createPrimitive(fillColor.alpha < 1 || !!depthFail, [
|
|
244
|
-
getGeometryInstanceFromOptions(options.primitiveOptions, fillColor),
|
|
245
|
-
], depthFail));
|
|
246
|
-
}
|
|
247
|
-
else if (depthFail) {
|
|
248
|
-
const transparent = Color.TRANSPARENT;
|
|
249
|
-
fillAndOutline.push(createPrimitive(true, [
|
|
250
|
-
getGeometryInstanceFromOptions(options.primitiveOptions, transparent),
|
|
251
|
-
], depthFail));
|
|
252
241
|
}
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
242
|
+
if (isRelativeHeightReference(heightInfo.heightReference) &&
|
|
243
|
+
heightInfo.groundLevel ==
|
|
244
|
+
null) {
|
|
245
|
+
makeClampedPrimitive(primitive, scale, headingPitchRoll, heightInfo.heightReference, scene, wgs84Coords, offset);
|
|
257
246
|
}
|
|
258
|
-
return
|
|
259
|
-
}));
|
|
260
|
-
return {
|
|
261
|
-
primitives: primitives.flatMap((p) => p),
|
|
262
|
-
options,
|
|
247
|
+
return primitive;
|
|
263
248
|
};
|
|
249
|
+
const fillAndOutline = [];
|
|
250
|
+
if (fillColor) {
|
|
251
|
+
fillAndOutline.push(createPrimitive(fillColor.alpha < 1 || !!depthFail, [getGeometryInstanceFromOptions(options.primitiveOptions, fillColor)], depthFail));
|
|
252
|
+
}
|
|
253
|
+
else if (depthFail) {
|
|
254
|
+
const transparent = Color.TRANSPARENT;
|
|
255
|
+
fillAndOutline.push(createPrimitive(true, [getGeometryInstanceFromOptions(options.primitiveOptions, transparent)], depthFail));
|
|
256
|
+
}
|
|
257
|
+
if (strokeColor) {
|
|
258
|
+
fillAndOutline.push(createPrimitive(strokeColor.alpha < 1 || !!depthFail, [
|
|
259
|
+
getGeometryInstanceFromOptions(options.primitiveOptions, strokeColor, true),
|
|
260
|
+
]));
|
|
261
|
+
}
|
|
262
|
+
return fillAndOutline.map((item) => ({
|
|
263
|
+
type: 'primitive',
|
|
264
|
+
item,
|
|
265
|
+
autoScale: options.autoScale,
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
268
|
+
export async function getModelOrPointPrimitiveOptions(feature, style, position, wgs84Coords, vectorProperties, heightInfo, scene) {
|
|
269
|
+
const renderAs = vectorProperties.renderAs(feature);
|
|
270
|
+
if (renderAs === 'model') {
|
|
271
|
+
const modelOptions = await getModelOptions(feature, position, wgs84Coords, vectorProperties, scene, heightInfo, style);
|
|
272
|
+
return modelOptions ? [modelOptions] : [];
|
|
273
|
+
}
|
|
274
|
+
if (renderAs === 'primitive') {
|
|
275
|
+
return getPrimitiveOptions(feature, style, position, wgs84Coords, vectorProperties, scene, heightInfo);
|
|
276
|
+
}
|
|
277
|
+
return [];
|
|
264
278
|
}
|
|
265
279
|
//# sourceMappingURL=pointHelpers.js.map
|