@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.
Files changed (209) hide show
  1. package/dist/cesium.d.ts +11 -0
  2. package/dist/index.d.ts +23 -16
  3. package/dist/index.js +21 -14
  4. package/dist/index.js.map +1 -1
  5. package/dist/ol.d.ts +15 -2
  6. package/dist/src/layer/cesium/clusterContext.d.ts +8 -14
  7. package/dist/src/layer/cesium/clusterContext.js +62 -41
  8. package/dist/src/layer/cesium/clusterContext.js.map +1 -1
  9. package/dist/src/layer/cesium/vectorCesiumImpl.d.ts +2 -3
  10. package/dist/src/layer/cesium/vectorCesiumImpl.js +16 -10
  11. package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
  12. package/dist/src/layer/cesium/vectorContext.d.ts +10 -53
  13. package/dist/src/layer/cesium/vectorContext.js +88 -172
  14. package/dist/src/layer/cesium/vectorContext.js.map +1 -1
  15. package/dist/src/layer/geojsonHelpers.d.ts +1 -1
  16. package/dist/src/layer/geojsonHelpers.js +5 -10
  17. package/dist/src/layer/geojsonHelpers.js.map +1 -1
  18. package/dist/src/layer/oblique/obliqueHelpers.js +6 -6
  19. package/dist/src/layer/oblique/obliqueHelpers.js.map +1 -1
  20. package/dist/src/layer/vectorLayer.d.ts +0 -37
  21. package/dist/src/layer/vectorLayer.js.map +1 -1
  22. package/dist/src/layer/vectorProperties.d.ts +8 -3
  23. package/dist/src/layer/vectorProperties.js +30 -5
  24. package/dist/src/layer/vectorProperties.js.map +1 -1
  25. package/dist/src/map/baseOLMap.js +1 -1
  26. package/dist/src/map/baseOLMap.js.map +1 -1
  27. package/dist/src/map/obliqueMap.d.ts +3 -0
  28. package/dist/src/map/obliqueMap.js +27 -6
  29. package/dist/src/map/obliqueMap.js.map +1 -1
  30. package/dist/src/map/vcsMap.d.ts +8 -0
  31. package/dist/src/map/vcsMap.js +11 -0
  32. package/dist/src/map/vcsMap.js.map +1 -1
  33. package/dist/src/oblique/helpers.js +5 -5
  34. package/dist/src/oblique/helpers.js.map +1 -1
  35. package/dist/src/oblique/obliqueDataSet.js +4 -4
  36. package/dist/src/oblique/obliqueDataSet.js.map +1 -1
  37. package/dist/src/ol/geom/geometryCollection.js +19 -2
  38. package/dist/src/ol/geom/geometryCollection.js.map +1 -1
  39. package/dist/src/style/arcStyle.js +1 -0
  40. package/dist/src/style/arcStyle.js.map +1 -1
  41. package/dist/src/util/editor/createFeatureSession.d.ts +5 -1
  42. package/dist/src/util/editor/createFeatureSession.js +48 -4
  43. package/dist/src/util/editor/createFeatureSession.js.map +1 -1
  44. package/dist/src/util/editor/editFeaturesSession.d.ts +10 -4
  45. package/dist/src/util/editor/editFeaturesSession.js +74 -37
  46. package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
  47. package/dist/src/util/editor/editGeometrySession.d.ts +5 -1
  48. package/dist/src/util/editor/editGeometrySession.js +77 -55
  49. package/dist/src/util/editor/editGeometrySession.js.map +1 -1
  50. package/dist/src/util/editor/editorHelpers.d.ts +12 -6
  51. package/dist/src/util/editor/editorHelpers.js +47 -20
  52. package/dist/src/util/editor/editorHelpers.js.map +1 -1
  53. package/dist/src/util/editor/editorSessionHelpers.d.ts +5 -0
  54. package/dist/src/util/editor/editorSessionHelpers.js +1 -0
  55. package/dist/src/util/editor/editorSessionHelpers.js.map +1 -1
  56. package/dist/src/util/editor/editorSymbols.d.ts +1 -1
  57. package/dist/src/util/editor/editorSymbols.js +1 -1
  58. package/dist/src/util/editor/editorSymbols.js.map +1 -1
  59. package/dist/src/util/editor/interactions/createBBoxInteraction.d.ts +1 -0
  60. package/dist/src/util/editor/interactions/createBBoxInteraction.js +20 -16
  61. package/dist/src/util/editor/interactions/createBBoxInteraction.js.map +1 -1
  62. package/dist/src/util/editor/interactions/createCircleInteraction.js +1 -1
  63. package/dist/src/util/editor/interactions/createCircleInteraction.js.map +1 -1
  64. package/dist/src/util/editor/interactions/createLineStringInteraction.js +3 -3
  65. package/dist/src/util/editor/interactions/createLineStringInteraction.js.map +1 -1
  66. package/dist/src/util/editor/interactions/createPointInteraction.js +1 -1
  67. package/dist/src/util/editor/interactions/createPointInteraction.js.map +1 -1
  68. package/dist/src/util/editor/interactions/createPolygonInteraction.d.ts +4 -0
  69. package/dist/src/util/editor/interactions/createPolygonInteraction.js +9 -3
  70. package/dist/src/util/editor/interactions/createPolygonInteraction.js.map +1 -1
  71. package/dist/src/util/editor/interactions/creationSnapping.d.ts +26 -0
  72. package/dist/src/util/editor/interactions/creationSnapping.js +139 -0
  73. package/dist/src/util/editor/interactions/creationSnapping.js.map +1 -0
  74. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js +3 -2
  75. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js.map +1 -1
  76. package/dist/src/util/editor/interactions/insertVertexInteraction.d.ts +3 -1
  77. package/dist/src/util/editor/interactions/insertVertexInteraction.js +14 -6
  78. package/dist/src/util/editor/interactions/insertVertexInteraction.js.map +1 -1
  79. package/dist/src/util/editor/interactions/layerSnapping.d.ts +19 -0
  80. package/dist/src/util/editor/interactions/layerSnapping.js +87 -0
  81. package/dist/src/util/editor/interactions/layerSnapping.js.map +1 -0
  82. package/dist/src/util/editor/interactions/translateVertexInteraction.js +2 -2
  83. package/dist/src/util/editor/interactions/translateVertexInteraction.js.map +1 -1
  84. package/dist/src/util/editor/interactions/translationSnapping.d.ts +25 -0
  85. package/dist/src/util/editor/interactions/translationSnapping.js +179 -0
  86. package/dist/src/util/editor/interactions/translationSnapping.js.map +1 -0
  87. package/dist/src/util/editor/snappingHelpers.d.ts +44 -0
  88. package/dist/src/util/editor/snappingHelpers.js +329 -0
  89. package/dist/src/util/editor/snappingHelpers.js.map +1 -0
  90. package/dist/src/util/editor/transformation/create2DHandlers.js +26 -26
  91. package/dist/src/util/editor/transformation/create2DHandlers.js.map +1 -1
  92. package/dist/src/util/editor/transformation/create3DHandlers.js +65 -14
  93. package/dist/src/util/editor/transformation/create3DHandlers.js.map +1 -1
  94. package/dist/src/util/editor/transformation/scaleInteraction.js +27 -5
  95. package/dist/src/util/editor/transformation/scaleInteraction.js.map +1 -1
  96. package/dist/src/util/editor/transformation/transformationHandler.js +56 -38
  97. package/dist/src/util/editor/transformation/transformationHandler.js.map +1 -1
  98. package/dist/src/util/editor/transformation/transformationTypes.d.ts +2 -0
  99. package/dist/src/util/editor/transformation/transformationTypes.js +4 -0
  100. package/dist/src/util/editor/transformation/transformationTypes.js.map +1 -1
  101. package/dist/src/util/featureconverter/arcToCesium.d.ts +5 -19
  102. package/dist/src/util/featureconverter/arcToCesium.js +15 -42
  103. package/dist/src/util/featureconverter/arcToCesium.js.map +1 -1
  104. package/dist/src/util/featureconverter/circleToCesium.d.ts +2 -27
  105. package/dist/src/util/featureconverter/circleToCesium.js +84 -63
  106. package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
  107. package/dist/src/util/featureconverter/clampedPrimitive.d.ts +2 -0
  108. package/dist/src/util/featureconverter/clampedPrimitive.js +29 -0
  109. package/dist/src/util/featureconverter/clampedPrimitive.js.map +1 -0
  110. package/dist/src/util/featureconverter/convert.d.ts +26 -7
  111. package/dist/src/util/featureconverter/convert.js +221 -44
  112. package/dist/src/util/featureconverter/convert.js.map +1 -1
  113. package/dist/src/util/featureconverter/extent3D.d.ts +4 -3
  114. package/dist/src/util/featureconverter/extent3D.js +4 -3
  115. package/dist/src/util/featureconverter/extent3D.js.map +1 -1
  116. package/dist/src/util/featureconverter/lineStringToCesium.d.ts +12 -27
  117. package/dist/src/util/featureconverter/lineStringToCesium.js +85 -107
  118. package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
  119. package/dist/src/util/featureconverter/pointHelpers.d.ts +8 -11
  120. package/dist/src/util/featureconverter/pointHelpers.js +134 -120
  121. package/dist/src/util/featureconverter/pointHelpers.js.map +1 -1
  122. package/dist/src/util/featureconverter/pointToCesium.d.ts +14 -17
  123. package/dist/src/util/featureconverter/pointToCesium.js +47 -96
  124. package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
  125. package/dist/src/util/featureconverter/polygonToCesium.d.ts +2 -26
  126. package/dist/src/util/featureconverter/polygonToCesium.js +62 -72
  127. package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
  128. package/dist/src/util/featureconverter/storeyHelpers.d.ts +17 -0
  129. package/dist/src/util/featureconverter/storeyHelpers.js +78 -0
  130. package/dist/src/util/featureconverter/storeyHelpers.js.map +1 -0
  131. package/dist/src/util/featureconverter/vectorGeometryFactory.d.ts +54 -0
  132. package/dist/src/util/featureconverter/vectorGeometryFactory.js +278 -0
  133. package/dist/src/util/featureconverter/vectorGeometryFactory.js.map +1 -0
  134. package/dist/src/util/featureconverter/vectorHeightInfo.d.ts +86 -0
  135. package/dist/src/util/featureconverter/vectorHeightInfo.js +242 -0
  136. package/dist/src/util/featureconverter/vectorHeightInfo.js.map +1 -0
  137. package/dist/src/util/geometryHelpers.d.ts +22 -1
  138. package/dist/src/util/geometryHelpers.js +65 -2
  139. package/dist/src/util/geometryHelpers.js.map +1 -1
  140. package/dist/src/util/mapCollection.js +8 -0
  141. package/dist/src/util/mapCollection.js.map +1 -1
  142. package/dist/src/util/math.d.ts +6 -2
  143. package/dist/src/util/math.js +34 -12
  144. package/dist/src/util/math.js.map +1 -1
  145. package/dist/tests/unit/helpers/cesiumHelpers.js +3 -1
  146. package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
  147. package/dist/tests/unit/helpers/helpers.d.ts +2 -9
  148. package/dist/tests/unit/helpers/helpers.js +2 -8
  149. package/dist/tests/unit/helpers/helpers.js.map +1 -1
  150. package/index.ts +74 -35
  151. package/package.json +3 -3
  152. package/src/cesium/cesium.d.ts +11 -0
  153. package/src/layer/cesium/clusterContext.ts +82 -91
  154. package/src/layer/cesium/vectorCesiumImpl.ts +17 -11
  155. package/src/layer/cesium/vectorContext.ts +120 -348
  156. package/src/layer/geojsonHelpers.ts +9 -12
  157. package/src/layer/oblique/obliqueHelpers.ts +6 -6
  158. package/src/layer/vectorLayer.ts +0 -71
  159. package/src/layer/vectorProperties.ts +46 -9
  160. package/src/map/baseOLMap.ts +1 -1
  161. package/src/map/obliqueMap.ts +46 -6
  162. package/src/map/vcsMap.ts +20 -2
  163. package/src/oblique/helpers.ts +11 -5
  164. package/src/oblique/obliqueDataSet.ts +4 -4
  165. package/src/ol/geom/geometryCollection.js +21 -2
  166. package/src/ol/ol.d.ts +15 -2
  167. package/src/style/arcStyle.ts +1 -0
  168. package/src/util/editor/createFeatureSession.ts +64 -6
  169. package/src/util/editor/editFeaturesSession.ts +105 -39
  170. package/src/util/editor/editGeometrySession.ts +118 -75
  171. package/src/util/editor/editorHelpers.ts +78 -30
  172. package/src/util/editor/editorSessionHelpers.ts +7 -0
  173. package/src/util/editor/editorSymbols.ts +1 -1
  174. package/src/util/editor/interactions/createBBoxInteraction.ts +25 -16
  175. package/src/util/editor/interactions/createCircleInteraction.ts +1 -1
  176. package/src/util/editor/interactions/createLineStringInteraction.ts +9 -3
  177. package/src/util/editor/interactions/createPointInteraction.ts +1 -1
  178. package/src/util/editor/interactions/createPolygonInteraction.ts +16 -3
  179. package/src/util/editor/interactions/creationSnapping.ts +226 -0
  180. package/src/util/editor/interactions/editGeometryMouseOverInteraction.ts +3 -2
  181. package/src/util/editor/interactions/insertVertexInteraction.ts +27 -7
  182. package/src/util/editor/interactions/layerSnapping.ts +136 -0
  183. package/src/util/editor/interactions/translateVertexInteraction.ts +8 -2
  184. package/src/util/editor/interactions/translationSnapping.ts +302 -0
  185. package/src/util/editor/snappingHelpers.ts +490 -0
  186. package/src/util/editor/transformation/create2DHandlers.ts +38 -26
  187. package/src/util/editor/transformation/create3DHandlers.ts +84 -22
  188. package/src/util/editor/transformation/scaleInteraction.ts +28 -5
  189. package/src/util/editor/transformation/transformationHandler.ts +72 -41
  190. package/src/util/editor/transformation/transformationTypes.ts +5 -0
  191. package/src/util/featureconverter/arcToCesium.ts +25 -95
  192. package/src/util/featureconverter/circleToCesium.ts +127 -113
  193. package/src/util/featureconverter/clampedPrimitive.ts +70 -0
  194. package/src/util/featureconverter/convert.ts +446 -114
  195. package/src/util/featureconverter/extent3D.ts +13 -6
  196. package/src/util/featureconverter/lineStringToCesium.ts +132 -179
  197. package/src/util/featureconverter/pointHelpers.ts +271 -214
  198. package/src/util/featureconverter/pointToCesium.ts +111 -175
  199. package/src/util/featureconverter/polygonToCesium.ts +98 -117
  200. package/src/util/featureconverter/storeyHelpers.ts +104 -0
  201. package/src/util/featureconverter/vectorGeometryFactory.ts +601 -0
  202. package/src/util/featureconverter/vectorHeightInfo.ts +393 -0
  203. package/src/util/geometryHelpers.ts +79 -5
  204. package/src/util/mapCollection.ts +8 -0
  205. package/src/util/math.ts +59 -12
  206. package/dist/src/util/featureconverter/featureconverterHelper.d.ts +0 -35
  207. package/dist/src/util/featureconverter/featureconverterHelper.js +0 -404
  208. package/dist/src/util/featureconverter/featureconverterHelper.js.map +0 -1
  209. package/src/util/featureconverter/featureconverterHelper.ts +0 -672
@@ -1,9 +1,6 @@
1
1
  import { circular } from 'ol/geom/Polygon.js';
2
2
  import type { Style } from 'ol/style.js';
3
3
  import type { Circle } from 'ol/geom.js';
4
- import type { Coordinate } from 'ol/coordinate.js';
5
- import type { Feature } from 'ol/index.js';
6
-
7
4
  import {
8
5
  Cartesian3,
9
6
  CircleGeometry,
@@ -12,57 +9,106 @@ import {
12
9
  Math as CesiumMath,
13
10
  Cartographic,
14
11
  PolylineGeometry,
15
- type Scene,
16
12
  } from '@vcmap-cesium/engine';
17
13
  import { parseNumber } from '@vcsuite/parsers';
18
- import { addPrimitivesToContext } from './featureconverterHelper.js';
19
- import Projection from '../projection.js';
20
- import type { VectorGeometryFactoryType } from '../../layer/vectorLayer.js';
21
- import type VectorProperties from '../../layer/vectorProperties.js';
22
- import type { AsyncCesiumVectorContext } from '../../layer/cesium/vectorContext.js';
23
-
24
- export function createSolidGeometries(
25
- options: ConstructorParameters<typeof CircleGeometry>[0],
14
+ import {
15
+ mercatorToCartesianTransformerForHeightInfo,
16
+ VectorHeightInfo,
17
+ } from './vectorHeightInfo.js';
18
+ import {
19
+ CesiumGeometryOption,
20
+ CircleGeometryOptions,
21
+ VectorGeometryFactory,
22
+ } from './vectorGeometryFactory.js';
23
+
24
+ function createCircleGeometry(
25
+ options: CircleGeometryOptions,
26
+ height: number,
27
+ perPositionHeight: boolean,
28
+ extrudedHeight?: number,
29
+ ): CircleGeometry {
30
+ const geometryOptions = {
31
+ ...options,
32
+ granularity: 0.02,
33
+ extrudedHeight,
34
+ };
35
+
36
+ if (!perPositionHeight) {
37
+ geometryOptions.height = height;
38
+ } else {
39
+ const cartographic = Cartographic.fromCartesian(options.center);
40
+ geometryOptions.height = cartographic.height;
41
+ }
42
+
43
+ return new CircleGeometry(geometryOptions);
44
+ }
45
+
46
+ function createSolidGeometries(
47
+ options: CircleGeometryOptions,
48
+ heightInfo: VectorHeightInfo,
26
49
  height: number,
27
- _perPositionHeight: boolean,
50
+ perPositionHeight: boolean,
28
51
  extrudedHeight?: number,
29
- ): CircleGeometry[] {
52
+ ): CesiumGeometryOption<'solid'>[] {
30
53
  return [
31
- new CircleGeometry({
32
- ...options,
33
- height,
34
- granularity: 0.02,
35
- extrudedHeight,
36
- }),
54
+ {
55
+ type: 'solid',
56
+ geometry: createCircleGeometry(
57
+ options,
58
+ height,
59
+ perPositionHeight,
60
+ extrudedHeight,
61
+ ),
62
+ heightInfo,
63
+ },
37
64
  ];
38
65
  }
39
66
 
40
- export function createOutlineGeometries(
41
- options: ConstructorParameters<typeof CircleGeometry>[0],
67
+ function createOutlineGeometries(
68
+ options: CircleGeometryOptions,
69
+ heightInfo: VectorHeightInfo,
42
70
  height: number,
43
- _perPositionHeight: boolean,
71
+ perPositionHeight: boolean,
44
72
  extrudedHeight?: number,
45
- ): CircleOutlineGeometry[] {
73
+ ): CesiumGeometryOption<'outline'>[] {
74
+ const geometryOptions = {
75
+ ...options,
76
+ granularity: 0.02,
77
+ extrudedHeight,
78
+ };
79
+
80
+ if (!perPositionHeight) {
81
+ geometryOptions.height = height;
82
+ } else {
83
+ const cartographic = Cartographic.fromCartesian(options.center);
84
+ geometryOptions.height = cartographic.height;
85
+ }
46
86
  return [
47
- new CircleOutlineGeometry({
48
- ...options,
49
- height,
50
- extrudedHeight,
51
- granularity: 0.02,
52
- }),
87
+ {
88
+ type: 'outline',
89
+ geometry: new CircleOutlineGeometry(geometryOptions),
90
+ heightInfo,
91
+ },
53
92
  ];
54
93
  }
55
94
 
56
- export function createFillGeometries(
57
- options: ConstructorParameters<typeof CircleGeometry>[0],
95
+ function createFillGeometries(
96
+ options: CircleGeometryOptions,
97
+ heightInfo: VectorHeightInfo,
58
98
  height: number,
59
99
  perPositionHeight: boolean,
60
- ): CircleGeometry[] {
61
- return createSolidGeometries(options, height, perPositionHeight, undefined);
100
+ ): CesiumGeometryOption<'fill'>[] {
101
+ return [
102
+ {
103
+ type: 'fill',
104
+ geometry: createCircleGeometry(options, height, perPositionHeight),
105
+ heightInfo,
106
+ },
107
+ ];
62
108
  }
63
109
 
64
- export function getLineGeometryOptions(
65
- options: ConstructorParameters<typeof CircleGeometry>[0],
110
+ function getLineGeometryOptions(
111
+ options: CircleGeometryOptions,
66
112
  style: Style,
67
113
  ): { width: number; positions: Cartesian3[] } {
68
114
  const width = parseNumber(style.getStroke()?.getWidth(), 1.0);
@@ -85,61 +131,58 @@ export function getLineGeometryOptions(
85
131
  };
86
132
  }
87
133
 
88
- export function createGroundLineGeometries(
89
- options: ConstructorParameters<typeof CircleGeometry>[0],
134
+ function createGroundLineGeometries(
135
+ options: CircleGeometryOptions,
136
+ heightInfo: VectorHeightInfo,
90
137
  style: Style,
91
- ): GroundPolylineGeometry[] {
138
+ ): CesiumGeometryOption<'groundLine'>[] {
92
139
  const lineOptions = getLineGeometryOptions(options, style);
93
- return [new GroundPolylineGeometry(lineOptions)];
140
+ return [
141
+ {
142
+ type: 'groundLine',
143
+ geometry: new GroundPolylineGeometry(lineOptions),
144
+ heightInfo,
145
+ },
146
+ ];
94
147
  }
95
148
 
96
- export function createLineGeometries(
97
- options: ConstructorParameters<typeof CircleGeometry>[0],
149
+ function createLineGeometries(
150
+ options: CircleGeometryOptions,
151
+ heightInfo: VectorHeightInfo,
98
152
  style: Style,
99
- ): PolylineGeometry[] {
153
+ ): CesiumGeometryOption<'line'>[] {
100
154
  const lineOptions = getLineGeometryOptions(options, style);
101
- return [new PolylineGeometry(lineOptions)];
155
+ return [
156
+ {
157
+ type: 'line',
158
+ geometry: new PolylineGeometry(lineOptions),
159
+ heightInfo,
160
+ },
161
+ ];
102
162
  }
103
163
 
104
164
  /**
105
165
  * extracts the center and radius from the CircleGeometry and converts it to Cartesian3/radius in m
106
166
  * @param geometry
107
- * @param positionHeightAdjustment
108
- * @param perPositionHeight
109
- * @param groundLevelOrMinHeight
167
+ * @param heightInfo
110
168
  * @returns
111
169
  * @private
112
170
  */
113
- export function getGeometryOptions(
171
+ function getGeometryOptions(
114
172
  geometry: Circle,
115
- positionHeightAdjustment: number,
116
- perPositionHeight: boolean,
117
- groundLevelOrMinHeight: number,
118
- ): ConstructorParameters<typeof CircleGeometry>[0] {
173
+ heightInfo: VectorHeightInfo,
174
+ ): CircleGeometryOptions {
119
175
  // olCoordinates of center and radius in WGS84
120
176
  const olCenter = geometry.getCenter();
121
177
  const olPoint = olCenter.slice();
122
178
  olPoint[0] += geometry.getRadius();
123
- const wgs84Center = Projection.mercatorToWgs84(olCenter, true);
124
- if (!perPositionHeight && groundLevelOrMinHeight) {
125
- wgs84Center[2] = groundLevelOrMinHeight;
126
- } else if (wgs84Center[2] != null) {
127
- wgs84Center[2] += positionHeightAdjustment;
128
- }
129
179
 
130
- const wgs84Point = Projection.mercatorToWgs84(olPoint, true);
180
+ const coordinateTransformer =
181
+ mercatorToCartesianTransformerForHeightInfo(heightInfo);
131
182
 
132
183
  // Cesium coordinates of center and radius
133
- const center = Cartesian3.fromDegrees(
134
- wgs84Center[0],
135
- wgs84Center[1],
136
- wgs84Center[2],
137
- );
138
- const point = Cartesian3.fromDegrees(
139
- wgs84Point[0],
140
- wgs84Point[1],
141
- wgs84Center[2],
142
- );
184
+ const center = coordinateTransformer(olCenter);
185
+ const point = coordinateTransformer(olPoint);
143
186
 
144
187
  // Computation of radius in Cesium 3D
145
188
  const radius = Cartesian3.distance(center, point);
@@ -149,29 +192,6 @@ export function getGeometryOptions(
149
192
  };
150
193
  }
151
194
 
152
- export function getCoordinates(geometries: Circle[]): Coordinate[] {
153
- return geometries.map((circle) => {
154
- return circle.getCenter();
155
- });
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
195
  /**
176
196
  * validates if a point is renderable
177
197
  */
@@ -192,26 +212,20 @@ export function validateCircle(circle: Circle): boolean {
192
212
  return false;
193
213
  }
194
214
 
195
- export default function circleToCesium(
196
- feature: Feature,
197
- style: Style,
198
- geometries: Circle[],
199
- vectorProperties: VectorProperties,
200
- scene: Scene,
201
- context: AsyncCesiumVectorContext,
202
- ): void {
203
- if (!style.getFill() && !style.getStroke()) {
204
- return;
215
+ let geometryFactory: VectorGeometryFactory<'circle'> | undefined;
216
+
217
+ export function getCircleGeometryFactory(): VectorGeometryFactory<'circle'> {
218
+ if (!geometryFactory) {
219
+ geometryFactory = {
220
+ type: 'circle',
221
+ getGeometryOptions,
222
+ createSolidGeometries,
223
+ createOutlineGeometries,
224
+ createFillGeometries,
225
+ createGroundLineGeometries,
226
+ createLineGeometries,
227
+ validateGeometry: validateCircle,
228
+ };
205
229
  }
206
- const circleGeometryFactory = getGeometryFactory();
207
- const validGeometries = geometries.filter((circle) => validateCircle(circle));
208
- addPrimitivesToContext(
209
- feature,
210
- style,
211
- validGeometries,
212
- vectorProperties,
213
- scene,
214
- circleGeometryFactory,
215
- context,
216
- );
230
+ return geometryFactory;
217
231
  }
@@ -0,0 +1,70 @@
1
+ import {
2
+ Cartesian3,
3
+ Cartographic,
4
+ HeightReference,
5
+ Matrix4,
6
+ Model,
7
+ Primitive,
8
+ Scene,
9
+ } from '@vcmap-cesium/engine';
10
+ import { mercatorToCartographic } from '../math.js';
11
+
12
+ const scratchUpdateHeightCartesian = new Cartesian3();
13
+
14
+ function getUpdateHeightCallback(
15
+ primitive: Primitive | Model,
16
+ originalPosition: Cartesian3,
17
+ ): (cartographic: Cartographic) => void {
18
+ return function updatePrimitiveHeight(clampedPosition: Cartographic) {
19
+ Cartographic.toCartesian(
20
+ clampedPosition,
21
+ undefined,
22
+ scratchUpdateHeightCartesian,
23
+ );
24
+
25
+ Cartesian3.subtract(
26
+ scratchUpdateHeightCartesian,
27
+ originalPosition,
28
+ scratchUpdateHeightCartesian,
29
+ );
30
+
31
+ const { modelMatrix } = primitive;
32
+ primitive.modelMatrix = Matrix4.setTranslation(
33
+ modelMatrix,
34
+ scratchUpdateHeightCartesian,
35
+ new Matrix4(),
36
+ );
37
+ };
38
+ }
39
+
40
+ // eslint-disable-next-line import/prefer-default-export
41
+ export function setupClampedPrimitive(
42
+ scene: Scene,
43
+ primitive: Primitive | Model,
44
+ origin: [number, number],
45
+ heightReference: HeightReference,
46
+ ): void {
47
+ const destroy = primitive.destroy.bind(primitive);
48
+ const originCartographic = mercatorToCartographic(origin);
49
+ const callback = getUpdateHeightCallback(
50
+ primitive,
51
+ Cartographic.toCartesian(originCartographic),
52
+ );
53
+ const callbackHandler = scene.updateHeight(
54
+ originCartographic,
55
+ callback,
56
+ heightReference,
57
+ );
58
+
59
+ const height = scene.getHeight(originCartographic, heightReference);
60
+ if (height) {
61
+ const updatedHeightCarto = originCartographic.clone();
62
+ updatedHeightCarto.height = height;
63
+ callback(updatedHeightCarto);
64
+ }
65
+
66
+ primitive.destroy = (): void => {
67
+ callbackHandler();
68
+ destroy();
69
+ };
70
+ }