@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,5 +1,4 @@
1
1
  import {
2
- Cartesian3,
3
2
  WallGeometry,
4
3
  WallOutlineGeometry,
5
4
  GroundPolylineGeometry,
@@ -7,7 +6,7 @@ import {
7
6
  Math as CesiumMath,
8
7
  HeightReference,
9
8
  type Scene,
10
- PolygonGeometry,
9
+ Cartesian3,
11
10
  } from '@vcmap-cesium/engine';
12
11
  import { Feature } from 'ol';
13
12
  import { type LineString, Point } from 'ol/geom.js';
@@ -15,15 +14,23 @@ import type { Coordinate } from 'ol/coordinate.js';
15
14
  import type { Style } from 'ol/style.js';
16
15
 
17
16
  import { parseNumber } from '@vcsuite/parsers';
18
- import Projection from '../projection.js';
19
- import { addPrimitivesToContext } from './featureconverterHelper.js';
20
- import { getFlatCoordinatesFromSimpleGeometry } from '../geometryHelpers.js';
21
17
  import ArrowStyle, { ArrowEnd } from '../../style/arrowStyle.js';
22
18
  import { getCartesianBearing, getCartesianPitch } from '../math.js';
23
19
  import { getPrimitiveOptions } from './pointHelpers.js';
24
20
  import type VectorProperties from '../../layer/vectorProperties.js';
25
- import type { VectorGeometryFactoryType } from '../../layer/vectorLayer.js';
26
- import type { AsyncCesiumVectorContext } from '../../layer/cesium/vectorContext.js';
21
+ import { getWgs84CoordinatesForPoint } from './pointToCesium.js';
22
+ import { ConvertedItem } from './convert.js';
23
+ import {
24
+ getHeightInfo,
25
+ VectorHeightInfo,
26
+ mercatorToCartesianTransformerForHeightInfo,
27
+ isAbsoluteHeightReference,
28
+ } from './vectorHeightInfo.js';
29
+ import {
30
+ CesiumGeometryOption,
31
+ PolylineGeometryOptions,
32
+ VectorGeometryFactory,
33
+ } from './vectorGeometryFactory.js';
27
34
 
28
35
  type ArrowOptions = {
29
36
  location: Coordinate;
@@ -36,8 +43,9 @@ function getArrowOptions(
36
43
  to: Coordinate,
37
44
  heightReference: HeightReference,
38
45
  ): ArrowOptions {
39
- let pitch =
40
- heightReference === HeightReference.NONE ? getCartesianPitch(to, from) : 0;
46
+ let pitch = isAbsoluteHeightReference(heightReference)
47
+ ? getCartesianPitch(to, from)
48
+ : 0;
41
49
  pitch += 90;
42
50
  return {
43
51
  location: to,
@@ -48,208 +56,179 @@ function getArrowOptions(
48
56
  };
49
57
  }
50
58
 
51
- export async function addArrowsToContext(
59
+ export function getArrowHeadPrimitives(
52
60
  feature: Feature,
53
61
  style: ArrowStyle,
54
- validGeometries: LineString[],
62
+ geometry: LineString,
55
63
  vectorProperties: VectorProperties,
56
64
  scene: Scene,
57
- lineGeometryFactory: VectorGeometryFactoryType,
58
- context: AsyncCesiumVectorContext,
59
- ): Promise<void> {
65
+ inputCoordinates?: Coordinate[],
66
+ ): ConvertedItem<'primitive'>[] {
60
67
  if (style.end === ArrowEnd.NONE || !style.primitiveOptions?.geometryOptions) {
61
- return;
68
+ return [];
62
69
  }
63
70
  const arrowOptions: ArrowOptions[] = [];
64
71
  const heightReference = vectorProperties.getAltitudeMode(feature);
65
- validGeometries.forEach((geom) => {
66
- const coordinates = lineGeometryFactory.getCoordinates([geom]);
67
- if (style.end === ArrowEnd.START || style.end === ArrowEnd.BOTH) {
68
- arrowOptions.push(
69
- getArrowOptions(coordinates[1], coordinates[0], heightReference),
70
- );
71
- }
72
+ const coordinates = inputCoordinates ?? geometry.getCoordinates();
73
+ if (style.end === ArrowEnd.START || style.end === ArrowEnd.BOTH) {
74
+ arrowOptions.push(
75
+ getArrowOptions(coordinates[1], coordinates[0], heightReference),
76
+ );
77
+ }
72
78
 
73
- if (style.end === ArrowEnd.END || style.end === ArrowEnd.BOTH) {
74
- arrowOptions.push(
75
- getArrowOptions(
76
- coordinates.at(-2)!,
77
- coordinates.at(-1)!,
78
- heightReference,
79
- ),
80
- );
81
- }
82
- });
79
+ if (style.end === ArrowEnd.END || style.end === ArrowEnd.BOTH) {
80
+ arrowOptions.push(
81
+ getArrowOptions(
82
+ coordinates.at(-2)!,
83
+ coordinates.at(-1)!,
84
+ heightReference,
85
+ ),
86
+ );
87
+ }
83
88
 
84
89
  if (arrowOptions.length === 0) {
85
- return;
90
+ return [];
86
91
  }
87
92
 
88
93
  const usedStyle = style.getOlcsStyle();
89
- const allowPicking = vectorProperties.getAllowPicking(feature);
90
94
 
91
- await Promise.all(
92
- arrowOptions.map(async (arrowOption) => {
95
+ return arrowOptions
96
+ .map((arrowOption): ConvertedItem<'primitive'>[] => {
97
+ const arrowHeadGeometry = new Point(arrowOption.location);
93
98
  const arrowFeature = new Feature({
94
99
  ...feature.getProperties(),
95
100
  olcs_primitiveOptions: style.primitiveOptions,
96
101
  olcs_modelHeading: arrowOption.heading,
97
102
  olcs_modelPitch: arrowOption.pitch,
98
- geometry: new Point(arrowOption.location),
103
+ geometry: arrowHeadGeometry,
99
104
  olcs_modelAutoScale: true,
100
105
  });
101
106
 
102
- const wgs84Position = Projection.mercatorToWgs84(arrowOption.location);
103
- const cartesianLocation = Cartesian3.fromDegrees(
104
- wgs84Position[0],
105
- wgs84Position[1],
106
- wgs84Position[2],
107
+ const heightInfo = getHeightInfo(
108
+ arrowFeature,
109
+ arrowHeadGeometry,
110
+ vectorProperties,
111
+ );
112
+
113
+ const wgs84Coords = getWgs84CoordinatesForPoint(
114
+ arrowHeadGeometry,
115
+ heightInfo,
116
+ );
117
+ const position = Cartesian3.fromDegrees(
118
+ wgs84Coords[0],
119
+ wgs84Coords[1],
120
+ wgs84Coords[2],
107
121
  );
108
- const primitiveOptions = await getPrimitiveOptions(
122
+
123
+ return getPrimitiveOptions(
109
124
  arrowFeature,
110
125
  usedStyle,
111
- [wgs84Position],
112
- [cartesianLocation],
126
+ position,
127
+ wgs84Coords,
113
128
  vectorProperties,
114
129
  scene,
130
+ heightInfo,
115
131
  );
116
-
117
- if (primitiveOptions?.primitives) {
118
- context.addScaledPrimitives(
119
- primitiveOptions.primitives,
120
- feature,
121
- allowPicking,
122
- );
123
- }
124
- }),
125
- );
132
+ })
133
+ .flat();
126
134
  }
127
135
 
128
- export type LineGeometryOptions = { positions: Cartesian3[] };
129
-
130
136
  export function createSolidGeometries(
131
- options: LineGeometryOptions,
137
+ options: PolylineGeometryOptions,
138
+ heightInfo: VectorHeightInfo,
132
139
  height: number,
133
140
  perPositionHeight: boolean,
134
141
  extrudedHeight?: number,
135
- ): WallGeometry[] {
142
+ ): CesiumGeometryOption<'solid'>[] {
136
143
  return [
137
- WallGeometry.fromConstantHeights({
138
- ...options,
139
- maximumHeight: !perPositionHeight ? height : undefined,
140
- minimumHeight: extrudedHeight,
141
- }),
144
+ {
145
+ type: 'solid',
146
+ geometry: WallGeometry.fromConstantHeights({
147
+ ...options,
148
+ maximumHeight: !perPositionHeight ? height : undefined,
149
+ minimumHeight: extrudedHeight,
150
+ }),
151
+ heightInfo,
152
+ },
142
153
  ];
143
154
  }
144
155
 
145
156
  export function createOutlineGeometries(
146
- options: LineGeometryOptions,
157
+ options: PolylineGeometryOptions,
158
+ heightInfo: VectorHeightInfo,
147
159
  height: number,
148
160
  perPositionHeight: boolean,
149
161
  extrudedHeight?: number,
150
- ): WallOutlineGeometry[] {
162
+ ): CesiumGeometryOption<'outline'>[] {
151
163
  // maxium and minimum are flipped, to create the same perPositionHeight behaviour as in polygons
152
164
  // WallGeometries extrudes down instead of up, so we switch the behaviour and extrude in the other direction
153
165
  return [
154
- WallOutlineGeometry.fromConstantHeights({
155
- ...options,
156
- maximumHeight: !perPositionHeight ? height : undefined,
157
- minimumHeight: extrudedHeight,
158
- }),
166
+ {
167
+ type: 'outline',
168
+ geometry: WallOutlineGeometry.fromConstantHeights({
169
+ ...options,
170
+ maximumHeight: !perPositionHeight ? height : undefined,
171
+ minimumHeight: extrudedHeight,
172
+ }),
173
+ heightInfo,
174
+ },
159
175
  ];
160
176
  }
161
177
 
162
- export function createFillGeometries(
163
- _options: LineGeometryOptions,
164
- _height: number,
165
- _perPositionHeight: boolean,
166
- ): PolygonGeometry[] {
167
- return [];
168
- }
169
-
170
178
  export function createGroundLineGeometries(
171
- options: LineGeometryOptions,
179
+ options: PolylineGeometryOptions,
180
+ heightInfo: VectorHeightInfo,
172
181
  style: Style,
173
- ): GroundPolylineGeometry[] {
182
+ ): CesiumGeometryOption<'groundLine'>[] {
174
183
  const width = parseNumber(style.getStroke()!.getWidth(), 1.0);
175
184
  return [
176
- new GroundPolylineGeometry({
177
- ...options,
178
- width,
179
- }),
185
+ {
186
+ type: 'groundLine',
187
+ geometry: new GroundPolylineGeometry({
188
+ ...options,
189
+ width,
190
+ }),
191
+ heightInfo,
192
+ },
180
193
  ];
181
194
  }
182
195
 
183
196
  export function createLineGeometries(
184
- options: LineGeometryOptions,
197
+ options: PolylineGeometryOptions,
198
+ heightInfo: VectorHeightInfo,
185
199
  style: Style,
186
- ): PolylineGeometry[] {
200
+ ): CesiumGeometryOption<'line'>[] {
187
201
  const width = parseNumber(style.getStroke()!.getWidth(), 1.0);
188
202
 
189
203
  return [
190
- new PolylineGeometry({
191
- ...options,
192
- width,
193
- }),
204
+ {
205
+ type: 'line',
206
+ geometry: new PolylineGeometry({
207
+ ...options,
208
+ width,
209
+ }),
210
+ heightInfo,
211
+ },
194
212
  ];
195
213
  }
196
214
 
197
215
  /**
198
216
  * Creates the positions array for PolylineGeometry
199
217
  * @param geometry
200
- * @param positionHeightAdjustment
201
- * @param perPositionHeight
202
- * @param groundLevelOrMinHeight
218
+ * @param heightInfo
203
219
  * @private
204
220
  */
205
221
  export function getGeometryOptions(
206
222
  geometry: LineString,
207
- positionHeightAdjustment: number,
208
- perPositionHeight: boolean,
209
- groundLevelOrMinHeight: number,
210
- ): LineGeometryOptions {
223
+ heightInfo: VectorHeightInfo,
224
+ ): PolylineGeometryOptions {
211
225
  const coords = geometry.getCoordinates();
212
- const positions = coords.map((coord) => {
213
- const wgs84Coords = Projection.mercatorToWgs84(coord);
214
- if (!perPositionHeight && groundLevelOrMinHeight) {
215
- wgs84Coords[2] = groundLevelOrMinHeight;
216
- } else if (wgs84Coords[2] != null) {
217
- wgs84Coords[2] += positionHeightAdjustment;
218
- }
219
- return Cartesian3.fromDegrees(
220
- wgs84Coords[0],
221
- wgs84Coords[1],
222
- wgs84Coords[2],
223
- );
224
- });
226
+ const coordinateTransformer =
227
+ mercatorToCartesianTransformerForHeightInfo(heightInfo);
228
+ const positions = coords.map(coordinateTransformer);
225
229
  return { positions };
226
230
  }
227
231
 
228
- export function getCoordinates(geometries: LineString[]): Coordinate[] {
229
- const coordinates: Coordinate[] = [];
230
- geometries.forEach((lineString) => {
231
- coordinates.push(...getFlatCoordinatesFromSimpleGeometry(lineString));
232
- });
233
- return coordinates;
234
- }
235
-
236
- let geometryFactory: VectorGeometryFactoryType | null = null;
237
-
238
- function getGeometryFactory(): VectorGeometryFactoryType {
239
- if (!geometryFactory) {
240
- geometryFactory = {
241
- getCoordinates,
242
- getGeometryOptions,
243
- createSolidGeometries,
244
- createOutlineGeometries,
245
- createFillGeometries,
246
- createGroundLineGeometries,
247
- createLineGeometries,
248
- };
249
- }
250
- return geometryFactory;
251
- }
252
-
253
232
  /**
254
233
  * validates if a lineString is renderable
255
234
  * @param lineString
@@ -266,48 +245,22 @@ export function validateLineString(lineString: LineString): boolean {
266
245
  return false;
267
246
  }
268
247
 
269
- /**
270
- * converts a linestring to a a cesium primitive, with optional labels
271
- * @param feature
272
- * @param style
273
- * @param geometries
274
- * @param vectorProperties
275
- * @param scene
276
- * @param context
277
- */
278
- export default async function lineStringToCesium(
279
- feature: Feature,
280
- style: Style,
281
- geometries: LineString[],
282
- vectorProperties: VectorProperties,
283
- scene: Scene,
284
- context: AsyncCesiumVectorContext,
285
- ): Promise<void> {
286
- if (!style.getFill() && !style.getStroke()) {
287
- return;
288
- }
289
- const lineGeometryFactory = getGeometryFactory();
290
- const validGeometries = geometries.filter((lineString) =>
291
- validateLineString(lineString),
292
- );
293
- addPrimitivesToContext(
294
- feature,
295
- style,
296
- validGeometries,
297
- vectorProperties,
298
- scene,
299
- lineGeometryFactory,
300
- context,
301
- );
302
- if (style instanceof ArrowStyle) {
303
- await addArrowsToContext(
304
- feature,
305
- style,
306
- validGeometries,
307
- vectorProperties,
308
- scene,
309
- lineGeometryFactory,
310
- context,
311
- );
248
+ let geometryFactory: VectorGeometryFactory<'lineString'> | undefined;
249
+
250
+ export function getLineStringGeometryFactory(): VectorGeometryFactory<'lineString'> {
251
+ if (!geometryFactory) {
252
+ geometryFactory = {
253
+ type: 'lineString',
254
+ getGeometryOptions,
255
+ createSolidGeometries,
256
+ createOutlineGeometries,
257
+ createFillGeometries(): never[] {
258
+ return [];
259
+ },
260
+ createGroundLineGeometries,
261
+ createLineGeometries,
262
+ validateGeometry: validateLineString,
263
+ };
312
264
  }
265
+ return geometryFactory;
313
266
  }