@vcmap/core 5.0.0-rc.28 → 5.0.0-rc.29

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 (191) hide show
  1. package/README.md +9 -3
  2. package/build/postinstall.js +13 -2
  3. package/index.d.ts +155 -106
  4. package/package.json +9 -4
  5. package/src/category/category.js +71 -32
  6. package/src/category/categoryCollection.js +27 -18
  7. package/src/cesium/cesiumVcsCameraPrimitive.js +13 -5
  8. package/src/cesium/entity.js +3 -1
  9. package/src/cesium/wallpaperMaterial.js +4 -2
  10. package/src/classRegistry.js +11 -4
  11. package/src/featureProvider/abstractFeatureProvider.js +43 -22
  12. package/src/featureProvider/tileProviderFeatureProvider.js +11 -5
  13. package/src/featureProvider/wmsFeatureProvider.js +37 -15
  14. package/src/interaction/abstractInteraction.js +5 -1
  15. package/src/interaction/coordinateAtPixel.js +34 -12
  16. package/src/interaction/eventHandler.js +63 -23
  17. package/src/interaction/featureAtPixelInteraction.js +96 -32
  18. package/src/interaction/featureProviderInteraction.js +23 -8
  19. package/src/interaction/interactionChain.js +19 -9
  20. package/src/interaction/interactionType.js +23 -26
  21. package/src/layer/cesium/cesiumTilesetCesiumImpl.js +45 -15
  22. package/src/layer/cesium/clusterContext.js +10 -3
  23. package/src/layer/cesium/dataSourceCesiumImpl.js +13 -4
  24. package/src/layer/cesium/openStreetMapCesiumImpl.js +7 -3
  25. package/src/layer/cesium/rasterLayerCesiumImpl.js +6 -2
  26. package/src/layer/cesium/singleImageCesiumImpl.js +14 -3
  27. package/src/layer/cesium/terrainCesiumImpl.js +3 -2
  28. package/src/layer/cesium/tmsCesiumImpl.js +15 -3
  29. package/src/layer/cesium/vectorCesiumImpl.js +69 -25
  30. package/src/layer/cesium/vectorContext.js +25 -5
  31. package/src/layer/cesium/vectorRasterTileCesiumImpl.js +15 -5
  32. package/src/layer/cesium/vectorTileImageryProvider.js +51 -13
  33. package/src/layer/cesium/wmsCesiumImpl.js +15 -3
  34. package/src/layer/cesium/wmtsCesiumImpl.js +18 -6
  35. package/src/layer/cesium/x3dmHelper.js +4 -1
  36. package/src/layer/cesiumTilesetLayer.js +55 -26
  37. package/src/layer/czmlLayer.js +11 -5
  38. package/src/layer/dataSourceLayer.js +25 -17
  39. package/src/layer/featureLayer.js +33 -18
  40. package/src/layer/featureStoreLayer.js +161 -99
  41. package/src/layer/featureStoreLayerChanges.js +57 -17
  42. package/src/layer/featureVisibility.js +89 -59
  43. package/src/layer/geojsonHelpers.js +70 -29
  44. package/src/layer/geojsonLayer.js +17 -11
  45. package/src/layer/globalHider.js +14 -4
  46. package/src/layer/layer.js +77 -44
  47. package/src/layer/layerImplementation.js +12 -4
  48. package/src/layer/oblique/layerObliqueImpl.js +3 -1
  49. package/src/layer/oblique/obliqueHelpers.js +75 -30
  50. package/src/layer/oblique/vectorObliqueImpl.js +175 -69
  51. package/src/layer/openStreetMapLayer.js +34 -20
  52. package/src/layer/openlayers/layerOpenlayersImpl.js +37 -15
  53. package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +3 -1
  54. package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +3 -1
  55. package/src/layer/openlayers/singleImageOpenlayersImpl.js +3 -1
  56. package/src/layer/openlayers/tileDebugOpenlayersImpl.js +3 -1
  57. package/src/layer/openlayers/tmsOpenlayersImpl.js +6 -3
  58. package/src/layer/openlayers/vectorOpenlayersImpl.js +14 -4
  59. package/src/layer/openlayers/vectorTileOpenlayersImpl.js +12 -5
  60. package/src/layer/openlayers/wmsOpenlayersImpl.js +3 -1
  61. package/src/layer/openlayers/wmtsOpenlayersImpl.js +12 -5
  62. package/src/layer/pointCloudLayer.js +21 -10
  63. package/src/layer/rasterLayer.js +73 -22
  64. package/src/layer/singleImageLayer.js +10 -7
  65. package/src/layer/terrainHelpers.js +30 -19
  66. package/src/layer/terrainLayer.js +16 -7
  67. package/src/layer/tileLoadedHelper.js +9 -4
  68. package/src/layer/tileProvider/mvtTileProvider.js +10 -4
  69. package/src/layer/tileProvider/staticGeojsonTileProvider.js +10 -4
  70. package/src/layer/tileProvider/tileProvider.js +163 -87
  71. package/src/layer/tileProvider/urlTemplateTileProvider.js +10 -4
  72. package/src/layer/tmsLayer.js +7 -6
  73. package/src/layer/vectorHelpers.js +34 -25
  74. package/src/layer/vectorLayer.js +77 -36
  75. package/src/layer/vectorProperties.js +245 -74
  76. package/src/layer/vectorSymbols.js +3 -1
  77. package/src/layer/vectorTileLayer.js +121 -70
  78. package/src/layer/wfsLayer.js +19 -8
  79. package/src/layer/wmsHelpers.js +11 -6
  80. package/src/layer/wmsLayer.js +36 -14
  81. package/src/layer/wmtsLayer.js +35 -20
  82. package/src/map/baseOLMap.js +57 -31
  83. package/src/map/cameraLimiter.js +67 -18
  84. package/src/map/cesiumMap.js +307 -95
  85. package/src/map/obliqueMap.js +84 -34
  86. package/src/map/openlayersMap.js +40 -19
  87. package/src/map/vcsMap.js +21 -8
  88. package/src/oblique/helpers.js +212 -64
  89. package/src/oblique/obliqueCollection.js +111 -48
  90. package/src/oblique/obliqueDataSet.js +53 -21
  91. package/src/oblique/obliqueImage.js +50 -17
  92. package/src/oblique/obliqueImageMeta.js +7 -6
  93. package/src/oblique/obliqueProvider.js +75 -27
  94. package/src/oblique/obliqueView.js +18 -7
  95. package/src/oblique/obliqueViewDirection.js +3 -2
  96. package/src/oblique/parseImageJson.js +57 -23
  97. package/src/ol/feature.js +8 -3
  98. package/src/ol/geom/circle.js +12 -3
  99. package/src/ol/geom/geometryCollection.js +11 -4
  100. package/src/ol/render/canvas/canvasTileRenderer.js +11 -9
  101. package/src/overrideClassRegistry.js +13 -3
  102. package/src/style/arcStyle.js +129 -36
  103. package/src/style/arrowStyle.js +57 -22
  104. package/src/style/declarativeStyleItem.js +107 -62
  105. package/src/style/shapesCategory.js +8 -6
  106. package/src/style/styleFactory.js +4 -1
  107. package/src/style/styleHelpers.js +17 -8
  108. package/src/style/styleItem.js +28 -10
  109. package/src/style/vectorStyleItem.js +160 -74
  110. package/src/style/writeStyle.js +5 -7
  111. package/src/util/clipping/clippingObject.js +72 -38
  112. package/src/util/clipping/clippingObjectManager.js +53 -19
  113. package/src/util/clipping/clippingPlaneHelper.js +120 -53
  114. package/src/util/collection.js +12 -6
  115. package/src/util/editor/createFeatureSession.js +21 -6
  116. package/src/util/editor/editFeaturesSession.js +41 -15
  117. package/src/util/editor/editGeometrySession.js +55 -30
  118. package/src/util/editor/editorHelpers.js +114 -29
  119. package/src/util/editor/editorSessionHelpers.js +8 -3
  120. package/src/util/editor/interactions/createBBoxInteraction.js +11 -3
  121. package/src/util/editor/interactions/createCircleInteraction.js +7 -2
  122. package/src/util/editor/interactions/createLineStringInteraction.js +7 -2
  123. package/src/util/editor/interactions/createPolygonInteraction.js +7 -2
  124. package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +7 -5
  125. package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +8 -3
  126. package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +4 -2
  127. package/src/util/editor/interactions/insertVertexInteraction.js +17 -6
  128. package/src/util/editor/interactions/mapInteractionController.js +31 -14
  129. package/src/util/editor/interactions/removeVertexInteraction.js +4 -1
  130. package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +19 -10
  131. package/src/util/editor/interactions/selectMultiFeatureInteraction.js +33 -20
  132. package/src/util/editor/interactions/selectSingleFeatureInteraction.js +14 -8
  133. package/src/util/editor/selectFeaturesSession.js +37 -21
  134. package/src/util/editor/transformation/create2DHandlers.js +82 -37
  135. package/src/util/editor/transformation/create3DHandlers.js +187 -84
  136. package/src/util/editor/transformation/extrudeInteraction.js +20 -5
  137. package/src/util/editor/transformation/rotateInteraction.js +29 -16
  138. package/src/util/editor/transformation/scaleInteraction.js +31 -15
  139. package/src/util/editor/transformation/transformationHandler.js +23 -8
  140. package/src/util/editor/transformation/transformationTypes.js +8 -4
  141. package/src/util/editor/transformation/translateInteraction.js +86 -32
  142. package/src/util/editor/validateGeoemetry.js +3 -1
  143. package/src/util/exclusiveManager.js +6 -3
  144. package/src/util/extent.js +20 -10
  145. package/src/util/featureconverter/arcToCesium.js +46 -12
  146. package/src/util/featureconverter/circleToCesium.js +61 -27
  147. package/src/util/featureconverter/convert.js +85 -13
  148. package/src/util/featureconverter/extent3D.js +69 -28
  149. package/src/util/featureconverter/featureconverterHelper.js +232 -79
  150. package/src/util/featureconverter/lineStringToCesium.js +107 -35
  151. package/src/util/featureconverter/pointHelpers.js +117 -45
  152. package/src/util/featureconverter/pointToCesium.js +128 -31
  153. package/src/util/featureconverter/polygonToCesium.js +50 -16
  154. package/src/util/fetch.js +3 -1
  155. package/src/util/geometryHelpers.js +15 -10
  156. package/src/util/indexedCollection.js +7 -3
  157. package/src/util/isMobile.js +8 -2
  158. package/src/util/layerCollection.js +28 -12
  159. package/src/util/mapCollection.js +37 -18
  160. package/src/util/math.js +35 -19
  161. package/src/util/overrideCollection.js +57 -32
  162. package/src/util/projection.js +21 -5
  163. package/src/util/urlHelpers.js +5 -3
  164. package/src/util/viewpoint.js +66 -33
  165. package/src/vcsApp.js +133 -69
  166. package/src/vcsModule.js +3 -2
  167. package/src/vcsModuleHelpers.js +24 -9
  168. package/src/vcsObject.js +3 -2
  169. package/tests/data/dynamicPointCzml.json +24 -35
  170. package/tests/data/oblique/imageData/imagev34.json +56 -272
  171. package/tests/data/oblique/imageData/imagev35.json +272 -19
  172. package/tests/data/oblique/imageData/imagev35PerImageSize.json +299 -19
  173. package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -1
  174. package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -1
  175. package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -1
  176. package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -1
  177. package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -1
  178. package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -1
  179. package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -1
  180. package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -1
  181. package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -1
  182. package/tests/data/oblique/tiledImageData/image.json +70 -1
  183. package/tests/data/terrain/layer.json +121 -130
  184. package/tests/data/testGeoJSON.json +4 -16
  185. package/tests/unit/helpers/cesiumHelpers.js +58 -33
  186. package/tests/unit/helpers/helpers.js +10 -2
  187. package/tests/unit/helpers/imageHelpers.js +8 -4
  188. package/tests/unit/helpers/obliqueData.js +39 -13
  189. package/tests/unit/helpers/obliqueHelpers.js +12 -9
  190. package/tests/unit/helpers/openlayersHelpers.js +4 -1
  191. package/tests/unit/helpers/terrain/terrainData.js +8 -7
@@ -1,4 +1,9 @@
1
- import { Color, Cesium3DTileFeature, Cesium3DTilePointFeature, Entity as CesiumEntity } from '@vcmap-cesium/engine';
1
+ import {
2
+ Color,
3
+ Cesium3DTileFeature,
4
+ Cesium3DTilePointFeature,
5
+ Entity as CesiumEntity,
6
+ } from '@vcmap-cesium/engine';
2
7
  import Feature from 'ol/Feature.js';
3
8
  import Style from 'ol/style/Style.js';
4
9
 
@@ -51,10 +56,12 @@ export const globalHidden = Symbol('globalHidden');
51
56
  * @returns {boolean}
52
57
  */
53
58
  export function featureExists(feature) {
54
- return feature &&
59
+ return (
60
+ feature &&
55
61
  feature.content &&
56
62
  !feature.content.isDestroyed() &&
57
- !feature.content.batchTable.isDestroyed();
63
+ !feature.content.batchTable.isDestroyed()
64
+ );
58
65
  }
59
66
 
60
67
  /**
@@ -63,10 +70,10 @@ export function featureExists(feature) {
63
70
  */
64
71
  export function hideFeature(feature) {
65
72
  if (
66
- (
67
- (feature instanceof Cesium3DTileFeature || feature instanceof Cesium3DTilePointFeature) &&
68
- featureExists(feature)
69
- ) || feature instanceof CesiumEntity
73
+ ((feature instanceof Cesium3DTileFeature ||
74
+ feature instanceof Cesium3DTilePointFeature) &&
75
+ featureExists(feature)) ||
76
+ feature instanceof CesiumEntity
70
77
  ) {
71
78
  feature.show = false;
72
79
  } else if (feature instanceof Feature) {
@@ -82,7 +89,8 @@ export function hideFeature(feature) {
82
89
  export function cacheOriginalStyle(feature) {
83
90
  if (!Reflect.has(feature, originalStyle)) {
84
91
  if (
85
- (feature instanceof Cesium3DTileFeature || feature instanceof Cesium3DTilePointFeature) &&
92
+ (feature instanceof Cesium3DTileFeature ||
93
+ feature instanceof Cesium3DTilePointFeature) &&
86
94
  featureExists(feature)
87
95
  ) {
88
96
  feature[originalStyle] = feature.color.clone();
@@ -100,7 +108,8 @@ export function resetOriginalStyle(feature) {
100
108
  if (!(feature[globalHidden] || feature[hidden] || feature[highlighted])) {
101
109
  const style = feature[originalStyle];
102
110
  if (
103
- (feature instanceof Cesium3DTileFeature || feature instanceof Cesium3DTilePointFeature) &&
111
+ (feature instanceof Cesium3DTileFeature ||
112
+ feature instanceof Cesium3DTilePointFeature) &&
104
113
  featureExists(feature)
105
114
  ) {
106
115
  feature.color = style;
@@ -119,7 +128,8 @@ export function highlightFeature(feature) {
119
128
  if (!(feature[globalHidden] || feature[hidden])) {
120
129
  const style = feature[highlighted];
121
130
  if (
122
- (feature instanceof Cesium3DTileFeature || feature instanceof Cesium3DTilePointFeature) &&
131
+ (feature instanceof Cesium3DTileFeature ||
132
+ feature instanceof Cesium3DTilePointFeature) &&
123
133
  featureExists(feature)
124
134
  ) {
125
135
  feature.color = style.cesiumFillColor;
@@ -162,10 +172,10 @@ export function showFeature(feature, symbol) {
162
172
 
163
173
  if (!(feature[hidden] || feature[globalHidden])) {
164
174
  if (
165
- (
166
- (feature instanceof Cesium3DTileFeature || feature instanceof Cesium3DTilePointFeature) &&
167
- featureExists(feature)
168
- ) || feature instanceof CesiumEntity
175
+ ((feature instanceof Cesium3DTileFeature ||
176
+ feature instanceof Cesium3DTilePointFeature) &&
177
+ featureExists(feature)) ||
178
+ feature instanceof CesiumEntity
169
179
  ) {
170
180
  feature.show = true;
171
181
  }
@@ -258,41 +268,47 @@ class FeatureVisibility {
258
268
  */
259
269
  highlight(toHighlight) {
260
270
  const updatedIds = [];
261
- Object.entries(toHighlight)
262
- .forEach(([id, style]) => {
263
- let usedStyle = style;
264
- if (style instanceof Color) {
265
- usedStyle = fromCesiumColor(style);
266
- } else if (style instanceof Style) {
267
- usedStyle = new VectorStyleItem({});
268
- if (style.getText() && style.getText().getText() && !Array.isArray(style.getText().getText())) {
269
- // getText can return a rich Text Array<string> We do not support this at the moment.
270
- usedStyle.label = String(style.getText().getText());
271
- }
272
- usedStyle.style = style;
273
- }
274
- // eslint-disable-next-line no-self-assign
275
- usedStyle = /** @type {VectorStyleItem} */ (usedStyle);
276
-
277
- if (!this.highlightedObjects[id]) {
278
- this.highlightedObjects[id] = {
279
- style: usedStyle,
280
- features: new Set(),
281
- };
282
- updatedIds.push(id);
283
- // @ts-ignore
284
- } else if (this.highlightedObjects[id].style !== usedStyle) {
285
- this.highlightedObjects[id].style = usedStyle;
286
- this.highlightedObjects[id].features.forEach((s, feature) => {
287
- feature[highlighted] = usedStyle;
288
- highlightFeature(feature);
289
- });
271
+ Object.entries(toHighlight).forEach(([id, style]) => {
272
+ let usedStyle = style;
273
+ if (style instanceof Color) {
274
+ usedStyle = fromCesiumColor(style);
275
+ } else if (style instanceof Style) {
276
+ usedStyle = new VectorStyleItem({});
277
+ if (
278
+ style.getText() &&
279
+ style.getText().getText() &&
280
+ !Array.isArray(style.getText().getText())
281
+ ) {
282
+ // getText can return a rich Text Array<string> We do not support this at the moment.
283
+ usedStyle.label = String(style.getText().getText());
290
284
  }
291
- });
285
+ usedStyle.style = style;
286
+ }
287
+ // eslint-disable-next-line no-self-assign
288
+ usedStyle = /** @type {VectorStyleItem} */ (usedStyle);
289
+
290
+ if (!this.highlightedObjects[id]) {
291
+ this.highlightedObjects[id] = {
292
+ style: usedStyle,
293
+ features: new Set(),
294
+ };
295
+ updatedIds.push(id);
296
+ // @ts-ignore
297
+ } else if (this.highlightedObjects[id].style !== usedStyle) {
298
+ this.highlightedObjects[id].style = usedStyle;
299
+ this.highlightedObjects[id].features.forEach((s, feature) => {
300
+ feature[highlighted] = usedStyle;
301
+ highlightFeature(feature);
302
+ });
303
+ }
304
+ });
292
305
 
293
306
  if (updatedIds.length > 0) {
294
307
  this.lastUpdated = Date.now();
295
- this.changed.raiseEvent({ action: FeatureVisibilityAction.HIGHLIGHT, ids: updatedIds });
308
+ this.changed.raiseEvent({
309
+ action: FeatureVisibilityAction.HIGHLIGHT,
310
+ ids: updatedIds,
311
+ });
296
312
  }
297
313
  }
298
314
 
@@ -305,17 +321,19 @@ class FeatureVisibility {
305
321
  const updatedIds = [];
306
322
  toUnHighlight.forEach((id) => {
307
323
  if (this.highlightedObjects[id]) {
308
- this.highlightedObjects[id].features
309
- .forEach((f) => {
310
- unhighlightFeature(f);
311
- });
324
+ this.highlightedObjects[id].features.forEach((f) => {
325
+ unhighlightFeature(f);
326
+ });
312
327
  delete this.highlightedObjects[id];
313
328
  updatedIds.push(id);
314
329
  }
315
330
  });
316
331
 
317
332
  if (updatedIds.length > 0) {
318
- this.changed.raiseEvent({ action: FeatureVisibilityAction.UNHIGHLIGHT, ids: updatedIds });
333
+ this.changed.raiseEvent({
334
+ action: FeatureVisibilityAction.UNHIGHLIGHT,
335
+ ids: updatedIds,
336
+ });
319
337
  }
320
338
  }
321
339
 
@@ -333,7 +351,10 @@ class FeatureVisibility {
333
351
  * @returns {boolean}
334
352
  */
335
353
  hasHighlightFeature(id, feature) {
336
- return this.highlightedObjects[id] && this.highlightedObjects[id].features.has(feature);
354
+ return (
355
+ this.highlightedObjects[id] &&
356
+ this.highlightedObjects[id].features.has(feature)
357
+ );
337
358
  }
338
359
 
339
360
  /**
@@ -365,7 +386,10 @@ class FeatureVisibility {
365
386
 
366
387
  if (updatedIds.length > 0) {
367
388
  this.lastUpdated = Date.now();
368
- this.changed.raiseEvent({ action: FeatureVisibilityAction.HIDE, ids: updatedIds });
389
+ this.changed.raiseEvent({
390
+ action: FeatureVisibilityAction.HIDE,
391
+ ids: updatedIds,
392
+ });
369
393
  }
370
394
  }
371
395
 
@@ -378,17 +402,19 @@ class FeatureVisibility {
378
402
  const updatedIds = [];
379
403
  unHide.forEach((id) => {
380
404
  if (this.hiddenObjects[id]) {
381
- this.hiddenObjects[id]
382
- .forEach((f) => {
383
- showFeature(f, hidden);
384
- });
405
+ this.hiddenObjects[id].forEach((f) => {
406
+ showFeature(f, hidden);
407
+ });
385
408
  delete this.hiddenObjects[id];
386
409
  updatedIds.push(id);
387
410
  }
388
411
  });
389
412
 
390
413
  if (updatedIds.length > 0) {
391
- this.changed.raiseEvent({ action: FeatureVisibilityAction.SHOW, ids: updatedIds });
414
+ this.changed.raiseEvent({
415
+ action: FeatureVisibilityAction.SHOW,
416
+ ids: updatedIds,
417
+ });
392
418
  }
393
419
  }
394
420
 
@@ -426,9 +452,13 @@ class FeatureVisibility {
426
452
  * Clears all caches and removes cesium events.
427
453
  */
428
454
  destroy() {
429
- Object.values(this.hiddenObjects).forEach((s) => { s.clear(); });
455
+ Object.values(this.hiddenObjects).forEach((s) => {
456
+ s.clear();
457
+ });
430
458
  this.hiddenObjects = {};
431
- Object.values(this.highlightedObjects).forEach(({ features }) => { features.clear(); });
459
+ Object.values(this.highlightedObjects).forEach(({ features }) => {
460
+ features.clear();
461
+ });
432
462
  this.highlightedObjects = {};
433
463
  this.changed.destroy();
434
464
  }
@@ -6,8 +6,14 @@ import Point from 'ol/geom/Point.js';
6
6
  import Circle from 'ol/geom/Circle.js';
7
7
 
8
8
  import { getDistance as haversineDistance } from 'ol/sphere.js';
9
- import Projection, { mercatorProjection, wgs84Projection } from '../util/projection.js';
10
- import VectorStyleItem, { defaultVectorStyle, vectorStyleSymbol } from '../style/vectorStyleItem.js';
9
+ import Projection, {
10
+ mercatorProjection,
11
+ wgs84Projection,
12
+ } from '../util/projection.js';
13
+ import VectorStyleItem, {
14
+ defaultVectorStyle,
15
+ vectorStyleSymbol,
16
+ } from '../style/vectorStyleItem.js';
11
17
  import { parseColor } from '../style/styleHelpers.js';
12
18
  import VectorLayer from './vectorLayer.js';
13
19
  import { featureStoreStateSymbol } from './featureStoreLayerState.js';
@@ -15,7 +21,11 @@ import { embedIconsInStyle } from '../style/writeStyle.js';
15
21
  import DeclarativeStyleItem from '../style/declarativeStyleItem.js';
16
22
  import { vcsMetaVersion } from './layer.js';
17
23
  import Extent3D from '../util/featureconverter/extent3D.js';
18
- import { circleFromCenterRadius, enforceEndingVertex, removeEndingVertexFromGeometry } from '../util/geometryHelpers.js';
24
+ import {
25
+ circleFromCenterRadius,
26
+ enforceEndingVertex,
27
+ removeEndingVertexFromGeometry,
28
+ } from '../util/geometryHelpers.js';
19
29
 
20
30
  const featureProjection = 'EPSG:3857';
21
31
 
@@ -70,7 +80,6 @@ function getFormat() {
70
80
  * @api
71
81
  */
72
82
 
73
-
74
83
  /**
75
84
  * @param {Object} geojson
76
85
  * @returns {string|null}
@@ -107,7 +116,11 @@ export function updateLegacyFeature(feature) {
107
116
  } else {
108
117
  const extent = Extent3D.fromGeometry(feature.getGeometry());
109
118
  const minHeight = Number.isFinite(extent.minZ) ? extent.minZ : 0;
110
- feature.set('olcs_extrudedHeight', feature.get('extrudedHeight') - minHeight, true);
119
+ feature.set(
120
+ 'olcs_extrudedHeight',
121
+ feature.get('extrudedHeight') - minHeight,
122
+ true,
123
+ );
111
124
  }
112
125
  feature.unset('extrudedHeight', true);
113
126
  }
@@ -142,11 +155,7 @@ function readGeometry(geometryObj, options) {
142
155
  * @todo this could also be done for declarative styles image and conditions could be checked?
143
156
  */
144
157
  function setEmbeddedIcons(object, options) {
145
- if (
146
- object.image &&
147
- object.image.src &&
148
- /^:\d+$/.test(object.image.src)
149
- ) {
158
+ if (object.image && object.image.src && /^:\d+$/.test(object.image.src)) {
150
159
  if (options.embeddedIcons) {
151
160
  object.image.src = options.embeddedIcons[object.image.src.substring(1)];
152
161
  } else {
@@ -217,7 +226,10 @@ function readFeature(featureObj, options) {
217
226
  return null;
218
227
  }
219
228
  const radius = featureObj.geometry.olcs_radius;
220
- let geometry = getFormat().readGeometry(featureObj.geometry, options.formatOptions);
229
+ let geometry = getFormat().readGeometry(
230
+ featureObj.geometry,
231
+ options.formatOptions,
232
+ );
221
233
 
222
234
  if (featureObj.radius && geometry instanceof Point) {
223
235
  const coordinates = geometry.getCoordinates();
@@ -243,7 +255,10 @@ function readFeature(featureObj, options) {
243
255
  }
244
256
  const { properties } = featureObj;
245
257
  if (options.readLegacyStyleOptions && !featureObj.vcsMeta.style) {
246
- featureObj.vcsMeta.style = parseLegacyStyleOptions(properties, geometry.getType());
258
+ featureObj.vcsMeta.style = parseLegacyStyleOptions(
259
+ properties,
260
+ geometry.getType(),
261
+ );
247
262
  }
248
263
  removeEndingVertexFromGeometry(geometry);
249
264
  const feature = new Feature({ ...properties, geometry });
@@ -256,7 +271,10 @@ function readFeature(featureObj, options) {
256
271
  }
257
272
 
258
273
  if (featureObj.vcsMeta.style && !options.dontReadStyle) {
259
- featureObj.vcsMeta.style = setEmbeddedIcons(featureObj.vcsMeta.style, options);
274
+ featureObj.vcsMeta.style = setEmbeddedIcons(
275
+ featureObj.vcsMeta.style,
276
+ options,
277
+ );
260
278
  let styleItem;
261
279
  if (options.defaultStyle) {
262
280
  styleItem = options.defaultStyle
@@ -287,16 +305,18 @@ export function parseGeoJSON(input, readOptions = {}) {
287
305
  const geoJSON = typeof input === 'string' ? JSON.parse(input) : input;
288
306
 
289
307
  const epsgCode = getEPSGCodeFromGeojson(geoJSON);
290
- const defaultDataProjection = epsgCode ? { epsg: epsgCode } : readOptions.dataProjection;
308
+ const defaultDataProjection = epsgCode
309
+ ? { epsg: epsgCode }
310
+ : readOptions.dataProjection;
291
311
  /** @type {GeoJSONinternalReadOptions} */
292
312
  const options = {
293
313
  formatOptions: {
294
- dataProjection: defaultDataProjection ?
295
- defaultDataProjection.epsg :
296
- wgs84Projection.epsg,
297
- featureProjection: readOptions.targetProjection ?
298
- readOptions.targetProjection.epsg :
299
- mercatorProjection.epsg,
314
+ dataProjection: defaultDataProjection
315
+ ? defaultDataProjection.epsg
316
+ : wgs84Projection.epsg,
317
+ featureProjection: readOptions.targetProjection
318
+ ? readOptions.targetProjection.epsg
319
+ : mercatorProjection.epsg,
300
320
  },
301
321
  dontReadStyle: readOptions.dontReadStyle,
302
322
  readLegacyStyleOptions: readOptions.readLegacyStyleOptions,
@@ -321,7 +341,10 @@ export function parseGeoJSON(input, readOptions = {}) {
321
341
  if (geoJSON.vcsMeta.style.type === DeclarativeStyleItem.className) {
322
342
  style = new DeclarativeStyleItem(geoJSON.vcsMeta.style);
323
343
  } else {
324
- geoJSON.vcsMeta.style = setEmbeddedIcons(geoJSON.vcsMeta.style, options);
344
+ geoJSON.vcsMeta.style = setEmbeddedIcons(
345
+ geoJSON.vcsMeta.style,
346
+ options,
347
+ );
325
348
  options.defaultStyle = options.defaultStyle
326
349
  .clone()
327
350
  .assign(new VectorStyleItem(geoJSON.vcsMeta.style));
@@ -329,13 +352,18 @@ export function parseGeoJSON(input, readOptions = {}) {
329
352
  }
330
353
  }
331
354
  return {
332
- features: geoJSON.features.map(f => readFeature(f, options)).filter(f => f),
355
+ features: geoJSON.features
356
+ .map((f) => readFeature(f, options))
357
+ .filter((f) => f),
333
358
  style: geoJSON.vcsMeta.style ? style : undefined,
334
359
  vcsMeta: geoJSON.vcsMeta ? geoJSON.vcsMeta : undefined,
335
360
  };
336
361
  } else if (geoJSON.type === 'Feature') {
337
362
  const feature = readFeature(geoJSON, options);
338
- return { features: feature ? [feature] : [], vcsMeta: geoJSON.vcsMeta ? geoJSON.vcsMeta : undefined };
363
+ return {
364
+ features: feature ? [feature] : [],
365
+ vcsMeta: geoJSON.vcsMeta ? geoJSON.vcsMeta : undefined,
366
+ };
339
367
  } else if (geoJSON.type != null) {
340
368
  return { features: [readGeometry(geoJSON, options)] };
341
369
  }
@@ -348,7 +376,11 @@ export function parseGeoJSON(input, readOptions = {}) {
348
376
  * @param {Array=} embeddedIcons
349
377
  * @returns {Object}
350
378
  */
351
- export function writeGeoJSONFeature(feature, options = {}, embeddedIcons) {
379
+ export function writeGeoJSONFeature(
380
+ feature,
381
+ options = {},
382
+ embeddedIcons = undefined,
383
+ ) {
352
384
  const featureObject = {
353
385
  type: 'Feature',
354
386
  properties: feature.getProperties(),
@@ -373,12 +405,16 @@ export function writeGeoJSONFeature(feature, options = {}, embeddedIcons) {
373
405
  geometry = new Point(geometry.getCenter());
374
406
  } else if (geometry instanceof Polygon) {
375
407
  const coordinates = geometry.getCoordinates();
376
- coordinates.forEach((ring) => { enforceEndingVertex(ring); });
408
+ coordinates.forEach((ring) => {
409
+ enforceEndingVertex(ring);
410
+ });
377
411
  geometry.setCoordinates(coordinates);
378
412
  } else if (geometry instanceof MultiPolygon) {
379
413
  const coordinates = geometry.getCoordinates();
380
414
  coordinates.forEach((poly) => {
381
- poly.forEach((ring) => { enforceEndingVertex(ring); });
415
+ poly.forEach((ring) => {
416
+ enforceEndingVertex(ring);
417
+ });
382
418
  });
383
419
  geometry.setCoordinates(coordinates);
384
420
  }
@@ -410,15 +446,20 @@ export function writeGeoJSONFeature(feature, options = {}, embeddedIcons) {
410
446
  * @param {GeoJSONwriteOptions=} options
411
447
  * @returns {string|Object}
412
448
  */
413
- export function writeGeoJSON(data, options = {}) { // how to handel embedded icons when they are not set on the vcsMeta but options is true?
449
+ export function writeGeoJSON(data, options = {}) {
450
+ // how to handel embedded icons when they are not set on the vcsMeta but options is true?
414
451
  const vcsMeta = data.vcsMeta || {};
415
452
  vcsMeta.version = vcsMetaVersion;
416
- const featureObjs = data.features.map(feature => writeGeoJSONFeature(feature, options, vcsMeta.embeddedIcons));
453
+ const featureObjs = data.features.map((feature) =>
454
+ writeGeoJSONFeature(feature, options, vcsMeta.embeddedIcons),
455
+ );
417
456
  const obj = {
418
457
  type: 'FeatureCollection',
419
458
  features: featureObjs,
420
459
  vcsMeta,
421
460
  };
422
461
 
423
- return options.asObject ? obj : JSON.stringify(obj, null, options.prettyPrint ? 2 : null);
462
+ return options.asObject
463
+ ? obj
464
+ : JSON.stringify(obj, null, options.prettyPrint ? 2 : null);
424
465
  }
@@ -16,7 +16,6 @@ import { requestJson } from '../util/fetch.js';
16
16
  */
17
17
  export const featureFromOptions = Symbol('featureFromOptions');
18
18
 
19
-
20
19
  /**
21
20
  * GeojsonLayer layer for Cesium, OpenlayersMap and ObliqueMap
22
21
  * @class
@@ -24,7 +23,9 @@ export const featureFromOptions = Symbol('featureFromOptions');
24
23
  * @api stable
25
24
  */
26
25
  class GeoJSONLayer extends VectorLayer {
27
- static get className() { return 'GeoJSONLayer'; }
26
+ static get className() {
27
+ return 'GeoJSONLayer';
28
+ }
28
29
 
29
30
  /**
30
31
  * @returns {GeoJSONOptions}
@@ -75,7 +76,9 @@ class GeoJSONLayer extends VectorLayer {
75
76
  */
76
77
  async reload() {
77
78
  if (this._dataFetchedPromise) {
78
- const configFeatures = this.getFeatures().filter(f => f[featureFromOptions]);
79
+ const configFeatures = this.getFeatures().filter(
80
+ (f) => f[featureFromOptions],
81
+ );
79
82
  this.removeAllFeatures();
80
83
  this.source.addFeatures(configFeatures);
81
84
  this._dataFetchedPromise = null;
@@ -100,10 +103,9 @@ class GeoJSONLayer extends VectorLayer {
100
103
  features: this._featuresToLoad,
101
104
  });
102
105
 
103
- this.getFeatures()
104
- .forEach((f) => {
105
- f[featureFromOptions] = true;
106
- });
106
+ this.getFeatures().forEach((f) => {
107
+ f[featureFromOptions] = true;
108
+ });
107
109
 
108
110
  this._featuresToLoad.splice(0);
109
111
  this._featuresToLoad = undefined;
@@ -111,9 +113,11 @@ class GeoJSONLayer extends VectorLayer {
111
113
 
112
114
  if (this.url) {
113
115
  this._dataFetchedPromise = requestJson(this.url)
114
- .then(data => this._parseGeojsonData(data))
116
+ .then((data) => this._parseGeojsonData(data))
115
117
  .catch((err) => {
116
- this.getLogger().warning(`Could not send request for loading layer content (${err.message})`);
118
+ this.getLogger().warning(
119
+ `Could not send request for loading layer content (${err.message})`,
120
+ );
117
121
  return Promise.reject(err);
118
122
  });
119
123
  } else {
@@ -160,9 +164,11 @@ class GeoJSONLayer extends VectorLayer {
160
164
  if (Array.isArray(this._featuresToLoad)) {
161
165
  config.features = this._featuresToLoad.slice();
162
166
  } else {
163
- const features = this.getFeatures().filter(f => f[featureFromOptions]);
167
+ const features = this.getFeatures().filter((f) => f[featureFromOptions]);
164
168
  if (features.length > 0) {
165
- config.features = features.map(f => writeGeoJSONFeature(f, { writeStyle: true, writeId: true }));
169
+ config.features = features.map((f) =>
170
+ writeGeoJSONFeature(f, { writeStyle: true, writeId: true }),
171
+ );
166
172
  }
167
173
  }
168
174
 
@@ -65,7 +65,10 @@ class GlobalHider {
65
65
 
66
66
  if (updatedIds.length > 0) {
67
67
  this.lastUpdated = Date.now();
68
- this.changed.raiseEvent({ action: FeatureVisibilityAction.HIDE, ids: updatedIds });
68
+ this.changed.raiseEvent({
69
+ action: FeatureVisibilityAction.HIDE,
70
+ ids: updatedIds,
71
+ });
69
72
  }
70
73
  }
71
74
 
@@ -95,7 +98,10 @@ class GlobalHider {
95
98
  });
96
99
 
97
100
  if (updatedIds.length > 0) {
98
- this.changed.raiseEvent({ action: FeatureVisibilityAction.SHOW, ids: updatedIds });
101
+ this.changed.raiseEvent({
102
+ action: FeatureVisibilityAction.SHOW,
103
+ ids: updatedIds,
104
+ });
99
105
  }
100
106
  }
101
107
 
@@ -119,12 +125,16 @@ class GlobalHider {
119
125
  * @returns {boolean}
120
126
  */
121
127
  hasFeature(uuid, feature) {
122
- return this._hiddenObjectFeatures[uuid] ? this._hiddenObjectFeatures[uuid].has(feature) : false;
128
+ return this._hiddenObjectFeatures[uuid]
129
+ ? this._hiddenObjectFeatures[uuid].has(feature)
130
+ : false;
123
131
  }
124
132
 
125
133
  destroy() {
126
134
  this.hiddenObjects = {};
127
- Object.values(this._hiddenObjectFeatures).forEach((set) => { set.clear(); });
135
+ Object.values(this._hiddenObjectFeatures).forEach((set) => {
136
+ set.clear();
137
+ });
128
138
  this._hiddenObjectFeatures = {};
129
139
  this.changed.destroy();
130
140
  }