@vcmap/core 6.0.0-rc.7 → 6.0.0-rc.9

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 (229) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/category/category.d.ts +2 -1
  5. package/dist/src/category/category.js +2 -1
  6. package/dist/src/category/category.js.map +1 -1
  7. package/dist/src/category/categoryCollection.js.map +1 -1
  8. package/dist/src/cesium/cesiumVcsCameraPrimitive.js.map +1 -1
  9. package/dist/src/classRegistry.d.ts +1 -1
  10. package/dist/src/classRegistry.js.map +1 -1
  11. package/dist/src/featureProvider/abstractFeatureProvider.js.map +1 -1
  12. package/dist/src/featureProvider/wmsFeatureProvider.js.map +1 -1
  13. package/dist/src/interaction/abstractInteraction.js.map +1 -1
  14. package/dist/src/interaction/coordinateAtPixel.js.map +1 -1
  15. package/dist/src/interaction/eventHandler.js.map +1 -1
  16. package/dist/src/interaction/featureAtPixelInteraction.js.map +1 -1
  17. package/dist/src/interaction/featureProviderInteraction.js.map +1 -1
  18. package/dist/src/interaction/interactionChain.js.map +1 -1
  19. package/dist/src/interaction/interactionType.js +4 -4
  20. package/dist/src/interaction/interactionType.js.map +1 -1
  21. package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js.map +1 -1
  22. package/dist/src/layer/cesium/clusterContext.js.map +1 -1
  23. package/dist/src/layer/cesium/dataSourceCesiumImpl.js.map +1 -1
  24. package/dist/src/layer/cesium/rasterLayerCesiumImpl.js.map +1 -1
  25. package/dist/src/layer/cesium/resourceHelper.js.map +1 -1
  26. package/dist/src/layer/cesium/singleImageCesiumImpl.js.map +1 -1
  27. package/dist/src/layer/cesium/terrainCesiumImpl.js.map +1 -1
  28. package/dist/src/layer/cesium/tmsCesiumImpl.js.map +1 -1
  29. package/dist/src/layer/cesium/vectorCesiumImpl.js +2 -2
  30. package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
  31. package/dist/src/layer/cesium/vectorContext.js +79 -14
  32. package/dist/src/layer/cesium/vectorContext.js.map +1 -1
  33. package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js.map +1 -1
  34. package/dist/src/layer/cesium/vectorTileImageryProvider.js.map +1 -1
  35. package/dist/src/layer/cesium/wmsCesiumImpl.js.map +1 -1
  36. package/dist/src/layer/cesiumTilesetLayer.js.map +1 -1
  37. package/dist/src/layer/czmlLayer.js.map +1 -1
  38. package/dist/src/layer/dataSourceLayer.js.map +1 -1
  39. package/dist/src/layer/featureLayer.js.map +1 -1
  40. package/dist/src/layer/featureStoreFeatureVisibility.js.map +1 -1
  41. package/dist/src/layer/featureStoreLayer.js.map +1 -1
  42. package/dist/src/layer/featureStoreLayerChanges.js.map +1 -1
  43. package/dist/src/layer/featureVisibility.js +1 -1
  44. package/dist/src/layer/featureVisibility.js.map +1 -1
  45. package/dist/src/layer/geojsonHelpers.js.map +1 -1
  46. package/dist/src/layer/geojsonLayer.js.map +1 -1
  47. package/dist/src/layer/globalHider.js.map +1 -1
  48. package/dist/src/layer/layer.js.map +1 -1
  49. package/dist/src/layer/layerImplementation.js.map +1 -1
  50. package/dist/src/layer/oblique/layerObliqueImpl.js.map +1 -1
  51. package/dist/src/layer/oblique/obliqueHelpers.js.map +1 -1
  52. package/dist/src/layer/oblique/vectorObliqueImpl.js.map +1 -1
  53. package/dist/src/layer/openStreetMapLayer.js.map +1 -1
  54. package/dist/src/layer/openlayers/layerOpenlayersImpl.js.map +1 -1
  55. package/dist/src/layer/openlayers/rasterLayerOpenlayersImpl.js.map +1 -1
  56. package/dist/src/layer/openlayers/singleImageOpenlayersImpl.js.map +1 -1
  57. package/dist/src/layer/openlayers/tmsOpenlayersImpl.js.map +1 -1
  58. package/dist/src/layer/openlayers/vectorOpenlayersImpl.js.map +1 -1
  59. package/dist/src/layer/openlayers/vectorTileOpenlayersImpl.js.map +1 -1
  60. package/dist/src/layer/openlayers/wmsOpenlayersImpl.js.map +1 -1
  61. package/dist/src/layer/openlayers/wmtsOpenlayersImpl.js.map +1 -1
  62. package/dist/src/layer/pointCloudLayer.js.map +1 -1
  63. package/dist/src/layer/rasterLayer.js +1 -1
  64. package/dist/src/layer/rasterLayer.js.map +1 -1
  65. package/dist/src/layer/singleImageLayer.js.map +1 -1
  66. package/dist/src/layer/terrainHelpers.js.map +1 -1
  67. package/dist/src/layer/terrainLayer.js.map +1 -1
  68. package/dist/src/layer/tileLoadedHelper.js.map +1 -1
  69. package/dist/src/layer/tileProvider/mvtTileProvider.js.map +1 -1
  70. package/dist/src/layer/tileProvider/staticGeojsonTileProvider.js.map +1 -1
  71. package/dist/src/layer/tileProvider/tileProvider.js.map +1 -1
  72. package/dist/src/layer/tileProvider/urlTemplateTileProvider.js.map +1 -1
  73. package/dist/src/layer/tmsLayer.js.map +1 -1
  74. package/dist/src/layer/vectorHelpers.js.map +1 -1
  75. package/dist/src/layer/vectorLayer.js +1 -3
  76. package/dist/src/layer/vectorLayer.js.map +1 -1
  77. package/dist/src/layer/vectorProperties.js +23 -1
  78. package/dist/src/layer/vectorProperties.js.map +1 -1
  79. package/dist/src/layer/vectorTileLayer.js.map +1 -1
  80. package/dist/src/layer/wfsLayer.js.map +1 -1
  81. package/dist/src/layer/wmsHelpers.js.map +1 -1
  82. package/dist/src/layer/wmsLayer.js.map +1 -1
  83. package/dist/src/layer/wmtsLayer.js.map +1 -1
  84. package/dist/src/map/baseOLMap.js.map +1 -1
  85. package/dist/src/map/cameraLimiter.js +1 -1
  86. package/dist/src/map/cameraLimiter.js.map +1 -1
  87. package/dist/src/map/cesiumMap.js.map +1 -1
  88. package/dist/src/map/obliqueMap.js.map +1 -1
  89. package/dist/src/map/openlayersMap.js +1 -1
  90. package/dist/src/map/openlayersMap.js.map +1 -1
  91. package/dist/src/map/vcsMap.js.map +1 -1
  92. package/dist/src/oblique/helpers.js.map +1 -1
  93. package/dist/src/oblique/obliqueCollection.js.map +1 -1
  94. package/dist/src/oblique/obliqueDataSet.js +1 -1
  95. package/dist/src/oblique/obliqueDataSet.js.map +1 -1
  96. package/dist/src/oblique/obliqueImage.js.map +1 -1
  97. package/dist/src/oblique/obliqueImageMeta.js.map +1 -1
  98. package/dist/src/oblique/obliqueProvider.js.map +1 -1
  99. package/dist/src/oblique/obliqueView.js.map +1 -1
  100. package/dist/src/oblique/obliqueViewDirection.js +1 -1
  101. package/dist/src/oblique/obliqueViewDirection.js.map +1 -1
  102. package/dist/src/oblique/parseImageJson.js.map +1 -1
  103. package/dist/src/ol/feature.js.map +1 -1
  104. package/dist/src/ol/geom/geometryCollection.js +68 -11
  105. package/dist/src/ol/geom/geometryCollection.js.map +1 -1
  106. package/dist/src/ol/render/canvas/canvasTileRenderer.js.map +1 -1
  107. package/dist/src/ol/source/ClusterEnhancedVectorSource.js.map +1 -1
  108. package/dist/src/ol/source/VcsCluster.js.map +1 -1
  109. package/dist/src/overrideClassRegistry.js.map +1 -1
  110. package/dist/src/style/arcStyle.js.map +1 -1
  111. package/dist/src/style/arrowStyle.js +1 -1
  112. package/dist/src/style/arrowStyle.js.map +1 -1
  113. package/dist/src/style/declarativeStyleItem.js.map +1 -1
  114. package/dist/src/style/shapesCategory.js.map +1 -1
  115. package/dist/src/style/styleFactory.js.map +1 -1
  116. package/dist/src/style/styleHelpers.js +1 -1
  117. package/dist/src/style/styleHelpers.js.map +1 -1
  118. package/dist/src/style/styleItem.js.map +1 -1
  119. package/dist/src/style/vectorStyleItem.js +1 -1
  120. package/dist/src/style/vectorStyleItem.js.map +1 -1
  121. package/dist/src/style/writeStyle.js.map +1 -1
  122. package/dist/src/util/clipping/clippingObject.js.map +1 -1
  123. package/dist/src/util/clipping/clippingObjectManager.js.map +1 -1
  124. package/dist/src/util/clipping/clippingPlaneHelper.js.map +1 -1
  125. package/dist/src/util/collection.js.map +1 -1
  126. package/dist/src/util/displayQuality/displayQuality.js +1 -1
  127. package/dist/src/util/displayQuality/displayQuality.js.map +1 -1
  128. package/dist/src/util/editor/createFeatureSession.js.map +1 -1
  129. package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
  130. package/dist/src/util/editor/editGeometrySession.js.map +1 -1
  131. package/dist/src/util/editor/editorHelpers.js.map +1 -1
  132. package/dist/src/util/editor/editorSessionHelpers.js +2 -2
  133. package/dist/src/util/editor/editorSessionHelpers.js.map +1 -1
  134. package/dist/src/util/editor/interactions/createBBoxInteraction.js.map +1 -1
  135. package/dist/src/util/editor/interactions/createCircleInteraction.js.map +1 -1
  136. package/dist/src/util/editor/interactions/createLineStringInteraction.js.map +1 -1
  137. package/dist/src/util/editor/interactions/createPointInteraction.js.map +1 -1
  138. package/dist/src/util/editor/interactions/createPolygonInteraction.js.map +1 -1
  139. package/dist/src/util/editor/interactions/creationSnapping.js.map +1 -1
  140. package/dist/src/util/editor/interactions/editFeaturesMouseOverInteraction.js.map +1 -1
  141. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js +5 -5
  142. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js.map +1 -1
  143. package/dist/src/util/editor/interactions/ensureHandlerSelectionInteraction.js.map +1 -1
  144. package/dist/src/util/editor/interactions/insertVertexInteraction.js.map +1 -1
  145. package/dist/src/util/editor/interactions/layerSnapping.js.map +1 -1
  146. package/dist/src/util/editor/interactions/mapInteractionController.js.map +1 -1
  147. package/dist/src/util/editor/interactions/removeVertexInteraction.js.map +1 -1
  148. package/dist/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +1 -1
  149. package/dist/src/util/editor/interactions/selectFeatureMouseOverInteraction.js.map +1 -1
  150. package/dist/src/util/editor/interactions/selectMultiFeatureInteraction.d.ts +1 -1
  151. package/dist/src/util/editor/interactions/selectMultiFeatureInteraction.js.map +1 -1
  152. package/dist/src/util/editor/interactions/selectSingleFeatureInteraction.d.ts +1 -1
  153. package/dist/src/util/editor/interactions/selectSingleFeatureInteraction.js.map +1 -1
  154. package/dist/src/util/editor/interactions/translateVertexInteraction.js.map +1 -1
  155. package/dist/src/util/editor/interactions/translationSnapping.js.map +1 -1
  156. package/dist/src/util/editor/selectFeaturesSession.js.map +1 -1
  157. package/dist/src/util/editor/snappingHelpers.js.map +1 -1
  158. package/dist/src/util/editor/transformation/create2DHandlers.js.map +1 -1
  159. package/dist/src/util/editor/transformation/create3DHandlers.js.map +1 -1
  160. package/dist/src/util/editor/transformation/extrudeInteraction.js.map +1 -1
  161. package/dist/src/util/editor/transformation/rotateInteraction.js.map +1 -1
  162. package/dist/src/util/editor/transformation/scaleInteraction.js.map +1 -1
  163. package/dist/src/util/editor/transformation/transformationHandler.js.map +1 -1
  164. package/dist/src/util/editor/transformation/transformationTypes.js +2 -2
  165. package/dist/src/util/editor/transformation/transformationTypes.js.map +1 -1
  166. package/dist/src/util/editor/transformation/translateInteraction.js.map +1 -1
  167. package/dist/src/util/editor/validateGeoemetry.js.map +1 -1
  168. package/dist/src/util/exclusiveManager.js.map +1 -1
  169. package/dist/src/util/extent.js.map +1 -1
  170. package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
  171. package/dist/src/util/featureconverter/clampedPrimitive.js.map +1 -1
  172. package/dist/src/util/featureconverter/convert.js.map +1 -1
  173. package/dist/src/util/featureconverter/extent3D.js.map +1 -1
  174. package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
  175. package/dist/src/util/featureconverter/pointHelpers.js.map +1 -1
  176. package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
  177. package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
  178. package/dist/src/util/featureconverter/storeyHelpers.js.map +1 -1
  179. package/dist/src/util/featureconverter/vectorGeometryFactory.js.map +1 -1
  180. package/dist/src/util/featureconverter/vectorHeightInfo.js +2 -4
  181. package/dist/src/util/featureconverter/vectorHeightInfo.js.map +1 -1
  182. package/dist/src/util/fetch.js.map +1 -1
  183. package/dist/src/util/flight/flightAnchor.js.map +1 -1
  184. package/dist/src/util/flight/flightCollection.js.map +1 -1
  185. package/dist/src/util/flight/flightHelpers.js.map +1 -1
  186. package/dist/src/util/flight/flightInstance.js.map +1 -1
  187. package/dist/src/util/flight/flightPlayer.js.map +1 -1
  188. package/dist/src/util/flight/flightVisualizer.js.map +1 -1
  189. package/dist/src/util/geometryHelpers.d.ts +1 -1
  190. package/dist/src/util/geometryHelpers.js +79 -56
  191. package/dist/src/util/geometryHelpers.js.map +1 -1
  192. package/dist/src/util/indexedCollection.js.map +1 -1
  193. package/dist/src/util/layerCollection.js.map +1 -1
  194. package/dist/src/util/locale.js.map +1 -1
  195. package/dist/src/util/mapCollection.js.map +1 -1
  196. package/dist/src/util/math.js.map +1 -1
  197. package/dist/src/util/overrideCollection.js.map +1 -1
  198. package/dist/src/util/projection.js.map +1 -1
  199. package/dist/src/util/urlHelpers.js.map +1 -1
  200. package/dist/src/util/viewpoint.js.map +1 -1
  201. package/dist/src/vcsApp.d.ts +3 -3
  202. package/dist/src/vcsApp.js +1 -0
  203. package/dist/src/vcsApp.js.map +1 -1
  204. package/dist/src/vcsEvent.js.map +1 -1
  205. package/dist/src/vcsModule.js.map +1 -1
  206. package/dist/src/vcsModuleHelpers.js.map +1 -1
  207. package/dist/src/vcsObject.js.map +1 -1
  208. package/dist/tests/unit/helpers/cesiumHelpers.d.ts +9 -9
  209. package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
  210. package/dist/tests/unit/helpers/importJSON.js.map +1 -1
  211. package/dist/tests/unit/helpers/obliqueHelpers.js.map +1 -1
  212. package/index.ts +1 -1
  213. package/package.json +5 -5
  214. package/src/category/category.ts +3 -2
  215. package/src/category/categoryCollection.ts +1 -1
  216. package/src/classRegistry.ts +1 -1
  217. package/src/global.d.ts +6 -1
  218. package/src/layer/cesium/clusterContext.ts +1 -1
  219. package/src/layer/cesium/vectorCesiumImpl.ts +2 -2
  220. package/src/layer/cesium/vectorContext.ts +124 -18
  221. package/src/layer/tileLoadedHelper.ts +1 -3
  222. package/src/layer/vectorLayer.ts +1 -3
  223. package/src/layer/vectorProperties.ts +27 -2
  224. package/src/ol/geom/geometryCollection.js +82 -13
  225. package/src/util/clipping/clippingObject.ts +1 -3
  226. package/src/util/featureconverter/pointHelpers.ts +4 -4
  227. package/src/util/featureconverter/vectorHeightInfo.ts +2 -3
  228. package/src/util/geometryHelpers.ts +111 -90
  229. package/src/vcsApp.ts +11 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcmap/core",
3
- "version": "6.0.0-rc.7",
3
+ "version": "6.0.0-rc.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -41,7 +41,7 @@
41
41
  "@types/chai": "^4.3.16",
42
42
  "@types/geojson": "^7946.0.10",
43
43
  "@types/mocha": "^10.0.7",
44
- "@types/node": "^20.14.10",
44
+ "@types/node": "^20.16.5",
45
45
  "@types/proj4": "^2.5.5",
46
46
  "@types/sinon": "^10.0.15",
47
47
  "@types/sinon-chai": "^3.2.12",
@@ -61,8 +61,8 @@
61
61
  "resize-observer-polyfill": "^1.5.1",
62
62
  "sinon": "^9.2.4",
63
63
  "sinon-chai": "^3.6.0",
64
- "typedoc": "^0.26.4",
65
- "typescript": "^5.0.4"
64
+ "typedoc": "^0.26.7",
65
+ "typescript": "^5.6.2"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "@vcmap-cesium/engine": "^11.0.2",
@@ -115,7 +115,7 @@
115
115
  "@vcsuite/logger": "^1.0.1",
116
116
  "@vcsuite/parsers": "^1.0.3",
117
117
  "fast-deep-equal": "^3.1.3",
118
- "proj4": "^2.12.0",
118
+ "proj4": "^2.12.1",
119
119
  "rbush": ">=4.0.0",
120
120
  "rbush-knn": "^4.0.0",
121
121
  "uuid": "^10.0.0"
@@ -72,7 +72,8 @@ function checkMergeOptionOverride<
72
72
  * the requestCategory API on the categories collection. Do not use toJSON to retrieve the state of a category, since
73
73
  * categories outlive modules and may be changed with mergeOptions to no longer reflect your initial state. Requestors
74
74
  * should keep track of the requested options themselves.
75
- * @template {Object|VcsObject} T
75
+ * @template {Object|VcsObject} T the type of objects in this category
76
+ * @template {Object} S the serialized state of the object in this category
76
77
  * @group Category
77
78
  */
78
79
  class Category<
@@ -192,7 +193,7 @@ class Category<
192
193
  if (feature) {
193
194
  feature.setId(String(id));
194
195
  setTimeout(() => {
195
- this._layer?.addFeatures([feature as Feature]);
196
+ this._layer?.addFeatures([feature]);
196
197
  }, 0); // We need to set a timeout, since removing and adding the feature in the same sync call leads to undefined behavior in OL TODO recheck in ol 6.11
197
198
  }
198
199
  }
@@ -118,7 +118,7 @@ class CategoryCollection extends IndexedCollection<Category> {
118
118
  options,
119
119
  );
120
120
  if (category) {
121
- if (this.add(category) == null) {
121
+ if (this.add(category as Category) == null) {
122
122
  return null;
123
123
  }
124
124
  }
@@ -110,7 +110,7 @@ export const mapClassRegistry: ClassRegistry<typeof VcsMap> =
110
110
  export const styleClassRegistry: ClassRegistry<typeof StyleItem> =
111
111
  new ClassRegistry();
112
112
 
113
- export const categoryClassRegistry: ClassRegistry<typeof Category> =
113
+ export const categoryClassRegistry: ClassRegistry<typeof Category<any, any>> =
114
114
  new ClassRegistry();
115
115
 
116
116
  /**
package/src/global.d.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import type VcsApp from './vcsApp.js';
2
2
  import { mouseOverSymbol } from './util/editor/editorSymbols.js';
3
+ // eslint-disable-next-line import/no-named-default
4
+ import type { default as VcsModule, VcsModuleConfig } from './vcsModule.js';
3
5
 
4
6
  declare global {
5
7
  interface Window {
6
- vcs: { apps: Map<string, VcsApp> };
8
+ vcs: {
9
+ apps: Map<string, VcsApp>;
10
+ createModuleFromConfig: (config: VcsModuleConfig) => VcsModule;
11
+ };
7
12
  opera?: string;
8
13
  }
9
14
  interface CSSStyleDeclaration {
@@ -58,7 +58,7 @@ class ClusterContext implements CesiumVectorContext {
58
58
 
59
59
  if (instance) {
60
60
  removeItem = (): void => {
61
- this.entities.remove(instance as Entity);
61
+ this.entities.remove(instance);
62
62
  };
63
63
  }
64
64
 
@@ -130,8 +130,8 @@ class VectorCesiumImpl
130
130
  private _addFeatures(features: Feature[]): void {
131
131
  // TODO we should make this non-blocking to better handle larger data sets check in RIWA Impl
132
132
  features.forEach((f) => {
133
- this._addFeature(f).catch(() => {
134
- this.getLogger().error('failed to convert feature');
133
+ this._addFeature(f).catch((err) => {
134
+ this.getLogger().error('failed to convert feature', f, err);
135
135
  });
136
136
  });
137
137
  }
@@ -31,6 +31,36 @@ export function setReferenceForPicking(
31
31
  primitive.olFeature = feature;
32
32
  }
33
33
 
34
+ function getIndexOfPrimitive(
35
+ item: PrimitiveType,
36
+ collection: PrimitiveCollection,
37
+ ): number {
38
+ const { length } = collection;
39
+ for (let i = 0; i < length; i++) {
40
+ const p = collection.get(i) as PrimitiveType;
41
+ if (p === item) {
42
+ return i;
43
+ }
44
+ }
45
+ return -1;
46
+ }
47
+
48
+ function addPrimitiveAtIndex(
49
+ type: 'scaled' | 'primitive',
50
+ item: PrimitiveType,
51
+ collection: PrimitiveCollection,
52
+ indices: ConvertedIndices,
53
+ ): PrimitiveType {
54
+ let index = indices[type];
55
+ if (index != null) {
56
+ if (index > collection.length) {
57
+ index = undefined;
58
+ }
59
+ }
60
+
61
+ return collection.add(item, index) as PrimitiveType;
62
+ }
63
+
34
64
  /**
35
65
  * Sets splitDirection on primitives. Currently only Model primitives support splitting.
36
66
  */
@@ -106,6 +136,10 @@ export interface CesiumVectorContext {
106
136
  clear(): void;
107
137
  }
108
138
 
139
+ type ConvertedItemIndex = { type: 'primitive' | 'scaled'; index: number };
140
+
141
+ type ConvertedIndices = { primitive?: number; scaled?: number };
142
+
109
143
  export default class VectorContext implements CesiumVectorContext {
110
144
  primitives = new PrimitiveCollection();
111
145
 
@@ -115,9 +149,13 @@ export default class VectorContext implements CesiumVectorContext {
115
149
 
116
150
  labels: LabelCollection;
117
151
 
118
- private _featureItems = new Map<Feature, (() => void)[]>();
152
+ private _featureItems = new Map<
153
+ Feature,
154
+ (() => ConvertedItemIndex | void)[]
155
+ >();
119
156
 
120
- private _convertingFeatures: Map<Feature, () => void> = new Map();
157
+ private _convertingFeatures: Map<Feature, (replace: boolean) => void> =
158
+ new Map();
121
159
 
122
160
  splitDirection: SplitDirection;
123
161
 
@@ -157,26 +195,63 @@ export default class VectorContext implements CesiumVectorContext {
157
195
  feature: Feature,
158
196
  allowPicking: boolean,
159
197
  items: ConvertedItem[],
198
+ indices: ConvertedIndices,
160
199
  ): void {
161
200
  const removeItems = items
162
201
  .map((item) => {
163
202
  let instance: PrimitiveType | Label | Billboard | undefined;
164
- let removeItem: (() => void) | undefined;
203
+ let removeItem: (() => ConvertedItemIndex | void) | undefined;
165
204
  if (item.type === 'primitive') {
166
205
  if (item.autoScale) {
167
- instance = this.scaledPrimitives.add(item.item) as PrimitiveType;
206
+ instance = addPrimitiveAtIndex(
207
+ 'scaled',
208
+ item.item,
209
+ this.scaledPrimitives,
210
+ indices,
211
+ );
212
+
168
213
  if (instance) {
169
- removeItem = (): void => {
170
- this._scaledDirty.value =
171
- this.scaledPrimitives.remove(instance);
214
+ removeItem = (): ConvertedItemIndex | undefined => {
215
+ const currentIndex = getIndexOfPrimitive(
216
+ instance as PrimitiveType,
217
+ this.scaledPrimitives,
218
+ );
219
+ if (currentIndex > -1) {
220
+ this._scaledDirty.value =
221
+ this.scaledPrimitives.remove(instance);
222
+
223
+ return {
224
+ type: 'scaled',
225
+ index: currentIndex,
226
+ };
227
+ }
228
+ return undefined;
172
229
  };
173
230
  this._scaledDirty.value = true;
174
231
  }
175
232
  } else {
176
- instance = this.primitives.add(item.item) as PrimitiveType;
233
+ instance = addPrimitiveAtIndex(
234
+ 'primitive',
235
+ item.item,
236
+ this.primitives,
237
+ indices,
238
+ );
239
+
177
240
  if (instance) {
178
- removeItem = (): void => {
179
- this.primitives.remove(instance);
241
+ removeItem = (): ConvertedItemIndex | undefined => {
242
+ const currentIndex = getIndexOfPrimitive(
243
+ instance as PrimitiveType,
244
+ this.primitives,
245
+ );
246
+
247
+ if (currentIndex > -1) {
248
+ this.primitives.remove(instance);
249
+ return {
250
+ type: 'primitive',
251
+ index: currentIndex,
252
+ };
253
+ }
254
+ return undefined;
180
255
  };
181
256
  }
182
257
  }
@@ -211,7 +286,7 @@ export default class VectorContext implements CesiumVectorContext {
211
286
  }
212
287
  return removeItem;
213
288
  })
214
- .filter((i): i is () => void => i != null);
289
+ .filter((i) => i != null);
215
290
 
216
291
  this._featureItems.set(feature, removeItems);
217
292
  }
@@ -222,10 +297,15 @@ export default class VectorContext implements CesiumVectorContext {
222
297
  vectorProperties: VectorProperties,
223
298
  scene: Scene,
224
299
  ): Promise<void> {
225
- this._convertingFeatures.get(feature)?.();
300
+ this._convertingFeatures.get(feature)?.(true);
226
301
  let deleted = false;
227
- this._convertingFeatures.set(feature, () => {
228
- deleted = true;
302
+ let replaced = false;
303
+ this._convertingFeatures.set(feature, (isReplacement?: boolean) => {
304
+ if (isReplacement) {
305
+ replaced = true;
306
+ } else {
307
+ deleted = true;
308
+ }
229
309
  });
230
310
 
231
311
  const convertedItems = await convert(
@@ -235,7 +315,32 @@ export default class VectorContext implements CesiumVectorContext {
235
315
  scene,
236
316
  );
237
317
 
238
- this._featureItems.get(feature)?.forEach((removeItem) => removeItem());
318
+ if (replaced) {
319
+ convertedItems.forEach((item) => {
320
+ if (item.type === 'primitive') {
321
+ item.item.destroy();
322
+ }
323
+ });
324
+ return;
325
+ }
326
+
327
+ const convertedIndices: ConvertedIndices =
328
+ this._featureItems
329
+ .get(feature)
330
+ ?.map((removeItem) => removeItem())
331
+ ?.filter((i) => i != null)
332
+ ?.reduce((items, current) => {
333
+ const minIndex = items[current.type];
334
+ if (minIndex != null) {
335
+ items[current.type] =
336
+ current.index != null && current.index < minIndex
337
+ ? current.index
338
+ : items[current.type];
339
+ } else {
340
+ items[current.type] = current.index;
341
+ }
342
+ return items;
343
+ }, {} as ConvertedIndices) ?? {};
239
344
  this._featureItems.delete(feature);
240
345
 
241
346
  if (deleted) {
@@ -249,12 +354,13 @@ export default class VectorContext implements CesiumVectorContext {
249
354
  feature,
250
355
  vectorProperties.getAllowPicking(feature),
251
356
  convertedItems,
357
+ convertedIndices,
252
358
  );
253
359
  }
254
360
  }
255
361
 
256
362
  removeFeature(feature: Feature): void {
257
- this._convertingFeatures.get(feature)?.();
363
+ this._convertingFeatures.get(feature)?.(false);
258
364
  this._convertingFeatures.delete(feature);
259
365
  this._featureItems.get(feature)?.forEach((removeItem) => removeItem());
260
366
  this._featureItems.delete(feature);
@@ -275,7 +381,7 @@ export default class VectorContext implements CesiumVectorContext {
275
381
  this.labels.removeAll();
276
382
  this._featureItems.clear();
277
383
  this._convertingFeatures.forEach((destroy) => {
278
- destroy();
384
+ destroy(true);
279
385
  });
280
386
  this._convertingFeatures.clear();
281
387
  }
@@ -294,7 +400,7 @@ export default class VectorContext implements CesiumVectorContext {
294
400
  // @ts-ignore
295
401
  this._rootCollection = null;
296
402
  this._convertingFeatures.forEach((destroy) => {
297
- destroy();
403
+ destroy(true);
298
404
  });
299
405
  this._convertingFeatures.clear();
300
406
  this._featureItems.clear();
@@ -33,9 +33,7 @@ export async function tiledLayerLoaded(
33
33
  ): Promise<void> {
34
34
  const impls = layer
35
35
  .getImplementations()
36
- .filter(
37
- (i) => i instanceof CesiumTilesetCesiumImpl,
38
- ) as CesiumTilesetCesiumImpl[];
36
+ .filter((i) => i instanceof CesiumTilesetCesiumImpl);
39
37
  if (!layer.active || impls.every((i) => i.cesium3DTileset?.tilesLoaded)) {
40
38
  return;
41
39
  }
@@ -433,9 +433,7 @@ class VectorLayer
433
433
  */
434
434
  getFeaturesById(ids: (string | number)[]): Feature[] {
435
435
  check(ids, [oneOf(String, Number)]);
436
- return ids
437
- .map((id) => this.getFeatureById(id))
438
- .filter((f) => f != null) as Feature[];
436
+ return ids.map((id) => this.getFeatureById(id)).filter((f) => f != null);
439
437
  }
440
438
 
441
439
  /**
@@ -225,7 +225,7 @@ export function parseNearFarScalar(
225
225
  if (Array.isArray(value)) {
226
226
  const valid = value
227
227
  .map((entry) => parseNumber(entry))
228
- .filter((entry) => entry != null) as number[];
228
+ .filter((entry) => entry != null);
229
229
  if (valid.length === 4) {
230
230
  return new NearFarScalar(valid[0], valid[1], valid[2], valid[3]);
231
231
  }
@@ -240,7 +240,7 @@ export function parseCartesian3(
240
240
  if (Array.isArray(value)) {
241
241
  const valid = value
242
242
  .map((entry) => parseNumber(entry))
243
- .filter((entry) => entry != null) as number[];
243
+ .filter((entry) => entry != null);
244
244
  if (valid.length === 3) {
245
245
  return new Cartesian3(valid[0], valid[1], valid[2]);
246
246
  }
@@ -1302,6 +1302,22 @@ class VectorProperties {
1302
1302
  }
1303
1303
  }
1304
1304
 
1305
+ if ('modelOptions' in options) {
1306
+ if (!deepEqual(this._modelOptions, options.modelOptions)) {
1307
+ this._modelOptions = options.modelOptions
1308
+ ? structuredClone(options.modelOptions)
1309
+ : undefined;
1310
+ changedProperties.push('modelOptions');
1311
+ }
1312
+ }
1313
+
1314
+ if ('modelAutoScale' in options) {
1315
+ if (this._modelAutoScale !== options.modelAutoScale) {
1316
+ this._modelAutoScale = !!options.modelAutoScale;
1317
+ changedProperties.push('modelAutoScale');
1318
+ }
1319
+ }
1320
+
1305
1321
  if ('baseUrl' in options) {
1306
1322
  if (options.baseUrl !== this._baseUrl) {
1307
1323
  this._baseUrl = options.baseUrl ?? '';
@@ -1309,6 +1325,15 @@ class VectorProperties {
1309
1325
  }
1310
1326
  }
1311
1327
 
1328
+ if ('primitiveOptions' in options) {
1329
+ if (!deepEqual(this._primitiveOptions, options.primitiveOptions)) {
1330
+ this._primitiveOptions = options.primitiveOptions
1331
+ ? structuredClone(options.primitiveOptions)
1332
+ : undefined;
1333
+ changedProperties.push('primitiveOptions');
1334
+ }
1335
+ }
1336
+
1312
1337
  if (changedProperties.length) {
1313
1338
  this.propertyChanged.raiseEvent(changedProperties);
1314
1339
  }
@@ -27,26 +27,68 @@ GeometryCollection.prototype.setCoordinates = function setCoordinates(
27
27
  );
28
28
  };
29
29
 
30
+ /**
31
+ * @type {Record<import("ol/geom/Geometry").GeometryLayout, number>}
32
+ */
33
+ const layoutScore = {
34
+ XY: 1,
35
+ XYM: 2,
36
+ XYZ: 3,
37
+ XYZM: 4,
38
+ };
39
+
40
+ /**
41
+ * @type {Record<import("ol/geom/Geometry").GeometryLayout, number>}
42
+ */
43
+ const layoutStride = {
44
+ XY: 2,
45
+ XYM: 3,
46
+ XYZ: 3,
47
+ XYZM: 4,
48
+ };
49
+
50
+ /**
51
+ * @param {import("ol/geom/Geometry").GeometryLayout} layout
52
+ * @param {import("ol/geom/Geometry").GeometryLayout=} minLayout
53
+ * @returns { import("ol/geom/Geometry").GeometryLayout}
54
+ */
55
+ function getMinLayout(layout, minLayout) {
56
+ if (!minLayout) {
57
+ return layout;
58
+ }
59
+ if (
60
+ (minLayout === 'XYM' && layout !== 'XYM') ||
61
+ (layout === 'XYM' && minLayout !== 'XYM')
62
+ ) {
63
+ return 'XY';
64
+ }
65
+ const inScore = layoutScore[layout];
66
+ const minScore = layoutScore[minLayout];
67
+ if (inScore < minScore) {
68
+ return layout;
69
+ }
70
+
71
+ return minLayout;
72
+ }
73
+
30
74
  /**
31
75
  * @returns {import("ol/geom/Geometry").GeometryLayout}
32
76
  */
33
77
  GeometryCollection.prototype.getLayout = function getLayout() {
34
- const firstGeom = this.getGeometriesArray()[0];
35
- if (firstGeom) {
36
- return firstGeom.getLayout();
37
- }
38
- return 'XYZ';
78
+ let maxCommonLayout;
79
+ this.getGeometriesArrayRecursive().forEach((geom) => {
80
+ maxCommonLayout = getMinLayout(geom.getLayout(), maxCommonLayout);
81
+ });
82
+
83
+ return maxCommonLayout ?? 'XY';
39
84
  };
40
85
 
41
86
  /**
42
87
  * @returns {number}
43
88
  */
44
89
  GeometryCollection.prototype.getStride = function getStride() {
45
- const firstGeom = this.getGeometriesArray()[0];
46
- if (firstGeom) {
47
- return firstGeom.getStride();
48
- }
49
- return 2;
90
+ const layout = this.getLayout();
91
+ return layoutStride[layout];
50
92
  };
51
93
 
52
94
  /**
@@ -54,7 +96,34 @@ GeometryCollection.prototype.getStride = function getStride() {
54
96
  */
55
97
  GeometryCollection.prototype.getFlatCoordinates =
56
98
  function getFlatCoordinates() {
57
- return this.getGeometriesArrayRecursive().flatMap((g) =>
58
- g.getFlatCoordinates(),
59
- );
99
+ const commonStride = this.getStride();
100
+ const flatCoordinates = [];
101
+ this.getGeometriesArrayRecursive().forEach((geom) => {
102
+ const geometryStride = geom.getStride();
103
+ const geometryFlatCoordinates = geom.getFlatCoordinates();
104
+ if (geometryStride === commonStride) {
105
+ flatCoordinates.push(geometryFlatCoordinates);
106
+ } else if (geometryStride > commonStride) {
107
+ const geometryCoordinateLength = geometryFlatCoordinates.length;
108
+ const numberOfCoordinates = Math.round(
109
+ geometryCoordinateLength / geometryStride,
110
+ );
111
+ const slicedGeometryCoordinates = new Array(
112
+ numberOfCoordinates * commonStride,
113
+ );
114
+ for (let i = 0; i < geometryCoordinateLength; i += geometryStride) {
115
+ for (let j = 0; j < commonStride; j++) {
116
+ const slicedGeometryCoordinateOffset = Math.round(
117
+ (i / geometryStride) * commonStride,
118
+ );
119
+
120
+ slicedGeometryCoordinates[slicedGeometryCoordinateOffset + j] =
121
+ geometryFlatCoordinates[i + j];
122
+ }
123
+ }
124
+ flatCoordinates.push(slicedGeometryCoordinates);
125
+ }
126
+ });
127
+
128
+ return [].concat(...flatCoordinates);
60
129
  };
@@ -166,9 +166,7 @@ class ClippingObject {
166
166
  if (layer.active) {
167
167
  const visualisations = map.getVisualizationsForLayer(layer);
168
168
  const tilesets = visualisations
169
- ? ([...visualisations].filter(
170
- (v) => v instanceof Cesium3DTileset,
171
- ) as Cesium3DTileset[])
169
+ ? [...visualisations].filter((v) => v instanceof Cesium3DTileset)
172
170
  : [];
173
171
 
174
172
  if (tilesets.length > 0) {
@@ -257,13 +257,13 @@ function getGeometryInstanceFromOptions(
257
257
  : new CylinderGeometry(options.geometryOptions);
258
258
  } else if (vectorPropertiesOfType(options, PrimitiveOptionsType.ELLIPSOID)) {
259
259
  if (Array.isArray(options.geometryOptions?.radii)) {
260
- options.geometryOptions!.radii = Cartesian3.fromArray(
261
- options.geometryOptions!.radii,
260
+ options.geometryOptions.radii = Cartesian3.fromArray(
261
+ options.geometryOptions.radii,
262
262
  );
263
263
  }
264
264
  if (Array.isArray(options.geometryOptions?.innerRadii)) {
265
- options.geometryOptions!.innerRadii = Cartesian3.fromArray(
266
- options.geometryOptions!.innerRadii,
265
+ options.geometryOptions.innerRadii = Cartesian3.fromArray(
266
+ options.geometryOptions.innerRadii,
267
267
  );
268
268
  }
269
269
  geometry = outline
@@ -1,4 +1,3 @@
1
- import { is } from '@vcsuite/check';
2
1
  import { Geometry, SimpleGeometry } from 'ol/geom.js';
3
2
  import type { Coordinate } from 'ol/coordinate.js';
4
3
  import { Cartesian3, HeightReference } from '@vcmap-cesium/engine';
@@ -190,8 +189,8 @@ export function getClampOrigin(geometry: SimpleGeometry): [number, number] {
190
189
  * @returns the minimum height
191
190
  */
192
191
  export function getMinHeight(geometry: Geometry): number {
193
- if (!is(geometry, SimpleGeometry) || is2DLayout(geometry.getLayout())) {
194
- throw new Error('expected geometry to be a simple YXZ geometry');
192
+ if (is2DLayout(geometry.getLayout())) {
193
+ throw new Error('expected geometry to have an YXZ geometry layout');
195
194
  }
196
195
 
197
196
  const stride = geometry.getStride();