@vcmap/core 5.0.0-rc.3 → 5.0.0-rc.30

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 (236) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +12 -5
  3. package/build/postinstall.js +14 -3
  4. package/index.d.ts +3477 -2007
  5. package/index.js +169 -131
  6. package/package.json +25 -27
  7. package/src/category/category.js +483 -0
  8. package/src/category/categoryCollection.js +153 -0
  9. package/src/cesium/cesium3DTileFeature.js +2 -2
  10. package/src/cesium/cesium3DTilePointFeature.js +1 -1
  11. package/src/cesium/cesiumVcsCameraPrimitive.js +16 -8
  12. package/src/cesium/entity.js +29 -0
  13. package/src/cesium/wallpaperMaterial.js +5 -3
  14. package/src/classRegistry.js +169 -0
  15. package/src/{vcs/vcm/util/featureProvider → featureProvider}/abstractFeatureProvider.js +49 -46
  16. package/src/{vcs/vcm/util/featureProvider → featureProvider}/tileProviderFeatureProvider.js +13 -5
  17. package/src/{vcs/vcm/util/featureProvider → featureProvider}/wmsFeatureProvider.js +56 -26
  18. package/src/{vcs/vcm/interaction → interaction}/abstractInteraction.js +33 -21
  19. package/src/{vcs/vcm/interaction → interaction}/coordinateAtPixel.js +40 -21
  20. package/src/{vcs/vcm/interaction → interaction}/eventHandler.js +131 -26
  21. package/src/{vcs/vcm/interaction → interaction}/featureAtPixelInteraction.js +108 -53
  22. package/src/interaction/featureProviderInteraction.js +58 -0
  23. package/src/{vcs/vcm/interaction → interaction}/interactionChain.js +40 -41
  24. package/src/{vcs/vcm/interaction → interaction}/interactionType.js +24 -31
  25. package/src/{vcs/vcm/layer/cesium/cesiumTilesetCesium.js → layer/cesium/cesiumTilesetCesiumImpl.js} +67 -55
  26. package/src/{vcs/vcm/layer → layer}/cesium/clusterContext.js +33 -8
  27. package/src/{vcs/vcm/layer/cesium/dataSourceCesium.js → layer/cesium/dataSourceCesiumImpl.js} +24 -13
  28. package/src/layer/cesium/openStreetMapCesiumImpl.js +32 -0
  29. package/src/{vcs/vcm/layer/cesium/rasterLayerCesium.js → layer/cesium/rasterLayerCesiumImpl.js} +12 -9
  30. package/src/{vcs/vcm/layer/cesium/singleImageCesium.js → layer/cesium/singleImageCesiumImpl.js} +19 -9
  31. package/src/{vcs/vcm/layer/cesium/terrainCesium.js → layer/cesium/terrainCesiumImpl.js} +6 -6
  32. package/src/{vcs/vcm/layer/cesium/tmsCesium.js → layer/cesium/tmsCesiumImpl.js} +21 -10
  33. package/src/{vcs/vcm/layer/cesium/vectorCesium.js → layer/cesium/vectorCesiumImpl.js} +93 -35
  34. package/src/layer/cesium/vectorContext.js +363 -0
  35. package/src/{vcs/vcm/layer/cesium/vectorRasterTileCesium.js → layer/cesium/vectorRasterTileCesiumImpl.js} +21 -13
  36. package/src/{vcs/vcm/layer → layer}/cesium/vectorTileImageryProvider.js +58 -21
  37. package/src/{vcs/vcm/layer/cesium/wmsCesium.js → layer/cesium/wmsCesiumImpl.js} +20 -9
  38. package/src/{vcs/vcm/layer/cesium/wmtsCesium.js → layer/cesium/wmtsCesiumImpl.js} +24 -13
  39. package/src/{vcs/vcm/layer → layer}/cesium/x3dmHelper.js +6 -3
  40. package/src/{vcs/vcm/layer/cesiumTileset.js → layer/cesiumTilesetLayer.js} +71 -108
  41. package/src/{vcs/vcm/layer/czml.js → layer/czmlLayer.js} +23 -20
  42. package/src/{vcs/vcm/layer/dataSource.js → layer/dataSourceLayer.js} +55 -90
  43. package/src/{vcs/vcm/layer → layer}/featureLayer.js +89 -74
  44. package/src/{vcs/vcm/layer/featureStore.js → layer/featureStoreLayer.js} +197 -150
  45. package/src/{vcs/vcm/layer/featureStoreChanges.js → layer/featureStoreLayerChanges.js} +150 -92
  46. package/src/{vcs/vcm/layer/featureStoreState.js → layer/featureStoreLayerState.js} +1 -2
  47. package/src/{vcs/vcm/layer → layer}/featureVisibility.js +114 -82
  48. package/src/{vcs/vcm/layer → layer}/geojsonHelpers.js +84 -69
  49. package/src/{vcs/vcm/layer/geojson.js → layer/geojsonLayer.js} +30 -27
  50. package/src/{vcs/vcm/layer → layer}/globalHider.js +25 -39
  51. package/src/{vcs/vcm/layer → layer}/layer.js +171 -96
  52. package/src/{vcs/vcm/layer → layer}/layerImplementation.js +13 -6
  53. package/src/{vcs/vcm/layer → layer}/layerState.js +0 -1
  54. package/src/{vcs/vcm/layer → layer}/layerSymbols.js +2 -1
  55. package/src/{vcs/vcm/layer/oblique/layerOblique.js → layer/oblique/layerObliqueImpl.js} +7 -5
  56. package/src/{vcs/vcm/layer → layer}/oblique/obliqueHelpers.js +76 -31
  57. package/src/{vcs/vcm/layer/oblique/vectorOblique.js → layer/oblique/vectorObliqueImpl.js} +198 -80
  58. package/src/{vcs/vcm/layer/openStreetMap.js → layer/openStreetMapLayer.js} +59 -40
  59. package/src/layer/openlayers/layerOpenlayersImpl.js +165 -0
  60. package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +28 -0
  61. package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +44 -0
  62. package/src/{vcs/vcm/layer/openlayers/singleImageOpenlayers.js → layer/openlayers/singleImageOpenlayersImpl.js} +8 -7
  63. package/src/{vcs/vcm/layer/openlayers/tileDebugOpenlayers.js → layer/openlayers/tileDebugOpenlayersImpl.js} +7 -6
  64. package/src/{vcs/vcm/layer/openlayers/tmsOpenlayers.js → layer/openlayers/tmsOpenlayersImpl.js} +12 -10
  65. package/src/{vcs/vcm/layer/openlayers/vectorOpenlayers.js → layer/openlayers/vectorOpenlayersImpl.js} +21 -12
  66. package/src/{vcs/vcm/layer/openlayers/vectorTileOpenlayers.js → layer/openlayers/vectorTileOpenlayersImpl.js} +18 -12
  67. package/src/{vcs/vcm/layer/openlayers/wmsOpenlayers.js → layer/openlayers/wmsOpenlayersImpl.js} +9 -8
  68. package/src/{vcs/vcm/layer/openlayers/wmtsOpenlayers.js → layer/openlayers/wmtsOpenlayersImpl.js} +19 -12
  69. package/src/{vcs/vcm/layer/pointCloud.js → layer/pointCloudLayer.js} +42 -39
  70. package/src/{vcs/vcm/layer → layer}/rasterLayer.js +86 -37
  71. package/src/{vcs/vcm/layer/singleImage.js → layer/singleImageLayer.js} +25 -22
  72. package/src/layer/terrainHelpers.js +98 -0
  73. package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +26 -18
  74. package/src/{vcs/vcm/layer → layer}/tileLoadedHelper.js +13 -8
  75. package/src/{vcs/vcm/layer → layer}/tileProvider/mvtTileProvider.js +51 -8
  76. package/src/layer/tileProvider/staticGeojsonTileProvider.js +87 -0
  77. package/src/{vcs/vcm/layer → layer}/tileProvider/tileProvider.js +200 -89
  78. package/src/{vcs/vcm/layer → layer}/tileProvider/urlTemplateTileProvider.js +54 -13
  79. package/src/{vcs/vcm/layer/tms.js → layer/tmsLayer.js} +22 -22
  80. package/src/layer/vectorHelpers.js +129 -0
  81. package/src/{vcs/vcm/layer/vector.js → layer/vectorLayer.js} +124 -94
  82. package/src/{vcs/vcm/layer → layer}/vectorProperties.js +419 -107
  83. package/src/{vcs/vcm/layer → layer}/vectorSymbols.js +11 -1
  84. package/src/{vcs/vcm/layer/vectorTile.js → layer/vectorTileLayer.js} +181 -116
  85. package/src/{vcs/vcm/layer/wfs.js → layer/wfsLayer.js} +33 -23
  86. package/src/{vcs/vcm/layer → layer}/wmsHelpers.js +14 -7
  87. package/src/{vcs/vcm/layer/wms.js → layer/wmsLayer.js} +53 -32
  88. package/src/{vcs/vcm/layer/wmts.js → layer/wmtsLayer.js} +56 -42
  89. package/src/{vcs/vcm/maps → map}/baseOLMap.js +83 -35
  90. package/src/{vcs/vcm/maps → map}/cameraLimiter.js +75 -32
  91. package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +429 -276
  92. package/src/{vcs/vcm/maps → map}/mapState.js +0 -1
  93. package/src/{vcs/vcm/maps/oblique.js → map/obliqueMap.js} +132 -97
  94. package/src/{vcs/vcm/maps/openlayers.js → map/openlayersMap.js} +69 -45
  95. package/src/{vcs/vcm/maps/map.js → map/vcsMap.js} +118 -46
  96. package/src/oblique/defaultObliqueCollection.js +62 -0
  97. package/src/{vcs/vcm/oblique → oblique}/helpers.js +221 -78
  98. package/src/{vcs/vcm/oblique/ObliqueCollection.js → oblique/obliqueCollection.js} +145 -54
  99. package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +62 -32
  100. package/src/{vcs/vcm/oblique/ObliqueImage.js → oblique/obliqueImage.js} +58 -26
  101. package/src/{vcs/vcm/oblique/ObliqueImageMeta.js → oblique/obliqueImageMeta.js} +9 -9
  102. package/src/{vcs/vcm/oblique/ObliqueProvider.js → oblique/obliqueProvider.js} +85 -35
  103. package/src/{vcs/vcm/oblique/ObliqueView.js → oblique/obliqueView.js} +45 -5
  104. package/src/{vcs/vcm/oblique/ObliqueViewDirection.js → oblique/obliqueViewDirection.js} +3 -5
  105. package/src/{vcs/vcm/oblique → oblique}/parseImageJson.js +62 -28
  106. package/src/ol/feature.js +34 -1
  107. package/src/ol/geom/circle.js +14 -5
  108. package/src/ol/geom/geometryCollection.js +14 -8
  109. package/src/ol/render/canvas/canvasTileRenderer.js +11 -10
  110. package/src/overrideClassRegistry.js +214 -0
  111. package/src/style/arcStyle.js +453 -0
  112. package/src/style/arrowStyle.js +304 -0
  113. package/src/{vcs/vcm/util/style → style}/declarativeStyleItem.js +147 -82
  114. package/src/{vcs/vcm/util/style → style}/shapesCategory.js +8 -8
  115. package/src/style/styleFactory.js +32 -0
  116. package/src/{vcs/vcm/util/style → style}/styleHelpers.js +24 -26
  117. package/src/style/styleItem.js +174 -0
  118. package/src/{vcs/vcm/util/style → style}/vectorStyleItem.js +230 -156
  119. package/src/{vcs/vcm/util/style → style}/writeStyle.js +7 -12
  120. package/src/{vcs/vcm/util → util}/clipping/clippingObject.js +84 -52
  121. package/src/{vcs/vcm/util → util}/clipping/clippingObjectManager.js +56 -23
  122. package/src/{vcs/vcm/util → util}/clipping/clippingPlaneHelper.js +149 -88
  123. package/src/{vcs/vcm/util → util}/collection.js +28 -10
  124. package/src/util/editor/createFeatureSession.js +195 -0
  125. package/src/util/editor/editFeaturesSession.js +325 -0
  126. package/src/util/editor/editGeometrySession.js +452 -0
  127. package/src/util/editor/editorHelpers.js +300 -0
  128. package/src/util/editor/editorSessionHelpers.js +132 -0
  129. package/src/util/editor/editorSymbols.js +21 -0
  130. package/src/util/editor/interactions/createBBoxInteraction.js +154 -0
  131. package/src/util/editor/interactions/createCircleInteraction.js +119 -0
  132. package/src/util/editor/interactions/createLineStringInteraction.js +119 -0
  133. package/src/util/editor/interactions/createPointInteraction.js +73 -0
  134. package/src/util/editor/interactions/createPolygonInteraction.js +136 -0
  135. package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +88 -0
  136. package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +119 -0
  137. package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +50 -0
  138. package/src/util/editor/interactions/insertVertexInteraction.js +103 -0
  139. package/src/util/editor/interactions/mapInteractionController.js +119 -0
  140. package/src/util/editor/interactions/removeVertexInteraction.js +42 -0
  141. package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +152 -0
  142. package/src/util/editor/interactions/selectMultiFeatureInteraction.js +165 -0
  143. package/src/util/editor/interactions/selectSingleFeatureInteraction.js +120 -0
  144. package/src/util/editor/interactions/translateVertexInteraction.js +60 -0
  145. package/src/util/editor/selectFeaturesSession.js +303 -0
  146. package/src/util/editor/transformation/create2DHandlers.js +339 -0
  147. package/src/util/editor/transformation/create3DHandlers.js +678 -0
  148. package/src/util/editor/transformation/extrudeInteraction.js +106 -0
  149. package/src/util/editor/transformation/rotateInteraction.js +201 -0
  150. package/src/util/editor/transformation/scaleInteraction.js +201 -0
  151. package/src/util/editor/transformation/transformationHandler.js +178 -0
  152. package/src/util/editor/transformation/transformationTypes.js +88 -0
  153. package/src/util/editor/transformation/translateInteraction.js +263 -0
  154. package/src/util/editor/validateGeoemetry.js +24 -0
  155. package/src/{vcs/vcm/util → util}/exclusiveManager.js +6 -3
  156. package/src/{vcs/vcm/util → util}/extent.js +26 -20
  157. package/src/util/featureconverter/arcToCesium.js +121 -0
  158. package/src/{vcs/vcm/util → util}/featureconverter/circleToCesium.js +70 -37
  159. package/src/{vcs/vcm/util → util}/featureconverter/convert.js +94 -16
  160. package/src/util/featureconverter/extent3D.js +284 -0
  161. package/src/{vcs/vcm/util → util}/featureconverter/featureconverterHelper.js +253 -94
  162. package/src/util/featureconverter/lineStringToCesium.js +343 -0
  163. package/src/util/featureconverter/pointHelpers.js +413 -0
  164. package/src/{vcs/vcm/util → util}/featureconverter/pointToCesium.js +157 -107
  165. package/src/{vcs/vcm/util → util}/featureconverter/polygonToCesium.js +57 -24
  166. package/src/util/fetch.js +34 -0
  167. package/src/{vcs/vcm/util → util}/geometryHelpers.js +25 -17
  168. package/src/{vcs/vcm/util → util}/indexedCollection.js +27 -8
  169. package/src/{vcs/vcm/util → util}/isMobile.js +8 -2
  170. package/src/{vcs/vcm/util → util}/layerCollection.js +109 -19
  171. package/src/util/locale.js +12 -0
  172. package/src/{vcs/vcm/util → util}/mapCollection.js +170 -63
  173. package/src/util/math.js +193 -0
  174. package/src/util/overrideCollection.js +261 -0
  175. package/src/{vcs/vcm/util → util}/projection.js +23 -31
  176. package/src/{vcs/vcm/util → util}/urlHelpers.js +5 -3
  177. package/src/{vcs/vcm/util → util}/viewpoint.js +83 -57
  178. package/src/vcsApp.js +657 -0
  179. package/src/{vcs/vcm/event/vcsEvent.js → vcsEvent.js} +2 -3
  180. package/src/vcsModule.js +130 -0
  181. package/src/vcsModuleHelpers.js +136 -0
  182. package/src/{vcs/vcm/object.js → vcsObject.js} +3 -10
  183. package/tests/data/dynamicPointCzml.json +53 -0
  184. package/tests/data/oblique/imageData/imagev34.json +136 -0
  185. package/tests/data/oblique/imageData/imagev35.json +307 -0
  186. package/tests/data/oblique/imageData/imagev35PerImageSize.json +333 -0
  187. package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -0
  188. package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -0
  189. package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -0
  190. package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -0
  191. package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -0
  192. package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -0
  193. package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -0
  194. package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -0
  195. package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -0
  196. package/tests/data/oblique/tiledImageData/image.json +70 -0
  197. package/tests/data/terrain/13/8800/6485.terrain +0 -0
  198. package/tests/data/terrain/13/8800/6486.terrain +0 -0
  199. package/tests/data/terrain/13/8801/6485.terrain +0 -0
  200. package/tests/data/terrain/13/8801/6486.terrain +0 -0
  201. package/tests/data/terrain/layer.json +127 -0
  202. package/tests/data/testGeoJSON.json +149 -0
  203. package/tests/data/tile.pbf +0 -0
  204. package/tests/unit/helpers/cesiumHelpers.js +326 -0
  205. package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
  206. package/tests/unit/helpers/helpers.js +32 -0
  207. package/tests/unit/helpers/imageHelpers.js +24 -0
  208. package/tests/unit/helpers/importJSON.js +15 -0
  209. package/tests/unit/helpers/obliqueData.js +102 -0
  210. package/tests/unit/helpers/obliqueHelpers.js +115 -0
  211. package/tests/unit/helpers/openlayersHelpers.js +25 -0
  212. package/tests/unit/helpers/terrain/terrainData.js +47 -0
  213. package/src/vcs/vcm/classRegistry.js +0 -106
  214. package/src/vcs/vcm/globalCollections.js +0 -11
  215. package/src/vcs/vcm/interaction/featureProviderInteraction.js +0 -54
  216. package/src/vcs/vcm/layer/buildings.js +0 -17
  217. package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +0 -29
  218. package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +0 -58
  219. package/src/vcs/vcm/layer/cesium/vectorContext.js +0 -167
  220. package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +0 -79
  221. package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +0 -27
  222. package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +0 -121
  223. package/src/vcs/vcm/layer/terrainHelpers.js +0 -119
  224. package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +0 -67
  225. package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +0 -28
  226. package/src/vcs/vcm/layer/vectorHelpers.js +0 -206
  227. package/src/vcs/vcm/util/dateTime.js +0 -60
  228. package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +0 -51
  229. package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
  230. package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +0 -171
  231. package/src/vcs/vcm/util/locale.js +0 -53
  232. package/src/vcs/vcm/util/math.js +0 -71
  233. package/src/vcs/vcm/util/splitScreen.js +0 -233
  234. package/src/vcs/vcm/util/style/styleFactory.js +0 -48
  235. package/src/vcs/vcm/util/style/styleItem.js +0 -243
  236. /package/src/{vcs/vcm/util/featureProvider → featureProvider}/featureProviderSymbols.js +0 -0
@@ -0,0 +1,88 @@
1
+ import { Color } from '@vcmap-cesium/engine';
2
+
3
+ /**
4
+ * Handlers are map specific transformation handlers wich enable the use of the transformation interactions.
5
+ * There visualization is {@see TransformationMode} specific. It is not adviced to create these handlers yourself,
6
+ * use {@see createTransformationHandler} instead.
7
+ * @typedef {Object} Handlers
8
+ * @property {boolean} show - whether to show or hide all handlers
9
+ * @property {function(import("ol/coordinate").Coordinate):void} setCenter - update the center of the handlers
10
+ * @property {AXIS_AND_PLANES} showAxis - highlight the given axis
11
+ * @property {boolean} greyOutZ - display Z axis handlers in grey and do not allow them to be picked
12
+ * @property {function():void} destroy - destroy the handlers, removing any resources created by create2DHandlers or create3DHandlers
13
+ */
14
+
15
+ /**
16
+ * This interface provides an abstraction from the other {@see Handlers} interface.
17
+ * @typedef {Object} TransformationHandler
18
+ * @property {function(number, number, number):void} translate - translate the center of the underlying handlers
19
+ * @property {import("ol/coordinate").Coordinate} center - readonly current center of the handler. this is a copy, not a reference
20
+ * @property {AXIS_AND_PLANES} showAxis - highlight the given axis
21
+ * @property {boolean} showing - readonly value indicating whether the handlers are showing (proxy for: features are selected)
22
+ * @property {function(Array<import("ol").Feature>):void} setFeatures - Sets transformation handle features. The handler is located in the center of the features.
23
+ * @property {function():void} destroy - destroy the handler and any resources created by it
24
+ */
25
+
26
+ /**
27
+ * @enum {string}
28
+ * @property {string} X
29
+ * @property {string} Y
30
+ * @property {string} Z
31
+ * @property {string} XY
32
+ * @property {string} XZ
33
+ * @property {string} YZ
34
+ * @property {string} NONE
35
+ */
36
+ export const AXIS_AND_PLANES = {
37
+ X: 'X',
38
+ Y: 'Y',
39
+ Z: 'Z',
40
+ XY: 'XY',
41
+ XZ: 'XZ',
42
+ YZ: 'YZ',
43
+ NONE: 'NONE',
44
+ };
45
+
46
+ /**
47
+ * @enum {string}
48
+ * @property {string} TRANSLATE
49
+ * @property {string} ROTATE
50
+ * @property {string} SCALE
51
+ * @property {string} EXTRUDE
52
+ */
53
+ export const TransformationMode = {
54
+ TRANSLATE: 'translate',
55
+ ROTATE: 'rotate',
56
+ SCALE: 'scale',
57
+ EXTRUDE: 'extrude',
58
+ };
59
+
60
+ /**
61
+ * @const
62
+ * @type {import("@vcmap-cesium/engine").Color}
63
+ */
64
+ export const greyedOutColor = Color.GRAY.withAlpha(0.5);
65
+
66
+ /**
67
+ * @param {AXIS_AND_PLANES} axis
68
+ * @returns {boolean}
69
+ */
70
+ export function is1DAxis(axis) {
71
+ return (
72
+ axis === AXIS_AND_PLANES.X ||
73
+ axis === AXIS_AND_PLANES.Y ||
74
+ axis === AXIS_AND_PLANES.Z
75
+ );
76
+ }
77
+
78
+ /**
79
+ * @param {AXIS_AND_PLANES} axis
80
+ * @returns {boolean}
81
+ */
82
+ export function is2DAxis(axis) {
83
+ return (
84
+ axis === AXIS_AND_PLANES.XY ||
85
+ axis === AXIS_AND_PLANES.XZ ||
86
+ axis === AXIS_AND_PLANES.YZ
87
+ );
88
+ }
@@ -0,0 +1,263 @@
1
+ import { Plane, Transforms } from '@vcmap-cesium/engine';
2
+ import AbstractInteraction from '../../../interaction/abstractInteraction.js';
3
+ import { EventType } from '../../../interaction/interactionType.js';
4
+ import { handlerSymbol } from '../editorSymbols.js';
5
+ import {
6
+ createCameraVerticalPlane,
7
+ getCartographicFromPlane,
8
+ getClosestPointOn2DLine,
9
+ } from '../editorHelpers.js';
10
+ import VcsEvent from '../../../vcsEvent.js';
11
+ import Projection, { mercatorProjection } from '../../projection.js';
12
+ import { cartographicToWgs84, mercatorToCartesian } from '../../math.js';
13
+ import { AXIS_AND_PLANES, is1DAxis, is2DAxis } from './transformationTypes.js';
14
+ import CesiumMap from '../../../map/cesiumMap.js';
15
+
16
+ /**
17
+ * A class to handle events on a {@see TransformationHandler}. Should be used with {@see TransformationHandler} created for mode TransformationMode.TRANSLATE.
18
+ * If the rings are dragged, the translated event will be raised.
19
+ * @class
20
+ * @extends {AbstractInteraction}
21
+ */
22
+ class TranslateInteraction extends AbstractInteraction {
23
+ /**
24
+ * @param {TransformationHandler} transformationHandler
25
+ */
26
+ constructor(transformationHandler) {
27
+ super(EventType.DRAGEVENTS);
28
+ /**
29
+ * @type {TransformationHandler}
30
+ */
31
+ this._transformationHandler = transformationHandler;
32
+ /**
33
+ * @type {VcsEvent<Array<number>>}
34
+ */
35
+ this._translated = new VcsEvent();
36
+ /**
37
+ * @type {null|function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):import("ol/coordinate").Coordinate}
38
+ * @private
39
+ */
40
+ this._getTranslateEvent = null;
41
+ }
42
+
43
+ /**
44
+ * Event raised if the handlers are dragged. The resulting array is of type [dx, dy, dz] where all numbers
45
+ * are considered to be deltas to the previous event (where 0 means no translating).
46
+ * @type {VcsEvent<Array<number>>}
47
+ * @readonly
48
+ */
49
+ get translated() {
50
+ return this._translated;
51
+ }
52
+
53
+ /**
54
+ * @param {InteractionEvent} event
55
+ * @returns {Promise<InteractionEvent>}
56
+ */
57
+ async pipe(event) {
58
+ if (this._getTranslateEvent) {
59
+ this._translated.raiseEvent(
60
+ this._getTranslateEvent(event.positionOrPixel, event.windowPosition),
61
+ );
62
+ if (event.type === EventType.DRAGEND) {
63
+ this._getTranslateEvent = null;
64
+ this._transformationHandler.showAxis = AXIS_AND_PLANES.NONE;
65
+ }
66
+ } else if (
67
+ event.type === EventType.DRAGSTART &&
68
+ event?.feature?.[handlerSymbol]
69
+ ) {
70
+ const axis = event.feature[handlerSymbol];
71
+ if (axis !== AXIS_AND_PLANES.NONE) {
72
+ this._transformationHandler.showAxis = axis;
73
+ if (event.map instanceof CesiumMap) {
74
+ if (is1DAxis(axis)) {
75
+ this._getTranslateEvent = this._dragAlongAxis3D(axis, event);
76
+ } else if (is2DAxis(axis)) {
77
+ this._getTranslateEvent = this._dragAlongPlane3D(axis, event);
78
+ }
79
+ } else if (is1DAxis(axis)) {
80
+ this._getTranslateEvent = this._dragAlongAxis2D(axis, event);
81
+ } else if (is2DAxis(axis)) {
82
+ this._getTranslateEvent = this._dragAlongPlane2D(axis, event);
83
+ }
84
+ }
85
+ }
86
+ return event;
87
+ }
88
+
89
+ /**
90
+ * @param {AXIS_AND_PLANES} axis
91
+ * @param {InteractionEvent} event
92
+ * @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):import("ol/coordinate").Coordinate}
93
+ * @private
94
+ */
95
+ _dragAlongAxis3D(axis, event) {
96
+ const scene = /** @type {import("@vcmap/core").CesiumMap} */ (
97
+ event.map
98
+ ).getScene();
99
+ if (axis !== AXIS_AND_PLANES.Z) {
100
+ const center = mercatorToCartesian(this._transformationHandler.center);
101
+ let plane = Plane.clone(Plane.ORIGIN_XY_PLANE);
102
+ plane = Plane.transform(
103
+ plane,
104
+ Transforms.eastNorthUpToFixedFrame(center),
105
+ plane,
106
+ );
107
+ let cartographic = getCartographicFromPlane(
108
+ plane,
109
+ scene.camera,
110
+ event.windowPosition,
111
+ );
112
+ let currentPosition = Projection.wgs84ToMercator(
113
+ cartographicToWgs84(cartographic),
114
+ );
115
+ return (c, windowPosition) => {
116
+ cartographic = getCartographicFromPlane(
117
+ plane,
118
+ scene.camera,
119
+ windowPosition,
120
+ );
121
+ const newPosition = Projection.wgs84ToMercator(
122
+ cartographicToWgs84(cartographic),
123
+ );
124
+ const translate =
125
+ axis === AXIS_AND_PLANES.X
126
+ ? [newPosition[0] - currentPosition[0], 0, 0]
127
+ : [0, newPosition[1] - currentPosition[1], 0];
128
+
129
+ currentPosition = newPosition;
130
+ return translate;
131
+ };
132
+ } else {
133
+ const plane = createCameraVerticalPlane(
134
+ this._transformationHandler.center.slice(),
135
+ scene,
136
+ );
137
+ let currentHeight = getCartographicFromPlane(
138
+ plane,
139
+ scene.camera,
140
+ event.windowPosition,
141
+ ).height;
142
+ return (c, windowPosition) => {
143
+ const newHeight = getCartographicFromPlane(
144
+ plane,
145
+ scene.camera,
146
+ windowPosition,
147
+ ).height;
148
+ const translate = [0, 0, newHeight - currentHeight];
149
+ currentHeight = newHeight;
150
+ return translate;
151
+ };
152
+ }
153
+ }
154
+
155
+ /**
156
+ * @param {AXIS_AND_PLANES} axis
157
+ * @param {InteractionEvent} event
158
+ * @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):import("ol/coordinate").Coordinate}
159
+ * @private
160
+ */
161
+ _dragAlongPlane3D(axis, event) {
162
+ const scene = /** @type {import("@vcmap/core").CesiumMap} */ (
163
+ event.map
164
+ ).getScene();
165
+ const center = mercatorToCartesian(this._transformationHandler.center);
166
+ let plane;
167
+ if (axis === AXIS_AND_PLANES.YZ) {
168
+ plane = Plane.clone(Plane.ORIGIN_YZ_PLANE);
169
+ } else if (axis === AXIS_AND_PLANES.XZ) {
170
+ plane = Plane.clone(Plane.ORIGIN_ZX_PLANE);
171
+ } else {
172
+ plane = Plane.clone(Plane.ORIGIN_XY_PLANE);
173
+ }
174
+ plane = Plane.transform(
175
+ plane,
176
+ Transforms.eastNorthUpToFixedFrame(center),
177
+ plane,
178
+ );
179
+ let cartographic = getCartographicFromPlane(
180
+ plane,
181
+ scene.camera,
182
+ event.windowPosition,
183
+ );
184
+ let currentPosition = Projection.wgs84ToMercator(
185
+ cartographicToWgs84(cartographic),
186
+ );
187
+ return (c, windowPosition) => {
188
+ cartographic = getCartographicFromPlane(
189
+ plane,
190
+ scene.camera,
191
+ windowPosition,
192
+ );
193
+ const newPosition = Projection.wgs84ToMercator(
194
+ cartographicToWgs84(cartographic),
195
+ );
196
+
197
+ const translate = [
198
+ newPosition[0] - currentPosition[0],
199
+ newPosition[1] - currentPosition[1],
200
+ newPosition[2] - currentPosition[2],
201
+ ];
202
+ currentPosition = newPosition;
203
+ return translate;
204
+ };
205
+ }
206
+
207
+ /**
208
+ * @param {AXIS_AND_PLANES} axis
209
+ * @param {InteractionEvent} event
210
+ * @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):import("ol/coordinate").Coordinate}
211
+ * @private
212
+ */
213
+ _dragAlongAxis2D(axis, event) {
214
+ const center = this._transformationHandler.center.slice();
215
+ const mercatorExtent = mercatorProjection.proj.getExtent();
216
+ const end =
217
+ axis === AXIS_AND_PLANES.X
218
+ ? [mercatorExtent[0], center[1], center[2]]
219
+ : [center[0], mercatorExtent[1], center[2]];
220
+
221
+ let lastPointOnAxis = getClosestPointOn2DLine(
222
+ center,
223
+ end,
224
+ event.positionOrPixel,
225
+ );
226
+ return (coords) => {
227
+ const newPointOnAxis = getClosestPointOn2DLine(center, end, coords);
228
+ const translate =
229
+ axis === AXIS_AND_PLANES.X
230
+ ? [newPointOnAxis[0] - lastPointOnAxis[0], 0, 0]
231
+ : [0, newPointOnAxis[1] - lastPointOnAxis[1], 0];
232
+
233
+ lastPointOnAxis = newPointOnAxis;
234
+ return translate;
235
+ };
236
+ }
237
+
238
+ /**
239
+ * @param {AXIS_AND_PLANES} axis
240
+ * @param {InteractionEvent} event
241
+ * @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):import("ol/coordinate").Coordinate}
242
+ * @private
243
+ */
244
+ // eslint-disable-next-line class-methods-use-this
245
+ _dragAlongPlane2D(axis, event) {
246
+ let current = event.positionOrPixel.slice();
247
+ return (coords) => {
248
+ const translate = [coords[0] - current[0], coords[1] - current[1], 0];
249
+ current = coords.slice();
250
+ return translate;
251
+ };
252
+ }
253
+
254
+ /**
255
+ * @inheritDoc
256
+ */
257
+ destroy() {
258
+ this._transformationHandler = null;
259
+ this._translated.destroy();
260
+ }
261
+ }
262
+
263
+ export default TranslateInteraction;
@@ -0,0 +1,24 @@
1
+ import { validateLineString } from '../featureconverter/lineStringToCesium.js';
2
+ import { validatePolygon } from '../featureconverter/polygonToCesium.js';
3
+ import { validatePoint } from '../featureconverter/pointToCesium.js';
4
+ import { validateCircle } from '../featureconverter/circleToCesium.js';
5
+
6
+ /**
7
+ * @param {import("ol/geom").Geometry} geometry
8
+ * @returns {boolean}
9
+ */
10
+ export default function geometryIsValid(geometry) {
11
+ const type = geometry.getType();
12
+ if (type === 'LineString') {
13
+ return validateLineString(
14
+ /** @type {import("ol/geom").LineString} */ (geometry),
15
+ );
16
+ } else if (type === 'Polygon') {
17
+ return validatePolygon(/** @type {import("ol/geom").Polygon} */ (geometry));
18
+ } else if (type === 'Point') {
19
+ return validatePoint(/** @type {import("ol/geom").Point} */ (geometry));
20
+ } else if (type === 'Circle') {
21
+ return validateCircle(/** @type {import("ol/geom").Circle} */ (geometry));
22
+ }
23
+ return false;
24
+ }
@@ -66,15 +66,18 @@ class ExclusiveManager {
66
66
  handleLayerActivated(layer) {
67
67
  const { exclusiveGroups } = layer;
68
68
  if (exclusiveGroups.length > 0) {
69
- const splitDirection = /** @type {SplitLayer} */ (layer).splitDirection || 0;
69
+ const splitDirection =
70
+ /** @type {SplitLayer} */ (layer).splitDirection || 0;
70
71
  exclusiveGroups.forEach((group) => {
71
72
  if (this.layers.has(group)) {
72
73
  this.layers.get(group).forEach((groupLayer) => {
73
74
  if (
74
- groupLayer !== layer && !(
75
+ groupLayer !== layer &&
76
+ !(
75
77
  splitDirection &&
76
78
  /** @type {SplitLayer} */ (groupLayer).splitDirection &&
77
- /** @type {SplitLayer} */ (groupLayer).splitDirection !== splitDirection
79
+ /** @type {SplitLayer} */ (groupLayer).splitDirection !==
80
+ splitDirection
78
81
  )
79
82
  ) {
80
83
  groupLayer.deactivate();
@@ -1,8 +1,10 @@
1
1
  import Projection from './projection.js';
2
2
 
3
3
  /**
4
- * @typedef {ProjectionOptions} ExtentOptions
5
- * @property {import("ol/extent").Extent|undefined} coordinates - if not specified, the extent of the projection is used
4
+ * @typedef {Object} ExtentOptions
5
+ * @property {string} [type]
6
+ * @property {import("ol/extent").Extent|undefined} [coordinates] - if not specified, the extent of the projection is used
7
+ * @property {ProjectionOptions} [projection] - if not specified the default projection is assumed
6
8
  * @api
7
9
  */
8
10
 
@@ -27,30 +29,25 @@ function checkExtentValidity(extent) {
27
29
  return extent[0] <= extent[2] && extent[1] <= extent[3];
28
30
  }
29
31
 
30
-
31
32
  /**
32
33
  * Extent Class
33
34
  * @class
34
- * @export
35
35
  * @api
36
36
  */
37
37
  class Extent {
38
38
  /**
39
39
  * @type {string}
40
40
  */
41
- static get className() { return 'vcs.vcm.util.Extent'; }
41
+ static get className() {
42
+ return 'Extent';
43
+ }
42
44
 
43
45
  /**
44
46
  * @param {ExtentOptions=} options object
45
47
  */
46
48
  constructor(options = {}) {
47
49
  /** @type {Projection} */
48
- this.projection = new Projection({
49
- epsg: options.epsg,
50
- proj4: options.proj4,
51
- alias: options.alias,
52
- prefix: options.prefix,
53
- });
50
+ this.projection = new Projection(options.projection);
54
51
 
55
52
  /** @type {import("ol/extent").Extent|null} */
56
53
  this.extent = options.coordinates || this.projection.proj.getExtent();
@@ -62,12 +59,14 @@ class Extent {
62
59
  * @returns {import("ol/extent").Extent}
63
60
  */
64
61
  getCoordinatesInProjection(destination, result) {
65
- if (destination.epsg === this.projection.epsg) { // TODO aliases?!
66
- const extent = result ? result.splice(0, 4, ...this.extent) : this.extent.slice();
62
+ if (destination.epsg === this.projection.epsg) {
63
+ // TODO aliases?!
64
+ const extent = result
65
+ ? result.splice(0, 4, ...this.extent)
66
+ : this.extent.slice();
67
67
  return /** @type {import("ol/extent").Extent} */ (extent);
68
68
  }
69
- const transformer = Projection
70
- .getTransformer(destination, this.projection);
69
+ const transformer = Projection.getTransformer(destination, this.projection);
71
70
  const target = result || [];
72
71
  transformer(this.extent, target, 2);
73
72
  return /** @type {import("ol/extent").Extent} */ (target);
@@ -87,7 +86,7 @@ class Extent {
87
86
  toJSON() {
88
87
  return {
89
88
  coordinates: this.extent.slice(),
90
- ...this.projection.toJSON(),
89
+ projection: this.projection.toJSON(),
91
90
  type: Extent.className,
92
91
  };
93
92
  }
@@ -108,10 +107,12 @@ class Extent {
108
107
  return true;
109
108
  }
110
109
 
111
- return this.isValid() &&
110
+ return (
111
+ this.isValid() &&
112
112
  extent.isValid() &&
113
113
  this.extent.every((c, i) => c === extent.extent[i]) &&
114
- this.projection.equals(extent.projection);
114
+ this.projection.equals(extent.projection)
115
+ );
115
116
  }
116
117
 
117
118
  /**
@@ -122,13 +123,18 @@ class Extent {
122
123
  * @api
123
124
  */
124
125
  static validateOptions(options) {
125
- return Projection.validateOptions(options) && checkExtentValidity(options.coordinates);
126
+ return (
127
+ Projection.validateOptions(options.projection || {}) &&
128
+ checkExtentValidity(options.coordinates)
129
+ );
126
130
  }
127
131
 
128
132
  /**
129
133
  * @type {import("ol/extent").Extent}
130
134
  */
131
- static get WGS_84_EXTENT() { return [-180, -90, 180, 90]; }
135
+ static get WGS_84_EXTENT() {
136
+ return [-180, -90, 180, 90];
137
+ }
132
138
  }
133
139
 
134
140
  export default Extent;
@@ -0,0 +1,121 @@
1
+ import { ArcType, Cartesian3, HeightReference } from '@vcmap-cesium/engine';
2
+ import Projection from '../projection.js';
3
+ import { addPrimitivesToContext } from './featureconverterHelper.js';
4
+ import {
5
+ createFillGeometries,
6
+ createGroundLineGeometries,
7
+ createLineGeometries,
8
+ createOutlineGeometries,
9
+ createSolidGeometries,
10
+ validateLineString,
11
+ getCoordinates as getLineStringCoordinates,
12
+ getGeometryOptions as getLineStringGeometryOptions,
13
+ addArrowsToContext,
14
+ } from './lineStringToCesium.js';
15
+ import { featureArcStruct } from '../../style/arcStyle.js';
16
+
17
+ /**
18
+ * Creates the positions & arcType option for the PolylineGeometry
19
+ * @param {Array<import("ol/coordinate").Coordinate>} coords
20
+ * @param {import("ol/geom/LineString").default} geometry
21
+ * @param {number} positionHeightAdjustment
22
+ * @returns {Object}
23
+ * @private
24
+ */
25
+ export function getGeometryOptions(coords, geometry, positionHeightAdjustment) {
26
+ const positions = coords.map((coord) => {
27
+ const wgs84Coords = Projection.mercatorToWgs84(coord);
28
+ if (wgs84Coords[2] != null) {
29
+ wgs84Coords[2] += positionHeightAdjustment;
30
+ }
31
+ return Cartesian3.fromDegrees(
32
+ wgs84Coords[0],
33
+ wgs84Coords[1],
34
+ wgs84Coords[2],
35
+ );
36
+ });
37
+ return { positions, arcType: ArcType.NONE };
38
+ }
39
+
40
+ /**
41
+ * In this special case, the coordinates are not taken from the geometries array
42
+ * @param {Array<import("ol/coordinate").Coordinate>} coords
43
+ * @param {Array<import("ol/geom/LineString").default>} geometries
44
+ * @returns {Array<import("ol/coordinate").Coordinate>}
45
+ * @private
46
+ */
47
+ // eslint-disable-next-line no-unused-vars
48
+ export function getCoordinates(coords, geometries) {
49
+ return coords;
50
+ }
51
+
52
+ /**
53
+ * @param {Array<import("ol/coordinate").Coordinate>} arcCoords - the coordinates of the arc to use instead of the geometries coordinates if height mode is absolute
54
+ * @param {import("@vcmap-cesium/engine").HeightReference} altitudeMode
55
+ * @returns {VectorGeometryFactoryType}
56
+ */
57
+ function getGeometryFactory(arcCoords, altitudeMode) {
58
+ return {
59
+ getCoordinates:
60
+ altitudeMode === HeightReference.NONE
61
+ ? getCoordinates.bind(null, arcCoords)
62
+ : getLineStringCoordinates,
63
+ getGeometryOptions:
64
+ altitudeMode === HeightReference.NONE
65
+ ? getGeometryOptions.bind(null, arcCoords)
66
+ : getLineStringGeometryOptions,
67
+ createSolidGeometries,
68
+ createOutlineGeometries,
69
+ createFillGeometries,
70
+ createGroundLineGeometries,
71
+ createLineGeometries,
72
+ };
73
+ }
74
+
75
+ /**
76
+ * converts a linestring with an ArcStyle to a a cesium primitive
77
+ * @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
78
+ * @param {import("@vcmap/core").ArcStyle} style
79
+ * @param {Array<import("ol/geom/LineString").default>} geometries
80
+ * @param {import("@vcmap/core").VectorProperties} vectorProperties
81
+ * @param {import("@vcmap-cesium/engine").Scene} scene
82
+ * @param {import("@vcmap/core").VectorContext|import("@vcmap/core").ClusterContext} context
83
+ */
84
+ export default function arcToCesium(
85
+ feature,
86
+ style,
87
+ geometries,
88
+ vectorProperties,
89
+ scene,
90
+ context,
91
+ ) {
92
+ if (!style.getFill() && !style.getStroke()) {
93
+ return;
94
+ }
95
+ const altitudeMode = vectorProperties.getAltitudeMode(feature);
96
+ const arcGeometryFactory = getGeometryFactory(
97
+ feature[featureArcStruct].coordinates,
98
+ altitudeMode,
99
+ );
100
+ const validGeometries = geometries.filter((lineString) =>
101
+ validateLineString(lineString),
102
+ );
103
+ addPrimitivesToContext(
104
+ feature,
105
+ style,
106
+ validGeometries,
107
+ vectorProperties,
108
+ scene,
109
+ arcGeometryFactory,
110
+ context,
111
+ );
112
+ addArrowsToContext(
113
+ feature,
114
+ style,
115
+ validGeometries,
116
+ vectorProperties,
117
+ scene,
118
+ arcGeometryFactory,
119
+ context,
120
+ ); // IDEA what about labels?
121
+ }