@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
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { Cartesian2 } from '@vcmap/cesium';
2
+ import { Cartesian2 } from '@vcmap-cesium/engine';
3
3
 
4
4
  import { check, checkMaybe } from '@vcsuite/check';
5
5
  import { getLogger as getLoggerByName } from '@vcsuite/logger';
@@ -7,9 +7,13 @@ import AbstractInteraction from './abstractInteraction.js';
7
7
  import InteractionChain from './interactionChain.js';
8
8
  import CoordinateAtPixel from './coordinateAtPixel.js';
9
9
  import FeatureAtPixelInteraction from './featureAtPixelInteraction.js';
10
- import { EventType, PointerEventType } from './interactionType.js';
10
+ import {
11
+ EventType,
12
+ ModificationKeyType,
13
+ PointerEventType,
14
+ } from './interactionType.js';
11
15
  import FeatureProviderInteraction from './featureProviderInteraction.js';
12
- import VcsEvent from '../event/vcsEvent.js';
16
+ import VcsEvent from '../vcsEvent.js';
13
17
 
14
18
  /**
15
19
  * @namespace interaction
@@ -27,18 +31,18 @@ import VcsEvent from '../event/vcsEvent.js';
27
31
  * @typedef {Object} MapEvent
28
32
  * @property {PointerEventType} pointerEvent
29
33
  * @property {import("@vcmap/core").VcsMap} map
30
- * @property {import("@vcmap/cesium").Cartesian2} windowPosition
34
+ * @property {import("@vcmap-cesium/engine").Cartesian2} windowPosition
31
35
  * @property {import("@vcmap/core").ModificationKeyType} key
32
36
  * @property {import("@vcmap/core").PointerKeyType} pointer
33
37
  * @property {import("ol/coordinate").Coordinate|undefined} position - position in web mercator coordinates
34
- * @property {import("ol/coordinate").Coordinate|undefined} positionOrPixel - position in web mercator coordinates or image coordinates in Oblique Map Mode
38
+ * @property {import("ol/coordinate").Coordinate|undefined} positionOrPixel - position in web mercator coordinates or image coordinates in ObliqueMap Map Mode
35
39
  * @property {boolean|undefined} multipleTouch - vcs:undocumented
36
40
  * @property {number|null|undefined} time - vcs:undocumented
37
41
  */
38
42
 
39
43
  /**
40
44
  * @typedef {Object} LastClick
41
- * @property {import("@vcmap/cesium").Cartesian2} windowPosition - vcs:undocumented
45
+ * @property {import("@vcmap-cesium/engine").Cartesian2} windowPosition - vcs:undocumented
42
46
  * @property {number|null} time - vcs:undocumented
43
47
  * @api
44
48
  */
@@ -47,7 +51,7 @@ import VcsEvent from '../event/vcsEvent.js';
47
51
  * @returns {import("@vcsuite/logger").Logger}
48
52
  */
49
53
  function getLogger() {
50
- return getLoggerByName('vcs.vcm.interaction.EventHandler');
54
+ return getLoggerByName('EventHandler');
51
55
  }
52
56
 
53
57
  /**
@@ -105,6 +109,20 @@ class EventHandler {
105
109
  windowPosition: new Cartesian2(),
106
110
  };
107
111
 
112
+ /**
113
+ * @type {Map<ModificationKeyType, boolean>}
114
+ * @private
115
+ */
116
+ this._lastKeyEventModifiers = new Map();
117
+ this._lastKeyEventModifiers.set(ModificationKeyType.SHIFT, false);
118
+ this._lastKeyEventModifiers.set(ModificationKeyType.ALT, false);
119
+ this._lastKeyEventModifiers.set(ModificationKeyType.CTRL, false);
120
+ /**
121
+ * @type {ModificationKeyType}
122
+ * @private
123
+ */
124
+ this._lastDispatchedModifier = ModificationKeyType.NONE;
125
+
108
126
  /**
109
127
  * @type {null|MapEvent}
110
128
  * @private
@@ -146,6 +164,19 @@ class EventHandler {
146
164
  * @api
147
165
  */
148
166
  this.exclusiveAdded = new VcsEvent();
167
+ /**
168
+ * @type {function(KeyboardEvent):void}
169
+ * @private
170
+ */
171
+ this._boundKeyListener = this._keyListener.bind(this);
172
+ window.addEventListener('keydown', this._boundKeyListener);
173
+ window.addEventListener('keyup', this._boundKeyListener);
174
+
175
+ /**
176
+ * @type {VcsEvent<ModificationKeyType>}
177
+ * @private
178
+ */
179
+ this._modifierChanged = new VcsEvent();
149
180
  }
150
181
 
151
182
  /**
@@ -153,21 +184,27 @@ class EventHandler {
153
184
  * @readonly
154
185
  * @api
155
186
  */
156
- get positionInteraction() { return this._positionInteraction; }
187
+ get positionInteraction() {
188
+ return this._positionInteraction;
189
+ }
157
190
 
158
191
  /**
159
192
  * @type {FeatureAtPixelInteraction}
160
193
  * @readonly
161
194
  * @api
162
195
  */
163
- get featureInteraction() { return this._featureInteraction; }
196
+ get featureInteraction() {
197
+ return this._featureInteraction;
198
+ }
164
199
 
165
200
  /**
166
201
  * @api
167
202
  * @readonly
168
203
  * @type {FeatureProviderInteraction}
169
204
  */
170
- get featureProviderInteraction() { return this._featureProviderInteraction; }
205
+ get featureProviderInteraction() {
206
+ return this._featureProviderInteraction;
207
+ }
171
208
 
172
209
  /**
173
210
  * A copy of all the EventHandler interactions
@@ -175,24 +212,35 @@ class EventHandler {
175
212
  * @type {AbstractInteraction[]}
176
213
  * @api
177
214
  */
178
- get interactions() { return this._interactionChain.chain.slice(); }
215
+ get interactions() {
216
+ return this._interactionChain.chain.slice();
217
+ }
218
+
219
+ /**
220
+ * An event called, when the modifier changes. Order of precedence, if more then one key is pressed: SHIFT, ALT, CTRL
221
+ * @type {VcsEvent<ModificationKeyType>}
222
+ * @readonly
223
+ */
224
+ get modifierChanged() {
225
+ return this._modifierChanged;
226
+ }
179
227
 
180
228
  /**
181
229
  * Add a dynamic interaction to the interaction chain. This is the default methodology for
182
230
  * user map interactions, such as drawing or measuring. If another exclusive interaction is added,
183
231
  * this interaction is removed and a provided callback is called. Use the id parameter to add multiple interactions
184
- * from the same source (if you don't wish to provide an {@link InteractionChain}
232
+ * from the same source (if you don't wish to provide an {@link InteractionChain})
185
233
  * @param {AbstractInteraction} interaction
186
234
  * @param {Function} removed - the callback for when the interaction is forcefully removed.
187
- * @param {number=} [index=3] - the position at which to push the interaction
235
+ * @param {number=} index - the position at which to push the interaction. If no index is provided, the interaction is pushed at the end and therefore is executed last.
188
236
  * @param {string=} id - an id to allow for multiple interactions to belong to the same exclusive registerer
189
237
  * @returns {Function} function to remove the interaction with. returns number of removed interactions (0|1)
190
238
  * @api
191
239
  */
192
- addExclusiveInteraction(interaction, removed, index = 3, id) {
240
+ addExclusiveInteraction(interaction, removed, index, id) {
193
241
  check(interaction, AbstractInteraction);
194
242
  check(removed, Function);
195
- check(index, Number);
243
+ checkMaybe(index, Number);
196
244
  checkMaybe(id, String);
197
245
 
198
246
  if (this._exclusiveInteraction && this._exclusiveInteraction.id !== id) {
@@ -210,7 +258,11 @@ class EventHandler {
210
258
  };
211
259
  }
212
260
  this.exclusiveAdded.raiseEvent();
213
- return this._exclusiveUnListen.bind(this, interaction, this._exclusiveInteraction.id);
261
+ return this._exclusiveUnListen.bind(
262
+ this,
263
+ interaction,
264
+ this._exclusiveInteraction.id,
265
+ );
214
266
  }
215
267
 
216
268
  /**
@@ -220,12 +272,12 @@ class EventHandler {
220
272
  removeExclusive() {
221
273
  if (this._exclusiveInteraction) {
222
274
  this._exclusiveInteraction.interactions
223
- .filter(i => i)
275
+ .filter((i) => i)
224
276
  .forEach((i) => {
225
277
  this._interactionChain.removeInteraction(i);
226
278
  });
227
279
  this._exclusiveInteraction.cb
228
- .filter(cb => cb)
280
+ .filter((cb) => cb)
229
281
  .forEach((cb) => {
230
282
  cb();
231
283
  });
@@ -242,17 +294,21 @@ class EventHandler {
242
294
  * @private
243
295
  */
244
296
  _exclusiveUnListen(interaction, id) {
245
- if (!this._exclusiveInteraction || (this._exclusiveInteraction && this._exclusiveInteraction.id !== id)) {
297
+ if (
298
+ !this._exclusiveInteraction ||
299
+ (this._exclusiveInteraction && this._exclusiveInteraction.id !== id)
300
+ ) {
246
301
  return 0;
247
302
  }
248
303
  const removed = this._interactionChain.removeInteraction(interaction);
249
- const index = this._exclusiveInteraction.interactions
250
- .findIndex(candidate => candidate && candidate.id === interaction.id);
304
+ const index = this._exclusiveInteraction.interactions.findIndex(
305
+ (candidate) => candidate && candidate.id === interaction.id,
306
+ );
251
307
  if (index > -1) {
252
308
  this._exclusiveInteraction.interactions.splice(index, 1, undefined);
253
309
  this._exclusiveInteraction.cb.splice(index, 1, undefined);
254
310
  }
255
- if (this._exclusiveInteraction.interactions.every(i => i === undefined)) {
311
+ if (this._exclusiveInteraction.interactions.every((i) => i === undefined)) {
256
312
  this._exclusiveInteraction = null;
257
313
  }
258
314
  if (removed > -1) {
@@ -274,7 +330,8 @@ class EventHandler {
274
330
  check(index, Number);
275
331
 
276
332
  this._interactionChain.addInteraction(interaction, index);
277
- return () => (this._interactionChain.removeInteraction(interaction) !== -1 ? 1 : 0);
333
+ return () =>
334
+ this._interactionChain.removeInteraction(interaction) !== -1 ? 1 : 0;
278
335
  }
279
336
 
280
337
  /**
@@ -334,13 +391,19 @@ class EventHandler {
334
391
  if (
335
392
  this._lastClick.time &&
336
393
  Date.now() - this._lastClick.time < this.clickDuration &&
337
- Cartesian2.distanceSquared(this._lastClick.windowPosition, actualEvent.windowPosition) < 12
394
+ Cartesian2.distanceSquared(
395
+ this._lastClick.windowPosition,
396
+ actualEvent.windowPosition,
397
+ ) < 12
338
398
  ) {
339
399
  this._lastClick.time = null;
340
400
  actualEvent.type = EventType.DBLCLICK;
341
401
  } else {
342
402
  this._lastClick.time = Date.now();
343
- Cartesian2.clone(actualEvent.windowPosition, this._lastClick.windowPosition);
403
+ Cartesian2.clone(
404
+ actualEvent.windowPosition,
405
+ this._lastClick.windowPosition,
406
+ );
344
407
  actualEvent.type = EventType.CLICK;
345
408
  }
346
409
  this._startChain(actualEvent);
@@ -361,7 +424,10 @@ class EventHandler {
361
424
  actualEvent.key = this._dragging.key;
362
425
  actualEvent.pointer = this._dragging.pointer;
363
426
  this._startChain(actualEvent, true);
364
- } else if (!this._dragging && Date.now() - this._lastDown.time > this.dragDuration) {
427
+ } else if (
428
+ !this._dragging &&
429
+ Date.now() - this._lastDown.time > this.dragDuration
430
+ ) {
365
431
  actualEvent = { type: EventType.DRAGSTART, ...this._lastDown };
366
432
  this._dragging = actualEvent;
367
433
  this._startChain(actualEvent, true);
@@ -372,6 +438,43 @@ class EventHandler {
372
438
  }
373
439
  }
374
440
 
441
+ /**
442
+ * @param {KeyboardEvent} event
443
+ * @private
444
+ */
445
+ _keyListener(event) {
446
+ if (event.key === 'Shift' || event.key === 'Alt') {
447
+ event.preventDefault();
448
+ event.stopPropagation();
449
+ }
450
+
451
+ if (
452
+ this._lastKeyEventModifiers.get(ModificationKeyType.SHIFT) !==
453
+ event.shiftKey ||
454
+ this._lastKeyEventModifiers.get(ModificationKeyType.ALT) !==
455
+ event.altKey ||
456
+ this._lastKeyEventModifiers.get(ModificationKeyType.CTRL) !==
457
+ event.ctrlKey
458
+ ) {
459
+ this._lastKeyEventModifiers.set(
460
+ ModificationKeyType.SHIFT,
461
+ event.shiftKey,
462
+ );
463
+ this._lastKeyEventModifiers.set(ModificationKeyType.ALT, event.altKey);
464
+ this._lastKeyEventModifiers.set(ModificationKeyType.CTRL, event.ctrlKey);
465
+ const modifier =
466
+ [...this._lastKeyEventModifiers.keys()].find((k) =>
467
+ this._lastKeyEventModifiers.get(k),
468
+ ) || ModificationKeyType.NONE;
469
+
470
+ if (modifier !== this._lastDispatchedModifier) {
471
+ this._interactionChain.modifierChanged(modifier);
472
+ this._lastDispatchedModifier = modifier;
473
+ this._modifierChanged.raiseEvent(modifier);
474
+ }
475
+ }
476
+ }
477
+
375
478
  /**
376
479
  * @param {InteractionEvent} event
377
480
  * @param {boolean=} discardOnRunning if true the event will discarded if an eventHandler is already Running
@@ -419,6 +522,8 @@ class EventHandler {
419
522
  this._featureInteraction.destroy();
420
523
  this._featureInteraction = null;
421
524
  this._eventQueue = [];
525
+ window.removeEventListener('keydown', this._boundKeyListener);
526
+ window.removeEventListener('keyup', this._boundKeyListener);
422
527
  }
423
528
  }
424
529
 
@@ -1,8 +1,19 @@
1
- import { Cartographic, Cartesian3, Math as CesiumMath, Cesium3DTileFeature, Cesium3DTilePointFeature } from '@vcmap/cesium';
1
+ import {
2
+ Cartographic,
3
+ Cartesian3,
4
+ Math as CesiumMath,
5
+ Cesium3DTileFeature,
6
+ Cesium3DTilePointFeature,
7
+ Entity,
8
+ } from '@vcmap-cesium/engine';
2
9
 
3
10
  import AbstractInteraction from './abstractInteraction.js';
4
11
  import Projection from '../util/projection.js';
5
- import { EventType, ModificationKeyType } from './interactionType.js';
12
+ import {
13
+ EventType,
14
+ ModificationKeyType,
15
+ PointerKeyType,
16
+ } from './interactionType.js';
6
17
  import { vcsLayerName } from '../layer/layerSymbols.js';
7
18
  import { originalFeatureSymbol } from '../layer/vectorSymbols.js';
8
19
 
@@ -12,7 +23,11 @@ import { originalFeatureSymbol } from '../layer/vectorSymbols.js';
12
23
  */
13
24
  class FeatureAtPixelInteraction extends AbstractInteraction {
14
25
  constructor() {
15
- super();
26
+ super(
27
+ EventType.ALL ^ EventType.MOVE,
28
+ ModificationKeyType.ALL,
29
+ PointerKeyType.ALL,
30
+ );
16
31
  /**
17
32
  * @type {EventType|number}
18
33
  * @private
@@ -47,19 +62,6 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
47
62
  */
48
63
  this.hitTolerance = 10;
49
64
 
50
- /**
51
- * @inheritDoc
52
- * @type {ModificationKeyType|number}
53
- * @protected
54
- */
55
- this._defaultModificationKey = ModificationKeyType.ALL;
56
- /**
57
- * @inheritDoc
58
- * @type {ModificationKeyType|number}
59
- * @protected
60
- */
61
- this._defaultActive = EventType.ALL ^ EventType.MOVE;
62
-
63
65
  /**
64
66
  * @type {import("ol").Feature<import("ol/geom/Geometry").default>|Object|null}
65
67
  * @private
@@ -73,7 +75,9 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
73
75
  * @type {number}
74
76
  * @api
75
77
  */
76
- get pickPosition() { return this._pickPosition; }
78
+ get pickPosition() {
79
+ return this._pickPosition;
80
+ }
77
81
 
78
82
  /**
79
83
  * @param {number} position
@@ -87,7 +91,9 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
87
91
  * @type {number}
88
92
  * @api
89
93
  */
90
- get excludedPickPositionEvents() { return ~this._pickPositionMask; }
94
+ get excludedPickPositionEvents() {
95
+ return ~this._pickPositionMask;
96
+ }
91
97
 
92
98
  /**
93
99
  * @param {number} position
@@ -113,11 +119,11 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
113
119
  this._draggingFeature = null;
114
120
  }
115
121
 
116
- if (event.map.className === 'vcs.vcm.maps.Openlayers') {
122
+ if (event.map.className === 'OpenlayersMap') {
117
123
  await this._openlayersHandler(event);
118
- } else if (event.map.className === 'vcs.vcm.maps.Oblique') {
124
+ } else if (event.map.className === 'ObliqueMap') {
119
125
  await this._obliqueHandler(event);
120
- } else if (event.map.className === 'vcs.vcm.maps.Cesium') {
126
+ } else if (event.map.className === 'CesiumMap') {
121
127
  await this._cesiumHandler(event);
122
128
  }
123
129
  if (event.type & EventType.DRAGSTART && event.feature) {
@@ -152,14 +158,26 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
152
158
  let found = null;
153
159
  /** @type {null|import("ol/layer/Layer").default} */
154
160
  let foundLayer = null;
155
- /** @type {import("@vcmap/core").Openlayers} */ (event.map).olMap
156
- .forEachFeatureAtPixel([event.windowPosition.x, event.windowPosition.y], (feat, layer) => {
157
- if (feat && (feat.get('olcs_allowPicking') == null || feat.get('olcs_allowPicking') === true)) {
158
- found = /** @type {import("ol").Feature<import("ol/geom/Geometry").default>} */ (feat);
161
+ /** @type {import("@vcmap/core").OpenlayersMap} */ (
162
+ event.map
163
+ ).olMap.forEachFeatureAtPixel(
164
+ [event.windowPosition.x, event.windowPosition.y],
165
+ (feat, layer) => {
166
+ if (
167
+ feat &&
168
+ (feat.get('olcs_allowPicking') == null ||
169
+ feat.get('olcs_allowPicking') === true)
170
+ ) {
171
+ found =
172
+ /** @type {import("ol").Feature<import("ol/geom/Geometry").default>} */ (
173
+ feat
174
+ );
159
175
  foundLayer = layer;
160
176
  }
161
177
  return true;
162
- }, { hitTolerance: this.hitTolerance });
178
+ },
179
+ { hitTolerance: this.hitTolerance },
180
+ );
163
181
  if (found && foundLayer) {
164
182
  event.feature = found;
165
183
  if (found.get('features')) {
@@ -180,14 +198,19 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
180
198
  let found = null;
181
199
  /** @type {null|import("ol/layer/Layer").default} */
182
200
  let foundLayer = null;
183
- /** @type {import("@vcmap/core").Oblique} */ (event.map).olMap
184
- .forEachFeatureAtPixel([event.windowPosition.x, event.windowPosition.y], (feat, layer) => {
201
+ /** @type {import("@vcmap/core").ObliqueMap} */ (
202
+ event.map
203
+ ).olMap.forEachFeatureAtPixel(
204
+ [event.windowPosition.x, event.windowPosition.y],
205
+ (feat, layer) => {
185
206
  if (feat) {
186
207
  found = feat[originalFeatureSymbol] || feat;
187
208
  }
188
209
  foundLayer = layer;
189
210
  return true;
190
- }, { hitTolerance: this.hitTolerance });
211
+ },
212
+ { hitTolerance: this.hitTolerance },
213
+ );
191
214
 
192
215
  if (found && foundLayer) {
193
216
  event.feature = found;
@@ -205,10 +228,16 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
205
228
  * @private
206
229
  */
207
230
  _cesiumHandler(event) {
208
- const cesiumMap = /** @type {import("@vcmap/core").CesiumMap} */ (event.map);
231
+ const cesiumMap = /** @type {import("@vcmap/core").CesiumMap} */ (
232
+ event.map
233
+ );
209
234
  const scene = cesiumMap.getScene();
210
235
 
211
- const object = scene.pick(event.windowPosition, this.hitTolerance, this.hitTolerance);
236
+ const object = scene.pick(
237
+ event.windowPosition,
238
+ this.hitTolerance,
239
+ this.hitTolerance,
240
+ );
212
241
 
213
242
  let scratchCartographic = new Cartographic();
214
243
  let scratchCartesian = new Cartesian3();
@@ -221,44 +250,63 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
221
250
  return Promise.resolve(event);
222
251
  }
223
252
  if (this.pullPickedPosition && event.ray) {
224
- scratchPullCartesian = Cartesian3
225
- .multiplyByScalar(event.ray.direction, this.pullPickedPosition, scratchPullCartesian);
253
+ scratchPullCartesian = Cartesian3.multiplyByScalar(
254
+ event.ray.direction,
255
+ this.pullPickedPosition,
256
+ scratchPullCartesian,
257
+ );
226
258
 
227
- scratchCartesian = Cartesian3.subtract(scratchCartesian, scratchPullCartesian, scratchCartesian);
259
+ scratchCartesian = Cartesian3.subtract(
260
+ scratchCartesian,
261
+ scratchPullCartesian,
262
+ scratchCartesian,
263
+ );
228
264
  }
229
- scratchCartographic = Cartographic
230
- .fromCartesian(scratchCartesian, scene.globe.ellipsoid, scratchCartographic);
231
- event.position = Projection.wgs84ToMercator([
232
- CesiumMath.toDegrees(scratchCartographic.longitude),
233
- CesiumMath.toDegrees(scratchCartographic.latitude),
234
- scratchCartographic.height,
235
- ], true);
265
+ scratchCartographic = Cartographic.fromCartesian(
266
+ scratchCartesian,
267
+ scene.globe.ellipsoid,
268
+ scratchCartographic,
269
+ );
270
+ event.position = Projection.wgs84ToMercator(
271
+ [
272
+ CesiumMath.toDegrees(scratchCartographic.longitude),
273
+ CesiumMath.toDegrees(scratchCartographic.latitude),
274
+ scratchCartographic.height,
275
+ ],
276
+ true,
277
+ );
236
278
  event.positionOrPixel = event.position;
237
279
  scene.pickTranslucentDepth = pickTranslucentDepth;
238
280
  return Promise.resolve(event);
239
281
  };
240
282
 
241
283
  if (object) {
242
- if (object.primitive && object.primitive.olFeature) { // vector & vectorCluster
284
+ if (object.primitive && object.primitive.olFeature) {
285
+ // vector & vectorCluster
243
286
  event.feature = object.primitive.olFeature;
244
287
  } else if (
245
288
  object.primitive &&
246
289
  object.primitive[vcsLayerName] &&
247
- (object instanceof Cesium3DTileFeature || object instanceof Cesium3DTilePointFeature)
248
- ) { // building
290
+ (object instanceof Cesium3DTileFeature ||
291
+ object instanceof Cesium3DTilePointFeature)
292
+ ) {
293
+ // building
249
294
  event.feature = object;
250
295
  const symbols = Object.getOwnPropertySymbols(object.primitive);
251
296
  const symbolLength = symbols.length;
252
297
  for (let i = 0; i < symbolLength; i++) {
253
298
  event.feature[symbols[i]] = object.primitive[symbols[i]];
254
299
  }
255
- } else if (object.id && object.id.olFeature) { // cluster size === 1
300
+ } else if (object.id && object.id.olFeature) {
301
+ // cluster size === 1
256
302
  event.feature = object.id.olFeature;
257
- } else if (object.id && object.id[vcsLayerName]) { // entity
258
- event.feature = object;
259
- event.feature[vcsLayerName] = object.id[vcsLayerName];
260
- } else {
261
- event.feature = object;
303
+ } else if (
304
+ object.id &&
305
+ object.id[vcsLayerName] &&
306
+ object.id instanceof Entity
307
+ ) {
308
+ // entity
309
+ event.feature = object.id;
262
310
  }
263
311
 
264
312
  if (!(event.type & this.pickPosition)) {
@@ -269,13 +317,20 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
269
317
  if (
270
318
  object.primitive &&
271
319
  this.pickTranslucent &&
272
- !(object.primitive.pointCloudShading && object.primitive.pointCloudShading.attenuation)
273
- ) { // XXX should this always be on, also for non vector?
320
+ !(
321
+ object.primitive.pointCloudShading &&
322
+ object.primitive.pointCloudShading.attenuation
323
+ )
324
+ ) {
325
+ // XXX should this always be on, also for non vector?
274
326
  scene.pickTranslucentDepth = true;
275
327
  scene.render(cesiumMap.getCesiumWidget().clock.currentTime);
276
328
  event.exactPosition = true;
277
329
  }
278
- scratchCartesian = scene.pickPosition(event.windowPosition, scratchCartesian);
330
+ scratchCartesian = scene.pickPosition(
331
+ event.windowPosition,
332
+ scratchCartesian,
333
+ );
279
334
  return handlePick();
280
335
  }
281
336
  }
@@ -0,0 +1,58 @@
1
+ import AbstractInteraction from './abstractInteraction.js';
2
+ import {
3
+ EventType,
4
+ ModificationKeyType,
5
+ PointerKeyType,
6
+ } from './interactionType.js';
7
+
8
+ /**
9
+ * @class
10
+ * @extends {AbstractInteraction}
11
+ */
12
+ class FeatureProviderInteraction extends AbstractInteraction {
13
+ constructor() {
14
+ super(EventType.CLICK, ModificationKeyType.ALL, PointerKeyType.ALL);
15
+
16
+ this.setActive();
17
+ }
18
+
19
+ /**
20
+ * @inheritDoc
21
+ * @param {InteractionEvent} event
22
+ * @returns {Promise<InteractionEvent>}
23
+ */
24
+ // eslint-disable-next-line class-methods-use-this
25
+ async pipe(event) {
26
+ if (!event.feature) {
27
+ const layersWithProvider = [...event.map.layerCollection].filter((l) => {
28
+ return (
29
+ l.featureProvider &&
30
+ l.active &&
31
+ l.isSupported(event.map) &&
32
+ l.featureProvider.isSupported(event.map)
33
+ );
34
+ });
35
+
36
+ if (layersWithProvider.length > 0) {
37
+ const resolution = event.map.getCurrentResolution(event.position);
38
+ const features = (
39
+ await Promise.all(
40
+ layersWithProvider.map((l) =>
41
+ l.featureProvider.getFeaturesByCoordinate(
42
+ event.position,
43
+ resolution,
44
+ ),
45
+ ),
46
+ )
47
+ ).flat();
48
+
49
+ if (features.length > 0) {
50
+ event.feature = features[0];
51
+ }
52
+ }
53
+ }
54
+ return event;
55
+ }
56
+ }
57
+
58
+ export default FeatureProviderInteraction;