@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
@@ -0,0 +1,261 @@
1
+ /* eslint no-underscore-dangle: ["error", { "allow": ["_array"] }] */
2
+ // eslint-disable-next-line max-classes-per-file
3
+ import { check } from '@vcsuite/check';
4
+ import { getLogger as getLoggerByName } from '@vcsuite/logger';
5
+ import { moduleIdSymbol } from '../vcsModuleHelpers.js';
6
+ import Collection from './collection.js';
7
+ import VcsEvent from '../vcsEvent.js';
8
+
9
+ /**
10
+ * @returns {import("@vcsuite/logger").Logger}
11
+ */
12
+ function getLogger() {
13
+ return getLoggerByName('OverrideCollection');
14
+ }
15
+
16
+ /**
17
+ * The override collection adds the ability to override a unique item and re-creating it, should the override
18
+ * be removed. This does change some flow of called events. 1) if you override an item, removed is not called for the
19
+ * removed current item. 2) added can be called more the once for the same unique id. 3) replaced is called for items
20
+ * which where replaced. replaced is called after added has been called for the item.
21
+ * @interface OverrideCollectionInterface
22
+ * @property {import("@vcmap/core").VcsEvent<T>} replaced - replaced is called after added
23
+ * @property {function(T):T|null} override - returns the overriden item or null if the item could not be inserted (this would be the result of a race condition)
24
+ * @property {Map<string, Array<Object>>} shadowMap
25
+ * @property {function(Array<Object>, string):Promise<void>} parseItems
26
+ * @property {function(string):Object} getSerializedByKey
27
+ * @property {function(string):Promise<void>} removeModule
28
+ * @property {function(string):Array<Object>} serializeModule
29
+ * @template {*} T
30
+ */
31
+
32
+ /**
33
+ * A symbol added to override collections.
34
+ * @type {symbol}
35
+ */
36
+ export const isOverrideCollection = Symbol('OverrideCollection');
37
+
38
+ /**
39
+ * @param {Collection<T>} collection
40
+ * @param {function():string} getDynamicModuleId - function to get the current dynamic module id
41
+ * @param {(function(T):Object)=} serializeItem - optional function to serialize an item, defaults to returning item.toJSON or item: i => (i.toJSON || i)
42
+ * @param {(function(Object):(T|Promise<T>))=} deserializeItem - optional deserialization function. defaults to returning the passed object: i => i
43
+ * @param {*=} ctor - optional constructor to validate deserialized items against. if passed, deserializeItem must be an instance of ctor.
44
+ * @param {(function(T, (T|null|undefined), (number|undefined)):number|null)=} determineShadowIndex - return the index where a shadow should be inserted. only has relevance, if the collection is indexed. previous and current index may be null.
45
+ * @template {*} T
46
+ * @returns {OverrideCollection<T>}
47
+ */
48
+ function makeOverrideCollection(
49
+ collection,
50
+ getDynamicModuleId,
51
+ serializeItem,
52
+ deserializeItem,
53
+ ctor,
54
+ determineShadowIndex,
55
+ ) {
56
+ check(collection, Collection);
57
+
58
+ const overrideCollection = /** @type {OverrideCollection<T>} */ (collection);
59
+ if (overrideCollection[isOverrideCollection]) {
60
+ throw new Error(
61
+ 'Cannot transform collection, collection already is an OverrideCollection',
62
+ );
63
+ }
64
+ overrideCollection[isOverrideCollection] = true;
65
+
66
+ const deserialize = deserializeItem || ((i) => i);
67
+ // @ts-ignore
68
+ const serialize = serializeItem || ((i) => (i.toJSON ? i.toJSON() : i));
69
+ const getShadowIndex =
70
+ determineShadowIndex || ((item, shadow, currentIndex) => currentIndex);
71
+
72
+ /**
73
+ * @type {Map<string, Array<Object>>}
74
+ */
75
+ overrideCollection.shadowMap = new Map();
76
+
77
+ /**
78
+ * @param {T} item
79
+ * @returns {T|null}
80
+ */
81
+ overrideCollection.override = function override(item) {
82
+ let shadow;
83
+ let index;
84
+ const itemId = item[overrideCollection.uniqueKey];
85
+
86
+ if (overrideCollection.hasKey(itemId)) {
87
+ shadow = overrideCollection.getByKey(itemId);
88
+
89
+ // @ts-ignore
90
+ // eslint-disable-next-line no-underscore-dangle
91
+ index = overrideCollection._remove(shadow);
92
+
93
+ if (!overrideCollection.shadowMap.has(itemId)) {
94
+ overrideCollection.shadowMap.set(itemId, []);
95
+ }
96
+ const shadowsArray = overrideCollection.shadowMap.get(itemId);
97
+ const serializedShadow = serialize(shadow);
98
+ serializedShadow[moduleIdSymbol] = shadow[moduleIdSymbol];
99
+ shadowsArray.push(serializedShadow);
100
+ }
101
+
102
+ const usedIndex = shadow ? getShadowIndex(shadow, item, index) : null;
103
+ if (shadow) {
104
+ overrideCollection.replaced.raiseEvent({ old: shadow, new: item });
105
+ // @ts-ignore
106
+ if (shadow.destroy) {
107
+ // @ts-ignore
108
+ shadow.destroy();
109
+ }
110
+ }
111
+ // @ts-ignore
112
+ if (overrideCollection.add(item, usedIndex) >= 0) {
113
+ return item;
114
+ }
115
+ return null;
116
+ };
117
+
118
+ /**
119
+ * @param {Array<Object>} configArray
120
+ * @param {string} moduleId
121
+ * @returns {Promise<void>}
122
+ */
123
+ overrideCollection.parseItems = async function parseItems(
124
+ configArray,
125
+ moduleId,
126
+ ) {
127
+ if (Array.isArray(configArray)) {
128
+ const instanceArray = await Promise.all(
129
+ configArray.map(async (config) => {
130
+ const item = await deserialize(config);
131
+ if (!item || (ctor && !(item instanceof ctor))) {
132
+ getLogger().warning(
133
+ `Could not load item ${
134
+ config[overrideCollection.uniqueKey]
135
+ } of type ${config.type}`,
136
+ );
137
+ return null;
138
+ }
139
+ item[moduleIdSymbol] = moduleId;
140
+ return item;
141
+ }),
142
+ );
143
+ instanceArray
144
+ .filter((i) => i)
145
+ .forEach((i) => {
146
+ overrideCollection.override(i);
147
+ });
148
+ }
149
+ };
150
+
151
+ /**
152
+ * @param {string} key
153
+ * @returns {Object|undefined}
154
+ */
155
+ overrideCollection.getSerializedByKey = function getSerializedByKey(key) {
156
+ const item = overrideCollection.getByKey(key);
157
+ if (item) {
158
+ return serialize(item);
159
+ }
160
+ return undefined;
161
+ };
162
+
163
+ overrideCollection.removed.addEventListener(async (item) => {
164
+ const itemId = item[overrideCollection.uniqueKey];
165
+
166
+ if (overrideCollection.shadowMap.has(itemId)) {
167
+ const serializedShadow = overrideCollection.shadowMap.get(itemId).pop();
168
+ if (serializedShadow) {
169
+ const reincarnation = await deserialize(serializedShadow);
170
+ reincarnation[moduleIdSymbol] = serializedShadow[moduleIdSymbol];
171
+ const index = getShadowIndex(
172
+ reincarnation,
173
+ item,
174
+ // @ts-ignore
175
+ item[overrideCollection.previousIndexSymbol],
176
+ );
177
+ // @ts-ignore
178
+ overrideCollection.add(reincarnation, index);
179
+ }
180
+
181
+ if (overrideCollection.shadowMap.get(itemId).length === 0) {
182
+ overrideCollection.shadowMap.delete(itemId);
183
+ }
184
+ }
185
+ });
186
+
187
+ overrideCollection.added.addEventListener((item) => {
188
+ if (!item[moduleIdSymbol]) {
189
+ item[moduleIdSymbol] = getDynamicModuleId();
190
+ }
191
+ });
192
+
193
+ /**
194
+ * @param {string} moduleId
195
+ * @returns {Promise<void>}
196
+ */
197
+ overrideCollection.removeModule = async function removeModule(moduleId) {
198
+ overrideCollection.shadowMap.forEach((shadowsArray, name) => {
199
+ const newShadowsArray = shadowsArray.filter(
200
+ (c) => c[moduleIdSymbol] !== moduleId,
201
+ );
202
+ if (newShadowsArray.length === 0) {
203
+ overrideCollection.shadowMap.delete(name);
204
+ } else if (newShadowsArray.length !== shadowsArray.length) {
205
+ overrideCollection.shadowMap.set(name, newShadowsArray);
206
+ }
207
+ });
208
+
209
+ await Promise.all(
210
+ [...overrideCollection]
211
+ .filter((item) => item[moduleIdSymbol] === moduleId)
212
+ .map(async (item) => {
213
+ overrideCollection.remove(item);
214
+ // @ts-ignore
215
+ if (item.destroy) {
216
+ // @ts-ignore
217
+ item.destroy();
218
+ }
219
+ }),
220
+ );
221
+ };
222
+
223
+ /**
224
+ * @type {VcsEvent<ReplacedEvent<T>>}
225
+ */
226
+ overrideCollection.replaced = new VcsEvent();
227
+
228
+ /**
229
+ * @param {string} moduleId
230
+ * @returns {Array<Object>}
231
+ */
232
+ overrideCollection.serializeModule = function serializeModule(moduleId) {
233
+ return [...overrideCollection]
234
+ .map((item) => {
235
+ if (item[moduleIdSymbol] === moduleId) {
236
+ return serialize(item);
237
+ }
238
+ if (
239
+ overrideCollection.shadowMap.has(item[overrideCollection.uniqueKey])
240
+ ) {
241
+ return overrideCollection.shadowMap
242
+ .get(item[overrideCollection.uniqueKey])
243
+ .find((i) => i[moduleIdSymbol] === moduleId);
244
+ }
245
+ return null;
246
+ })
247
+ .filter((i) => i);
248
+ };
249
+
250
+ const originalDestroy = overrideCollection.destroy.bind(overrideCollection);
251
+
252
+ overrideCollection.destroy = function destroy() {
253
+ originalDestroy();
254
+ overrideCollection.shadowMap.clear();
255
+ overrideCollection.replaced.destroy();
256
+ };
257
+
258
+ return overrideCollection;
259
+ }
260
+
261
+ export default makeOverrideCollection;
@@ -1,9 +1,7 @@
1
1
  import { getTransform, get as getProjection, equivalent } from 'ol/proj.js';
2
2
  import { register } from 'ol/proj/proj4.js';
3
3
  import proj4 from 'proj4';
4
- import { getLogger as getLoggerByName } from '@vcsuite/logger';
5
4
  import { check } from '@vcsuite/check';
6
- import { VcsClassRegistry } from '../classRegistry.js';
7
5
 
8
6
  /**
9
7
  * @typedef {Object} ProjectionOptions
@@ -14,17 +12,18 @@ import { VcsClassRegistry } from '../classRegistry.js';
14
12
  * @property {string|undefined} [prefix='EPSG:'] - an alternate prefix to use for custom projection
15
13
  * @api stable
16
14
  */
17
-
18
- export const wgs84ToMercatorTransformer = getTransform('EPSG:4326', 'EPSG:3857');
19
- export const mercatorToWgs84Transformer = getTransform('EPSG:3857', 'EPSG:4326');
20
-
21
-
22
15
  /**
23
- * @returns {import("@vcsuite/logger").Logger}
16
+ * @typedef {function(Array<number>, Array<number>=, number=): Array<number>} CorrectTransformFunction
24
17
  */
25
- function getLogger() {
26
- return getLoggerByName('vcs.vcm.util.Projection');
27
- }
18
+
19
+ export const wgs84ToMercatorTransformer =
20
+ /** @type {CorrectTransformFunction} */ (
21
+ getTransform('EPSG:4326', 'EPSG:3857')
22
+ );
23
+ export const mercatorToWgs84Transformer =
24
+ /** @type {CorrectTransformFunction} */ (
25
+ getTransform('EPSG:3857', 'EPSG:4326')
26
+ );
28
27
 
29
28
  /**
30
29
  * @type {ProjectionOptions}
@@ -105,7 +104,6 @@ function registerProjection(options) {
105
104
  * projection created prior to this functions call.
106
105
  * @param {ProjectionOptions} options
107
106
  * @api
108
- * @export
109
107
  */
110
108
  export function setDefaultProjectionOptions(options) {
111
109
  check(options, { epsg: [String, Number], proj4: [String, undefined, null] });
@@ -118,7 +116,6 @@ export function setDefaultProjectionOptions(options) {
118
116
  /**
119
117
  * Projection Class, if no valid options are given, the Projection will initialize with the Framework default Projection
120
118
  * @class
121
- * @export
122
119
  * For example:
123
120
  * <pre><code>
124
121
  * {
@@ -132,7 +129,9 @@ class Projection {
132
129
  /**
133
130
  * @returns {string}
134
131
  */
135
- static get className() { return 'vcs.vcm.util.Projection'; }
132
+ static get className() {
133
+ return 'Projection';
134
+ }
136
135
 
137
136
  /**
138
137
  * @param {ProjectionOptions} options
@@ -199,16 +198,6 @@ class Projection {
199
198
  return getProjection(this.epsg);
200
199
  }
201
200
 
202
- /**
203
- * @returns {import("ol/proj/Projection").default}
204
- * @api
205
- * @deprecated 3.7
206
- */
207
- getProjection() {
208
- getLogger().deprecate('getProjection', 'Access the property proj directly');
209
- return this.proj;
210
- }
211
-
212
201
  /**
213
202
  * @param {Projection} projection
214
203
  * @returns {boolean}
@@ -312,7 +301,11 @@ class Projection {
312
301
  * @api
313
302
  */
314
303
  static mercatorToWgs84(coords, inPlace) {
315
- return mercatorToWgs84Transformer(coords, inPlace ? coords : undefined, coords.length);
304
+ return mercatorToWgs84Transformer(
305
+ coords,
306
+ inPlace ? coords : undefined,
307
+ coords.length,
308
+ );
316
309
  }
317
310
 
318
311
  /**
@@ -323,7 +316,11 @@ class Projection {
323
316
  * @api
324
317
  */
325
318
  static wgs84ToMercator(coords, inPlace) {
326
- return wgs84ToMercatorTransformer(coords, inPlace ? coords : undefined, coords.length);
319
+ return wgs84ToMercatorTransformer(
320
+ coords,
321
+ inPlace ? coords : undefined,
322
+ coords.length,
323
+ );
327
324
  }
328
325
 
329
326
  /**
@@ -358,7 +355,6 @@ export default Projection;
358
355
  * Returns the default Projection.
359
356
  * @api stable
360
357
  * @returns {Projection}
361
- * @export
362
358
  */
363
359
  export function getDefaultProjection() {
364
360
  return new Projection(defaultProjectionOption);
@@ -368,15 +364,11 @@ export function getDefaultProjection() {
368
364
  * wgs84 Projection EPSG Code: 4326
369
365
  * @api stable
370
366
  * @type {Projection}
371
- * @export
372
367
  */
373
368
  export const wgs84Projection = new Projection({ epsg: 4326 });
374
369
  /**
375
370
  * mercator Projection EPSG Code: 3857
376
371
  * @api stable
377
372
  * @type {Projection}
378
- * @export
379
373
  */
380
374
  export const mercatorProjection = new Projection({ epsg: 3857 });
381
-
382
- VcsClassRegistry.registerClass(Projection.className, Projection);
@@ -5,12 +5,14 @@
5
5
  // eslint-disable-next-line import/prefer-default-export
6
6
  export function isSameOrigin(source) {
7
7
  const { location } = window;
8
- const url = new URL(source, `${location.protocol}//${location.host}${location.pathname}`);
8
+ const url = new URL(
9
+ source,
10
+ `${location.protocol}//${location.host}${location.pathname}`,
11
+ );
9
12
  // for instance data: URIs have no host information and are implicitly same origin
10
13
  // see https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#inherited_origins
11
14
  if (!url.host) {
12
15
  return true;
13
16
  }
14
- return url.protocol === location.protocol &&
15
- url.host === location.host;
17
+ return url.protocol === location.protocol && url.host === location.host;
16
18
  }