@vcmap/core 5.0.0-rc.1 → 5.0.0-rc.12

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 (185) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -2
  3. package/index.d.ts +2085 -1969
  4. package/index.js +137 -131
  5. package/package.json +14 -22
  6. package/src/category/appBackedCategory.js +76 -0
  7. package/src/category/category.js +417 -0
  8. package/src/category/categoryCollection.js +145 -0
  9. package/src/cesium/cesium3DTileFeature.js +1 -1
  10. package/src/classRegistry.js +162 -0
  11. package/src/context.js +72 -0
  12. package/src/{vcs/vcm/util/featureProvider → featureProvider}/abstractFeatureProvider.js +8 -9
  13. package/src/{vcs/vcm/util/featureProvider → featureProvider}/featureProviderHelpers.js +4 -5
  14. package/src/{vcs/vcm/util/featureProvider → featureProvider}/featureProviderSymbols.js +0 -0
  15. package/src/{vcs/vcm/util/featureProvider → featureProvider}/tileProviderFeatureProvider.js +4 -2
  16. package/src/{vcs/vcm/util/featureProvider → featureProvider}/wmsFeatureProvider.js +25 -18
  17. package/src/{vcs/vcm/interaction → interaction}/abstractInteraction.js +19 -18
  18. package/src/{vcs/vcm/interaction → interaction}/coordinateAtPixel.js +6 -9
  19. package/src/{vcs/vcm/interaction → interaction}/eventHandler.js +3 -3
  20. package/src/{vcs/vcm/interaction → interaction}/featureAtPixelInteraction.js +6 -19
  21. package/src/{vcs/vcm/interaction → interaction}/featureProviderInteraction.js +2 -13
  22. package/src/{vcs/vcm/interaction → interaction}/interactionChain.js +11 -32
  23. package/src/{vcs/vcm/interaction → interaction}/interactionType.js +1 -5
  24. package/src/{vcs/vcm/layer/cesium/cesiumTilesetCesium.js → layer/cesium/cesiumTilesetCesiumImpl.js} +10 -13
  25. package/src/{vcs/vcm/layer → layer}/cesium/clusterContext.js +0 -0
  26. package/src/{vcs/vcm/layer/cesium/dataSourceCesium.js → layer/cesium/dataSourceCesiumImpl.js} +5 -3
  27. package/src/{vcs/vcm/layer/cesium/openStreetMapCesium.js → layer/cesium/openStreetMapCesiumImpl.js} +6 -7
  28. package/src/{vcs/vcm/layer/cesium/rasterLayerCesium.js → layer/cesium/rasterLayerCesiumImpl.js} +5 -6
  29. package/src/{vcs/vcm/layer/cesium/singleImageCesium.js → layer/cesium/singleImageCesiumImpl.js} +5 -6
  30. package/src/{vcs/vcm/layer/cesium/terrainCesium.js → layer/cesium/terrainCesiumImpl.js} +4 -5
  31. package/src/{vcs/vcm/layer/cesium/tmsCesium.js → layer/cesium/tmsCesiumImpl.js} +6 -7
  32. package/src/{vcs/vcm/layer/cesium/vectorCesium.js → layer/cesium/vectorCesiumImpl.js} +6 -7
  33. package/src/{vcs/vcm/layer → layer}/cesium/vectorContext.js +0 -0
  34. package/src/{vcs/vcm/layer/cesium/vectorRasterTileCesium.js → layer/cesium/vectorRasterTileCesiumImpl.js} +5 -6
  35. package/src/{vcs/vcm/layer → layer}/cesium/vectorTileImageryProvider.js +1 -2
  36. package/src/{vcs/vcm/layer/cesium/wmsCesium.js → layer/cesium/wmsCesiumImpl.js} +6 -7
  37. package/src/{vcs/vcm/layer/cesium/wmtsCesium.js → layer/cesium/wmtsCesiumImpl.js} +6 -7
  38. package/src/{vcs/vcm/layer → layer}/cesium/x3dmHelper.js +0 -0
  39. package/src/{vcs/vcm/layer/cesiumTileset.js → layer/cesiumTilesetLayer.js} +38 -37
  40. package/src/{vcs/vcm/layer/czml.js → layer/czmlLayer.js} +14 -17
  41. package/src/{vcs/vcm/layer/dataSource.js → layer/dataSourceLayer.js} +38 -29
  42. package/src/{vcs/vcm/layer → layer}/featureLayer.js +27 -31
  43. package/src/{vcs/vcm/layer/featureStore.js → layer/featureStoreLayer.js} +54 -54
  44. package/src/{vcs/vcm/layer/featureStoreChanges.js → layer/featureStoreLayerChanges.js} +98 -82
  45. package/src/{vcs/vcm/layer/featureStoreState.js → layer/featureStoreLayerState.js} +1 -2
  46. package/src/{vcs/vcm/layer → layer}/featureVisibility.js +9 -6
  47. package/src/{vcs/vcm/layer → layer}/geojsonHelpers.js +15 -41
  48. package/src/{vcs/vcm/layer/geojson.js → layer/geojsonLayer.js} +19 -22
  49. package/src/{vcs/vcm/layer → layer}/globalHider.js +8 -32
  50. package/src/{vcs/vcm/layer → layer}/layer.js +63 -20
  51. package/src/{vcs/vcm/layer → layer}/layerImplementation.js +2 -3
  52. package/src/{vcs/vcm/layer → layer}/layerState.js +0 -1
  53. package/src/{vcs/vcm/layer → layer}/layerSymbols.js +0 -0
  54. package/src/{vcs/vcm/layer/oblique/layerOblique.js → layer/oblique/layerObliqueImpl.js} +4 -4
  55. package/src/{vcs/vcm/layer → layer}/oblique/obliqueHelpers.js +2 -2
  56. package/src/{vcs/vcm/layer/oblique/vectorOblique.js → layer/oblique/vectorObliqueImpl.js} +7 -9
  57. package/src/{vcs/vcm/layer/openStreetMap.js → layer/openStreetMapLayer.js} +32 -33
  58. package/src/{vcs/vcm/layer/openlayers/layerOpenlayers.js → layer/openlayers/layerOpenlayersImpl.js} +5 -6
  59. package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +26 -0
  60. package/src/{vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js → layer/openlayers/rasterLayerOpenlayersImpl.js} +15 -14
  61. package/src/{vcs/vcm/layer/openlayers/singleImageOpenlayers.js → layer/openlayers/singleImageOpenlayersImpl.js} +6 -7
  62. package/src/{vcs/vcm/layer/openlayers/tileDebugOpenlayers.js → layer/openlayers/tileDebugOpenlayersImpl.js} +5 -6
  63. package/src/{vcs/vcm/layer/openlayers/tmsOpenlayers.js → layer/openlayers/tmsOpenlayersImpl.js} +7 -8
  64. package/src/{vcs/vcm/layer/openlayers/vectorOpenlayers.js → layer/openlayers/vectorOpenlayersImpl.js} +8 -9
  65. package/src/{vcs/vcm/layer/openlayers/vectorTileOpenlayers.js → layer/openlayers/vectorTileOpenlayersImpl.js} +6 -7
  66. package/src/{vcs/vcm/layer/openlayers/wmsOpenlayers.js → layer/openlayers/wmsOpenlayersImpl.js} +7 -8
  67. package/src/{vcs/vcm/layer/openlayers/wmtsOpenlayers.js → layer/openlayers/wmtsOpenlayersImpl.js} +7 -8
  68. package/src/{vcs/vcm/layer/pointCloud.js → layer/pointCloudLayer.js} +26 -34
  69. package/src/{vcs/vcm/layer → layer}/rasterLayer.js +18 -20
  70. package/src/{vcs/vcm/layer/singleImage.js → layer/singleImageLayer.js} +20 -20
  71. package/src/{vcs/vcm/layer → layer}/terrainHelpers.js +13 -49
  72. package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +13 -14
  73. package/src/{vcs/vcm/layer → layer}/tileLoadedHelper.js +5 -5
  74. package/src/{vcs/vcm/layer → layer}/tileProvider/mvtTileProvider.js +22 -5
  75. package/src/layer/tileProvider/staticGeojsonTileProvider.js +81 -0
  76. package/src/{vcs/vcm/layer → layer}/tileProvider/tileProvider.js +16 -8
  77. package/src/{vcs/vcm/layer → layer}/tileProvider/urlTemplateTileProvider.js +20 -6
  78. package/src/{vcs/vcm/layer/tms.js → layer/tmsLayer.js} +19 -20
  79. package/src/{vcs/vcm/layer → layer}/vectorHelpers.js +5 -5
  80. package/src/{vcs/vcm/layer/vector.js → layer/vectorLayer.js} +38 -48
  81. package/src/{vcs/vcm/layer → layer}/vectorProperties.js +3 -4
  82. package/src/{vcs/vcm/layer → layer}/vectorSymbols.js +0 -0
  83. package/src/{vcs/vcm/layer/vectorTile.js → layer/vectorTileLayer.js} +55 -54
  84. package/src/{vcs/vcm/layer/wfs.js → layer/wfsLayer.js} +19 -20
  85. package/src/{vcs/vcm/layer → layer}/wmsHelpers.js +1 -1
  86. package/src/{vcs/vcm/layer/wms.js → layer/wmsLayer.js} +22 -23
  87. package/src/{vcs/vcm/layer/wmts.js → layer/wmtsLayer.js} +20 -21
  88. package/src/{vcs/vcm/maps → map}/baseOLMap.js +5 -6
  89. package/src/{vcs/vcm/maps → map}/cameraLimiter.js +11 -17
  90. package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +21 -34
  91. package/src/{vcs/vcm/maps → map}/mapState.js +0 -1
  92. package/src/{vcs/vcm/maps/oblique.js → map/obliqueMap.js} +42 -57
  93. package/src/{vcs/vcm/maps/openlayers.js → map/openlayersMap.js} +17 -15
  94. package/src/{vcs/vcm/maps/map.js → map/vcsMap.js} +41 -22
  95. package/src/oblique/defaultObliqueCollection.js +62 -0
  96. package/src/{vcs/vcm/oblique → oblique}/helpers.js +13 -44
  97. package/src/{vcs/vcm/oblique/ObliqueCollection.js → oblique/obliqueCollection.js} +117 -37
  98. package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +67 -26
  99. package/src/{vcs/vcm/oblique/ObliqueImage.js → oblique/obliqueImage.js} +1 -2
  100. package/src/{vcs/vcm/oblique/ObliqueImageMeta.js → oblique/obliqueImageMeta.js} +4 -5
  101. package/src/{vcs/vcm/oblique/ObliqueProvider.js → oblique/obliqueProvider.js} +17 -12
  102. package/src/{vcs/vcm/oblique/ObliqueView.js → oblique/obliqueView.js} +31 -2
  103. package/src/{vcs/vcm/oblique/ObliqueViewDirection.js → oblique/obliqueViewDirection.js} +0 -3
  104. package/src/{vcs/vcm/oblique → oblique}/parseImageJson.js +20 -12
  105. package/src/ol/geom/circle.js +1 -1
  106. package/src/ol/render/canvas/canvasTileRenderer.js +0 -1
  107. package/src/overrideClassRegistry.js +204 -0
  108. package/src/{vcs/vcm/util/style → style}/declarativeStyleItem.js +43 -20
  109. package/src/{vcs/vcm/util/style → style}/shapesCategory.js +0 -2
  110. package/src/style/styleFactory.js +29 -0
  111. package/src/{vcs/vcm/util/style → style}/styleHelpers.js +3 -14
  112. package/src/{vcs/vcm/util/style → style}/styleItem.js +23 -86
  113. package/src/{vcs/vcm/util/style → style}/vectorStyleItem.js +73 -85
  114. package/src/{vcs/vcm/util/style → style}/writeStyle.js +4 -7
  115. package/src/{vcs/vcm/util → util}/clipping/clippingObject.js +10 -12
  116. package/src/{vcs/vcm/util → util}/clipping/clippingObjectManager.js +2 -3
  117. package/src/{vcs/vcm/util → util}/clipping/clippingPlaneHelper.js +4 -8
  118. package/src/{vcs/vcm/util → util}/collection.js +16 -4
  119. package/src/{vcs/vcm/util → util}/dateTime.js +0 -0
  120. package/src/{vcs/vcm/util → util}/exclusiveManager.js +0 -0
  121. package/src/{vcs/vcm/util → util}/extent.js +18 -12
  122. package/src/{vcs/vcm/util → util}/featureconverter/circleToCesium.js +0 -0
  123. package/src/{vcs/vcm/util → util}/featureconverter/convert.js +0 -0
  124. package/src/util/featureconverter/extent3D.js +181 -0
  125. package/src/{vcs/vcm/util → util}/featureconverter/featureconverterHelper.js +1 -1
  126. package/src/{vcs/vcm/util → util}/featureconverter/lineStringToCesium.js +0 -0
  127. package/src/{vcs/vcm/util → util}/featureconverter/pointToCesium.js +3 -3
  128. package/src/{vcs/vcm/util → util}/featureconverter/polygonToCesium.js +1 -1
  129. package/src/util/fetch.js +32 -0
  130. package/src/{vcs/vcm/util → util}/geometryHelpers.js +0 -0
  131. package/src/{vcs/vcm/util → util}/indexedCollection.js +24 -2
  132. package/src/{vcs/vcm/util → util}/isMobile.js +0 -0
  133. package/src/{vcs/vcm/util → util}/layerCollection.js +49 -12
  134. package/src/{vcs/vcm/util → util}/locale.js +1 -1
  135. package/src/{vcs/vcm/util → util}/mapCollection.js +91 -34
  136. package/src/{vcs/vcm/util → util}/math.js +0 -0
  137. package/src/util/overrideCollection.js +223 -0
  138. package/src/{vcs/vcm/util → util}/projection.js +39 -29
  139. package/src/{vcs/vcm/util → util}/splitScreen.js +10 -10
  140. package/src/{vcs/vcm/util → util}/urlHelpers.js +0 -0
  141. package/src/{vcs/vcm/util → util}/viewpoint.js +5 -9
  142. package/src/vcsApp.js +471 -0
  143. package/src/vcsAppContextHelpers.js +121 -0
  144. package/src/{vcs/vcm/event/vcsEvent.js → vcsEvent.js} +2 -3
  145. package/src/{vcs/vcm/object.js → vcsObject.js} +2 -10
  146. package/tests/data/buildings/tileset.json +428 -0
  147. package/tests/data/dynamicPointCzml.json +64 -0
  148. package/tests/data/oblique/imageData/imagev34.json +352 -0
  149. package/tests/data/oblique/imageData/imagev35.json +54 -0
  150. package/tests/data/oblique/imageData/imagev35PerImageSize.json +53 -0
  151. package/tests/data/oblique/tiledImageData/12/2199/1342.json +1 -0
  152. package/tests/data/oblique/tiledImageData/12/2199/1343.json +1 -0
  153. package/tests/data/oblique/tiledImageData/12/2199/1344.json +1 -0
  154. package/tests/data/oblique/tiledImageData/12/2200/1342.json +1 -0
  155. package/tests/data/oblique/tiledImageData/12/2200/1343.json +1 -0
  156. package/tests/data/oblique/tiledImageData/12/2200/1344.json +1 -0
  157. package/tests/data/oblique/tiledImageData/12/2201/1342.json +1 -0
  158. package/tests/data/oblique/tiledImageData/12/2201/1343.json +1 -0
  159. package/tests/data/oblique/tiledImageData/12/2201/1344.json +1 -0
  160. package/tests/data/oblique/tiledImageData/image.json +1 -0
  161. package/tests/data/terrain/13/8800/6485.terrain +0 -0
  162. package/tests/data/terrain/13/8800/6486.terrain +0 -0
  163. package/tests/data/terrain/13/8801/6485.terrain +0 -0
  164. package/tests/data/terrain/13/8801/6486.terrain +0 -0
  165. package/tests/data/terrain/layer.json +136 -0
  166. package/tests/data/testGeoJSON.json +161 -0
  167. package/tests/data/tile.pbf +0 -0
  168. package/tests/unit/helpers/cesiumHelpers.js +272 -0
  169. package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
  170. package/tests/unit/helpers/helpers.js +11 -0
  171. package/tests/unit/helpers/imageHelpers.js +20 -0
  172. package/tests/unit/helpers/importJSON.js +15 -0
  173. package/tests/unit/helpers/obliqueData.js +76 -0
  174. package/tests/unit/helpers/obliqueHelpers.js +112 -0
  175. package/tests/unit/helpers/openlayersHelpers.js +22 -0
  176. package/tests/unit/helpers/terrain/terrainData.js +46 -0
  177. package/src/vcs/vcm/classRegistry.js +0 -106
  178. package/src/vcs/vcm/globalCollections.js +0 -11
  179. package/src/vcs/vcm/layer/buildings.js +0 -17
  180. package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +0 -58
  181. package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +0 -27
  182. package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +0 -67
  183. package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +0 -28
  184. package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
  185. package/src/vcs/vcm/util/style/styleFactory.js +0 -48
@@ -1,34 +1,34 @@
1
- import axios from 'axios';
2
1
  import Feature from 'ol/Feature.js';
3
- import { Cesium3DTileFeature, Cesium3DTilePointFeature, ImagerySplitDirection } from '@vcmap/cesium';
2
+ import { Cesium3DTileFeature, Cesium3DTilePointFeature, SplitDirection } from '@vcmap/cesium';
4
3
  import VectorSource from 'ol/source/Vector.js';
5
4
  import { createEmpty, extend as extendExtent } from 'ol/extent.js';
6
5
 
7
- import Vector from './vector.js';
8
- import { featureStoreStateSymbol, featureStoreState } from './featureStoreState.js';
6
+ import VectorLayer from './vectorLayer.js';
7
+ import { featureStoreStateSymbol, FeatureStoreLayerState } from './featureStoreLayerState.js';
9
8
  import { parseGeoJSON } from './geojsonHelpers.js';
10
9
  import { mercatorProjection } from '../util/projection.js';
11
- import FeatureStoreChanges from './featureStoreChanges.js';
12
- import VectorStyleItem, { defaultVectorStyle, vectorStyleSymbol } from '../util/style/vectorStyleItem.js';
10
+ import FeatureStoreLayerChanges from './featureStoreLayerChanges.js';
11
+ import VectorStyleItem, { defaultVectorStyle, vectorStyleSymbol } from '../style/vectorStyleItem.js';
13
12
  import FeatureVisibility, {
14
13
  FeatureVisibilityAction,
15
14
  originalStyle,
16
15
  synchronizeFeatureVisibility,
17
16
  updateOriginalStyle,
18
17
  } from './featureVisibility.js';
19
- import CesiumTilesetCesium, { getExtentFromTileset } from './cesium/cesiumTilesetCesium.js';
20
- import CesiumMap from '../maps/cesium.js';
21
- import Openlayers from '../maps/openlayers.js';
22
- import Oblique from '../maps/oblique.js';
23
- import CesiumTileset from './cesiumTileset.js';
18
+ import CesiumTilesetCesiumImpl, { getExtentFromTileset } from './cesium/cesiumTilesetCesiumImpl.js';
19
+ import CesiumMap from '../map/cesiumMap.js';
20
+ import OpenlayersMap from '../map/openlayersMap.js';
21
+ import ObliqueMap from '../map/obliqueMap.js';
22
+ import CesiumTilesetLayer from './cesiumTilesetLayer.js';
24
23
  import VectorProperties from './vectorProperties.js';
25
- import VectorOpenlayers from './openlayers/vectorOpenlayers.js';
24
+ import VectorOpenlayersImpl from './openlayers/vectorOpenlayersImpl.js';
26
25
  import Layer from './layer.js';
27
- import DeclarativeStyleItem from '../util/style/declarativeStyleItem.js';
28
- import VectorOblique from './oblique/vectorOblique.js';
26
+ import DeclarativeStyleItem from '../style/declarativeStyleItem.js';
27
+ import VectorObliqueImpl from './oblique/vectorObliqueImpl.js';
29
28
  import Extent from '../util/extent.js';
30
29
  import { isMobile } from '../util/isMobile.js';
31
- import { VcsClassRegistry } from '../classRegistry.js';
30
+ import { layerClassRegistry } from '../classRegistry.js';
31
+ import { requestJson } from '../util/fetch.js';
32
32
 
33
33
  /**
34
34
  * @typedef {Object} FeatureStoreStaticRepresentation
@@ -43,7 +43,7 @@ import { VcsClassRegistry } from '../classRegistry.js';
43
43
  * @property {Object} properties - the properties bag
44
44
  * @property {Object} geometry
45
45
  * @property {Object|undefined} vcsMeta
46
- * @property {featureStoreState} state
46
+ * @property {FeatureStoreLayerState} state
47
47
  * @property {string} type - the featureType
48
48
  * @todo write vcsMeta for features
49
49
  * @todo set type to be one of an enum
@@ -66,7 +66,7 @@ import { VcsClassRegistry } from '../classRegistry.js';
66
66
 
67
67
  /**
68
68
  * @typedef {FeatureStoreLayerSchema} FeatureStoreOptions
69
- * @property {Function|undefined} injectedFetchDynamicFeatureFunc - injected function for fetching dynamic features from a remote FeatureStore server
69
+ * @property {Function|undefined} injectedFetchDynamicFeatureFunc - injected function for fetching dynamic features from a remote FeatureStoreLayer server
70
70
  * @api
71
71
  */
72
72
 
@@ -74,14 +74,13 @@ import { VcsClassRegistry } from '../classRegistry.js';
74
74
  export const isTiledFeature = Symbol('isTiledFeature');
75
75
 
76
76
  /**
77
- * FeatureStore Layer
77
+ * FeatureStoreLayer Layer
78
78
  * @class
79
- * @export
80
- * @extends {Vector}
79
+ * @extends {VectorLayer}
81
80
  * @api
82
81
  */
83
- class FeatureStore extends Vector {
84
- static get className() { return 'vcs.vcm.layer.FeatureStore'; }
82
+ class FeatureStoreLayer extends VectorLayer {
83
+ static get className() { return 'FeatureStoreLayer'; }
85
84
 
86
85
  /**
87
86
  * @returns {FeatureStoreOptions}
@@ -89,11 +88,11 @@ class FeatureStore extends Vector {
89
88
  static getDefaultOptions() {
90
89
  return {
91
90
  id: '',
92
- type: 'vcs.vcm.layer.FeatureStore',
91
+ type: 'FeatureStoreLayer',
93
92
  featureType: 'simple',
94
93
  features: [],
95
- ...Vector.getDefaultOptions(),
96
- projection: mercatorProjection.getConfigObject(),
94
+ ...VectorLayer.getDefaultOptions(),
95
+ projection: mercatorProjection.toJSON(),
97
96
  staticRepresentation: {},
98
97
  hiddenStaticFeatureIds: [],
99
98
  vcsMeta: {
@@ -108,7 +107,7 @@ class FeatureStore extends Vector {
108
107
  * @param {FeatureStoreOptions} options
109
108
  */
110
109
  constructor(options) {
111
- const defaultOptions = FeatureStore.getDefaultOptions();
110
+ const defaultOptions = FeatureStoreLayer.getDefaultOptions();
112
111
  const vectorOptions = {
113
112
  projection: defaultOptions.projection,
114
113
  ...options,
@@ -116,8 +115,8 @@ class FeatureStore extends Vector {
116
115
  super(vectorOptions);
117
116
  this._supportedMaps = [
118
117
  CesiumMap.className,
119
- Openlayers.className,
120
- Oblique.className,
118
+ OpenlayersMap.className,
119
+ ObliqueMap.className,
121
120
  ];
122
121
 
123
122
  /**
@@ -136,10 +135,10 @@ class FeatureStore extends Vector {
136
135
  this.hiddenStaticFeatureIds = new Set(options.hiddenStaticFeatureIds || defaultOptions.hiddenStaticFeatureIds);
137
136
 
138
137
  /**
139
- * @type {FeatureStoreChanges}
138
+ * @type {FeatureStoreLayerChanges}
140
139
  * @api
141
140
  */
142
- this.changeTracker = new FeatureStoreChanges(this);
141
+ this.changeTracker = new FeatureStoreLayerChanges(this);
143
142
 
144
143
  const { vcsMeta } = defaultOptions;
145
144
  if (options.vcsMeta) {
@@ -249,7 +248,7 @@ class FeatureStore extends Vector {
249
248
  _loadTwoDim() {
250
249
  if (!this._twoDimLoaded) {
251
250
  this._twoDimLoaded = (async () => {
252
- const { data } = await axios.get(this.staticRepresentation.twoDim);
251
+ const data = await requestJson(this.staticRepresentation.twoDim);
253
252
  const { features } = parseGeoJSON(data, {
254
253
  targetProjection: mercatorProjection,
255
254
  dynamicStyle: true,
@@ -288,14 +287,14 @@ class FeatureStore extends Vector {
288
287
 
289
288
  /**
290
289
  * @param {import("@vcmap/core").VcsMap} map
291
- * @returns {Array<VectorOblique|import("@vcmap/core").VectorCesium|VectorOpenlayers|CesiumTilesetCesium>}
290
+ * @returns {Array<VectorObliqueImpl|import("@vcmap/core").VectorCesiumImpl|VectorOpenlayersImpl|CesiumTilesetCesiumImpl>}
292
291
  */
293
292
  // @ts-ignore
294
293
  createImplementationsForMap(map) {
295
294
  const impls = /** @type {Array<import("@vcmap/core").LayerImplementation>} */
296
295
  (super.createImplementationsForMap(map));
297
296
  if (map instanceof CesiumMap && this.staticRepresentation && this.staticRepresentation.threeDim) {
298
- impls.push(new CesiumTilesetCesium(map, /** @type {CesiumTilesetImplementationOptions} */ ({
297
+ impls.push(new CesiumTilesetCesiumImpl(map, /** @type {CesiumTilesetImplementationOptions} */ ({
299
298
  url: this.staticRepresentation.threeDim,
300
299
  tilesetOptions: {
301
300
  maximumScreenSpaceError: isMobile() ? this.screenSpaceErrorMobile : this.screenSpaceError,
@@ -310,19 +309,20 @@ class FeatureStore extends Vector {
310
309
  name: this.name,
311
310
  style: this.style,
312
311
  featureVisibility: this._staticFeatureVisibility,
313
- splitDirection: ImagerySplitDirection.NONE,
312
+ globalHider: this.globalHider,
313
+ splitDirection: SplitDirection.NONE,
314
314
  jumpToLocation: false,
315
315
  })));
316
316
  } else if (this.staticRepresentation && this.staticRepresentation.twoDim) {
317
317
  this._loadTwoDim();
318
- if (map instanceof Openlayers) {
319
- impls.push(new VectorOpenlayers(map, this._getTwoDimStaticImplOptions()));
320
- } else if (map instanceof Oblique) {
321
- impls.push(new VectorOblique(map, this._getTwoDimStaticImplOptions()));
318
+ if (map instanceof OpenlayersMap) {
319
+ impls.push(new VectorOpenlayersImpl(map, this._getTwoDimStaticImplOptions()));
320
+ } else if (map instanceof ObliqueMap) {
321
+ impls.push(new VectorObliqueImpl(map, this._getTwoDimStaticImplOptions()));
322
322
  }
323
323
  }
324
324
  // eslint-disable-next-line max-len
325
- return /** @type {Array<VectorOblique|import("@vcmap/core").VectorCesium|VectorOpenlayers|CesiumTilesetCesium>} */ (impls);
325
+ return /** @type {Array<VectorObliqueImpl|import("@vcmap/core").VectorCesiumImpl|VectorOpenlayersImpl|CesiumTilesetCesiumImpl>} */ (impls);
326
326
  }
327
327
 
328
328
  /**
@@ -371,7 +371,7 @@ class FeatureStore extends Vector {
371
371
 
372
372
  /**
373
373
  * @inheritDoc
374
- * @param {string|import("ol/style/Style").default|import("ol/style/Style").StyleFunction|import("@vcmap/core").StyleItem} style
374
+ * @param {import("ol/style/Style").default|import("ol/style/Style").StyleFunction|import("@vcmap/core").StyleItem} style
375
375
  * @param {boolean=} silent
376
376
  * @api
377
377
  */
@@ -409,7 +409,7 @@ class FeatureStore extends Vector {
409
409
  */
410
410
  setEditing(symbol, featureType) {
411
411
  this.getImplementations().forEach((impl) => {
412
- if (impl instanceof CesiumTilesetCesium) {
412
+ if (impl instanceof CesiumTilesetCesiumImpl) {
413
413
  if (impl.initialized) {
414
414
  if (featureType != null) {
415
415
  impl.cesium3DTileset[symbol] = featureType;
@@ -447,7 +447,7 @@ class FeatureStore extends Vector {
447
447
  */
448
448
  objectClickedHandler(feature) {
449
449
  if ((feature instanceof Cesium3DTileFeature || feature instanceof Cesium3DTilePointFeature)) {
450
- return CesiumTileset.prototype.objectClickedHandler.call(this, feature);
450
+ return CesiumTilesetLayer.prototype.objectClickedHandler.call(this, feature);
451
451
  } else if (feature instanceof Feature) {
452
452
  return super.objectClickedHandler(feature);
453
453
  }
@@ -463,7 +463,7 @@ class FeatureStore extends Vector {
463
463
  // @ts-ignore
464
464
  return super.getGenericFeatureFromClickedObject(/** @type {VectorClickedObject} */ (object));
465
465
  }
466
- const generic = CesiumTileset.prototype.getGenericFeatureFromClickedObject.call(this, object);
466
+ const generic = CesiumTilesetLayer.prototype.getGenericFeatureFromClickedObject.call(this, object);
467
467
  generic.layerName = this.name;
468
468
  generic.layerClass = this.className;
469
469
  return generic;
@@ -481,9 +481,9 @@ class FeatureStore extends Vector {
481
481
  const extent = super.getZoomToExtent();
482
482
  const mercatorExtent = extent ? extent.getCoordinatesInProjection(mercatorProjection) : createEmpty();
483
483
  if (this.staticRepresentation.threeDim) {
484
- const threeDImpl = /** @type {CesiumTilesetCesium} */ (this.getImplementations()
484
+ const threeDImpl = /** @type {CesiumTilesetCesiumImpl} */ (this.getImplementations()
485
485
  .find((impl) => {
486
- return impl instanceof CesiumTilesetCesium && impl.cesium3DTileset;
486
+ return impl instanceof CesiumTilesetCesiumImpl && impl.cesium3DTileset;
487
487
  }));
488
488
 
489
489
  if (threeDImpl) {
@@ -497,7 +497,7 @@ class FeatureStore extends Vector {
497
497
  }
498
498
 
499
499
  const actualExtent = new Extent({
500
- ...mercatorProjection.getConfigObject(),
500
+ projection: mercatorProjection.toJSON(),
501
501
  coordinates: mercatorExtent,
502
502
  });
503
503
 
@@ -522,7 +522,7 @@ class FeatureStore extends Vector {
522
522
 
523
523
  this.getImplementations()
524
524
  .forEach((impl) => {
525
- if (impl instanceof CesiumTilesetCesium && impl.cesium3DTileset) {
525
+ if (impl instanceof CesiumTilesetCesiumImpl && impl.cesium3DTileset) {
526
526
  impl.cesium3DTileset.maximumScreenSpaceError = value;
527
527
  }
528
528
  });
@@ -530,7 +530,7 @@ class FeatureStore extends Vector {
530
530
 
531
531
  /**
532
532
  * switch an array of static features to dynamic features
533
- * This is done by hiding the static features and adding their dynamic counterparts to the FeatureStore layer
533
+ * This is done by hiding the static features and adding their dynamic counterparts to the FeatureStoreLayer layer
534
534
  * @param {string|number} [featureId] input static feature ID
535
535
  * @returns {Promise<import("ol").Feature<import("ol/geom/Geometry").default>>}
536
536
  * @api
@@ -573,7 +573,7 @@ class FeatureStore extends Vector {
573
573
  this.hiddenStaticFeatureIds.add(featureId);
574
574
  const feature = new Feature();
575
575
  feature.setId(featureId);
576
- feature[featureStoreStateSymbol] = featureStoreState.STATIC;
576
+ feature[featureStoreStateSymbol] = FeatureStoreLayerState.STATIC;
577
577
  this.changeTracker.removeFeature(feature);
578
578
  }
579
579
 
@@ -596,9 +596,9 @@ class FeatureStore extends Vector {
596
596
  * @inheritDoc
597
597
  * @returns {FeatureStoreOptions}
598
598
  */
599
- getConfigObject() {
600
- const config = /** @type {FeatureStoreOptions} */ (super.getConfigObject());
601
- const defaultOptions = FeatureStore.getDefaultOptions();
599
+ toJSON() {
600
+ const config = /** @type {FeatureStoreOptions} */ (super.toJSON());
601
+ const defaultOptions = FeatureStoreLayer.getDefaultOptions();
602
602
 
603
603
  delete config.projection;
604
604
  config.vcsMeta = this.vectorProperties
@@ -643,5 +643,5 @@ class FeatureStore extends Vector {
643
643
  }
644
644
  }
645
645
 
646
- VcsClassRegistry.registerClass(FeatureStore.className, FeatureStore);
647
- export default FeatureStore;
646
+ layerClassRegistry.registerClass(FeatureStoreLayer.className, FeatureStoreLayer);
647
+ export default FeatureStoreLayer;
@@ -1,10 +1,10 @@
1
- import axios from 'axios';
2
1
  import { unByKey } from 'ol/Observable.js';
3
2
  import Feature from 'ol/Feature.js';
4
3
  import { check } from '@vcsuite/check';
5
- import { featureStoreState, featureStoreStateSymbol } from './featureStoreState.js';
4
+ import { FeatureStoreLayerState, featureStoreStateSymbol } from './featureStoreLayerState.js';
6
5
  import { parseGeoJSON, writeGeoJSONFeature } from './geojsonHelpers.js';
7
- import VcsObject from '../object.js';
6
+ import VcsObject from '../vcsObject.js';
7
+ import { requestJson } from '../util/fetch.js';
8
8
 
9
9
  /**
10
10
  * @typedef {Object} FeatureStoreTrackResults
@@ -26,22 +26,81 @@ import VcsObject from '../object.js';
26
26
  * @property {boolean} changed
27
27
  */
28
28
 
29
+ /**
30
+ * @typedef {Object} CommitAction
31
+ * @property {string} action
32
+ * @property {import("ol/format/GeoJSON").GeoJSONFeature} feature
33
+ * @property {import("ol").Feature<import("ol/geom/Geometry").default>} original
34
+ * @property {function(string=):void} success
35
+ */
36
+
37
+ /**
38
+ * @param {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} added
39
+ * @param {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} edited
40
+ * @param {Set<import("ol").Feature<import("ol/geom/Geometry").default>>} removed
41
+ * @returns {Array<CommitAction>}
42
+ * @private
43
+ */
44
+ export function createCommitActions(added, edited, removed) {
45
+ const actions = [];
46
+ added.forEach((f) => {
47
+ const feature = writeGeoJSONFeature(f, { writeStyle: true });
48
+ actions.push({
49
+ action: 'add',
50
+ feature,
51
+ original: f,
52
+ success(data) {
53
+ f.setId(data);
54
+ f[featureStoreStateSymbol] = FeatureStoreLayerState.DYNAMIC;
55
+ },
56
+ });
57
+ });
58
+
59
+ edited.forEach((f) => {
60
+ const feature = writeGeoJSONFeature(f, { writeStyle: true });
61
+ feature._id = f.getId();
62
+ feature.geomety = 'test'; // XXX why test???
63
+ actions.push({
64
+ action: 'edit',
65
+ original: f,
66
+ feature,
67
+ success() {
68
+ if (f[featureStoreStateSymbol] === FeatureStoreLayerState.STATIC) {
69
+ f[featureStoreStateSymbol] = FeatureStoreLayerState.EDITED;
70
+ }
71
+ },
72
+ });
73
+ });
74
+
75
+ removed.forEach((f) => {
76
+ const _id = f.getId();
77
+ actions.push({
78
+ original: f,
79
+ action: 'remove',
80
+ feature: { _id },
81
+ success() {},
82
+ });
83
+ });
84
+
85
+ return actions;
86
+ }
87
+
29
88
  /**
30
89
  * do not construct directly, use the layers .changeTracker instead
31
90
  * @class
32
91
  * @extends {VcsObject}
33
92
  * @api
34
93
  */
35
- class FeatureStoreChanges extends VcsObject {
36
- static get className() { return 'vcs.vcm.layer.FeatureStoreChanges'; }
94
+ class FeatureStoreLayerChanges extends VcsObject {
95
+ static get className() { return 'FeatureStoreLayerChanges'; }
37
96
 
38
97
  /**
39
- * @param {import("@vcmap/core").FeatureStore} layer
98
+ * @param {import("@vcmap/core").FeatureStoreLayer} layer
40
99
  */
41
100
  constructor(layer) {
42
101
  super({});
43
102
 
44
- /** @type {import("@vcmap/core").FeatureStore} */
103
+ /** @type {import("@vcmap/core").FeatureStoreLayer} */
45
104
  this.layer = layer;
46
105
  /** @type {FeatureStoreChangesListeners} */
47
106
  this._changesListeners = {
@@ -107,85 +166,42 @@ class FeatureStoreChanges extends VcsObject {
107
166
  * @returns {Promise<void>}
108
167
  * @api
109
168
  */
110
- commitChanges(url) {
111
- const actions = [];
112
- this._addedFeatures.forEach((f) => {
113
- const feature = writeGeoJSONFeature(f, { writeStyle: true });
114
- actions.push({
115
- action: 'add',
116
- feature,
117
- original: f,
118
- success(data) {
119
- f.setId(data);
120
- f[featureStoreStateSymbol] = featureStoreState.DYNAMIC;
169
+ async commitChanges(url) {
170
+ const actions = createCommitActions(this._addedFeatures, this._editedFeatures, this._removedFeatures);
171
+ if (actions.length > 0) {
172
+ const data = await requestJson(url.toString(), {
173
+ method: 'POST',
174
+ headers: {
175
+ 'Content-Type': 'application/json',
121
176
  },
177
+ body: JSON.stringify(actions.map(a => ({ action: a.action, feature: a.feature }))),
122
178
  });
123
- });
124
179
 
125
- this._editedFeatures.forEach((f) => {
126
- const feature = writeGeoJSONFeature(f, { writeStyle: true });
127
- feature._id = f.getId();
128
- feature.geomety = 'test';
129
- actions.push({
130
- action: 'edit',
131
- original: f,
132
- feature,
133
- success() {
134
- if (f[featureStoreStateSymbol] === featureStoreState.STATIC) {
135
- f[featureStoreStateSymbol] = featureStoreState.EDITED;
136
- }
137
- },
180
+ const failures = data.failedActions.map(({ index, error }) => {
181
+ const action = actions[index];
182
+ this.getLogger().log(`failed action ${action.action}: ${error}`);
183
+ actions[index] = null;
184
+ return this._resetFeature(action.original);
138
185
  });
139
- });
140
186
 
141
- this._removedFeatures.forEach((f) => {
142
- const _id = f.getId();
143
- actions.push({
144
- original: f,
145
- action: 'remove',
146
- feature: { _id },
147
- success() {},
148
- });
149
- });
150
- /** @type {Promise<void>} */
151
- let promise = Promise.resolve();
152
- if (actions.length) {
153
- // @ts-ignore
154
- promise = axios.post(url.toString(), actions.map(a => ({ action: a.action, feature: a.feature })))
155
- .then(({ data }) => {
156
- const failures = data.failedActions.map(({ index, error }) => {
157
- const action = actions[index];
158
- this.getLogger().log(`failed action ${action.action}: ${error}`);
159
- actions[index] = null;
160
- return this._resetFeature(action.original);
161
- });
162
-
163
- actions
164
- .filter(a => a)
165
- .forEach(({ action, success }) => {
166
- if (action === 'add') {
167
- success(data.insertedIds.shift()._id); // XXX should this be shift or should we find the index?
168
- } else {
169
- success();
170
- }
171
- });
172
- return Promise.all(failures);
187
+ actions
188
+ .filter(a => a)
189
+ .forEach(({ action, success }) => {
190
+ if (action === 'add') {
191
+ success(data.insertedIds.shift()._id); // XXX should this be shift or should we find the index?
192
+ } else {
193
+ success();
194
+ }
173
195
  });
174
- }
175
-
176
- return promise
177
- .then(() => {
178
- const promises = [];
179
- this._convertedFeatures.forEach((f) => { promises.push(this._resetFeature(f)); });
180
- return Promise.all(promises);
181
- })
182
- .then(() => {
183
- this._resetValues();
184
- })
185
- .catch((err) => {
186
- this._resetValues();
196
+ await Promise.all(failures);
197
+ } else {
198
+ try {
199
+ await Promise.all([...this._convertedFeatures].map(async (f) => { await this._resetFeature(f); }));
200
+ } catch (err) {
187
201
  this.getLogger().error(err.message);
188
- });
202
+ }
203
+ this._resetValues();
204
+ }
189
205
  }
190
206
 
191
207
  /**
@@ -222,7 +238,7 @@ class FeatureStoreChanges extends VcsObject {
222
238
  return Promise.resolve();
223
239
  }
224
240
 
225
- if (feature[featureStoreStateSymbol] === featureStoreState.STATIC) {
241
+ if (feature[featureStoreStateSymbol] === FeatureStoreLayerState.STATIC) {
226
242
  this.layer.resetStaticFeature(featureId);
227
243
  return Promise.resolve();
228
244
  }
@@ -279,7 +295,7 @@ class FeatureStoreChanges extends VcsObject {
279
295
  if (!feature[featureStoreStateSymbol]) {
280
296
  this._addedFeatures.add(feature);
281
297
  this.values.changed = true;
282
- } else if (feature[featureStoreStateSymbol] === featureStoreState.STATIC) {
298
+ } else if (feature[featureStoreStateSymbol] === FeatureStoreLayerState.STATIC) {
283
299
  this._convertedFeatures.add(feature);
284
300
  this.values.changed = true;
285
301
  }
@@ -357,4 +373,4 @@ class FeatureStoreChanges extends VcsObject {
357
373
  }
358
374
  }
359
375
 
360
- export default FeatureStoreChanges;
376
+ export default FeatureStoreLayerChanges;
@@ -10,9 +10,8 @@ export const featureStoreStateSymbol = Symbol('vcsFeatureType');
10
10
  * @property {string} STATIC
11
11
  * @property {string} EDITED
12
12
  * @api
13
- * @export
14
13
  */
15
- export const featureStoreState = {
14
+ export const FeatureStoreLayerState = {
16
15
  DYNAMIC: 'dynamic',
17
16
  STATIC: 'static',
18
17
  EDITED: 'edited',
@@ -2,9 +2,9 @@ import { Color, Cesium3DTileFeature, Cesium3DTilePointFeature, Entity as CesiumE
2
2
  import Feature from 'ol/Feature.js';
3
3
  import Style from 'ol/style/Style.js';
4
4
 
5
- import VectorStyleItem, { fromCesiumColor } from '../util/style/vectorStyleItem.js';
6
- import { emptyStyle } from '../util/style/styleHelpers.js';
7
- import VcsEvent from '../event/vcsEvent.js';
5
+ import VectorStyleItem, { fromCesiumColor } from '../style/vectorStyleItem.js';
6
+ import { emptyStyle } from '../style/styleHelpers.js';
7
+ import VcsEvent from '../vcsEvent.js';
8
8
 
9
9
  /**
10
10
  * Set on an ol.Feature or Cesium.Cesium3DTileFeature to indicate its style before it was hidden or highlighted.
@@ -181,7 +181,6 @@ export function showFeature(feature, symbol) {
181
181
  /**
182
182
  * Enumeration of feature visibility actions.
183
183
  * @enum {number}
184
- * @export
185
184
  * @api
186
185
  * @property {number} HIGHLIGHT
187
186
  * @property {number} UNHIGHLIGHT
@@ -232,6 +231,9 @@ export function synchronizeFeatureVisibility(source, destination) {
232
231
  }
233
232
 
234
233
  /**
234
+ * FeatureVisibility handles the visibility and highlighting of features of a specific {@link FeatureLayer} or {@link DataSourceLayer}
235
+ * and its {@link FeatureLayerImplementation} resp. {@link DataSourceCesiumImpl}.
236
+ * The visibility is being synchronized with the {@link GlobalHider}.
235
237
  * @class
236
238
  */
237
239
  class FeatureVisibility {
@@ -264,8 +266,9 @@ class FeatureVisibility {
264
266
  usedStyle = fromCesiumColor(style);
265
267
  } else if (style instanceof Style) {
266
268
  usedStyle = new VectorStyleItem({});
267
- if (style.getText() && style.getText().getText()) {
268
- usedStyle.label = style.getText().getText();
269
+ if (style.getText() && style.getText().getText() && !Array.isArray(style.getText().getText())) {
270
+ // getText can return a rich Text Array<string> We do not support this at the moment.
271
+ usedStyle.label = String(style.getText().getText());
269
272
  }
270
273
  usedStyle.style = style;
271
274
  }