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

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 +3480 -2008
  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} +83 -70
  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} +8 -9
  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 -112
  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 +95 -0
  73. package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +28 -21
  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 +64 -37
  91. package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +431 -277
  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} +151 -55
  99. package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +77 -46
  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 +79 -49
  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 +45 -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,71 +0,0 @@
1
- import { Math as CesiumMath, Cartesian3 } from '@vcmap/cesium';
2
-
3
- /**
4
- * returns a new coordinate ([lon, lat] in degrees) from a distance, bearing and starting coordinate
5
- * @param {Array.<number>} coord [lon, lat] in degrees
6
- * @param {number} d distance in m to new coordinate
7
- * @param {number} brng bearing in degrees ( 0 == north, 90° == east)
8
- * @returns {Array.<number>};
9
- */
10
- export function coordinateAtDistance(coord, d, brng) {
11
- const R = 6371000;
12
- const brngRadians = CesiumMath.toRadians(brng);
13
- const lat1 = CesiumMath.toRadians(coord[1]);
14
- const lon1 = CesiumMath.toRadians(coord[0]);
15
- const lat2 = Math.asin((Math.sin(lat1) * Math.cos(d / R)) +
16
- (Math.cos(lat1) * Math.sin(d / R) * Math.cos(brngRadians)));
17
- const lon2 = lon1 + Math.atan2(
18
- Math.sin(brngRadians) * Math.sin(d / R) * Math.cos(lat1),
19
- Math.cos(d / R) - (Math.sin(lat1) * Math.sin(lat2)),
20
- );
21
- return [parseFloat(CesiumMath.toDegrees(lon2).toFixed(5)), parseFloat(CesiumMath.toDegrees(lat2).toFixed(5))];
22
- }
23
-
24
-
25
- /**
26
- * returns the initial bearing in degrees (0-360) between two coordinates
27
- * @param {Array.<number>} coords1 [lon, lat] in degrees
28
- * @param {Array.<number>} coords2 [lon, lat] in degrees
29
- * @returns {number};
30
- */
31
- export function initialBearingBetweenCoords(coords1, coords2) {
32
- // long
33
- const l1 = CesiumMath.toRadians(coords1[0]);
34
- // lat
35
- const f1 = CesiumMath.toRadians(coords1[1]);
36
- // long
37
- const l2 = CesiumMath.toRadians(coords2[0]);
38
- // lat
39
- const f2 = CesiumMath.toRadians(coords2[1]);
40
-
41
- const y = Math.sin(l2 - l1) * Math.cos(f2);
42
- const x = (Math.cos(f1) * Math.sin(f2)) - (Math.sin(f1) * Math.cos(f2) * Math.cos(l2 - l1));
43
- let brng = CesiumMath.toDegrees(Math.atan2(y, x));
44
- brng = (brng + 360) % 360;
45
- return brng;
46
- }
47
-
48
-
49
- /**
50
- * returns distance between two coordinates
51
- * @param {import("ol/coordinate").Coordinate} point0
52
- * @param {import("ol/coordinate").Coordinate} point1
53
- * @returns {number}
54
- */
55
- export function cartesian2DDistance(point0, point1) {
56
- const distX = point0[0] - point1[0];
57
- const distY = point0[1] - point1[1];
58
- return Math.sqrt((distX ** 2) + (distY ** 2));
59
- }
60
-
61
- /**
62
- * @param {import("ol/coordinate").Coordinate} p1
63
- * @param {import("ol/coordinate").Coordinate} p2
64
- * @returns {number}
65
- */
66
- export function cartesian3DDistance(p1, p2) {
67
- const point0 = Cartesian3.fromElements(p1[0], p1[1], p1[2]);
68
- const point1 = Cartesian3.fromElements(p2[0], p2[1], p2[2]);
69
- return Cartesian3.distance(point0, point1);
70
- }
71
-
@@ -1,233 +0,0 @@
1
- import {
2
- Cartesian3,
3
- Matrix4,
4
- Plane,
5
- ClippingPlane,
6
- ClippingPlaneCollection,
7
- ImagerySplitDirection,
8
- } from '@vcmap/cesium';
9
-
10
- import { check } from '@vcsuite/check';
11
- import CesiumMap from '../maps/cesium.js';
12
- import ClippingObject from './clipping/clippingObject.js';
13
- import Openlayers from '../maps/openlayers.js';
14
-
15
- /**
16
- * @class
17
- * @api
18
- */
19
- class SplitScreen {
20
- /**
21
- * @param {import("@vcmap/core").ClippingObjectManager} clippingObjectManager
22
- */
23
- constructor(clippingObjectManager) {
24
- /**
25
- * @type {number}
26
- * @private
27
- */
28
- this._position = 0.5;
29
- /**
30
- * @type {import("@vcmap/cesium").Scene|null}
31
- */
32
- this.scene = null;
33
- /**
34
- * @type {import("ol/Map").default|null}
35
- */
36
- this.olMap = null;
37
- /**
38
- * @type {boolean}
39
- * @api
40
- */
41
- this.initialized = false;
42
- /**
43
- * @type {ClippingObject}
44
- */
45
- this.leftScreenClippingObject = new ClippingObject();
46
- /**
47
- * @type {ClippingObject}
48
- */
49
- this.rightScreenClippingObject = new ClippingObject();
50
- /**
51
- * @type {Function|null}
52
- * @private
53
- */
54
- this._cameraListener = null;
55
- /**
56
- * @type {number|null}
57
- */
58
- this.originalCameraPercentageChanged = null;
59
- /**
60
- * @type {Array<Function>}
61
- * @private
62
- */
63
- this._targetsChangedListeners = [];
64
-
65
- this._targetsChangedListeners = [
66
- this.rightScreenClippingObject.targetsUpdated.addEventListener(() => { this._targetsChanged(); }),
67
- this.leftScreenClippingObject.targetsUpdated.addEventListener(() => { this._targetsChanged(); }),
68
- ];
69
-
70
- /**
71
- * @type {import("@vcmap/core").ClippingObjectManager}
72
- * @private
73
- */
74
- this._clippingObjectManager = clippingObjectManager;
75
- this._clippingObjectManager.addClippingObject(this.rightScreenClippingObject);
76
- this._clippingObjectManager.addClippingObject(this.leftScreenClippingObject);
77
- }
78
-
79
- /**
80
- * @type {number}
81
- * @api
82
- */
83
- get position() { return this._position; }
84
-
85
- /**
86
- * @param {number} position
87
- */
88
- set position(position) {
89
- check(position, Number);
90
- if (position < 0 || position > 1) {
91
- throw new Error('Position must be between 0 and 1');
92
- }
93
-
94
- if (Math.abs(this._position - position) > 0.0001) {
95
- this._updatePosition(position);
96
- }
97
- }
98
-
99
- _targetsChanged() {
100
- if (this.scene) {
101
- const numTargets = this.rightScreenClippingObject.targets.size + this.leftScreenClippingObject.targets.size;
102
- const { camera } = this.scene;
103
-
104
- if (this._cameraListener && numTargets === 0) {
105
- this._cameraListener();
106
- this._cameraListener = null;
107
- camera.percentageChanged = this.originalCameraPercentageChanged;
108
- } else if (!this._cameraListener && numTargets > 0) {
109
- this.originalCameraPercentageChanged = camera.percentageChanged;
110
- camera.percentageChanged = 0;
111
- this._cameraListener = camera.changed.addEventListener(this._updateClippingPlanes.bind(this));
112
- this._updateClippingPlanes();
113
- }
114
- }
115
- }
116
-
117
- /**
118
- * @param {number} position
119
- * @private
120
- */
121
- _updatePosition(position) {
122
- this._position = position;
123
- if (this.scene) {
124
- this.scene.imagerySplitPosition = position;
125
- this._updateClippingPlanes();
126
- } else if (this.olMap) {
127
- this.olMap.render();
128
- }
129
- }
130
-
131
- /**
132
- * @param {import("@vcmap/core").VcsMap} map
133
- */
134
- mapActivated(map) {
135
- if (map instanceof CesiumMap) {
136
- this.scene = map.getScene();
137
- this.olMap = null;
138
- this._targetsChanged();
139
- } else if (map instanceof Openlayers) {
140
- this.scene = null;
141
- this.olMap = map.olMap;
142
- }
143
- this._updatePosition(this.position);
144
- }
145
-
146
- /**
147
- * calculate a clipping plane from the current swipe position for the given Cesium3DTileset
148
- * @returns {import("@vcmap/cesium").ClippingPlane}
149
- * @private
150
- */
151
- _calcClippingPlane() {
152
- const { camera } = this.scene;
153
- const { fov, near } = /** @type {import("@vcmap/cesium").PerspectiveFrustum} */ (camera.frustum);
154
- const screenWidth = this.scene.canvas.width || 1;
155
- const screenHeight = this.scene.canvas.height || 1;
156
- let pixelSize;
157
- if (screenHeight > screenWidth) {
158
- pixelSize = (near * Math.tan(0.5 * fov) * 2.0) / screenHeight;
159
- } else {
160
- pixelSize = (near * Math.tan(0.5 * fov) * 2.0) / screenWidth;
161
- }
162
-
163
- // extract 3 points lying on swipe plane
164
- const screenX = (screenWidth * this.position) - (screenWidth / 2);
165
- const screenY = screenHeight / 2;
166
- const p1 = new Cartesian3(pixelSize * screenX, pixelSize * screenY, -1 * near);
167
- const p2 = new Cartesian3(pixelSize * screenX, -1 * pixelSize * screenY, -1 * near);
168
- Matrix4.multiplyByPoint(camera.inverseViewMatrix, p1, p1);
169
- Matrix4.multiplyByPoint(camera.inverseViewMatrix, p2, p2);
170
- const p3WC = camera.positionWC;
171
-
172
- Cartesian3.subtract(p3WC, p1, p1);
173
- Cartesian3.subtract(p3WC, p2, p2);
174
- const normal = Cartesian3.cross(p1, p2, new Cartesian3());
175
- Cartesian3.normalize(normal, normal);
176
- const planeInFixedFrame = Plane.fromPointNormal(p3WC, normal);
177
-
178
- return ClippingPlane.fromPlane(planeInFixedFrame);
179
- }
180
-
181
- /**
182
- * update the clipping planes for all Cesium3DTilesets loaded in the vcMap
183
- * @private
184
- */
185
- _updateClippingPlanes() {
186
- const plane = this._calcClippingPlane();
187
- this.leftScreenClippingObject.clippingPlaneCollection = new ClippingPlaneCollection({ planes: [plane] });
188
- const revClippingPlane = ClippingPlane.clone(plane);
189
- revClippingPlane.normal = Cartesian3.negate(revClippingPlane.normal, revClippingPlane.normal);
190
- revClippingPlane.distance *= -1;
191
- this.rightScreenClippingObject.clippingPlaneCollection =
192
- new ClippingPlaneCollection({ planes: [revClippingPlane] });
193
- }
194
-
195
- /**
196
- * Gets the clipping object for a split direction
197
- * @param {import("@vcmap/cesium").ImagerySplitDirection} splitDirection
198
- * @returns {ClippingObject|null}
199
- * @api
200
- */
201
- getClippingObjectForDirection(splitDirection) {
202
- check(splitDirection, [
203
- ImagerySplitDirection.LEFT,
204
- ImagerySplitDirection.RIGHT,
205
- ImagerySplitDirection.NONE,
206
- ]);
207
-
208
- if (splitDirection === ImagerySplitDirection.LEFT) {
209
- return this.leftScreenClippingObject;
210
- }
211
- if (splitDirection === ImagerySplitDirection.RIGHT) {
212
- return this.rightScreenClippingObject;
213
- }
214
-
215
- return null;
216
- }
217
-
218
- destroy() {
219
- if (this._clippingObjectManager) {
220
- this._clippingObjectManager.removeClippingObject(this.rightScreenClippingObject);
221
- this._clippingObjectManager.removeClippingObject(this.leftScreenClippingObject);
222
- }
223
- this._targetsChangedListeners.forEach((cb) => { cb(); });
224
- this._targetsChangedListeners = [];
225
- this._clippingObjectManager = null;
226
- if (this._cameraListener) {
227
- this._cameraListener();
228
- this._cameraListener = null;
229
- }
230
- }
231
- }
232
-
233
- export default SplitScreen;
@@ -1,48 +0,0 @@
1
- import { getLogger as getLoggerByName } from '@vcsuite/logger';
2
- import StyleItem, { StyleType } from './styleItem.js';
3
- import DeclarativeStyleItem, { defaultDeclarativeStyle } from './declarativeStyleItem.js';
4
- import VectorStyleItem from './vectorStyleItem.js';
5
- import { styleCollection } from '../../globalCollections.js';
6
-
7
- /**
8
- * @returns {import("@vcsuite/logger").Logger}
9
- */
10
- function getLogger() {
11
- return getLoggerByName('vcs.vcm.util.style.styleFactory');
12
- }
13
-
14
- /**
15
- * @param {(Reference|DeclarativeStyleItemOptions|VectorStyleItemOptions|StyleItem|string)=} styleOptions
16
- * @param {(VectorStyleItem|DeclarativeStyleItem)=} defaultStyle
17
- * @returns {StyleItem}
18
- */
19
- // eslint-disable-next-line import/prefer-default-export
20
- export function getStyleOrDefaultStyle(styleOptions, defaultStyle) {
21
- if (typeof styleOptions === 'string') {
22
- const styleItem = styleCollection.getByKey(styleOptions);
23
- if (styleItem) {
24
- return styleItem;
25
- }
26
- getLogger().warning(`could not find style with name ${styleOptions}`);
27
- } else if (styleOptions && (styleOptions instanceof StyleItem)) {
28
- return styleOptions;
29
- } else if (styleOptions) { // DeclarativeStyleItemOptions || VectorStyleItemOptions || ClusterStyleItemOptions
30
- if (
31
- /** @type {DeclarativeStyleItemOptions} */ (styleOptions).type === StyleType.DECLARATIVE ||
32
- /** @type {DeclarativeStyleItemOptions} */ (styleOptions).declarativeStyle) {
33
- return new DeclarativeStyleItem(/** @type {DeclarativeStyleItemOptions} */ (styleOptions));
34
- } else if (/** @type {Reference} */ (styleOptions).type === StyleType.REFERENCE) {
35
- const { name } = /** @type {Reference} */ (styleOptions);
36
- const styleItem = styleCollection.getByKey(name);
37
- if (styleItem) {
38
- return styleItem;
39
- }
40
- getLogger().warning(`could not find style with name ${name}`);
41
- } else {
42
- // @ts-ignore
43
- const vectorStyle = new VectorStyleItem(/** @type {VectorStyleItemOptions} */ styleOptions);
44
- return defaultStyle instanceof VectorStyleItem ? defaultStyle.assign(vectorStyle) : vectorStyle;
45
- }
46
- }
47
- return defaultStyle || defaultDeclarativeStyle.clone();
48
- }
@@ -1,243 +0,0 @@
1
- import { Cesium3DTileStyle, Cesium3DTileColorBlendMode } from '@vcmap/cesium';
2
- import deepEqual from 'fast-deep-equal';
3
-
4
- import { parseEnumValue } from '@vcsuite/parsers';
5
- import VcsObject from '../../object.js';
6
- import VcsEvent from '../../event/vcsEvent.js';
7
-
8
- /**
9
- * @namespace style
10
- * @export
11
- * @api
12
- */
13
-
14
- /**
15
- * @typedef {Object} StyleItemLegendEntry
16
- * @property {string} color - the color to display
17
- * @property {string|Object<string, string>} name - the name to display for the given color
18
- * @api
19
- */
20
-
21
- /**
22
- * @typedef {VcsObjectOptions} StyleItemOptions
23
- * @property {string|undefined} [type] - used in configuration to differentiate vector from declarative styles
24
- * @property {string|Object<string, string>|undefined} title - name is used when none is specifies
25
- * @property {Array<StyleItemLegendEntry>|undefined} [legend]
26
- * @property {number} [colorBlendMode=import("@vcmap/cesium").Cesium3DTileColorBlendMode.HIGHLIGHT] - colorBlendMode for 3D Tiledataset @see https://cesiumjs.org/import("@vcmap/cesium").Build/Documentation/Cesium3DTileColorBlendMode.html
27
- * @api
28
- */
29
-
30
- /**
31
- * @typedef {Object} Reference
32
- * @property {string} [type=StyleType.REFERENCE]
33
- * @property {string} name
34
- * @property {string|undefined} [url] - vcs:undocumented this is not yet implemented
35
- * @api
36
- */
37
-
38
- /**
39
- * @typedef {Object} StyleItemSections
40
- * @property {boolean|undefined} [meta]
41
- * @api
42
- */
43
-
44
- /**
45
- * Enumeration of possible style types.
46
- * @enum {string}
47
- * @property {string} VECTOR
48
- * @property {string} DECLARATIVE
49
- * @property {string} REFERENCE
50
- * @export
51
- * @api
52
- */
53
- export const StyleType = {
54
- VECTOR: 'vector',
55
- DECLARATIVE: 'declarative',
56
- REFERENCE: 'reference',
57
- CLUSTER: 'cluster',
58
- };
59
-
60
- /**
61
- * indicates, that this style is part of the config and can be referenced by name
62
- * @type {symbol}
63
- * @export
64
- * @api
65
- */
66
- export const referenceableStyleSymbol = Symbol('referencableStyleSymbol');
67
-
68
- /**
69
- * An abstract style definition which can be applied to a layer
70
- * @class
71
- * @export
72
- * @api
73
- * @abstract
74
- * @extends {VcsObject}
75
- */
76
- class StyleItem extends VcsObject {
77
- static get className() { return 'vcs.vcm.util.style.StyleItem'; }
78
-
79
- /**
80
- * @param {StyleItemOptions} options
81
- */
82
- constructor(options) {
83
- super(options);
84
-
85
- /**
86
- * @type {string|Object<string, string>}
87
- */
88
- this.title = options.title || this.name.toString();
89
-
90
- /**
91
- * Legend entries
92
- * @type {Array<StyleItemLegendEntry>}
93
- * @api
94
- */
95
- this.legend = options.legend || [];
96
-
97
- /** @type {Array<string>} */
98
- this.supportedLayers = [];
99
-
100
- /**
101
- * The 3D representation of this style
102
- * @type {import("@vcmap/cesium").Cesium3DTileStyle}
103
- * @api
104
- */
105
- this.cesiumStyle = new Cesium3DTileStyle({ show: true });
106
-
107
- /**
108
- * Fired on style updates
109
- * @type {VcsEvent<void>}
110
- * @api
111
- */
112
- this.styleChanged = new VcsEvent();
113
-
114
- /** @type {import("@vcmap/cesium").Cesium3DTileColorBlendMode} */
115
- this.colorBlendMode = /** @type {import("@vcmap/cesium").Cesium3DTileColorBlendMode} */(parseEnumValue(
116
- options.colorBlendMode, Cesium3DTileColorBlendMode, Cesium3DTileColorBlendMode.HIGHLIGHT,
117
- ));
118
-
119
- /**
120
- * @type {import("ol/style/Style").default|import("ol/style/Style").StyleFunction}
121
- * @protected
122
- */
123
- this._style = null;
124
- }
125
-
126
- /**
127
- * The 2D representation of this style
128
- * @type {import("ol/style/Style").default|import("ol/style/Style").StyleFunction}
129
- * @api
130
- */
131
- get style() { return this._style; }
132
-
133
- /**
134
- * @param {import("ol/style/Style").default|import("ol/style/Style").StyleFunction} style
135
- */
136
- set style(style) { this._style = style; }
137
-
138
- /**
139
- * @param {string} className
140
- * @returns {boolean}
141
- * @todo redundant, remove
142
- */
143
- isSupported(className) {
144
- return this.supportedLayers.length === 0 ||
145
- this.supportedLayers.indexOf(className) > -1;
146
- }
147
-
148
- /**
149
- * Gets the options for this style item to be used in a config or vcsMeta
150
- * @param {(VectorStyleItemSections|DeclarativeStyleItemSections)=} sections
151
- * @returns {VectorStyleItemOptions|DeclarativeStyleItemOptions}
152
- * @api
153
- */
154
- getOptions(sections) {
155
- if (sections && sections.meta) {
156
- return {
157
- name: this.name.toString(),
158
- title: this.title,
159
- legend: this.legend.length ? this.legend : undefined,
160
- };
161
- }
162
- return {};
163
- }
164
-
165
- /**
166
- * @inheritDoc
167
- * @returns {StyleItemOptions}
168
- */
169
- toJSON() {
170
- const config = { ...super.toJSON(), ...this.getOptions() };
171
- if (this.title) {
172
- config.title = this.title;
173
- }
174
-
175
- if (this.legend.length > 0) {
176
- config.legend = this.legend.slice();
177
- }
178
-
179
- return config;
180
- }
181
-
182
- /**
183
- * Clones this style
184
- * @param {StyleItem=} result
185
- * @returns {StyleItem}
186
- * @api
187
- */
188
- // eslint-disable-next-line class-methods-use-this
189
- clone(result) { return result; }
190
-
191
- /**
192
- * @param {StyleItem} styleItem
193
- * @returns {StyleItem}
194
- * @api
195
- */
196
- // eslint-disable-next-line class-methods-use-this
197
- assign(styleItem) { return styleItem; }
198
-
199
- /**
200
- * @param {StyleItem} styleItem
201
- * @returns {boolean}
202
- * @api
203
- */
204
- equals(styleItem) {
205
- if (this !== styleItem) {
206
- const options = this.getOptions();
207
- const candidateOptions = styleItem.getOptions();
208
- return deepEqual(options, candidateOptions);
209
- }
210
-
211
- return true;
212
- }
213
-
214
- /**
215
- * gets a reference to this style by its name. should only be used for static styles, aka styles already part of the config
216
- * @returns {Reference}
217
- * @api
218
- */
219
- getReference() {
220
- return {
221
- type: StyleType.REFERENCE,
222
- name: this.name.toString(),
223
- };
224
- }
225
-
226
- /**
227
- * @protected
228
- */
229
- _styleChanged() {
230
- this.styleChanged.raiseEvent();
231
- }
232
-
233
- /**
234
- * @api
235
- */
236
- destroy() {
237
- this.cesiumStyle = null;
238
- this.styleChanged.destroy();
239
- super.destroy();
240
- }
241
- }
242
-
243
- export default StyleItem;