@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
@@ -30,6 +30,7 @@ import {
30
30
  Handlers,
31
31
  is1DAxis,
32
32
  is2DAxis,
33
+ is3DAxis,
33
34
  TransformationMode,
34
35
  } from './transformationTypes.js';
35
36
  import Projection from '../../projection.js';
@@ -206,7 +207,8 @@ function createAxisPrimitive(
206
207
  if (
207
208
  axis === AxisAndPlanes.X ||
208
209
  axis === AxisAndPlanes.XY ||
209
- axis === AxisAndPlanes.XZ
210
+ axis === AxisAndPlanes.XZ ||
211
+ axis === AxisAndPlanes.XYZ
210
212
  ) {
211
213
  primitives.push(
212
214
  new Primitive({
@@ -229,7 +231,8 @@ function createAxisPrimitive(
229
231
  if (
230
232
  axis === AxisAndPlanes.Y ||
231
233
  axis === AxisAndPlanes.XY ||
232
- axis === AxisAndPlanes.YZ
234
+ axis === AxisAndPlanes.YZ ||
235
+ axis === AxisAndPlanes.XYZ
233
236
  ) {
234
237
  primitives.push(
235
238
  new Primitive({
@@ -252,7 +255,8 @@ function createAxisPrimitive(
252
255
  if (
253
256
  axis === AxisAndPlanes.Z ||
254
257
  axis === AxisAndPlanes.XZ ||
255
- axis === AxisAndPlanes.YZ
258
+ axis === AxisAndPlanes.YZ ||
259
+ axis === AxisAndPlanes.XYZ
256
260
  ) {
257
261
  primitives.push(
258
262
  new Primitive({
@@ -263,13 +267,13 @@ function createAxisPrimitive(
263
267
  positions: Cartesian3.fromDegreesArrayHeights([
264
268
  centerWgs84[0],
265
269
  centerWgs84[1],
266
- center[2] - 500000,
270
+ (center[2] ?? 0) - 500000,
267
271
  centerWgs84[0],
268
272
  centerWgs84[1],
269
273
  center[2],
270
274
  centerWgs84[0],
271
275
  centerWgs84[1],
272
- center[2] + 500000,
276
+ (center[2] ?? 0) + 500000,
273
277
  ]),
274
278
  width: 1,
275
279
  }),
@@ -481,6 +485,28 @@ function createPlanePrimitive(
481
485
  return primitive;
482
486
  }
483
487
 
488
+ function createBoxPrimitive(modelMatrix: Matrix4, greyOut = false): Primitive {
489
+ const color = greyOut ? greyedOutColor : Color.GAINSBORO;
490
+ const primitive = new Primitive({
491
+ allowPicking: !greyOut,
492
+ asynchronous: false,
493
+ geometryInstances: [
494
+ new GeometryInstance({
495
+ geometry: new BoxGeometry({
496
+ minimum: new Cartesian3(0.2, 0.2, 0.2),
497
+ maximum: new Cartesian3(0.4, 0.4, 0.4),
498
+ }),
499
+ }),
500
+ ],
501
+ ...getPolygonAppearance(color),
502
+ modelMatrix,
503
+ });
504
+ if (!greyOut) {
505
+ primitive[handlerSymbol] = AxisAndPlanes.XYZ;
506
+ }
507
+ return primitive;
508
+ }
509
+
484
510
  function createShowShadowPrimitive(
485
511
  primitiveCollection: PrimitiveCollection,
486
512
  ): (
@@ -503,6 +529,8 @@ function createShowShadowPrimitive(
503
529
  });
504
530
  } else if (is2DAxis(axis)) {
505
531
  primitive.add(createPlanePrimitive(axis, modelMatrix, true));
532
+ } else if (is3DAxis(axis)) {
533
+ primitive.add(createBoxPrimitive(modelMatrix, true));
506
534
  }
507
535
  primitiveCollection.add(primitive);
508
536
  }
@@ -524,36 +552,47 @@ export default function create3DHandlers(
524
552
  const modelMatrix = Matrix4.fromTranslation(Cartesian3.fromDegrees(0, 0, 0));
525
553
  const zPrimitives: Primitive[] = [];
526
554
 
527
- if (
528
- mode === TransformationMode.TRANSLATE ||
529
- mode === TransformationMode.SCALE
530
- ) {
555
+ if (mode === TransformationMode.TRANSLATE) {
531
556
  const primitives = [
532
557
  ...createLineAxisPrimitives(AxisAndPlanes.X, modelMatrix, mode),
533
558
  ...createLineAxisPrimitives(AxisAndPlanes.Y, modelMatrix, mode),
534
559
  createPlanePrimitive(AxisAndPlanes.XY, modelMatrix),
535
560
  ];
536
561
 
537
- if (mode === TransformationMode.TRANSLATE) {
538
- zPrimitives.push(
539
- ...createLineAxisPrimitives(AxisAndPlanes.Z, modelMatrix, mode),
540
- createPlanePrimitive(AxisAndPlanes.XZ, modelMatrix),
541
- createPlanePrimitive(AxisAndPlanes.YZ, modelMatrix),
542
- );
543
- primitives.push(...zPrimitives);
544
- }
562
+ zPrimitives.push(
563
+ ...createLineAxisPrimitives(AxisAndPlanes.Z, modelMatrix, mode),
564
+ createPlanePrimitive(AxisAndPlanes.XZ, modelMatrix),
565
+ createPlanePrimitive(AxisAndPlanes.YZ, modelMatrix),
566
+ );
567
+ primitives.push(...zPrimitives);
545
568
  primitives.forEach((p) => {
546
569
  setFeatureOnPrimitive(p);
547
570
  primitiveCollection.add(p);
548
571
  });
549
572
  } else if (mode === TransformationMode.ROTATE) {
550
- primitiveCollection.add(
551
- createRingPrimitive(AxisAndPlanes.X, modelMatrix, true),
552
- );
553
- primitiveCollection.add(
554
- createRingPrimitive(AxisAndPlanes.Y, modelMatrix, true),
573
+ zPrimitives.push(
574
+ createRingPrimitive(AxisAndPlanes.X, modelMatrix),
575
+ createRingPrimitive(AxisAndPlanes.Y, modelMatrix),
555
576
  );
577
+ zPrimitives.forEach((p) => {
578
+ primitiveCollection.add(p);
579
+ });
556
580
  primitiveCollection.add(createRingPrimitive(AxisAndPlanes.Z, modelMatrix));
581
+ } else if (mode === TransformationMode.SCALE) {
582
+ const primitives = [
583
+ ...createLineAxisPrimitives(AxisAndPlanes.X, modelMatrix, mode),
584
+ ...createLineAxisPrimitives(AxisAndPlanes.Y, modelMatrix, mode),
585
+ ];
586
+
587
+ zPrimitives.push(
588
+ ...createLineAxisPrimitives(AxisAndPlanes.Z, modelMatrix, mode),
589
+ createBoxPrimitive(modelMatrix),
590
+ );
591
+ primitives.push(...zPrimitives);
592
+ primitives.forEach((p) => {
593
+ setFeatureOnPrimitive(p);
594
+ primitiveCollection.add(p);
595
+ });
557
596
  } else if (mode === TransformationMode.EXTRUDE) {
558
597
  createLineAxisPrimitives(AxisAndPlanes.Z, modelMatrix, mode).forEach(
559
598
  (p) => {
@@ -629,6 +668,29 @@ export default function create3DHandlers(
629
668
  createPlanePrimitive(AxisAndPlanes.XZ, modelMatrix, greyOut),
630
669
  createPlanePrimitive(AxisAndPlanes.YZ, modelMatrix, greyOut),
631
670
  );
671
+ } else if (mode === TransformationMode.ROTATE) {
672
+ if (!greyOut) {
673
+ zPrimitives.push(
674
+ createRingPrimitive(AxisAndPlanes.X, modelMatrix, greyOut),
675
+ createRingPrimitive(AxisAndPlanes.Y, modelMatrix, greyOut),
676
+ );
677
+ }
678
+ } else if (mode === TransformationMode.SCALE) {
679
+ if (!greyOut) {
680
+ zPrimitives.push(
681
+ ...createLineAxisPrimitives(
682
+ AxisAndPlanes.Z,
683
+ modelMatrix,
684
+ mode,
685
+ greyOut,
686
+ ),
687
+ createBoxPrimitive(modelMatrix),
688
+ );
689
+ } else {
690
+ zPrimitives.push(
691
+ createPlanePrimitive(AxisAndPlanes.XY, modelMatrix),
692
+ );
693
+ }
632
694
  }
633
695
 
634
696
  zPrimitives.forEach((p) => {
@@ -12,6 +12,7 @@ import VcsEvent from '../../../vcsEvent.js';
12
12
  import Projection from '../../projection.js';
13
13
  import {
14
14
  cartesian2DDistance,
15
+ cartesian3DDistance,
15
16
  cartographicToWgs84,
16
17
  mercatorToCartesian,
17
18
  } from '../../math.js';
@@ -37,23 +38,30 @@ function createGetScaledEvent(
37
38
  const { center } = transformationHandler;
38
39
  let flippedX = false;
39
40
  let flippedY = false;
41
+ let flippedZ = false;
40
42
 
41
43
  const getDistance = (
42
44
  coordinate: Coordinate,
43
45
  windowPosition: Cartesian2,
44
- ): { distance: number; dx: number; dy: number } => {
46
+ ): { distance: number; dx: number; dy: number; dz: number } => {
45
47
  const position = getPosition(coordinate, windowPosition);
46
48
  const dx = position[0] - center[0];
47
49
  const dy = position[1] - center[1];
50
+ let dz = position[2] - center[2];
51
+ dz = Number.isFinite(dz) ? dz : 0;
48
52
  let distance;
49
53
  if (axis === AxisAndPlanes.X) {
50
54
  distance = Math.abs(dx);
51
55
  } else if (axis === AxisAndPlanes.Y) {
52
56
  distance = Math.abs(dy);
57
+ } else if (axis === AxisAndPlanes.Z) {
58
+ distance = Math.abs(dz);
59
+ } else if (axis === AxisAndPlanes.XYZ) {
60
+ distance = cartesian3DDistance(center, position);
53
61
  } else {
54
62
  distance = cartesian2DDistance(center, position);
55
63
  }
56
- return { distance, dx, dy };
64
+ return { distance, dx, dy, dz };
57
65
  };
58
66
 
59
67
  const { distance: initialDistance } = getDistance(
@@ -62,13 +70,16 @@ function createGetScaledEvent(
62
70
  );
63
71
  let currentDistance = initialDistance;
64
72
  return (coordinate, windowPosition) => {
65
- const { distance, dx, dy } = getDistance(coordinate, windowPosition);
73
+ const { distance, dx, dy, dz } = getDistance(coordinate, windowPosition);
66
74
 
67
75
  const distanceDelta = distance / currentDistance;
68
76
  const currentFlippedX = dx < 0;
69
77
  const currentFlippedY = dy < 0;
78
+ const currentFlippedZ = dz < 0;
70
79
  let sx = distanceDelta;
71
80
  let sy = distanceDelta;
81
+ let sz = distanceDelta;
82
+
72
83
  if (currentFlippedX !== flippedX) {
73
84
  flippedX = currentFlippedX;
74
85
  sx *= -1;
@@ -79,14 +90,24 @@ function createGetScaledEvent(
79
90
  sy *= -1;
80
91
  }
81
92
 
93
+ if (currentFlippedZ !== flippedZ) {
94
+ flippedZ = currentFlippedZ;
95
+ sz *= -1;
96
+ }
97
+
82
98
  currentDistance = distance;
83
99
  if (axis === AxisAndPlanes.X) {
84
100
  return [sx, 1, 1];
85
101
  } else if (axis === AxisAndPlanes.Y) {
86
102
  return [1, sy, 1];
87
- } else {
103
+ } else if (axis === AxisAndPlanes.XY) {
88
104
  return [sx, sy, 1];
105
+ } else if (axis === AxisAndPlanes.XYZ) {
106
+ return [sx, sy, sz];
107
+ } else if (axis === AxisAndPlanes.Z) {
108
+ return [1, 1, sz];
89
109
  }
110
+ return [1, 1, 1];
90
111
  };
91
112
  }
92
113
 
@@ -142,7 +163,9 @@ class ScaleInteraction extends AbstractInteraction {
142
163
  ): GetScaleCallback {
143
164
  const scene = (event.map as CesiumMap).getScene() as Scene;
144
165
  const center = mercatorToCartesian(this._transformationHandler!.center);
145
- let plane = Plane.clone(Plane.ORIGIN_XY_PLANE);
166
+ let plane = Plane.clone(
167
+ axis === AxisAndPlanes.Z ? Plane.ORIGIN_ZX_PLANE : Plane.ORIGIN_XY_PLANE,
168
+ );
146
169
  plane = Plane.transform(
147
170
  plane,
148
171
  Transforms.eastNorthUpToFixedFrame(center),
@@ -1,12 +1,12 @@
1
1
  import type { Feature } from 'ol/index.js';
2
2
  import type { SimpleGeometry } from 'ol/geom.js';
3
3
  import type { Coordinate } from 'ol/coordinate.js';
4
- import { HeightReference } from '@vcmap-cesium/engine';
5
4
  import {
6
5
  createEmpty as createEmptyExtent,
7
6
  extend as extendExtent,
8
7
  getCenter as getExtentCenter,
9
8
  } from 'ol/extent.js';
9
+ import { HeightReference } from '@vcmap-cesium/engine';
10
10
  import Extent3D from '../../featureconverter/extent3D.js';
11
11
  import CesiumMap from '../../../map/cesiumMap.js';
12
12
  import BaseOLMap from '../../../map/baseOLMap.js';
@@ -21,44 +21,69 @@ import {
21
21
  TransformationMode,
22
22
  } from './transformationTypes.js';
23
23
  import type VcsMap from '../../../map/vcsMap.js';
24
+ import {
25
+ isAbsoluteHeightReference,
26
+ isClampedHeightReference,
27
+ isRelativeHeightReference,
28
+ } from '../../featureconverter/vectorHeightInfo.js';
29
+ import { mercatorToCartographic } from '../../math.js';
30
+ import { is2DLayout } from '../../geometryHelpers.js';
24
31
 
25
32
  type FeatureCenterInfo = {
26
33
  center: import('ol/coordinate.js').Coordinate;
27
- someClamped: boolean;
28
- someNoTerrain: boolean;
34
+ greyOutZ: boolean;
35
+ calculateHeight: boolean;
36
+ offsetHeight: boolean;
29
37
  };
30
38
 
31
39
  function getCenterFromFeatures3D(
32
40
  layer: VectorLayer,
41
+ mode: TransformationMode,
33
42
  features: Feature[],
34
43
  ): FeatureCenterInfo {
35
44
  const extent3D = new Extent3D();
36
- let someClamped = false;
37
- let someNoTerrain = false;
38
- const layerIsClamped =
39
- layer.vectorProperties.altitudeMode === HeightReference.CLAMP_TO_GROUND;
45
+ let calculateHeight = false;
46
+ let greyOutZ = mode !== TransformationMode.TRANSLATE;
47
+ let offsetHeight: boolean | undefined;
40
48
 
41
49
  features.forEach((f) => {
42
50
  const geometry = f.getGeometry() as SimpleGeometry;
43
51
  extent3D.extendWithGeometry(geometry);
44
- if (!someNoTerrain) {
45
- const firstCoordinates = geometry.getFirstCoordinate();
46
- if (!firstCoordinates[2]) {
47
- someNoTerrain = true;
48
- }
52
+ calculateHeight = calculateHeight || is2DLayout(geometry.getLayout());
53
+ const heightReference = layer.vectorProperties.getAltitudeMode(f);
54
+ if (offsetHeight !== false) {
55
+ const isRelative = isRelativeHeightReference(heightReference);
56
+ offsetHeight = isRelative;
57
+ calculateHeight = calculateHeight || isRelative;
49
58
  }
59
+ calculateHeight =
60
+ calculateHeight || isClampedHeightReference(heightReference);
50
61
 
51
- if (!someClamped) {
52
- const altitudeMode = f.get('olcs_altitudeMode') as string;
53
- someClamped =
54
- altitudeMode === 'clampToGround' || (!altitudeMode && layerIsClamped);
55
- }
62
+ greyOutZ =
63
+ greyOutZ ||
64
+ is2DLayout(geometry.getLayout()) ||
65
+ isClampedHeightReference(heightReference) ||
66
+ (isRelativeHeightReference(heightReference) &&
67
+ layer.vectorProperties.getHeightAboveGround(f) != null) ||
68
+ (isAbsoluteHeightReference(heightReference) &&
69
+ layer.vectorProperties.getGroundLevel(f) != null);
56
70
  });
71
+
72
+ if (
73
+ features.length === 1 &&
74
+ (mode === TransformationMode.ROTATE || mode === TransformationMode.SCALE) &&
75
+ features[0].getGeometry()?.getType() === 'Point' &&
76
+ layer.vectorProperties.renderAs(features[0]) !== 'geometry'
77
+ ) {
78
+ greyOutZ = false;
79
+ }
57
80
  const center = extent3D.getCenter();
81
+
58
82
  return {
59
83
  center,
60
- someClamped,
61
- someNoTerrain,
84
+ calculateHeight,
85
+ greyOutZ,
86
+ offsetHeight: !!offsetHeight,
62
87
  };
63
88
  }
64
89
 
@@ -71,9 +96,10 @@ function getCenterFromFeatures2D(features: Feature[]): FeatureCenterInfo {
71
96
  });
72
97
 
73
98
  return {
74
- center: [...getExtentCenter(extent), 0],
75
- someClamped: false,
76
- someNoTerrain: false,
99
+ center: [...getExtentCenter(extent)],
100
+ calculateHeight: false,
101
+ greyOutZ: false,
102
+ offsetHeight: false,
77
103
  };
78
104
  }
79
105
 
@@ -102,33 +128,40 @@ export default function createTransformationHandler(
102
128
  let getCenterFromFeatures: (features: Feature[]) => FeatureCenterInfo;
103
129
  let cesiumMap: CesiumMap | null = null;
104
130
 
105
- let cancelAsyncSetting = (): void => {};
106
- const setFeatures = async (features: Feature[]): Promise<void> => {
107
- cancelAsyncSetting();
131
+ const setFeatures = (features: Feature[]): void => {
108
132
  const show = features.length > 0;
109
133
  if (show) {
110
134
  const {
111
135
  center: newCenter,
112
- someClamped,
113
- someNoTerrain,
136
+ calculateHeight,
137
+ greyOutZ,
138
+ offsetHeight,
114
139
  } = getCenterFromFeatures(features);
115
140
  center = newCenter;
116
- if (!cesiumMap || !someNoTerrain) {
141
+ handlerFeatures.greyOutZ = greyOutZ;
142
+ if (!cesiumMap || !calculateHeight) {
117
143
  // only set center sync, if updating will not change it too drastically (to avoid jumps)
118
144
  handlerFeatures.show = true;
119
145
  handlerFeatures.setCenter(center);
120
146
  }
121
- handlerFeatures.greyOutZ = someClamped;
122
- if (cesiumMap && (someClamped || someNoTerrain)) {
123
- let cancel = false;
124
- cancelAsyncSetting = (): void => {
125
- cancel = true;
126
- };
127
- await cesiumMap.getHeightFromTerrain([center]);
128
- if (!cancel) {
129
- handlerFeatures.show = true;
130
- handlerFeatures.setCenter(center);
147
+ if (cesiumMap && calculateHeight) {
148
+ const height = cesiumMap
149
+ .getScene()!
150
+ .getHeight(
151
+ mercatorToCartographic(center),
152
+ HeightReference.CLAMP_TO_GROUND,
153
+ );
154
+
155
+ if (height) {
156
+ if (offsetHeight) {
157
+ center[2] += height;
158
+ } else {
159
+ center[2] = height;
160
+ }
131
161
  }
162
+
163
+ handlerFeatures.show = true;
164
+ handlerFeatures.setCenter(center);
132
165
  }
133
166
  } else {
134
167
  handlerFeatures.show = false;
@@ -137,7 +170,7 @@ export default function createTransformationHandler(
137
170
 
138
171
  if (map instanceof CesiumMap) {
139
172
  handlerFeatures = create3DHandlers(map, mode);
140
- getCenterFromFeatures = getCenterFromFeatures3D.bind(null, layer);
173
+ getCenterFromFeatures = getCenterFromFeatures3D.bind(null, layer, mode);
141
174
  cesiumMap = map;
142
175
  } else if (map instanceof BaseOLMap) {
143
176
  handlerFeatures = create2DHandlers(map, scratchLayer, mode);
@@ -163,10 +196,8 @@ export default function createTransformationHandler(
163
196
  center[2] += dz;
164
197
  handlerFeatures.setCenter(center);
165
198
  },
166
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
167
199
  setFeatures,
168
200
  destroy(): void {
169
- cancelAsyncSetting();
170
201
  handlerFeatures.destroy();
171
202
  scratchLayer.removeAllFeatures();
172
203
  },
@@ -43,6 +43,7 @@ export enum AxisAndPlanes {
43
43
  XY = 'XY',
44
44
  XZ = 'XZ',
45
45
  YZ = 'YZ',
46
+ XYZ = 'XYZ',
46
47
  NONE = 'NONE',
47
48
  }
48
49
  export enum TransformationMode {
@@ -69,3 +70,7 @@ export function is2DAxis(axis: AxisAndPlanes): boolean {
69
70
  axis === AxisAndPlanes.YZ
70
71
  );
71
72
  }
73
+
74
+ export function is3DAxis(axis: AxisAndPlanes): boolean {
75
+ return axis === AxisAndPlanes.XYZ;
76
+ }
@@ -1,130 +1,60 @@
1
- import {
2
- ArcType,
3
- Cartesian3,
4
- HeightReference,
5
- Scene,
6
- } from '@vcmap-cesium/engine';
1
+ import { ArcType, HeightReference } from '@vcmap-cesium/engine';
7
2
  import type { Coordinate } from 'ol/coordinate.js';
8
3
  import type { LineString } from 'ol/geom.js';
9
- import type { Feature } from 'ol/index.js';
10
4
 
11
- import Projection from '../projection.js';
12
- import { addPrimitivesToContext } from './featureconverterHelper.js';
13
5
  import {
14
- createFillGeometries,
15
6
  createGroundLineGeometries,
16
7
  createLineGeometries,
17
8
  createOutlineGeometries,
18
9
  createSolidGeometries,
19
10
  validateLineString,
20
- getCoordinates as getLineStringCoordinates,
21
11
  getGeometryOptions as getLineStringGeometryOptions,
22
- addArrowsToContext,
23
12
  } from './lineStringToCesium.js';
24
- import ArcStyle, { featureArcStruct } from '../../style/arcStyle.js';
25
- import { VectorGeometryFactoryType } from '../../layer/vectorLayer.js';
26
- import VectorProperties from '../../layer/vectorProperties.js';
27
- import type { AsyncCesiumVectorContext } from '../../layer/cesium/vectorContext.js';
13
+ import {
14
+ mercatorToCartesianTransformerForHeightInfo,
15
+ VectorHeightInfo,
16
+ } from './vectorHeightInfo.js';
17
+ import {
18
+ PolylineGeometryOptions,
19
+ VectorGeometryFactory,
20
+ } from './vectorGeometryFactory.js';
28
21
 
29
22
  /**
30
23
  * Creates the positions & arcType option for the PolylineGeometry
31
24
  */
32
- export function getGeometryOptions(
25
+ function getGeometryOptions(
33
26
  coords: Coordinate[],
34
27
  _geometry: LineString,
35
- positionHeightAdjustment: number,
36
- perPositionHeight: boolean,
37
- groundLevelOrMinHeight: number,
38
- ): { positions: Cartesian3[]; arcType: ArcType } {
39
- const positions = coords.map((coord) => {
40
- const wgs84Coords = Projection.mercatorToWgs84(coord);
41
- if (!perPositionHeight && groundLevelOrMinHeight) {
42
- wgs84Coords[2] = groundLevelOrMinHeight;
43
- } else if (wgs84Coords[2] != null) {
44
- wgs84Coords[2] += positionHeightAdjustment;
45
- }
46
- return Cartesian3.fromDegrees(
47
- wgs84Coords[0],
48
- wgs84Coords[1],
49
- wgs84Coords[2],
50
- );
51
- });
28
+ heightInfo: VectorHeightInfo,
29
+ ): PolylineGeometryOptions {
30
+ const coordinateTransformer =
31
+ mercatorToCartesianTransformerForHeightInfo(heightInfo);
32
+ const positions = coords.map(coordinateTransformer);
52
33
  return { positions, arcType: ArcType.NONE };
53
34
  }
54
35
 
55
36
  /**
56
- * In this special case, the coordinates are not taken from the geometries array
37
+ * @param arcCoords - the coordinates of the arc to use instead of the geometries coordinates if height mode is absolute
38
+ * @param altitudeMode
57
39
  */
58
- // eslint-disable-next-line no-unused-vars
59
- export function getCoordinates(
60
- coords: Coordinate[],
61
- _geometries: LineString[],
62
- ): Coordinate[] {
63
- return coords;
64
- }
65
-
66
- /**
67
- * @param arcCoords - the coordinates of the arc to use instead of the geometries coordinates if height mode is absolute
68
- */
69
- function getGeometryFactory(
40
+ // eslint-disable-next-line import/prefer-default-export
41
+ export function getArcGeometryFactory(
70
42
  arcCoords: Coordinate[],
71
43
  altitudeMode: HeightReference,
72
- ): VectorGeometryFactoryType {
44
+ ): VectorGeometryFactory<'arc'> {
73
45
  return {
74
- getCoordinates:
75
- altitudeMode === HeightReference.NONE
76
- ? getCoordinates.bind(null, arcCoords)
77
- : getLineStringCoordinates,
46
+ type: 'arc',
78
47
  getGeometryOptions:
79
48
  altitudeMode === HeightReference.NONE
80
49
  ? getGeometryOptions.bind(null, arcCoords)
81
50
  : getLineStringGeometryOptions,
82
51
  createSolidGeometries,
83
52
  createOutlineGeometries,
84
- createFillGeometries,
53
+ createFillGeometries(): never[] {
54
+ return [];
55
+ },
85
56
  createGroundLineGeometries,
86
57
  createLineGeometries,
58
+ validateGeometry: validateLineString,
87
59
  };
88
60
  }
89
-
90
- /**
91
- * converts a linestring with an ArcStyle to a a cesium primitive
92
- */
93
- export default async function arcToCesium(
94
- feature: Feature,
95
- style: ArcStyle,
96
- geometries: LineString[],
97
- vectorProperties: VectorProperties,
98
- scene: Scene,
99
- context: AsyncCesiumVectorContext,
100
- ): Promise<void> {
101
- if (!style.getFill() && !style.getStroke()) {
102
- return;
103
- }
104
- const altitudeMode = vectorProperties.getAltitudeMode(feature);
105
- const arcGeometryFactory = getGeometryFactory(
106
- feature[featureArcStruct]!.coordinates!,
107
- altitudeMode,
108
- );
109
- const validGeometries = geometries.filter((lineString) =>
110
- validateLineString(lineString),
111
- );
112
- addPrimitivesToContext(
113
- feature,
114
- style,
115
- validGeometries,
116
- vectorProperties,
117
- scene,
118
- arcGeometryFactory,
119
- context,
120
- );
121
- await addArrowsToContext(
122
- feature,
123
- style,
124
- validGeometries,
125
- vectorProperties,
126
- scene,
127
- arcGeometryFactory,
128
- context,
129
- ); // IDEA what about labels?
130
- }