@vcmap/core 6.0.0-rc.6 → 6.0.0-rc.8

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 (246) hide show
  1. package/dist/cesium.d.ts +1 -0
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/category/category.d.ts +2 -1
  6. package/dist/src/category/category.js +2 -1
  7. package/dist/src/category/category.js.map +1 -1
  8. package/dist/src/category/categoryCollection.js.map +1 -1
  9. package/dist/src/cesium/cesiumVcsCameraPrimitive.js.map +1 -1
  10. package/dist/src/classRegistry.d.ts +1 -1
  11. package/dist/src/classRegistry.js.map +1 -1
  12. package/dist/src/featureProvider/abstractFeatureProvider.js.map +1 -1
  13. package/dist/src/featureProvider/wmsFeatureProvider.js.map +1 -1
  14. package/dist/src/interaction/abstractInteraction.js.map +1 -1
  15. package/dist/src/interaction/coordinateAtPixel.js.map +1 -1
  16. package/dist/src/interaction/eventHandler.js.map +1 -1
  17. package/dist/src/interaction/featureAtPixelInteraction.js.map +1 -1
  18. package/dist/src/interaction/featureProviderInteraction.js.map +1 -1
  19. package/dist/src/interaction/interactionChain.js.map +1 -1
  20. package/dist/src/interaction/interactionType.js +4 -4
  21. package/dist/src/interaction/interactionType.js.map +1 -1
  22. package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js.map +1 -1
  23. package/dist/src/layer/cesium/clusterContext.d.ts +4 -2
  24. package/dist/src/layer/cesium/clusterContext.js +14 -3
  25. package/dist/src/layer/cesium/clusterContext.js.map +1 -1
  26. package/dist/src/layer/cesium/dataSourceCesiumImpl.js.map +1 -1
  27. package/dist/src/layer/cesium/rasterLayerCesiumImpl.js.map +1 -1
  28. package/dist/src/layer/cesium/resourceHelper.js.map +1 -1
  29. package/dist/src/layer/cesium/singleImageCesiumImpl.js.map +1 -1
  30. package/dist/src/layer/cesium/terrainCesiumImpl.js.map +1 -1
  31. package/dist/src/layer/cesium/tmsCesiumImpl.js.map +1 -1
  32. package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
  33. package/dist/src/layer/cesium/vectorContext.d.ts +2 -2
  34. package/dist/src/layer/cesium/vectorContext.js +7 -5
  35. package/dist/src/layer/cesium/vectorContext.js.map +1 -1
  36. package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js.map +1 -1
  37. package/dist/src/layer/cesium/vectorTileImageryProvider.js.map +1 -1
  38. package/dist/src/layer/cesium/wmsCesiumImpl.js.map +1 -1
  39. package/dist/src/layer/cesiumTilesetLayer.js.map +1 -1
  40. package/dist/src/layer/czmlLayer.js.map +1 -1
  41. package/dist/src/layer/dataSourceLayer.js.map +1 -1
  42. package/dist/src/layer/featureLayer.js.map +1 -1
  43. package/dist/src/layer/featureStoreFeatureVisibility.js.map +1 -1
  44. package/dist/src/layer/featureStoreLayer.js.map +1 -1
  45. package/dist/src/layer/featureStoreLayerChanges.js.map +1 -1
  46. package/dist/src/layer/featureVisibility.js +1 -1
  47. package/dist/src/layer/featureVisibility.js.map +1 -1
  48. package/dist/src/layer/geojsonHelpers.js.map +1 -1
  49. package/dist/src/layer/geojsonLayer.js.map +1 -1
  50. package/dist/src/layer/globalHider.js.map +1 -1
  51. package/dist/src/layer/layer.js.map +1 -1
  52. package/dist/src/layer/layerImplementation.js.map +1 -1
  53. package/dist/src/layer/oblique/layerObliqueImpl.js.map +1 -1
  54. package/dist/src/layer/oblique/obliqueHelpers.js +3 -3
  55. package/dist/src/layer/oblique/obliqueHelpers.js.map +1 -1
  56. package/dist/src/layer/oblique/vectorObliqueImpl.js.map +1 -1
  57. package/dist/src/layer/openStreetMapLayer.js.map +1 -1
  58. package/dist/src/layer/openlayers/layerOpenlayersImpl.js.map +1 -1
  59. package/dist/src/layer/openlayers/rasterLayerOpenlayersImpl.js.map +1 -1
  60. package/dist/src/layer/openlayers/singleImageOpenlayersImpl.js.map +1 -1
  61. package/dist/src/layer/openlayers/tmsOpenlayersImpl.js.map +1 -1
  62. package/dist/src/layer/openlayers/vectorOpenlayersImpl.js.map +1 -1
  63. package/dist/src/layer/openlayers/vectorTileOpenlayersImpl.js.map +1 -1
  64. package/dist/src/layer/openlayers/wmsOpenlayersImpl.js.map +1 -1
  65. package/dist/src/layer/openlayers/wmtsOpenlayersImpl.js.map +1 -1
  66. package/dist/src/layer/pointCloudLayer.js.map +1 -1
  67. package/dist/src/layer/rasterLayer.js +1 -1
  68. package/dist/src/layer/rasterLayer.js.map +1 -1
  69. package/dist/src/layer/singleImageLayer.js.map +1 -1
  70. package/dist/src/layer/terrainHelpers.js.map +1 -1
  71. package/dist/src/layer/terrainLayer.js.map +1 -1
  72. package/dist/src/layer/tileLoadedHelper.js.map +1 -1
  73. package/dist/src/layer/tileProvider/mvtTileProvider.js.map +1 -1
  74. package/dist/src/layer/tileProvider/staticGeojsonTileProvider.js.map +1 -1
  75. package/dist/src/layer/tileProvider/tileProvider.js.map +1 -1
  76. package/dist/src/layer/tileProvider/urlTemplateTileProvider.js.map +1 -1
  77. package/dist/src/layer/tmsLayer.js.map +1 -1
  78. package/dist/src/layer/vectorHelpers.js.map +1 -1
  79. package/dist/src/layer/vectorLayer.js +1 -3
  80. package/dist/src/layer/vectorLayer.js.map +1 -1
  81. package/dist/src/layer/vectorProperties.d.ts +2 -2
  82. package/dist/src/layer/vectorProperties.js +29 -5
  83. package/dist/src/layer/vectorProperties.js.map +1 -1
  84. package/dist/src/layer/vectorTileLayer.js.map +1 -1
  85. package/dist/src/layer/wfsLayer.js.map +1 -1
  86. package/dist/src/layer/wmsHelpers.js.map +1 -1
  87. package/dist/src/layer/wmsLayer.js.map +1 -1
  88. package/dist/src/layer/wmtsLayer.js.map +1 -1
  89. package/dist/src/map/baseOLMap.js.map +1 -1
  90. package/dist/src/map/cameraLimiter.js +1 -1
  91. package/dist/src/map/cameraLimiter.js.map +1 -1
  92. package/dist/src/map/cesiumMap.js.map +1 -1
  93. package/dist/src/map/obliqueMap.js.map +1 -1
  94. package/dist/src/map/openlayersMap.js +1 -1
  95. package/dist/src/map/openlayersMap.js.map +1 -1
  96. package/dist/src/map/vcsMap.js.map +1 -1
  97. package/dist/src/oblique/helpers.js.map +1 -1
  98. package/dist/src/oblique/obliqueCollection.js.map +1 -1
  99. package/dist/src/oblique/obliqueDataSet.js +1 -1
  100. package/dist/src/oblique/obliqueDataSet.js.map +1 -1
  101. package/dist/src/oblique/obliqueImage.js.map +1 -1
  102. package/dist/src/oblique/obliqueImageMeta.js.map +1 -1
  103. package/dist/src/oblique/obliqueProvider.js.map +1 -1
  104. package/dist/src/oblique/obliqueView.js.map +1 -1
  105. package/dist/src/oblique/obliqueViewDirection.js +1 -1
  106. package/dist/src/oblique/obliqueViewDirection.js.map +1 -1
  107. package/dist/src/oblique/parseImageJson.js.map +1 -1
  108. package/dist/src/ol/feature.js.map +1 -1
  109. package/dist/src/ol/geom/geometryCollection.js +68 -11
  110. package/dist/src/ol/geom/geometryCollection.js.map +1 -1
  111. package/dist/src/ol/render/canvas/canvasTileRenderer.js.map +1 -1
  112. package/dist/src/ol/source/ClusterEnhancedVectorSource.js.map +1 -1
  113. package/dist/src/ol/source/VcsCluster.js.map +1 -1
  114. package/dist/src/overrideClassRegistry.js.map +1 -1
  115. package/dist/src/style/arcStyle.js.map +1 -1
  116. package/dist/src/style/arrowStyle.js +1 -1
  117. package/dist/src/style/arrowStyle.js.map +1 -1
  118. package/dist/src/style/declarativeStyleItem.js.map +1 -1
  119. package/dist/src/style/shapesCategory.js.map +1 -1
  120. package/dist/src/style/styleFactory.js.map +1 -1
  121. package/dist/src/style/styleHelpers.js +1 -1
  122. package/dist/src/style/styleHelpers.js.map +1 -1
  123. package/dist/src/style/styleItem.js.map +1 -1
  124. package/dist/src/style/vectorStyleItem.js +1 -1
  125. package/dist/src/style/vectorStyleItem.js.map +1 -1
  126. package/dist/src/style/writeStyle.js.map +1 -1
  127. package/dist/src/util/clipping/clippingObject.js.map +1 -1
  128. package/dist/src/util/clipping/clippingObjectManager.js.map +1 -1
  129. package/dist/src/util/clipping/clippingPlaneHelper.js +2 -2
  130. package/dist/src/util/clipping/clippingPlaneHelper.js.map +1 -1
  131. package/dist/src/util/collection.js.map +1 -1
  132. package/dist/src/util/displayQuality/displayQuality.js +1 -1
  133. package/dist/src/util/displayQuality/displayQuality.js.map +1 -1
  134. package/dist/src/util/editor/createFeatureSession.js.map +1 -1
  135. package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
  136. package/dist/src/util/editor/editGeometrySession.js.map +1 -1
  137. package/dist/src/util/editor/editorHelpers.js +3 -3
  138. package/dist/src/util/editor/editorHelpers.js.map +1 -1
  139. package/dist/src/util/editor/editorSessionHelpers.js +2 -2
  140. package/dist/src/util/editor/editorSessionHelpers.js.map +1 -1
  141. package/dist/src/util/editor/interactions/createBBoxInteraction.js.map +1 -1
  142. package/dist/src/util/editor/interactions/createCircleInteraction.js.map +1 -1
  143. package/dist/src/util/editor/interactions/createLineStringInteraction.js.map +1 -1
  144. package/dist/src/util/editor/interactions/createPointInteraction.js.map +1 -1
  145. package/dist/src/util/editor/interactions/createPolygonInteraction.js.map +1 -1
  146. package/dist/src/util/editor/interactions/creationSnapping.js.map +1 -1
  147. package/dist/src/util/editor/interactions/editFeaturesMouseOverInteraction.js.map +1 -1
  148. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js +5 -5
  149. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js.map +1 -1
  150. package/dist/src/util/editor/interactions/ensureHandlerSelectionInteraction.js.map +1 -1
  151. package/dist/src/util/editor/interactions/insertVertexInteraction.js.map +1 -1
  152. package/dist/src/util/editor/interactions/layerSnapping.js.map +1 -1
  153. package/dist/src/util/editor/interactions/mapInteractionController.js.map +1 -1
  154. package/dist/src/util/editor/interactions/removeVertexInteraction.js.map +1 -1
  155. package/dist/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +1 -1
  156. package/dist/src/util/editor/interactions/selectFeatureMouseOverInteraction.js.map +1 -1
  157. package/dist/src/util/editor/interactions/selectMultiFeatureInteraction.d.ts +1 -1
  158. package/dist/src/util/editor/interactions/selectMultiFeatureInteraction.js.map +1 -1
  159. package/dist/src/util/editor/interactions/selectSingleFeatureInteraction.d.ts +1 -1
  160. package/dist/src/util/editor/interactions/selectSingleFeatureInteraction.js.map +1 -1
  161. package/dist/src/util/editor/interactions/translateVertexInteraction.js.map +1 -1
  162. package/dist/src/util/editor/interactions/translationSnapping.js.map +1 -1
  163. package/dist/src/util/editor/selectFeaturesSession.js.map +1 -1
  164. package/dist/src/util/editor/snappingHelpers.js.map +1 -1
  165. package/dist/src/util/editor/transformation/create2DHandlers.js.map +1 -1
  166. package/dist/src/util/editor/transformation/create3DHandlers.js.map +1 -1
  167. package/dist/src/util/editor/transformation/extrudeInteraction.js.map +1 -1
  168. package/dist/src/util/editor/transformation/rotateInteraction.js.map +1 -1
  169. package/dist/src/util/editor/transformation/scaleInteraction.js.map +1 -1
  170. package/dist/src/util/editor/transformation/transformationHandler.js.map +1 -1
  171. package/dist/src/util/editor/transformation/transformationTypes.js +2 -2
  172. package/dist/src/util/editor/transformation/transformationTypes.js.map +1 -1
  173. package/dist/src/util/editor/transformation/translateInteraction.js.map +1 -1
  174. package/dist/src/util/editor/validateGeoemetry.js.map +1 -1
  175. package/dist/src/util/exclusiveManager.js.map +1 -1
  176. package/dist/src/util/extent.js.map +1 -1
  177. package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
  178. package/dist/src/util/featureconverter/clampedPrimitive.js.map +1 -1
  179. package/dist/src/util/featureconverter/convert.d.ts +4 -0
  180. package/dist/src/util/featureconverter/convert.js +1 -1
  181. package/dist/src/util/featureconverter/convert.js.map +1 -1
  182. package/dist/src/util/featureconverter/extent3D.js.map +1 -1
  183. package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
  184. package/dist/src/util/featureconverter/pointHelpers.js +9 -3
  185. package/dist/src/util/featureconverter/pointHelpers.js.map +1 -1
  186. package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
  187. package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
  188. package/dist/src/util/featureconverter/storeyHelpers.js.map +1 -1
  189. package/dist/src/util/featureconverter/vectorGeometryFactory.js.map +1 -1
  190. package/dist/src/util/featureconverter/vectorHeightInfo.js +2 -4
  191. package/dist/src/util/featureconverter/vectorHeightInfo.js.map +1 -1
  192. package/dist/src/util/fetch.js.map +1 -1
  193. package/dist/src/util/flight/flightAnchor.js.map +1 -1
  194. package/dist/src/util/flight/flightCollection.js.map +1 -1
  195. package/dist/src/util/flight/flightHelpers.js.map +1 -1
  196. package/dist/src/util/flight/flightInstance.js.map +1 -1
  197. package/dist/src/util/flight/flightPlayer.js.map +1 -1
  198. package/dist/src/util/flight/flightVisualizer.js.map +1 -1
  199. package/dist/src/util/geometryHelpers.d.ts +12 -1
  200. package/dist/src/util/geometryHelpers.js +112 -12
  201. package/dist/src/util/geometryHelpers.js.map +1 -1
  202. package/dist/src/util/indexedCollection.js.map +1 -1
  203. package/dist/src/util/layerCollection.js.map +1 -1
  204. package/dist/src/util/locale.js.map +1 -1
  205. package/dist/src/util/mapCollection.js.map +1 -1
  206. package/dist/src/util/math.js.map +1 -1
  207. package/dist/src/util/overrideCollection.js.map +1 -1
  208. package/dist/src/util/projection.js.map +1 -1
  209. package/dist/src/util/urlHelpers.js.map +1 -1
  210. package/dist/src/util/viewpoint.js.map +1 -1
  211. package/dist/src/vcsApp.d.ts +3 -3
  212. package/dist/src/vcsApp.js +1 -0
  213. package/dist/src/vcsApp.js.map +1 -1
  214. package/dist/src/vcsEvent.js.map +1 -1
  215. package/dist/src/vcsModule.js.map +1 -1
  216. package/dist/src/vcsModuleHelpers.js.map +1 -1
  217. package/dist/src/vcsObject.js.map +1 -1
  218. package/dist/tests/unit/helpers/cesiumHelpers.d.ts +9 -9
  219. package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
  220. package/dist/tests/unit/helpers/helpers.d.ts +1 -1
  221. package/dist/tests/unit/helpers/helpers.js +2 -2
  222. package/dist/tests/unit/helpers/helpers.js.map +1 -1
  223. package/dist/tests/unit/helpers/importJSON.js.map +1 -1
  224. package/dist/tests/unit/helpers/obliqueHelpers.js.map +1 -1
  225. package/index.ts +3 -1
  226. package/package.json +5 -5
  227. package/src/category/category.ts +3 -2
  228. package/src/category/categoryCollection.ts +1 -1
  229. package/src/cesium/cesium.d.ts +1 -0
  230. package/src/classRegistry.ts +1 -1
  231. package/src/global.d.ts +6 -1
  232. package/src/layer/cesium/clusterContext.ts +17 -4
  233. package/src/layer/cesium/vectorContext.ts +13 -10
  234. package/src/layer/oblique/obliqueHelpers.ts +3 -3
  235. package/src/layer/tileLoadedHelper.ts +1 -3
  236. package/src/layer/vectorLayer.ts +1 -3
  237. package/src/layer/vectorProperties.ts +34 -7
  238. package/src/ol/geom/geometryCollection.js +82 -11
  239. package/src/util/clipping/clippingObject.ts +1 -3
  240. package/src/util/clipping/clippingPlaneHelper.ts +3 -4
  241. package/src/util/editor/editorHelpers.ts +3 -3
  242. package/src/util/featureconverter/convert.ts +3 -1
  243. package/src/util/featureconverter/pointHelpers.ts +13 -8
  244. package/src/util/featureconverter/vectorHeightInfo.ts +2 -3
  245. package/src/util/geometryHelpers.ts +166 -14
  246. package/src/vcsApp.ts +11 -4
@@ -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
  }
@@ -897,10 +897,10 @@ class VectorProperties {
897
897
  }
898
898
 
899
899
  /**
900
- * Get the features or the properties modelOptions. Returns an empty Object if both are undefined
900
+ * Get the features or the properties modelOptions.
901
901
  * @param feature
902
902
  */
903
- getModelOptions(feature: Feature): Record<string, unknown> {
903
+ getModelOptions(feature: Feature): Record<string, unknown> | undefined {
904
904
  const featureValue = feature.get('olcs_modelOptions') as
905
905
  | Record<string, unknown>
906
906
  | undefined;
@@ -910,7 +910,7 @@ class VectorProperties {
910
910
  if (this.modelOptions) {
911
911
  return this.modelOptions;
912
912
  }
913
- return {};
913
+ return undefined;
914
914
  }
915
915
 
916
916
  get modelAutoScale(): boolean {
@@ -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,13 +1325,22 @@ 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
  }
1315
1340
  }
1316
1341
 
1317
1342
  getValues(): VectorPropertiesOptions {
1318
- const values = {
1343
+ return {
1319
1344
  altitudeMode: getAltitudeModeOptions(this.altitudeMode),
1320
1345
  allowPicking: this.allowPicking,
1321
1346
  classificationType: getClassificationTypeOptions(this.classificationType),
@@ -1336,9 +1361,11 @@ class VectorProperties {
1336
1361
  modelHeading: this.modelHeading,
1337
1362
  modelPitch: this.modelPitch,
1338
1363
  modelRoll: this.modelRoll,
1364
+ modelAutoScale: this.modelAutoScale,
1365
+ modelOptions: this.modelOptions,
1339
1366
  baseUrl: this.baseUrl,
1367
+ primitiveOptions: this.primitiveOptions,
1340
1368
  };
1341
- return values;
1342
1369
  }
1343
1370
 
1344
1371
  /**
@@ -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,5 +96,34 @@ GeometryCollection.prototype.getStride = function getStride() {
54
96
  */
55
97
  GeometryCollection.prototype.getFlatCoordinates =
56
98
  function getFlatCoordinates() {
57
- return this.getGeometriesArray().flatMap((g) => g.getFlatCoordinates());
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);
58
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) {
@@ -13,7 +13,6 @@ import {
13
13
  type Camera,
14
14
  } from '@vcmap-cesium/engine';
15
15
  import type { Coordinate } from 'ol/coordinate.js';
16
- import type { Geometry } from 'ol/geom.js';
17
16
  import Feature from 'ol/Feature.js';
18
17
  import LineString from 'ol/geom/LineString.js';
19
18
  import { offset } from 'ol/sphere.js';
@@ -27,7 +26,7 @@ import Extent3D from '../featureconverter/extent3D.js';
27
26
  import {
28
27
  enforceEndingVertex,
29
28
  enforceRightHand,
30
- getFlatCoordinatesFromGeometry,
29
+ getFlatCoordinateReferences,
31
30
  } from '../geometryHelpers.js';
32
31
  import { mercatorToCartesian } from '../math.js';
33
32
 
@@ -162,7 +161,7 @@ export function createClippingPlaneCollection(
162
161
  check(transformMatrix, optional(Matrix4));
163
162
 
164
163
  const clippingPlanes = [];
165
- const geometry = feature.getGeometry() as Geometry;
164
+ const geometry = feature.getGeometry()!;
166
165
  const geometryType = geometry.getType();
167
166
 
168
167
  if (geometryType === 'Point') {
@@ -174,7 +173,7 @@ export function createClippingPlaneCollection(
174
173
  ),
175
174
  );
176
175
  } else {
177
- const coords = getFlatCoordinatesFromGeometry(geometry);
176
+ const coords = getFlatCoordinateReferences(geometry);
178
177
  if (
179
178
  coords.length < 2 ||
180
179
  (coords[0][0] === coords[1][0] && coords[0][1] === coords[1][1])
@@ -18,7 +18,7 @@ import {
18
18
  } from '@vcmap-cesium/engine';
19
19
 
20
20
  import { mercatorToCartesian } from '../math.js';
21
- import { getFlatCoordinatesFromGeometry } from '../geometryHelpers.js';
21
+ import { getFlatCoordinateReferences } from '../geometryHelpers.js';
22
22
  import CesiumMap from '../../map/cesiumMap.js';
23
23
  import { vertexIndexSymbol, vertexSymbol } from './editorSymbols.js';
24
24
  import {
@@ -365,7 +365,7 @@ export async function drapeGeometryOnTerrain(
365
365
  ): Promise<void> {
366
366
  if (map instanceof CesiumMap) {
367
367
  const coordinates = geometry.getCoordinates() as any[];
368
- const flats = getFlatCoordinatesFromGeometry(geometry, coordinates);
368
+ const flats = getFlatCoordinateReferences(geometry, coordinates);
369
369
  await map.getHeightFromTerrain(flats);
370
370
  geometry.setCoordinates(coordinates, 'XYZ');
371
371
  }
@@ -382,7 +382,7 @@ export async function placeGeometryOnTerrain(
382
382
  ): Promise<void> {
383
383
  if (map instanceof CesiumMap) {
384
384
  const coordinates = geometry.getCoordinates() as any[];
385
- const flats = getFlatCoordinatesFromGeometry(geometry, coordinates);
385
+ const flats = getFlatCoordinateReferences(geometry, coordinates);
386
386
  await map.getHeightFromTerrain(flats);
387
387
  let minHeight = Infinity;
388
388
  flats.forEach((coord) => {
@@ -109,7 +109,9 @@ export function getStylesArray(
109
109
  return styles;
110
110
  }
111
111
 
112
- function getSingleGeometriesFromGeometry(geometry: Geometry): SingleGeometry[] {
112
+ export function getSingleGeometriesFromGeometry(
113
+ geometry: Geometry,
114
+ ): SingleGeometry[] {
113
115
  if (
114
116
  geometry instanceof Point ||
115
117
  geometry instanceof Polygon ||
@@ -44,6 +44,7 @@ import {
44
44
  RelativeHeightReference,
45
45
  VectorHeightInfo,
46
46
  } from './vectorHeightInfo.js';
47
+ import { scaleSymbol } from '../../layer/cesium/vectorContext.js';
47
48
 
48
49
  function makeOffsetAutoScalePrimitive(
49
50
  primitive: Primitive | Model,
@@ -114,12 +115,16 @@ function makeClampedPrimitive(
114
115
  undefined,
115
116
  scratchUpdateHeightCartesian,
116
117
  );
117
-
118
- const geometryModelMatrix = Matrix4.fromScale(scale);
118
+ let usedScale = scale;
119
+ const autoScale = primitive[scaleSymbol];
120
+ if (autoScale != null) {
121
+ usedScale = new Cartesian3(autoScale, autoScale, autoScale);
122
+ }
123
+ const geometryModelMatrix = Matrix4.fromScale(usedScale);
119
124
  if (offset) {
120
125
  Matrix4.setTranslation(
121
126
  geometryModelMatrix,
122
- Cartesian3.multiplyComponents(offset, scale, new Cartesian3()),
127
+ Cartesian3.multiplyComponents(offset, usedScale, new Cartesian3()),
123
128
  geometryModelMatrix,
124
129
  );
125
130
  }
@@ -131,7 +136,7 @@ function makeClampedPrimitive(
131
136
  primitive.modelMatrix = Matrix4.multiply(
132
137
  transform,
133
138
  geometryModelMatrix,
134
- new Matrix4(),
139
+ primitive.modelMatrix,
135
140
  );
136
141
  };
137
142
 
@@ -252,13 +257,13 @@ function getGeometryInstanceFromOptions(
252
257
  : new CylinderGeometry(options.geometryOptions);
253
258
  } else if (vectorPropertiesOfType(options, PrimitiveOptionsType.ELLIPSOID)) {
254
259
  if (Array.isArray(options.geometryOptions?.radii)) {
255
- options.geometryOptions!.radii = Cartesian3.fromArray(
256
- options.geometryOptions!.radii,
260
+ options.geometryOptions.radii = Cartesian3.fromArray(
261
+ options.geometryOptions.radii,
257
262
  );
258
263
  }
259
264
  if (Array.isArray(options.geometryOptions?.innerRadii)) {
260
- options.geometryOptions!.innerRadii = Cartesian3.fromArray(
261
- options.geometryOptions!.innerRadii,
265
+ options.geometryOptions.innerRadii = Cartesian3.fromArray(
266
+ options.geometryOptions.innerRadii,
262
267
  );
263
268
  }
264
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();
@@ -19,8 +19,18 @@ import {
19
19
  Polygon,
20
20
  SimpleGeometry,
21
21
  } from 'ol/geom.js';
22
+ import { Feature } from 'ol';
22
23
  import Projection from './projection.js';
23
24
  import { mercatorToCartographic } from './math.js';
25
+ import VectorProperties from '../layer/vectorProperties.js';
26
+ import {
27
+ getHeightInfo,
28
+ isClampedHeightReference,
29
+ isRelativeHeightReference,
30
+ RelativeHeightReference,
31
+ VectorHeightInfo,
32
+ } from './featureconverter/vectorHeightInfo.js';
33
+ import { getSingleGeometriesFromGeometry } from './featureconverter/convert.js';
24
34
 
25
35
  export function getFlatCoordinatesFromSimpleGeometry(
26
36
  geometry: SimpleGeometry,
@@ -44,7 +54,7 @@ export function getFlatCoordinatesFromSimpleGeometry(
44
54
  return [];
45
55
  }
46
56
 
47
- export function getFlatCoordinatesFromGeometry(
57
+ export function getFlatCoordinateReferences(
48
58
  geometry: Geometry,
49
59
  inputCoordinates?: any[],
50
60
  ): Coordinate[] {
@@ -78,9 +88,7 @@ export function getFlatCoordinatesFromGeometry(
78
88
  } else if (geometry instanceof GeometryCollection) {
79
89
  flattenCoordinates = geometry
80
90
  .getGeometries()
81
- .map((g, i) =>
82
- getFlatCoordinatesFromGeometry(g, coordinates?.[i] as any[]),
83
- )
91
+ .map((g, i) => getFlatCoordinateReferences(g, coordinates?.[i] as any[]))
84
92
  .reduce((current, next) => current.concat(next));
85
93
  }
86
94
  return flattenCoordinates as Coordinate[];
@@ -195,7 +203,7 @@ export function from3Dto2DLayout(geometry: Geometry): void {
195
203
  return;
196
204
  }
197
205
  const coordinates = geometry.getCoordinates() as any[];
198
- const flatCoordinates = getFlatCoordinatesFromGeometry(geometry, coordinates);
206
+ const flatCoordinates = getFlatCoordinateReferences(geometry, coordinates);
199
207
  flatCoordinates.forEach((coordinate) => {
200
208
  if (layout === 'XYZM') {
201
209
  coordinate[2] = coordinate.pop()!;
@@ -207,13 +215,13 @@ export function from3Dto2DLayout(geometry: Geometry): void {
207
215
  }
208
216
 
209
217
  /**
210
- * Wil transform a 2D geometry (layout XY XYM) in place to 3D (XYZ XYZM) using the provided scene & height reference.
211
- * will no apply anything, if the layout is already 3D
218
+ * Places a geometry on to the ground (or terrain). The geometry is changed in place. This function
219
+ * will set the layout to a respective 3D layout.
212
220
  * @param geometry
213
221
  * @param scene
214
- * @param heightReference
222
+ * @param heightReference - clamp to ground will use `scene.getHeightMostDetailed`, terrain will use `sampleTerrainMostDetailed` using the scenes terrain provider
215
223
  */
216
- export async function from2Dto3DLayout(
224
+ export async function placeGeometryOnGround(
217
225
  geometry: Geometry,
218
226
  scene: Scene,
219
227
  heightReference:
@@ -221,17 +229,15 @@ export async function from2Dto3DLayout(
221
229
  | HeightReference.CLAMP_TO_TERRAIN,
222
230
  ): Promise<void> {
223
231
  const layout = geometry.getLayout();
224
- if (!is2DLayout(layout)) {
225
- return;
226
- }
227
232
  const coordinates = geometry.getCoordinates() as any[];
228
- const flatCoordinates = getFlatCoordinatesFromGeometry(geometry, coordinates);
233
+ const flatCoordinates = getFlatCoordinateReferences(geometry, coordinates);
229
234
  const cartographics = flatCoordinates.map((c) => mercatorToCartographic(c));
230
235
  if (heightReference === HeightReference.CLAMP_TO_GROUND) {
231
236
  await scene.sampleHeightMostDetailed(cartographics);
232
237
  } else {
233
238
  await sampleTerrainMostDetailed(scene.terrainProvider, cartographics);
234
239
  }
240
+
235
241
  cartographics.forEach((c, index) => {
236
242
  if (layout === 'XYM') {
237
243
  flatCoordinates[index][3] = flatCoordinates[index][2];
@@ -240,5 +246,151 @@ export async function from2Dto3DLayout(
240
246
  flatCoordinates[index][2] = c.height;
241
247
  }
242
248
  });
243
- geometry.setCoordinates(coordinates, layout === 'XYM' ? 'XYZM' : 'XYZ');
249
+
250
+ geometry.setCoordinates(
251
+ coordinates,
252
+ layout === 'XYM' || layout === 'XYZM' ? 'XYZM' : 'XYZ',
253
+ );
254
+ }
255
+
256
+ /**
257
+ * Wil transform a 2D geometry (layout XY XYM) in place to 3D (XYZ XYZM) using the provided scene & height reference.
258
+ * will no apply anything, if the layout is already 3D
259
+ * @param geometry
260
+ * @param scene
261
+ * @param heightReference
262
+ */
263
+ export async function from2Dto3DLayout(
264
+ geometry: Geometry,
265
+ scene: Scene,
266
+ heightReference:
267
+ | HeightReference.CLAMP_TO_GROUND
268
+ | HeightReference.CLAMP_TO_TERRAIN,
269
+ ): Promise<void> {
270
+ if (is2DLayout(geometry.getLayout())) {
271
+ await placeGeometryOnGround(geometry, scene, heightReference);
272
+ }
273
+ }
274
+
275
+ function setZCoordinate(geometry: Geometry, z: number): void {
276
+ const layout = geometry.getLayout();
277
+ const coordinates = geometry.getCoordinates() as any[];
278
+ const flatCoordinates = getFlatCoordinateReferences(geometry, coordinates);
279
+
280
+ flatCoordinates.forEach((c) => {
281
+ if (layout === 'XYM') {
282
+ c[3] = c[2];
283
+ c[2] = z;
284
+ } else {
285
+ c[2] = z;
286
+ }
287
+ });
288
+
289
+ geometry.setCoordinates(
290
+ coordinates,
291
+ layout === 'XYM' || layout === 'XYZM' ? 'XYZM' : 'XYZ',
292
+ );
293
+ }
294
+
295
+ export async function createAbsoluteFeature(
296
+ feature: Feature,
297
+ vectorProperties: VectorProperties,
298
+ scene: Scene,
299
+ ): Promise<Feature | null> {
300
+ const clone = feature.clone();
301
+ const geometry = clone.getGeometry();
302
+ if (!geometry) {
303
+ return null;
304
+ }
305
+
306
+ const altitudeMode = vectorProperties.getAltitudeMode(clone);
307
+ let groundLevel = vectorProperties.getGroundLevel(clone);
308
+
309
+ if (altitudeMode === HeightReference.NONE) {
310
+ if (groundLevel != null) {
311
+ setZCoordinate(geometry, groundLevel);
312
+ } else if (is2DLayout(geometry.getLayout())) {
313
+ await from2Dto3DLayout(geometry, scene, HeightReference.CLAMP_TO_GROUND);
314
+ }
315
+ } else if (isClampedHeightReference(altitudeMode)) {
316
+ if (groundLevel != null) {
317
+ setZCoordinate(geometry, groundLevel);
318
+ } else {
319
+ await placeGeometryOnGround(
320
+ geometry,
321
+ scene,
322
+ altitudeMode !== HeightReference.CLAMP_TO_TERRAIN
323
+ ? HeightReference.CLAMP_TO_GROUND
324
+ : HeightReference.CLAMP_TO_TERRAIN,
325
+ );
326
+ }
327
+ } else if (isRelativeHeightReference(altitudeMode)) {
328
+ const singleGeometries = getSingleGeometriesFromGeometry(geometry);
329
+ await Promise.all(
330
+ singleGeometries.map(async (singleGeometry) => {
331
+ const heightInfo = getHeightInfo(
332
+ clone,
333
+ singleGeometry,
334
+ vectorProperties,
335
+ ) as VectorHeightInfo<RelativeHeightReference>;
336
+
337
+ ({ groundLevel } = heightInfo);
338
+ if (heightInfo.clampOrigin) {
339
+ const cartographics = [
340
+ mercatorToCartographic(heightInfo.clampOrigin),
341
+ ];
342
+ if (
343
+ heightInfo.heightReference === HeightReference.RELATIVE_TO_TERRAIN
344
+ ) {
345
+ await sampleTerrainMostDetailed(
346
+ scene.terrainProvider,
347
+ cartographics,
348
+ );
349
+ } else {
350
+ await scene.sampleHeightMostDetailed(cartographics);
351
+ }
352
+ groundLevel = cartographics[0].height;
353
+ }
354
+
355
+ const coordinates = singleGeometry.getCoordinates() as any[];
356
+ const flatCoordinates = getFlatCoordinateReferences(
357
+ singleGeometry,
358
+ coordinates,
359
+ );
360
+ const { heightAboveGround } = heightInfo;
361
+ const setCoordinate =
362
+ heightAboveGround == null
363
+ ? (c: Coordinate): void => {
364
+ c[2] += groundLevel as number;
365
+ }
366
+ : (c: Coordinate): void => {
367
+ c[2] = (groundLevel as number) + heightAboveGround;
368
+ };
369
+ flatCoordinates.forEach(setCoordinate);
370
+ singleGeometry.setCoordinates(coordinates, 'XYZ');
371
+ }),
372
+ );
373
+
374
+ if (geometry instanceof MultiPoint) {
375
+ geometry.setCoordinates(
376
+ singleGeometries.map((g) => g.getCoordinates() as Coordinate),
377
+ );
378
+ } else if (geometry instanceof MultiPolygon) {
379
+ geometry.setCoordinates(
380
+ singleGeometries.map((g) => g.getCoordinates() as Coordinate[][]),
381
+ );
382
+ } else if (geometry instanceof MultiLineString) {
383
+ geometry.setCoordinates(
384
+ singleGeometries.map((g) => g.getCoordinates() as Coordinate[]),
385
+ );
386
+ } else if (geometry instanceof GeometryCollection) {
387
+ geometry.setGeometries(singleGeometries);
388
+ }
389
+ }
390
+
391
+ clone.set('olcs_altitudeMode', 'absolute');
392
+ clone.unset('olcs_groundLevel');
393
+ clone.unset('olcs_heightAboveGround');
394
+
395
+ return clone;
244
396
  }
package/src/vcsApp.ts CHANGED
@@ -27,6 +27,7 @@ import { setDefaultProjectionOptions } from './util/projection.js';
27
27
  import ObliqueMap from './map/obliqueMap.js';
28
28
  import OverrideClassRegistry from './overrideClassRegistry.js';
29
29
  import ClassRegistry, {
30
+ AbstractCtor,
30
31
  categoryClassRegistry,
31
32
  Ctor,
32
33
  featureProviderClassRegistry,
@@ -117,7 +118,9 @@ class VcsApp {
117
118
 
118
119
  private _flights: OverrideCollection<FlightInstance, FlightCollection>;
119
120
 
120
- private _categoryClassRegistry: OverrideClassRegistry<typeof Category>;
121
+ private _categoryClassRegistry: OverrideClassRegistry<
122
+ typeof Category<any, any>
123
+ >;
121
124
 
122
125
  private _categories: CategoryCollection;
123
126
 
@@ -347,11 +350,13 @@ class VcsApp {
347
350
  return this._styleClassRegistry;
348
351
  }
349
352
 
350
- get categoryClassRegistry(): OverrideClassRegistry<typeof Category> {
353
+ get categoryClassRegistry(): OverrideClassRegistry<
354
+ typeof Category<any, any>
355
+ > {
351
356
  return this._categoryClassRegistry;
352
357
  }
353
358
 
354
- get categoryItemClassRegistry(): OverrideClassRegistry<Ctor<any>> {
359
+ get categoryItemClassRegistry(): OverrideClassRegistry<AbstractCtor> {
355
360
  return this._categoryItemClassRegistry;
356
361
  }
357
362
 
@@ -422,7 +427,7 @@ class VcsApp {
422
427
  [...this._maps]
423
428
  .filter((m) => m instanceof ObliqueMap)
424
429
  .map((m) => {
425
- return (m as ObliqueMap).setCollection(startingObliqueCollection);
430
+ return m.setCollection(startingObliqueCollection);
426
431
  }),
427
432
  );
428
433
  }
@@ -623,5 +628,7 @@ export function getVcsAppById(id: string): VcsApp | undefined {
623
628
 
624
629
  window.vcs = window.vcs || {};
625
630
  window.vcs.apps = vcsApps;
631
+ window.vcs.createModuleFromConfig = (config: VcsModuleConfig): VcsModule =>
632
+ new VcsModule(config);
626
633
 
627
634
  export default VcsApp;