@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
package/src/vcsApp.js ADDED
@@ -0,0 +1,657 @@
1
+ import { getLogger as getLoggerByName } from '@vcsuite/logger';
2
+ import { v4 as uuidv4 } from 'uuid';
3
+ import { check } from '@vcsuite/check';
4
+ import VcsModule from './vcsModule.js';
5
+ import {
6
+ moduleIdSymbol,
7
+ destroyCollection,
8
+ deserializeViewpoint,
9
+ deserializeMap,
10
+ getLayerIndex,
11
+ serializeLayer,
12
+ deserializeLayer,
13
+ } from './vcsModuleHelpers.js';
14
+ import makeOverrideCollection from './util/overrideCollection.js';
15
+ import CategoryCollection from './category/categoryCollection.js';
16
+ import MapCollection from './util/mapCollection.js';
17
+ import VcsMap from './map/vcsMap.js';
18
+ import Layer from './layer/layer.js';
19
+ import Collection from './util/collection.js';
20
+ import ObliqueCollection from './oblique/obliqueCollection.js';
21
+ import Viewpoint from './util/viewpoint.js';
22
+ import StyleItem from './style/styleItem.js';
23
+ import IndexedCollection from './util/indexedCollection.js';
24
+ import VcsEvent from './vcsEvent.js';
25
+ import { setDefaultProjectionOptions } from './util/projection.js';
26
+ import ObliqueMap from './map/obliqueMap.js';
27
+ import OverrideClassRegistry from './overrideClassRegistry.js';
28
+ import ClassRegistry, {
29
+ categoryClassRegistry,
30
+ featureProviderClassRegistry,
31
+ getObjectFromClassRegistry,
32
+ layerClassRegistry,
33
+ mapClassRegistry,
34
+ styleClassRegistry,
35
+ tileProviderClassRegistry,
36
+ } from './classRegistry.js';
37
+ import { detectBrowserLocale } from './util/locale.js';
38
+
39
+ /**
40
+ * @returns {import("@vcsuite/logger").Logger}
41
+ */
42
+ function getLogger() {
43
+ return getLoggerByName('init');
44
+ }
45
+
46
+ /**
47
+ * @type {Map<string, VcsApp>}
48
+ */
49
+ const vcsApps = new Map();
50
+
51
+ /**
52
+ * @type {string}
53
+ */
54
+ export const defaultDynamicModuleId = '_defaultDynamicModule';
55
+
56
+ /**
57
+ * @class
58
+ */
59
+ class VcsApp {
60
+ constructor() {
61
+ /**
62
+ * @type {string}
63
+ * @private
64
+ */
65
+ this._id = uuidv4();
66
+ /**
67
+ * @type {VcsModule}
68
+ * @private
69
+ */
70
+ this._defaultDynamicModule = new VcsModule({ _id: defaultDynamicModuleId });
71
+ /**
72
+ * @type {VcsModule}
73
+ * @private
74
+ */
75
+ this._dynamicModule = this._defaultDynamicModule;
76
+
77
+ const getDynamicModuleId = () => this._dynamicModule._id;
78
+
79
+ /**
80
+ * @type {VcsEvent<string>}
81
+ * @private
82
+ */
83
+ this._dynamicModuleIdChanged = new VcsEvent();
84
+
85
+ /**
86
+ * represents the current Locale.
87
+ * @type {string}
88
+ * @private
89
+ */
90
+ this._locale = detectBrowserLocale();
91
+
92
+ /**
93
+ * fires if the current Locale changes.
94
+ * @type {VcsEvent<string>}
95
+ * @private
96
+ */
97
+ this._localeChanged = new VcsEvent();
98
+
99
+ /**
100
+ * @type {OverrideClassRegistry<VcsMap>}
101
+ * @private
102
+ */
103
+ this._mapClassRegistry = new OverrideClassRegistry(mapClassRegistry);
104
+ /**
105
+ * @type {OverrideMapCollection}
106
+ * @private
107
+ */
108
+ // @ts-ignore
109
+ this._maps = makeOverrideCollection(
110
+ new MapCollection(),
111
+ getDynamicModuleId,
112
+ null,
113
+ deserializeMap.bind(null, this),
114
+ VcsMap,
115
+ );
116
+ /**
117
+ * @type {OverrideClassRegistry<Layer>}
118
+ * @private
119
+ */
120
+ this._layerClassRegistry = new OverrideClassRegistry(layerClassRegistry);
121
+ /**
122
+ * @type {OverrideLayerCollection}
123
+ * @private
124
+ */
125
+ // @ts-ignore
126
+ this._layers = makeOverrideCollection(
127
+ this._maps.layerCollection,
128
+ getDynamicModuleId,
129
+ serializeLayer.bind(null, this),
130
+ deserializeLayer.bind(null, this),
131
+ Layer,
132
+ getLayerIndex,
133
+ );
134
+ this._layers.locale = this.locale;
135
+
136
+ /**
137
+ * @type {OverrideCollection<import("@vcmap/core").ObliqueCollection>}
138
+ * @private
139
+ */
140
+ this._obliqueCollections = makeOverrideCollection(
141
+ new Collection(),
142
+ getDynamicModuleId,
143
+ null,
144
+ (config) => new ObliqueCollection(config),
145
+ ObliqueCollection,
146
+ );
147
+ /**
148
+ * @type {OverrideCollection<import("@vcmap/core").Viewpoint>}
149
+ * @private
150
+ */
151
+ this._viewpoints = makeOverrideCollection(
152
+ new Collection(),
153
+ getDynamicModuleId,
154
+ null,
155
+ deserializeViewpoint,
156
+ Viewpoint,
157
+ );
158
+ /**
159
+ * @type {OverrideClassRegistry<StyleItem>}
160
+ * @private
161
+ */
162
+ this._styleClassRegistry = new OverrideClassRegistry(styleClassRegistry);
163
+ /**
164
+ * @type {OverrideCollection<import("@vcmap/core").StyleItem>}
165
+ * @private
166
+ */
167
+ this._styles = makeOverrideCollection(
168
+ new Collection(),
169
+ getDynamicModuleId,
170
+ null,
171
+ getObjectFromClassRegistry.bind(null, this._styleClassRegistry),
172
+ StyleItem,
173
+ );
174
+
175
+ /**
176
+ * @type {IndexedCollection<VcsModule>}
177
+ * @private
178
+ */
179
+ this._modules = new IndexedCollection('_id');
180
+ this._modules.add(this._dynamicModule);
181
+ /**
182
+ * @type {OverrideClassRegistry<import("@vcmap/core").Category<Object|import("@vcmap/core").VcsObject>>}
183
+ * @private
184
+ */
185
+ this._categoryClassRegisty = new OverrideClassRegistry(
186
+ categoryClassRegistry,
187
+ );
188
+ /**
189
+ * @type {CategoryCollection}
190
+ * @private
191
+ */
192
+ this._categories = new CategoryCollection(this);
193
+ /**
194
+ * @type {import("@vcmap/core").VcsEvent<void>}
195
+ * @private
196
+ */
197
+ this._destroyed = new VcsEvent();
198
+ /**
199
+ * @type {Promise<void>}
200
+ * @private
201
+ */
202
+ this._moduleMutationPromise = Promise.resolve();
203
+ /**
204
+ * @type {OverrideClassRegistry<*>}
205
+ * @private
206
+ */
207
+ this._categoryItemClassRegistry = new OverrideClassRegistry(
208
+ new ClassRegistry(),
209
+ );
210
+ /**
211
+ * @type {OverrideClassRegistry<import("@vcmap/core").TileProvider>}
212
+ * @private
213
+ */
214
+ this._tileProviderClassRegsitry = new OverrideClassRegistry(
215
+ tileProviderClassRegistry,
216
+ );
217
+ /**
218
+ * @type {OverrideClassRegistry<import("@vcmap/core").AbstractFeatureProvider>}
219
+ * @private
220
+ */
221
+ this._featureProviderClassRegsitry = new OverrideClassRegistry(
222
+ featureProviderClassRegistry,
223
+ );
224
+
225
+ vcsApps.set(this._id, this);
226
+ }
227
+
228
+ /**
229
+ * @type {string}
230
+ * @readonly
231
+ */
232
+ get id() {
233
+ return this._id;
234
+ }
235
+
236
+ /**
237
+ * @returns {string}
238
+ */
239
+ get locale() {
240
+ return this._locale;
241
+ }
242
+
243
+ /**
244
+ * sets the locale of the vcsApp and the linked layerCollection.
245
+ * This will trigger the localeChanged Event.
246
+ * @param {string} value new locale with 2 letters
247
+ */
248
+ set locale(value) {
249
+ check(value, String);
250
+
251
+ if (value.length !== 2) {
252
+ getLogger().warning(
253
+ 'Provide a valid locale, for example "en", "de" with max. 2 letters',
254
+ );
255
+ return;
256
+ }
257
+ if (this._locale !== value) {
258
+ this._locale = value;
259
+ this.layers.locale = value;
260
+ this._localeChanged.raiseEvent(value);
261
+ }
262
+ }
263
+
264
+ /**
265
+ * @type {VcsEvent<string>}
266
+ * @readonly
267
+ */
268
+ get localeChanged() {
269
+ return this._localeChanged;
270
+ }
271
+
272
+ /**
273
+ * @type {OverrideMapCollection}
274
+ * @readonly
275
+ */
276
+ get maps() {
277
+ return this._maps;
278
+ }
279
+
280
+ /**
281
+ * @type {OverrideLayerCollection}
282
+ * @readonly
283
+ */
284
+ get layers() {
285
+ return this._layers;
286
+ }
287
+
288
+ /**
289
+ * @type {OverrideCollection<import("@vcmap/core").ObliqueCollection>}
290
+ * @readonly
291
+ */
292
+ get obliqueCollections() {
293
+ return this._obliqueCollections;
294
+ }
295
+
296
+ /**
297
+ * @type {OverrideCollection<import("@vcmap/core").Viewpoint>}
298
+ * @readonly
299
+ */
300
+ get viewpoints() {
301
+ return this._viewpoints;
302
+ }
303
+
304
+ /**
305
+ * @type {OverrideCollection<import("@vcmap/core").StyleItem>}
306
+ * @readonly
307
+ */
308
+ get styles() {
309
+ return this._styles;
310
+ }
311
+
312
+ /**
313
+ * @type {CategoryCollection}
314
+ * @readonly
315
+ */
316
+ get categories() {
317
+ return this._categories;
318
+ }
319
+
320
+ /**
321
+ * @type {VcsEvent<void>}
322
+ * @readonly
323
+ */
324
+ get destroyed() {
325
+ return this._destroyed;
326
+ }
327
+
328
+ /**
329
+ * @type {Array<VcsModule>}
330
+ * @readonly
331
+ */
332
+ get modules() {
333
+ return [...this._modules];
334
+ }
335
+
336
+ /**
337
+ * @returns {VcsEvent<VcsModule>}
338
+ * @readonly
339
+ */
340
+ get moduleAdded() {
341
+ return this._modules.added;
342
+ }
343
+
344
+ /**
345
+ * @returns {VcsEvent<VcsModule>}
346
+ * @readonly
347
+ */
348
+ get moduleRemoved() {
349
+ return this._modules.removed;
350
+ }
351
+
352
+ /**
353
+ * @type {string}
354
+ * @readonly
355
+ */
356
+ get dynamicModuleId() {
357
+ return this._dynamicModule._id;
358
+ }
359
+
360
+ /**
361
+ * @type {VcsEvent<string>}
362
+ * @readonly
363
+ */
364
+ get dynamicModuleIdChanged() {
365
+ return this._dynamicModuleIdChanged;
366
+ }
367
+
368
+ /**
369
+ * @type {OverrideClassRegistry<VcsMap>}
370
+ * @readonly
371
+ */
372
+ get mapClassRegistry() {
373
+ return this._mapClassRegistry;
374
+ }
375
+
376
+ /**
377
+ * @type {OverrideClassRegistry<Layer>}
378
+ * @readonly
379
+ */
380
+ get layerClassRegistry() {
381
+ return this._layerClassRegistry;
382
+ }
383
+
384
+ /**
385
+ * @type {OverrideClassRegistry<StyleItem>}
386
+ * @readonly
387
+ */
388
+ get styleClassRegistry() {
389
+ return this._styleClassRegistry;
390
+ }
391
+
392
+ /**
393
+ * @type {OverrideClassRegistry<import("@vcmap/core").Category<Object|import("@vcmap/core").VcsObject>>}
394
+ * @readonly
395
+ */
396
+ get categoryClassRegistry() {
397
+ return this._categoryClassRegisty;
398
+ }
399
+
400
+ /**
401
+ * @type {OverrideClassRegistry<*>}
402
+ * @readonly
403
+ */
404
+ get categoryItemClassRegistry() {
405
+ return this._categoryItemClassRegistry;
406
+ }
407
+
408
+ /**
409
+ * @type {OverrideClassRegistry<import("@vcmap/core").TileProvider>}
410
+ * @readonly
411
+ */
412
+ get tileProviderClassRegistry() {
413
+ return this._tileProviderClassRegsitry;
414
+ }
415
+
416
+ /**
417
+ * @type {OverrideClassRegistry<import("@vcmap/core").AbstractFeatureProvider>}
418
+ * @readonly
419
+ */
420
+ get featureProviderClassRegistry() {
421
+ return this._featureProviderClassRegsitry;
422
+ }
423
+
424
+ /**
425
+ * @param {string} id
426
+ * @returns {VcsModule}
427
+ */
428
+ getModuleById(id) {
429
+ return this._modules.getByKey(id);
430
+ }
431
+
432
+ /**
433
+ * @param {VcsModule} module
434
+ * @returns {Promise<void>}
435
+ * @protected
436
+ */
437
+ async _parseModule(module) {
438
+ const { config } = module;
439
+ if (config.projection) {
440
+ // XXX this needs fixing. this should be _projections_ and there should be a `defaultProjection`
441
+ setDefaultProjectionOptions(config.projection);
442
+ }
443
+
444
+ await this._styles.parseItems(config.styles, module._id);
445
+ await this._layers.parseItems(config.layers, module._id);
446
+ // TODO add flights & ade here
447
+
448
+ await this._obliqueCollections.parseItems(
449
+ config.obliqueCollections,
450
+ module._id,
451
+ );
452
+ await this._viewpoints.parseItems(config.viewpoints, module._id);
453
+ await this._maps.parseItems(config.maps, module._id);
454
+
455
+ if (Array.isArray(config.categories)) {
456
+ await Promise.all(
457
+ config.categories.map(async ({ name, items }) => {
458
+ await this._categories.parseCategoryItems(name, items, module._id);
459
+ }),
460
+ );
461
+ }
462
+ }
463
+
464
+ /**
465
+ * @param {VcsModule} module
466
+ * @returns {Promise<void>}
467
+ * @protected
468
+ */
469
+ async _setModuleState(module) {
470
+ const { config } = module;
471
+ [...this._layers]
472
+ .filter((l) => l[moduleIdSymbol] === module._id)
473
+ .forEach((l) => {
474
+ if (l.activeOnStartup) {
475
+ l.activate().catch((err) => {
476
+ getLogger().error(
477
+ `Failed to activate active on startup layer ${l.name}`,
478
+ );
479
+ getLogger().error(err);
480
+ this._layers.remove(l);
481
+ l.destroy();
482
+ });
483
+ }
484
+ });
485
+
486
+ const activeObliqueCollection = [...this._obliqueCollections].find(
487
+ (c) => c[moduleIdSymbol] === module._id && c.activeOnStartup,
488
+ );
489
+
490
+ if (activeObliqueCollection) {
491
+ [...this._maps]
492
+ .filter((m) => m instanceof ObliqueMap)
493
+ .forEach((m) => {
494
+ /** @type {ObliqueMap} */ (m).setCollection(activeObliqueCollection);
495
+ });
496
+ }
497
+
498
+ if (config.startingMapName) {
499
+ await this._maps.setActiveMap(config.startingMapName);
500
+ } else if (!this._maps.activeMap && this._maps.size > 0) {
501
+ await this._maps.setActiveMap([...this._maps][0].name);
502
+ }
503
+
504
+ if (config.startingViewpointName && this._maps.activeMap) {
505
+ const startViewpoint = this._viewpoints.getByKey(
506
+ config.startingViewpointName,
507
+ );
508
+ if (startViewpoint) {
509
+ await this._maps.activeMap.gotoViewpoint(startViewpoint);
510
+ }
511
+ }
512
+ }
513
+
514
+ /**
515
+ * @param {VcsModule} module
516
+ * @returns {Promise<void>}
517
+ */
518
+ addModule(module) {
519
+ check(module, VcsModule);
520
+
521
+ this._moduleMutationPromise = this._moduleMutationPromise.then(async () => {
522
+ if (this._modules.has(module)) {
523
+ getLogger().info(`module with id ${module._id} already loaded`);
524
+ return;
525
+ }
526
+
527
+ await this._parseModule(module);
528
+ await this._setModuleState(module);
529
+ this._modules.add(module);
530
+ });
531
+ return this._moduleMutationPromise;
532
+ }
533
+
534
+ /**
535
+ * @param {string} moduleId
536
+ * @returns {VcsModuleConfig}
537
+ */
538
+ serializeModule(moduleId) {
539
+ check(moduleId, String);
540
+ if (!this._modules.hasKey(moduleId)) {
541
+ throw new Error(
542
+ 'VcsModule is not managed by this app, call add(module) before',
543
+ );
544
+ }
545
+ const config = this._modules.getByKey(moduleId).toJSON();
546
+ config.maps = this._maps.serializeModule(moduleId);
547
+ config.layers = this._layers.serializeModule(moduleId);
548
+ config.obliqueCollections =
549
+ this._obliqueCollections.serializeModule(moduleId);
550
+ config.viewpoints = this._viewpoints.serializeModule(moduleId);
551
+ config.styles = this._styles.serializeModule(moduleId);
552
+ config.categories = [...this._categories]
553
+ .map((c) => c.serializeModule(moduleId))
554
+ .filter((c) => !!c);
555
+
556
+ return config;
557
+ }
558
+
559
+ /**
560
+ * sets the given module as the dynamic
561
+ * @param {VcsModule} module
562
+ */
563
+ setDynamicModule(module) {
564
+ if (!this._modules.has(module)) {
565
+ throw new Error(
566
+ 'VcsModule is not managed by this app, call add(module) before',
567
+ );
568
+ }
569
+ if (this._dynamicModule !== module) {
570
+ this._dynamicModule = module;
571
+ this.dynamicModuleIdChanged.raiseEvent(this.dynamicModuleId);
572
+ }
573
+ }
574
+
575
+ /**
576
+ * resets the dynamic VcsModule to the "defaultDynamicModule"
577
+ */
578
+ resetDynamicModule() {
579
+ this.setDynamicModule(this._defaultDynamicModule);
580
+ }
581
+
582
+ /**
583
+ * @param {string} moduleId
584
+ * @returns {Promise<void>}
585
+ * @protected
586
+ */
587
+ async _removeModule(moduleId) {
588
+ await Promise.all([
589
+ this._maps.removeModule(moduleId),
590
+ this._layers.removeModule(moduleId),
591
+ this._viewpoints.removeModule(moduleId),
592
+ this._styles.removeModule(moduleId),
593
+ this._obliqueCollections.removeModule(moduleId),
594
+ ]);
595
+ }
596
+
597
+ /**
598
+ * @param {string} moduleId
599
+ * @returns {Promise<void>}
600
+ */
601
+ removeModule(moduleId) {
602
+ this._moduleMutationPromise = this._moduleMutationPromise.then(async () => {
603
+ const module = this._modules.getByKey(moduleId);
604
+ if (!module) {
605
+ getLogger().info(`module with id ${moduleId} has already been removed`);
606
+ return;
607
+ }
608
+ await this._removeModule(moduleId);
609
+ this._modules.remove(module);
610
+ });
611
+
612
+ return this._moduleMutationPromise;
613
+ }
614
+
615
+ /**
616
+ * Destroys the app and all its collections, their content and ui managers.
617
+ */
618
+ destroy() {
619
+ Object.defineProperty(this, '_moduleMutationPromise', {
620
+ get() {
621
+ throw new Error('VcsApp was destroyed');
622
+ },
623
+ });
624
+ vcsApps.delete(this._id);
625
+ destroyCollection(this._maps);
626
+ destroyCollection(this._layers);
627
+ destroyCollection(this._obliqueCollections);
628
+ destroyCollection(this._viewpoints);
629
+ destroyCollection(this._styles);
630
+ destroyCollection(this._modules);
631
+ destroyCollection(this._categories);
632
+ this._mapClassRegistry.destroy();
633
+ this._layerClassRegistry.destroy();
634
+ this._styleClassRegistry.destroy();
635
+ this._categoryClassRegisty.destroy();
636
+ this._categoryItemClassRegistry.destroy();
637
+ this._tileProviderClassRegsitry.destroy();
638
+ this._featureProviderClassRegsitry.destroy();
639
+ this.destroyed.raiseEvent();
640
+ this.destroyed.destroy();
641
+ this.localeChanged.destroy();
642
+ this.dynamicModuleIdChanged.destroy();
643
+ }
644
+ }
645
+
646
+ /**
647
+ * @param {string} id
648
+ * @returns {VcsApp}
649
+ */
650
+ export function getVcsAppById(id) {
651
+ return vcsApps.get(id);
652
+ }
653
+
654
+ window.vcs = window.vcs || {};
655
+ window.vcs.apps = vcsApps;
656
+
657
+ export default VcsApp;
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * @class
3
3
  * @template {*} T
4
- * @export
5
4
  * @api
6
5
  */
7
6
  class VcsEvent {
@@ -58,7 +57,7 @@ class VcsEvent {
58
57
  * @api
59
58
  */
60
59
  raiseEvent(event) {
61
- this._listeners.forEach((cb) => {
60
+ [...this._listeners].forEach((cb) => {
62
61
  cb(event);
63
62
  });
64
63
  }
@@ -70,7 +69,7 @@ class VcsEvent {
70
69
  async awaitRaisedEvent(event) {
71
70
  const promises = new Array(this._listeners.size);
72
71
  let i = 0;
73
- this._listeners.forEach((cb) => {
72
+ [...this._listeners].forEach((cb) => {
74
73
  promises[i] = cb(event);
75
74
  i += 1;
76
75
  });