@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
@@ -62,7 +62,7 @@ class Collection {
62
62
  this.removed = new VcsEvent();
63
63
  }
64
64
 
65
- * [Symbol.iterator]() {
65
+ *[Symbol.iterator]() {
66
66
  const arrayLength = this._array.length;
67
67
  for (let i = 0; i < arrayLength; i++) {
68
68
  yield this._array[i];
@@ -75,14 +75,18 @@ class Collection {
75
75
  * @type {string|symbol}
76
76
  * @api
77
77
  */
78
- get uniqueKey() { return this._uniqueKey; }
78
+ get uniqueKey() {
79
+ return this._uniqueKey;
80
+ }
79
81
 
80
82
  /**
81
83
  * @readonly
82
84
  * @type {number}
83
85
  * @api
84
86
  */
85
- get size() { return this._array.length; }
87
+ get size() {
88
+ return this._array.length;
89
+ }
86
90
 
87
91
  /**
88
92
  * Returns an item identified by the unique constraint key. Returns null, if there is no uniqueness constraint.
@@ -94,7 +98,7 @@ class Collection {
94
98
  if (!this._uniqueKey) {
95
99
  return undefined;
96
100
  }
97
- return this._array.find(e => e[this._uniqueKey] === value);
101
+ return this._array.find((e) => e[this._uniqueKey] === value);
98
102
  }
99
103
 
100
104
  /**
@@ -180,7 +184,7 @@ class Collection {
180
184
  if (!this._uniqueKey) {
181
185
  return undefined;
182
186
  }
183
- return this._array.some(e => e[this._uniqueKey] === value);
187
+ return this._array.some((e) => e[this._uniqueKey] === value);
184
188
  }
185
189
 
186
190
  /**
@@ -188,7 +192,9 @@ class Collection {
188
192
  * @api
189
193
  */
190
194
  clear() {
191
- this._array.forEach((i) => { this.removed.raiseEvent(i); });
195
+ this._array.forEach((i) => {
196
+ this.removed.raiseEvent(i);
197
+ });
192
198
  this._array.splice(0);
193
199
  }
194
200
 
@@ -1,7 +1,11 @@
1
1
  import { check } from '@vcsuite/check';
2
2
  import { Feature } from 'ol';
3
3
  import VcsEvent from '../../vcsEvent.js';
4
- import { GeometryType, SessionType, setupInteractionChain } from './editorSessionHelpers.js';
4
+ import {
5
+ GeometryType,
6
+ SessionType,
7
+ setupInteractionChain,
8
+ } from './editorSessionHelpers.js';
5
9
  import CreateLineStringInteraction from './interactions/createLineStringInteraction.js';
6
10
  import CreateCircleInteraction from './interactions/createCircleInteraction.js';
7
11
  import CreateBBoxInteraction from './interactions/createBBoxInteraction.js';
@@ -9,7 +13,10 @@ import CreatePointInteraction from './interactions/createPointInteraction.js';
9
13
  import CreatePolygonInteraction from './interactions/createPolygonInteraction.js';
10
14
  import VcsApp from '../../vcsApp.js';
11
15
  import VectorLayer from '../../layer/vectorLayer.js';
12
- import { createSync } from '../../layer/vectorSymbols.js';
16
+ import {
17
+ alreadyTransformedToMercator,
18
+ createSync,
19
+ } from '../../layer/vectorSymbols.js';
13
20
  import geometryIsValid from './validateGeoemetry.js';
14
21
  import ObliqueMap from '../../map/obliqueMap.js';
15
22
 
@@ -74,7 +81,9 @@ function startCreateFeatureSession(app, layer, geometryType) {
74
81
  currentInteraction.destroy();
75
82
  currentInteraction = null;
76
83
  }
77
- interactionListeners.forEach((cb) => { cb(); });
84
+ interactionListeners.forEach((cb) => {
85
+ cb();
86
+ });
78
87
  interactionListeners = [];
79
88
  };
80
89
 
@@ -98,6 +107,7 @@ function startCreateFeatureSession(app, layer, geometryType) {
98
107
  /** @type {ObliqueMap} */ (app.maps.activeMap).switchEnabled = false;
99
108
  }
100
109
  currentFeature = new Feature({ geometry });
110
+ currentFeature[alreadyTransformedToMercator] = true;
101
111
  currentFeature[createSync] = true;
102
112
  layer.addFeatures([currentFeature]);
103
113
  featureCreated.raiseEvent(currentFeature);
@@ -108,7 +118,11 @@ function startCreateFeatureSession(app, layer, geometryType) {
108
118
  }
109
119
  if (currentFeature) {
110
120
  delete currentFeature[createSync];
111
- if (!geometry || currentFeature.getGeometry() !== geometry || !geometryIsValid(geometry)) {
121
+ if (
122
+ !geometry ||
123
+ currentFeature.getGeometry() !== geometry ||
124
+ !geometryIsValid(geometry)
125
+ ) {
112
126
  layer.removeFeaturesById([currentFeature.getId()]);
113
127
  currentFeature = null;
114
128
  }
@@ -138,8 +152,9 @@ function startCreateFeatureSession(app, layer, geometryType) {
138
152
  const { activeMap } = app.maps;
139
153
  isOblique = activeMap instanceof ObliqueMap;
140
154
  if (isOblique) {
141
- obliqueImageChangedListener = /** @type {ObliqueMap} */ (activeMap).imageChanged
142
- .addEventListener(resetCurrentInteraction);
155
+ obliqueImageChangedListener = /** @type {ObliqueMap} */ (
156
+ activeMap
157
+ ).imageChanged.addEventListener(resetCurrentInteraction);
143
158
  } else {
144
159
  obliqueImageChangedListener = () => {};
145
160
  }
@@ -1,8 +1,17 @@
1
- import { extend as extendExtent, createEmpty as createEmptyExtent, getCenter, isEmpty } from 'ol/extent.js';
1
+ import {
2
+ extend as extendExtent,
3
+ createEmpty as createEmptyExtent,
4
+ getCenter,
5
+ isEmpty,
6
+ } from 'ol/extent.js';
2
7
  import { getLogger } from '@vcsuite/logger';
3
8
 
4
9
  import VcsEvent from '../../vcsEvent.js';
5
- import { setupInteractionChain, SessionType, setupScratchLayer } from './editorSessionHelpers.js';
10
+ import {
11
+ setupInteractionChain,
12
+ SessionType,
13
+ setupScratchLayer,
14
+ } from './editorSessionHelpers.js';
6
15
  import createTransformationHandler from './transformation/transformationHandler.js';
7
16
  import { TransformationMode } from './transformation/transformationTypes.js';
8
17
  import MapInteractionController from './interactions/mapInteractionController.js';
@@ -72,7 +81,6 @@ function startEditFeaturesSession(
72
81
  layer,
73
82
  interactionId,
74
83
  initialMode = TransformationMode.TRANSLATE,
75
-
76
84
  ) {
77
85
  /**
78
86
  * @type {VcsEvent<void>}
@@ -92,11 +100,15 @@ function startEditFeaturesSession(
92
100
  const allowPickingMap = new Map();
93
101
  let modificationKey;
94
102
  /** Callback to remove the modifier changed listener. */
95
- const modifierChangedListener = app.maps.eventHandler.modifierChanged.addEventListener((mod) => { // CTRL is used to modify the current selection set, we must allow picking again so you can deselect a feature
96
- modificationKey = mod;
97
- const allowPicking = modificationKey === ModificationKeyType.CTRL;
98
- currentFeatures.forEach((feature) => { feature.set('olcs_allowPicking', allowPicking); });
99
- });
103
+ const modifierChangedListener =
104
+ app.maps.eventHandler.modifierChanged.addEventListener((mod) => {
105
+ // CTRL is used to modify the current selection set, we must allow picking again so you can deselect a feature
106
+ modificationKey = mod;
107
+ const allowPicking = modificationKey === ModificationKeyType.CTRL;
108
+ currentFeatures.forEach((feature) => {
109
+ feature.set('olcs_allowPicking', allowPicking);
110
+ });
111
+ });
100
112
 
101
113
  const scratchLayer = setupScratchLayer(app.layers);
102
114
 
@@ -109,7 +121,9 @@ function startEditFeaturesSession(
109
121
  const mouseOverInteraction = new EditFeaturesMouseOverInteraction();
110
122
  interactionChain.addInteraction(mouseOverInteraction);
111
123
 
112
- interactionChain.addInteraction(new EnsureHandlerSelectionInteraction(currentFeatures));
124
+ interactionChain.addInteraction(
125
+ new EnsureHandlerSelectionInteraction(currentFeatures),
126
+ );
113
127
 
114
128
  const mapInteractionController = new MapInteractionController();
115
129
  interactionChain.addInteraction(mapInteractionController);
@@ -152,7 +166,8 @@ function startEditFeaturesSession(
152
166
 
153
167
  const scale = (sx, sy) => {
154
168
  let center = transformationHandler?.center;
155
- if (!center) { // XXX copy paste
169
+ if (!center) {
170
+ // XXX copy paste
156
171
  const extent = createEmptyExtent();
157
172
  currentFeatures.forEach((f) => {
158
173
  extendExtent(extent, f.getGeometry().getExtent());
@@ -224,8 +239,13 @@ function startEditFeaturesSession(
224
239
  const modeChanged = new VcsEvent();
225
240
  const setMode = (newMode) => {
226
241
  if (newMode !== mode) {
227
- if (newMode === TransformationMode.EXTRUDE && !(app.maps.activeMap instanceof CesiumMap)) {
228
- getLogger('EditFeaturesSession').warning('Cannot set extrude mode if map is not a CesiumMap');
242
+ if (
243
+ newMode === TransformationMode.EXTRUDE &&
244
+ !(app.maps.activeMap instanceof CesiumMap)
245
+ ) {
246
+ getLogger('EditFeaturesSession').warning(
247
+ 'Cannot set extrude mode if map is not a CesiumMap',
248
+ );
229
249
  } else {
230
250
  mode = newMode;
231
251
  createTransformations();
@@ -261,7 +281,9 @@ function startEditFeaturesSession(
261
281
  obliqueImageChangedListener();
262
282
  mapChangedListener();
263
283
  modifierChangedListener();
264
- currentFeatures.forEach(feature => clearAllowPicking(feature, allowPickingMap));
284
+ currentFeatures.forEach((feature) =>
285
+ clearAllowPicking(feature, allowPickingMap),
286
+ );
265
287
  allowPickingMap.clear();
266
288
  app.layers.remove(scratchLayer);
267
289
  modeChanged.destroy();
@@ -284,10 +306,14 @@ function startEditFeaturesSession(
284
306
  translate,
285
307
  scale,
286
308
  setFeatures(features) {
287
- currentFeatures.forEach(feature => clearAllowPicking(feature, allowPickingMap));
309
+ currentFeatures.forEach((feature) =>
310
+ clearAllowPicking(feature, allowPickingMap),
311
+ );
288
312
  currentFeatures.length = 0;
289
313
  currentFeatures.push(...features);
290
- currentFeatures.forEach(feature => setAllowPicking(feature, allowPickingMap, modificationKey));
314
+ currentFeatures.forEach((feature) =>
315
+ setAllowPicking(feature, allowPickingMap, modificationKey),
316
+ );
291
317
  transformationHandler?.setFeatures(features);
292
318
  },
293
319
  get features() {
@@ -1,6 +1,11 @@
1
1
  import { getLogger } from '@vcsuite/logger';
2
2
  import { unByKey } from 'ol/Observable.js';
3
- import { GeometryType, SessionType, setupInteractionChain, setupScratchLayer } from './editorSessionHelpers.js';
3
+ import {
4
+ GeometryType,
5
+ SessionType,
6
+ setupInteractionChain,
7
+ setupScratchLayer,
8
+ } from './editorSessionHelpers.js';
4
9
  import InteractionChain from '../../interaction/interactionChain.js';
5
10
  import VcsEvent from '../../vcsEvent.js';
6
11
  import TranslateVertexInteraction from './interactions/translateVertexInteraction.js';
@@ -37,7 +42,9 @@ function createEditLineStringGeometryInteraction(feature, scratchLayer) {
37
42
  const vertices = geometry.getCoordinates().map(createVertex);
38
43
  scratchLayer.addFeatures(vertices);
39
44
  const resetGeometry = () => {
40
- geometry.setCoordinates(vertices.map(f => f.getGeometry().getCoordinates()));
45
+ geometry.setCoordinates(
46
+ vertices.map((f) => f.getGeometry().getCoordinates()),
47
+ );
41
48
  };
42
49
  const translateVertex = new TranslateVertexInteraction();
43
50
  translateVertex.vertexChanged.addEventListener(resetGeometry);
@@ -68,7 +75,7 @@ function createEditLineStringGeometryInteraction(feature, scratchLayer) {
68
75
  return {
69
76
  interactionChain,
70
77
  destroy: () => {
71
- scratchLayer.removeFeaturesById(vertices.map(v => v.getId()));
78
+ scratchLayer.removeFeaturesById(vertices.map((v) => v.getId()));
72
79
  interactionChain.destroy();
73
80
  },
74
81
  };
@@ -103,10 +110,9 @@ function createEditCircleGeometryInteraction(feature, scratchLayer) {
103
110
 
104
111
  const geometryListener = geometry.on('change', () => {
105
112
  if (!suspend) {
106
- geometry.getCoordinates()
107
- .forEach((c, index) => {
108
- vertices[index].getGeometry().setCoordinates(c);
109
- });
113
+ geometry.getCoordinates().forEach((c, index) => {
114
+ vertices[index].getGeometry().setCoordinates(c);
115
+ });
110
116
  }
111
117
  });
112
118
 
@@ -115,7 +121,7 @@ function createEditCircleGeometryInteraction(feature, scratchLayer) {
115
121
  return {
116
122
  interactionChain,
117
123
  destroy: () => {
118
- scratchLayer.removeFeaturesById(vertices.map(v => v.getId()));
124
+ scratchLayer.removeFeaturesById(vertices.map((v) => v.getId()));
119
125
  interactionChain.destroy();
120
126
  unByKey(geometryListener);
121
127
  },
@@ -169,16 +175,17 @@ function createEditBBoxGeometryInteraction(feature, scratchLayer) {
169
175
  updateOtherVertex(leftOfIndex);
170
176
 
171
177
  suspend = true;
172
- geometry.setCoordinates([vertices.map(f => f.getGeometry().getCoordinates())]);
178
+ geometry.setCoordinates([
179
+ vertices.map((f) => f.getGeometry().getCoordinates()),
180
+ ]);
173
181
  suspend = false;
174
182
  });
175
183
 
176
184
  const geometryListener = geometry.on('change', () => {
177
185
  if (!suspend) {
178
- geometry.getCoordinates()[0]
179
- .forEach((c, index) => {
180
- vertices[index].getGeometry().setCoordinates(c);
181
- });
186
+ geometry.getCoordinates()[0].forEach((c, index) => {
187
+ vertices[index].getGeometry().setCoordinates(c);
188
+ });
182
189
  }
183
190
  });
184
191
  const interactionChain = new InteractionChain([translateVertex]);
@@ -186,7 +193,7 @@ function createEditBBoxGeometryInteraction(feature, scratchLayer) {
186
193
  return {
187
194
  interactionChain,
188
195
  destroy: () => {
189
- scratchLayer.removeFeaturesById(vertices.map(v => v.getId()));
196
+ scratchLayer.removeFeaturesById(vertices.map((v) => v.getId()));
190
197
  interactionChain.destroy();
191
198
  unByKey(geometryListener);
192
199
  },
@@ -204,9 +211,11 @@ function createEditSimplePolygonInteraction(feature, scratchLayer) {
204
211
  const vertices = linearRing.getCoordinates().map(createVertex);
205
212
  scratchLayer.addFeatures(vertices);
206
213
  const resetGeometry = () => {
207
- const coordinates = vertices.map(f => f.getGeometry().getCoordinates());
214
+ const coordinates = vertices.map((f) => f.getGeometry().getCoordinates());
208
215
  linearRing.setCoordinates(coordinates); // update linear ring for proper vertex insertion
209
- geometry.setCoordinates([vertices.map(f => f.getGeometry().getCoordinates())]); // update actual geometry, since linear ring is a clone and not a ref
216
+ geometry.setCoordinates([
217
+ vertices.map((f) => f.getGeometry().getCoordinates()),
218
+ ]); // update actual geometry, since linear ring is a clone and not a ref
210
219
  };
211
220
 
212
221
  const translateVertex = new TranslateVertexInteraction();
@@ -238,7 +247,7 @@ function createEditSimplePolygonInteraction(feature, scratchLayer) {
238
247
  return {
239
248
  interactionChain,
240
249
  destroy: () => {
241
- scratchLayer.removeFeaturesById(vertices.map(v => v.getId()));
250
+ scratchLayer.removeFeaturesById(vertices.map((v) => v.getId()));
242
251
  interactionChain.destroy();
243
252
  },
244
253
  };
@@ -271,9 +280,7 @@ function createEditPointInteraction(feature, scratchLayer, layer) {
271
280
  }
272
281
  });
273
282
 
274
- const interactionChain = new InteractionChain([
275
- translateVertex,
276
- ]);
283
+ const interactionChain = new InteractionChain([translateVertex]);
277
284
 
278
285
  return {
279
286
  interactionChain,
@@ -323,10 +330,11 @@ function startEditGeometrySession(app, layer, interactionId) {
323
330
  */
324
331
  let currentFeature = null;
325
332
 
326
-
327
333
  const destroyCurrentInteractionSet = () => {
328
334
  if (currentInteractionSet) {
329
- interactionChain.removeInteraction(currentInteractionSet.interactionChain);
335
+ interactionChain.removeInteraction(
336
+ currentInteractionSet.interactionChain,
337
+ );
330
338
  currentInteractionSet.destroy();
331
339
  currentInteractionSet = null;
332
340
  }
@@ -354,29 +362,43 @@ function startEditGeometrySession(app, layer, interactionId) {
354
362
  if (geometryType === GeometryType.Polygon) {
355
363
  if (geometry.get('_vcsGeomType') === GeometryType.BBox) {
356
364
  currentInteractionSet = createEditBBoxGeometryInteraction(
357
- /** @type {import("ol").Feature<import("ol/geom").Polygon>} */ (feature),
365
+ /** @type {import("ol").Feature<import("ol/geom").Polygon>} */ (
366
+ feature
367
+ ),
358
368
  scratchLayer,
359
369
  );
360
- } else if (/** @type {import("ol/geom").Polygon} */ (geometry).getLinearRingCount() === 1) {
370
+ } else if (
371
+ /** @type {import("ol/geom").Polygon} */ (
372
+ geometry
373
+ ).getLinearRingCount() === 1
374
+ ) {
361
375
  currentInteractionSet = createEditSimplePolygonInteraction(
362
- /** @type {import("ol").Feature<import("ol/geom").Polygon>} */ (feature),
376
+ /** @type {import("ol").Feature<import("ol/geom").Polygon>} */ (
377
+ feature
378
+ ),
363
379
  scratchLayer,
364
380
  );
365
381
  }
366
382
  } else if (geometryType === GeometryType.LineString) {
367
383
  currentInteractionSet = createEditLineStringGeometryInteraction(
368
- /** @type {import("ol").Feature<import("ol/geom").LineString>} */ (feature),
384
+ /** @type {import("ol").Feature<import("ol/geom").LineString>} */ (
385
+ feature
386
+ ),
369
387
  scratchLayer,
370
388
  );
371
389
  } else if (geometryType === GeometryType.Point) {
372
390
  currentInteractionSet = createEditPointInteraction(
373
- /** @type {import("ol").Feature<import("ol/geom").Point>} */ (feature),
391
+ /** @type {import("ol").Feature<import("ol/geom").Point>} */ (
392
+ feature
393
+ ),
374
394
  scratchLayer,
375
395
  layer,
376
396
  );
377
397
  } else if (geometryType === GeometryType.Circle) {
378
398
  currentInteractionSet = createEditCircleGeometryInteraction(
379
- /** @type {import("ol").Feature<import("ol/geom").Circle>} */ (feature),
399
+ /** @type {import("ol").Feature<import("ol/geom").Circle>} */ (
400
+ feature
401
+ ),
380
402
  scratchLayer,
381
403
  );
382
404
  }
@@ -384,7 +406,9 @@ function startEditGeometrySession(app, layer, interactionId) {
384
406
  if (currentInteractionSet) {
385
407
  interactionChain.addInteraction(currentInteractionSet.interactionChain);
386
408
  } else {
387
- getLogger('EditGeometrySession').warning(`Geometry of type ${geometryType} is currently not supported`);
409
+ getLogger('EditGeometrySession').warning(
410
+ `Geometry of type ${geometryType} is currently not supported`,
411
+ );
388
412
  currentFeature[createSync] = false;
389
413
  currentFeature = null;
390
414
  }
@@ -396,7 +420,8 @@ function startEditGeometrySession(app, layer, interactionId) {
396
420
  mouseOverInteraction.reset();
397
421
  createCurrentInteractionSet(null);
398
422
  };
399
- const mapActivatedListener = app.maps.mapActivated.addEventListener(setupActiveMap);
423
+ const mapActivatedListener =
424
+ app.maps.mapActivated.addEventListener(setupActiveMap);
400
425
  setupActiveMap();
401
426
 
402
427
  const stop = () => {
@@ -5,7 +5,10 @@ import {
5
5
  Cartesian3,
6
6
  Math as CesiumMath,
7
7
  Plane,
8
- Ray, IntersectionTests, Cartographic, HeightReference,
8
+ Ray,
9
+ IntersectionTests,
10
+ Cartographic,
11
+ HeightReference,
9
12
  } from '@vcmap-cesium/engine';
10
13
 
11
14
  import { mercatorToCartesian } from '../math.js';
@@ -46,15 +49,34 @@ let scratchCartesian33 = new Cartesian3();
46
49
  * @returns {!import("ol/coordinate").Coordinate}
47
50
  */
48
51
  export function getClosestPointOn2DLine(start, end, point) {
49
- scratchCartesian21 = Cartesian2.fromElements(end[0] - start[0], end[1] - start[1], scratchCartesian21);
52
+ scratchCartesian21 = Cartesian2.fromElements(
53
+ end[0] - start[0],
54
+ end[1] - start[1],
55
+ scratchCartesian21,
56
+ );
50
57
  if (scratchCartesian21.equals(Cartesian2.ZERO)) {
51
58
  scratchCartesian21 = Cartesian2.fromElements(1, 1, scratchCartesian21);
52
59
  }
53
- scratchCartesian21 = Cartesian2.normalize(scratchCartesian21, scratchCartesian21);
54
- scratchCartesian22 = Cartesian2.fromElements(point[0] - start[0], point[1] - start[1], scratchCartesian22);
60
+ scratchCartesian21 = Cartesian2.normalize(
61
+ scratchCartesian21,
62
+ scratchCartesian21,
63
+ );
64
+ scratchCartesian22 = Cartesian2.fromElements(
65
+ point[0] - start[0],
66
+ point[1] - start[1],
67
+ scratchCartesian22,
68
+ );
55
69
  const lambda = Cartesian2.dot(scratchCartesian21, scratchCartesian22);
56
- scratchCartesian21 = Cartesian2.multiplyByScalar(scratchCartesian21, lambda, scratchCartesian21);
57
- return [scratchCartesian21.x + start[0], scratchCartesian21.y + start[1], point[2]];
70
+ scratchCartesian21 = Cartesian2.multiplyByScalar(
71
+ scratchCartesian21,
72
+ lambda,
73
+ scratchCartesian21,
74
+ );
75
+ return [
76
+ scratchCartesian21.x + start[0],
77
+ scratchCartesian21.y + start[1],
78
+ point[2],
79
+ ];
58
80
  }
59
81
 
60
82
  /**
@@ -65,12 +87,24 @@ export function getClosestPointOn2DLine(start, end, point) {
65
87
  * @returns {boolean}
66
88
  */
67
89
  export function pointOnLine3D(start, end, point, epsilon) {
68
- scratchCartesian31 = Cartesian3
69
- .fromElements(end[0] - start[0], end[1] - start[1], end[2] - start[2], scratchCartesian31);
70
- scratchCartesian32 = Cartesian3
71
- .fromElements(point[0] - start[0], point[1] - start[1], point[2] - start[2], scratchCartesian32);
72
- scratchCartesian33 = Cartesian3
73
- .fromElements(point[0] - end[0], point[1] - end[1], point[2] - point[2], scratchCartesian33);
90
+ scratchCartesian31 = Cartesian3.fromElements(
91
+ end[0] - start[0],
92
+ end[1] - start[1],
93
+ end[2] - start[2],
94
+ scratchCartesian31,
95
+ );
96
+ scratchCartesian32 = Cartesian3.fromElements(
97
+ point[0] - start[0],
98
+ point[1] - start[1],
99
+ point[2] - start[2],
100
+ scratchCartesian32,
101
+ );
102
+ scratchCartesian33 = Cartesian3.fromElements(
103
+ point[0] - end[0],
104
+ point[1] - end[1],
105
+ point[2] - point[2],
106
+ scratchCartesian33,
107
+ );
74
108
  const mag1 = Cartesian3.magnitude(scratchCartesian31);
75
109
  if (
76
110
  mag1 < Cartesian3.magnitude(scratchCartesian32) ||
@@ -79,9 +113,18 @@ export function pointOnLine3D(start, end, point, epsilon) {
79
113
  return false;
80
114
  }
81
115
 
82
- scratchCartesian31 = Cartesian3.normalize(scratchCartesian31, scratchCartesian31);
83
- scratchCartesian32 = Cartesian3.normalize(scratchCartesian32, scratchCartesian32);
84
- return scratchCartesian31.equalsEpsilon(scratchCartesian32, epsilon || CesiumMath.EPSILON5);
116
+ scratchCartesian31 = Cartesian3.normalize(
117
+ scratchCartesian31,
118
+ scratchCartesian31,
119
+ );
120
+ scratchCartesian32 = Cartesian3.normalize(
121
+ scratchCartesian32,
122
+ scratchCartesian32,
123
+ );
124
+ return scratchCartesian31.equalsEpsilon(
125
+ scratchCartesian32,
126
+ epsilon || CesiumMath.EPSILON5,
127
+ );
85
128
  }
86
129
 
87
130
  /**
@@ -92,9 +135,21 @@ export function pointOnLine3D(start, end, point, epsilon) {
92
135
  * @returns {boolean}
93
136
  */
94
137
  export function pointOnLine2D(start, end, point, epsilon) {
95
- scratchCartesian21 = Cartesian2.fromElements(end[0] - start[0], end[1] - start[1], scratchCartesian21);
96
- scratchCartesian22 = Cartesian2.fromElements(point[0] - start[0], point[1] - start[1], scratchCartesian22);
97
- scratchCartesian23 = Cartesian2.fromElements(point[0] - end[0], point[1] - end[1], scratchCartesian23);
138
+ scratchCartesian21 = Cartesian2.fromElements(
139
+ end[0] - start[0],
140
+ end[1] - start[1],
141
+ scratchCartesian21,
142
+ );
143
+ scratchCartesian22 = Cartesian2.fromElements(
144
+ point[0] - start[0],
145
+ point[1] - start[1],
146
+ scratchCartesian22,
147
+ );
148
+ scratchCartesian23 = Cartesian2.fromElements(
149
+ point[0] - end[0],
150
+ point[1] - end[1],
151
+ scratchCartesian23,
152
+ );
98
153
  const mag1 = Cartesian2.magnitude(scratchCartesian21);
99
154
  if (
100
155
  mag1 < Cartesian2.magnitude(scratchCartesian22) ||
@@ -103,10 +158,19 @@ export function pointOnLine2D(start, end, point, epsilon) {
103
158
  return false;
104
159
  }
105
160
 
106
- scratchCartesian21 = Cartesian2.normalize(scratchCartesian21, scratchCartesian21);
107
- scratchCartesian22 = Cartesian2.normalize(scratchCartesian22, scratchCartesian22);
161
+ scratchCartesian21 = Cartesian2.normalize(
162
+ scratchCartesian21,
163
+ scratchCartesian21,
164
+ );
165
+ scratchCartesian22 = Cartesian2.normalize(
166
+ scratchCartesian22,
167
+ scratchCartesian22,
168
+ );
108
169
 
109
- return scratchCartesian21.equalsEpsilon(scratchCartesian22, epsilon || CesiumMath.EPSILON5);
170
+ return scratchCartesian21.equalsEpsilon(
171
+ scratchCartesian22,
172
+ epsilon || CesiumMath.EPSILON5,
173
+ );
110
174
  }
111
175
 
112
176
  /**
@@ -115,10 +179,23 @@ export function pointOnLine2D(start, end, point, epsilon) {
115
179
  * @returns {!import("@vcmap-cesium/engine").Plane}
116
180
  */
117
181
  export function createCameraVerticalPlane(originCoordinates, scene) {
118
- scratchCartesian31 = mercatorToCartesian(originCoordinates, scratchCartesian31);
119
- scratchCartesian32 = scene.globe.ellipsoid.geodeticSurfaceNormal(scratchCartesian31, scratchCartesian32);
120
- scratchCartesian32 = Cartesian3.cross(scene.camera.rightWC, scratchCartesian32, scratchCartesian32);
121
- scratchCartesian32 = Cartesian3.normalize(scratchCartesian32, scratchCartesian32);
182
+ scratchCartesian31 = mercatorToCartesian(
183
+ originCoordinates,
184
+ scratchCartesian31,
185
+ );
186
+ scratchCartesian32 = scene.globe.ellipsoid.geodeticSurfaceNormal(
187
+ scratchCartesian31,
188
+ scratchCartesian32,
189
+ );
190
+ scratchCartesian32 = Cartesian3.cross(
191
+ scene.camera.rightWC,
192
+ scratchCartesian32,
193
+ scratchCartesian32,
194
+ );
195
+ scratchCartesian32 = Cartesian3.normalize(
196
+ scratchCartesian32,
197
+ scratchCartesian32,
198
+ );
122
199
 
123
200
  return Plane.fromPointNormal(scratchCartesian31, scratchCartesian32);
124
201
  }
@@ -129,8 +206,14 @@ export function createCameraVerticalPlane(originCoordinates, scene) {
129
206
  * @returns {!import("@vcmap-cesium/engine").Plane}
130
207
  */
131
208
  export function createHorizontalPlane(originCoordinates, scene) {
132
- scratchCartesian31 = mercatorToCartesian(originCoordinates, scratchCartesian31);
133
- scratchCartesian32 = scene.globe.ellipsoid.geodeticSurfaceNormal(scratchCartesian31, scratchCartesian32);
209
+ scratchCartesian31 = mercatorToCartesian(
210
+ originCoordinates,
211
+ scratchCartesian31,
212
+ );
213
+ scratchCartesian32 = scene.globe.ellipsoid.geodeticSurfaceNormal(
214
+ scratchCartesian31,
215
+ scratchCartesian32,
216
+ );
134
217
 
135
218
  return Plane.fromPointNormal(scratchCartesian31, scratchCartesian32);
136
219
  }
@@ -195,8 +278,10 @@ export async function placeGeometryOnTerrain(geometry, map) {
195
278
  * @param {import("@vcmap/core").VcsMap} cesiumMap
196
279
  * @returns {Promise<void>}
197
280
  */
198
- export async function ensureFeatureAbsolute(feature, layer, cesiumMap) { // XXX this does not ensure 3D coordinates
199
- const layerIsClamped = layer.vectorProperties.altitudeMode === HeightReference.CLAMP_TO_GROUND;
281
+ export async function ensureFeatureAbsolute(feature, layer, cesiumMap) {
282
+ // XXX this does not ensure 3D coordinates
283
+ const layerIsClamped =
284
+ layer.vectorProperties.altitudeMode === HeightReference.CLAMP_TO_GROUND;
200
285
  const altitudeMode = feature.get('olcs_altitudeMode');
201
286
  if (altitudeMode === 'clampToGround' || (!altitudeMode && layerIsClamped)) {
202
287
  feature.set('olcs_altitudeMode', 'absolute', true);
@@ -38,7 +38,8 @@ export const SessionType = {
38
38
  * @param {import("@vcmap/core").LayerCollection} layerCollection
39
39
  * @returns {VectorLayer}
40
40
  */
41
- export function setupScratchLayer(layerCollection) { // IDEA pass in stopped and cleanup ourselves?
41
+ export function setupScratchLayer(layerCollection) {
42
+ // IDEA pass in stopped and cleanup ourselves?
42
43
  const layer = new VectorLayer({
43
44
  projection: mercatorProjection.toJSON(),
44
45
  vectorProperties: {
@@ -91,12 +92,16 @@ export function setupInteractionChain(eventHandler, interactionId) {
91
92
  const removed = new VcsEvent();
92
93
  const listener = eventHandler.addExclusiveInteraction(
93
94
  interactionChain,
94
- () => { removed.raiseEvent(); },
95
+ () => {
96
+ removed.raiseEvent();
97
+ },
95
98
  undefined,
96
99
  interactionId,
97
100
  );
98
101
  const currentFeatureInteractionEvent = eventHandler.featureInteraction.active;
99
- eventHandler.featureInteraction.setActive(EventType.CLICKMOVE | EventType.DRAGSTART);
102
+ eventHandler.featureInteraction.setActive(
103
+ EventType.CLICKMOVE | EventType.DRAGSTART,
104
+ );
100
105
 
101
106
  return {
102
107
  interactionChain,