@vcmap/core 6.3.0-rc.1 → 6.3.0-rc.2

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 (159) hide show
  1. package/dist/cesium.d.ts +12 -0
  2. package/dist/index.d.ts +10 -2
  3. package/dist/index.js +9 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/ol.d.ts +13 -2
  6. package/dist/src/cesium/cesium3DTileFeature.d.ts +1 -0
  7. package/dist/src/cesium/cesium3DTileFeature.js +16 -3
  8. package/dist/src/cesium/cesium3DTileFeature.js.map +1 -1
  9. package/dist/src/cesium/cesium3DTilePointFeature.js +2 -1
  10. package/dist/src/cesium/cesium3DTilePointFeature.js.map +1 -1
  11. package/dist/src/classRegistry.d.ts +7 -1
  12. package/dist/src/classRegistry.js.map +1 -1
  13. package/dist/src/featureProvider/abstractAttributeProvider.d.ts +62 -0
  14. package/dist/src/featureProvider/abstractAttributeProvider.js +129 -0
  15. package/dist/src/featureProvider/abstractAttributeProvider.js.map +1 -0
  16. package/dist/src/featureProvider/abstractFeatureProvider.d.ts +9 -18
  17. package/dist/src/featureProvider/abstractFeatureProvider.js +7 -38
  18. package/dist/src/featureProvider/abstractFeatureProvider.js.map +1 -1
  19. package/dist/src/featureProvider/compositeFeatureProvider.d.ts +27 -0
  20. package/dist/src/featureProvider/compositeFeatureProvider.js +53 -0
  21. package/dist/src/featureProvider/compositeFeatureProvider.js.map +1 -0
  22. package/dist/src/featureProvider/csvAttributeProvider.d.ts +41 -0
  23. package/dist/src/featureProvider/csvAttributeProvider.js +126 -0
  24. package/dist/src/featureProvider/csvAttributeProvider.js.map +1 -0
  25. package/dist/src/featureProvider/featureProviderFactory.d.ts +3 -0
  26. package/dist/src/featureProvider/featureProviderFactory.js +17 -0
  27. package/dist/src/featureProvider/featureProviderFactory.js.map +1 -0
  28. package/dist/src/featureProvider/i3sAttributeProvider.d.ts +7 -0
  29. package/dist/src/featureProvider/i3sAttributeProvider.js +43 -0
  30. package/dist/src/featureProvider/i3sAttributeProvider.js.map +1 -0
  31. package/dist/src/featureProvider/jsonAttributeProvider.d.ts +26 -0
  32. package/dist/src/featureProvider/jsonAttributeProvider.js +73 -0
  33. package/dist/src/featureProvider/jsonAttributeProvider.js.map +1 -0
  34. package/dist/src/featureProvider/tileProviderFeatureProvider.d.ts +4 -6
  35. package/dist/src/featureProvider/tileProviderFeatureProvider.js +9 -11
  36. package/dist/src/featureProvider/tileProviderFeatureProvider.js.map +1 -1
  37. package/dist/src/featureProvider/urlIdAttributeProvider.d.ts +28 -0
  38. package/dist/src/featureProvider/urlIdAttributeProvider.js +50 -0
  39. package/dist/src/featureProvider/urlIdAttributeProvider.js.map +1 -0
  40. package/dist/src/featureProvider/wmsFeatureProvider.d.ts +12 -3
  41. package/dist/src/featureProvider/wmsFeatureProvider.js +17 -6
  42. package/dist/src/featureProvider/wmsFeatureProvider.js.map +1 -1
  43. package/dist/src/interaction/featureAtPixelInteraction.d.ts +15 -3
  44. package/dist/src/interaction/featureAtPixelInteraction.js +41 -1
  45. package/dist/src/interaction/featureAtPixelInteraction.js.map +1 -1
  46. package/dist/src/interaction/featureProviderInteraction.js +42 -26
  47. package/dist/src/interaction/featureProviderInteraction.js.map +1 -1
  48. package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.d.ts +14 -5
  49. package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js +243 -128
  50. package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js.map +1 -1
  51. package/dist/src/layer/cesium/i3sCesiumImpl.d.ts +33 -0
  52. package/dist/src/layer/cesium/i3sCesiumImpl.js +107 -0
  53. package/dist/src/layer/cesium/i3sCesiumImpl.js.map +1 -0
  54. package/dist/src/layer/cesium/vcsTile/vcsQuadtreeTileProvider.js +2 -1
  55. package/dist/src/layer/cesium/vcsTile/vcsQuadtreeTileProvider.js.map +1 -1
  56. package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js +7 -6
  57. package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js.map +1 -1
  58. package/dist/src/layer/cesium/vectorTileImageryProvider.js +2 -2
  59. package/dist/src/layer/cesium/vectorTileImageryProvider.js.map +1 -1
  60. package/dist/src/layer/cesiumTilesetLayer.d.ts +9 -0
  61. package/dist/src/layer/cesiumTilesetLayer.js +26 -1
  62. package/dist/src/layer/cesiumTilesetLayer.js.map +1 -1
  63. package/dist/src/layer/i3sLayer.d.ts +80 -0
  64. package/dist/src/layer/i3sLayer.js +242 -0
  65. package/dist/src/layer/i3sLayer.js.map +1 -0
  66. package/dist/src/layer/layer.d.ts +8 -3
  67. package/dist/src/layer/layer.js +7 -1
  68. package/dist/src/layer/layer.js.map +1 -1
  69. package/dist/src/layer/layerSymbols.d.ts +4 -0
  70. package/dist/src/layer/layerSymbols.js +4 -0
  71. package/dist/src/layer/layerSymbols.js.map +1 -1
  72. package/dist/src/layer/panoramaDatasetLayer.d.ts +2 -0
  73. package/dist/src/layer/panoramaDatasetLayer.js +33 -13
  74. package/dist/src/layer/panoramaDatasetLayer.js.map +1 -1
  75. package/dist/src/layer/tileProvider/flatGeobufTileProvider.js +3 -2
  76. package/dist/src/layer/tileProvider/flatGeobufTileProvider.js.map +1 -1
  77. package/dist/src/layer/tileProvider/mvtTileProvider.js +3 -2
  78. package/dist/src/layer/tileProvider/mvtTileProvider.js.map +1 -1
  79. package/dist/src/layer/tileProvider/tileProvider.d.ts +6 -0
  80. package/dist/src/layer/tileProvider/tileProvider.js +12 -1
  81. package/dist/src/layer/tileProvider/tileProvider.js.map +1 -1
  82. package/dist/src/layer/vectorLayer.js +2 -2
  83. package/dist/src/layer/vectorLayer.js.map +1 -1
  84. package/dist/src/layer/vectorProperties.js +10 -1
  85. package/dist/src/layer/vectorProperties.js.map +1 -1
  86. package/dist/src/layer/vectorTileLayer.d.ts +14 -5
  87. package/dist/src/layer/vectorTileLayer.js +78 -26
  88. package/dist/src/layer/vectorTileLayer.js.map +1 -1
  89. package/dist/src/layer/wmsLayer.d.ts +3 -0
  90. package/dist/src/layer/wmsLayer.js +62 -32
  91. package/dist/src/layer/wmsLayer.js.map +1 -1
  92. package/dist/src/map/baseCesiumMap.d.ts +4 -4
  93. package/dist/src/map/baseCesiumMap.js +12 -0
  94. package/dist/src/map/baseCesiumMap.js.map +1 -1
  95. package/dist/src/map/cesiumMap.js +0 -11
  96. package/dist/src/map/cesiumMap.js.map +1 -1
  97. package/dist/src/map/obliqueMap.js +11 -4
  98. package/dist/src/map/obliqueMap.js.map +1 -1
  99. package/dist/src/map/panoramaMap.js +1 -1
  100. package/dist/src/panorama/panoramaImage.js +6 -5
  101. package/dist/src/panorama/panoramaImage.js.map +1 -1
  102. package/dist/src/style/declarativeStyleItem.js +7 -8
  103. package/dist/src/style/declarativeStyleItem.js.map +1 -1
  104. package/dist/src/util/fetch.d.ts +7 -0
  105. package/dist/src/util/fetch.js +7 -0
  106. package/dist/src/util/fetch.js.map +1 -1
  107. package/dist/src/vcsApp.d.ts +2 -3
  108. package/dist/src/vcsApp.js.map +1 -1
  109. package/dist/src/vcsModuleHelpers.d.ts +5 -2
  110. package/dist/src/vcsModuleHelpers.js +27 -1
  111. package/dist/src/vcsModuleHelpers.js.map +1 -1
  112. package/dist/tests/unit/helpers/cesiumHelpers.js +7 -1
  113. package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
  114. package/index.ts +27 -0
  115. package/package.json +2 -2
  116. package/src/cesium/cesium.d.ts +12 -0
  117. package/src/cesium/cesium3DTileFeature.ts +25 -3
  118. package/src/cesium/cesium3DTilePointFeature.ts +3 -1
  119. package/src/classRegistry.ts +8 -3
  120. package/src/featureProvider/abstractAttributeProvider.ts +201 -0
  121. package/src/featureProvider/abstractFeatureProvider.ts +27 -47
  122. package/src/featureProvider/compositeFeatureProvider.ts +103 -0
  123. package/src/featureProvider/csvAttributeProvider.ts +186 -0
  124. package/src/featureProvider/featureProviderFactory.ts +31 -0
  125. package/src/featureProvider/i3sAttributeProvider.ts +60 -0
  126. package/src/featureProvider/jsonAttributeProvider.ts +109 -0
  127. package/src/featureProvider/tileProviderFeatureProvider.ts +13 -14
  128. package/src/featureProvider/urlIdAttributeProvider.ts +82 -0
  129. package/src/featureProvider/wmsFeatureProvider.ts +24 -7
  130. package/src/global.d.ts +2 -0
  131. package/src/interaction/featureAtPixelInteraction.ts +53 -3
  132. package/src/interaction/featureProviderInteraction.ts +59 -38
  133. package/src/layer/cesium/cesiumTilesetCesiumImpl.ts +296 -157
  134. package/src/layer/cesium/i3sCesiumImpl.ts +141 -0
  135. package/src/layer/cesium/vcsTile/vcsQuadtreeTileProvider.ts +4 -3
  136. package/src/layer/cesium/vectorRasterTileCesiumImpl.ts +7 -6
  137. package/src/layer/cesium/vectorTileImageryProvider.ts +2 -2
  138. package/src/layer/cesiumTilesetLayer.ts +51 -1
  139. package/src/layer/i3sLayer.ts +343 -0
  140. package/src/layer/layer.ts +30 -3
  141. package/src/layer/layerSymbols.ts +5 -0
  142. package/src/layer/panoramaDatasetLayer.ts +44 -13
  143. package/src/layer/tileProvider/flatGeobufTileProvider.ts +3 -2
  144. package/src/layer/tileProvider/mvtTileProvider.ts +3 -2
  145. package/src/layer/tileProvider/tileProvider.ts +13 -1
  146. package/src/layer/vectorLayer.ts +4 -2
  147. package/src/layer/vectorProperties.ts +10 -1
  148. package/src/layer/vectorTileLayer.ts +135 -47
  149. package/src/layer/wmsLayer.ts +77 -44
  150. package/src/map/baseCesiumMap.ts +29 -5
  151. package/src/map/cesiumMap.ts +0 -15
  152. package/src/map/obliqueMap.ts +13 -6
  153. package/src/map/panoramaMap.ts +1 -1
  154. package/src/ol/ol.d.ts +13 -2
  155. package/src/panorama/panoramaImage.ts +8 -5
  156. package/src/style/declarativeStyleItem.ts +7 -9
  157. package/src/util/fetch.ts +7 -0
  158. package/src/vcsApp.ts +7 -8
  159. package/src/vcsModuleHelpers.ts +62 -4
@@ -33,8 +33,14 @@ class VectorRasterTileCesiumImpl extends RasterLayerCesiumImpl {
33
33
  imageryProvider: undefined | VectorTileImageryProvider = undefined;
34
34
 
35
35
  constructor(map: CesiumMap, options: VectorTileImplementationOptions) {
36
+ const minRenderingLevel = options.minLevel;
37
+ const maxRenderingLevel = options.maxLevel;
36
38
  const rasterLayerOptions: RasterLayerImplementationOptions = {
39
+ maxLevel: 25,
40
+ minLevel: 0,
37
41
  ...options,
42
+ minRenderingLevel,
43
+ maxRenderingLevel,
38
44
  tilingSchema: TilingScheme.MERCATOR,
39
45
  opacity: 1,
40
46
  };
@@ -50,12 +56,7 @@ class VectorRasterTileCesiumImpl extends RasterLayerCesiumImpl {
50
56
  headers: this.headers,
51
57
  });
52
58
 
53
- const layerOptions: CesiumImageryLayer.ConstructorOptions = {
54
- alpha: this.opacity,
55
- splitDirection: this.splitDirection,
56
- minimumTerrainLevel: this.minLevel,
57
- maximumTerrainLevel: this.maxLevel,
58
- };
59
+ const layerOptions = this.getCesiumLayerOptions();
59
60
  if (this.extent && this.extent.isValid()) {
60
61
  const extent = this.extent.getCoordinatesInProjection(wgs84Projection);
61
62
  layerOptions.rectangle = Rectangle.fromDegrees(
@@ -17,9 +17,9 @@ import type { Feature } from 'ol/index.js';
17
17
  // eslint-disable-next-line import/no-named-default
18
18
  import type { default as Style, StyleFunction } from 'ol/style/Style.js';
19
19
  import type TileProvider from '../tileProvider/tileProvider.js';
20
- import { rectangleToExtent } from '../tileProvider/tileProvider.js';
21
20
  import { wgs84ToMercatorTransformer } from '../../util/projection.js';
22
21
  import CanvasTileRenderer from '../../ol/render/canvas/canvasTileRenderer.js';
22
+ import { rectangleToMercatorExtent } from '../../util/math.js';
23
23
 
24
24
  export function toContext(
25
25
  extent: Extent,
@@ -222,7 +222,7 @@ class VectorTileImageryProvider {
222
222
  y,
223
223
  level,
224
224
  );
225
- const extent = rectangleToExtent(rectangle);
225
+ const extent = rectangleToMercatorExtent(rectangle);
226
226
  const center = Rectangle.center(rectangle);
227
227
  return getCanvasFromFeatures(features, extent, center, this._tileSize);
228
228
  }
@@ -4,7 +4,7 @@ import {
4
4
  type CustomShader,
5
5
  Matrix4,
6
6
  } from '@vcmap-cesium/engine';
7
- import { check, maybe } from '@vcsuite/check';
7
+ import { check, is, maybe, oneOf } from '@vcsuite/check';
8
8
  import { parseInteger } from '@vcsuite/parsers';
9
9
  import type { Coordinate } from 'ol/coordinate.js';
10
10
  import type { VectorStyleItemOptions } from '../style/vectorStyleItem.js';
@@ -25,6 +25,12 @@ import type VcsMap from '../map/vcsMap.js';
25
25
  import { cesiumColorToColor, getStringColor } from '../style/styleHelpers.js';
26
26
  import PanoramaMap from '../map/panoramaMap.js';
27
27
  import BaseCesiumMap from '../map/baseCesiumMap.js';
28
+ import AbstractAttributeProvider, {
29
+ type AbstractAttributeProviderOptions,
30
+ type AttributeProvider,
31
+ } from '../featureProvider/abstractAttributeProvider.js';
32
+ import { getProviderForOption } from '../featureProvider/featureProviderFactory.js';
33
+ import CompositeFeatureProvider from '../featureProvider/compositeFeatureProvider.js';
28
34
 
29
35
  export type CesiumTilesetOptions = LayerOptions & {
30
36
  /**
@@ -46,6 +52,10 @@ export type CesiumTilesetOptions = LayerOptions & {
46
52
  * a css string color to be used as an outline.
47
53
  */
48
54
  outlineColor?: string;
55
+ /**
56
+ * an optional attribute provider to provide custom attributes for the tileset features on load
57
+ */
58
+ attributeProvider?: AttributeProvider | AbstractAttributeProviderOptions;
49
59
  };
50
60
 
51
61
  export type CesiumTilesetTilesetProperties = {
@@ -61,6 +71,7 @@ export type CesiumTilesetImplementationOptions =
61
71
  modelMatrix?: Matrix4;
62
72
  offset?: Coordinate;
63
73
  customShader?: CustomShader;
74
+ attributeProvider?: AttributeProvider;
64
75
  };
65
76
 
66
77
  /**
@@ -100,6 +111,8 @@ class CesiumTilesetLayer extends FeatureLayer<CesiumTilesetCesiumImpl> {
100
111
 
101
112
  private _customShader: CustomShader | undefined = undefined;
102
113
 
114
+ private _attributeProvider?: AttributeProvider;
115
+
103
116
  constructor(options: CesiumTilesetOptions) {
104
117
  const defaultOptions = CesiumTilesetLayer.getDefaultOptions();
105
118
  super({ ...defaultOptions, ...options });
@@ -138,6 +151,17 @@ class CesiumTilesetLayer extends FeatureLayer<CesiumTilesetCesiumImpl> {
138
151
  this._modelMatrix = undefined;
139
152
 
140
153
  this._offset = options.offset || defaultOptions.offset;
154
+
155
+ const attributeProvider = getProviderForOption(options.attributeProvider);
156
+
157
+ if (
158
+ is(
159
+ attributeProvider,
160
+ oneOf(CompositeFeatureProvider, AbstractAttributeProvider),
161
+ )
162
+ ) {
163
+ this._attributeProvider = attributeProvider;
164
+ }
141
165
  }
142
166
 
143
167
  /**
@@ -188,6 +212,26 @@ class CesiumTilesetLayer extends FeatureLayer<CesiumTilesetCesiumImpl> {
188
212
  }
189
213
  }
190
214
 
215
+ get attributeProvider(): AttributeProvider | undefined {
216
+ return this._attributeProvider;
217
+ }
218
+
219
+ set attributeProvider(provider: AttributeProvider | undefined) {
220
+ check(
221
+ provider,
222
+ maybe(oneOf(AbstractAttributeProvider, CompositeFeatureProvider)),
223
+ );
224
+
225
+ if (this._attributeProvider !== provider) {
226
+ this._attributeProvider = provider;
227
+ this.forceRedraw().catch((e: unknown) => {
228
+ this.getLogger().error(
229
+ `Error forcing redraw after setting attribute provider: ${String(e)}`,
230
+ );
231
+ });
232
+ }
233
+ }
234
+
191
235
  getImplementationOptions(): CesiumTilesetImplementationOptions {
192
236
  return {
193
237
  ...super.getImplementationOptions(),
@@ -196,6 +240,7 @@ class CesiumTilesetLayer extends FeatureLayer<CesiumTilesetCesiumImpl> {
196
240
  modelMatrix: this.modelMatrix,
197
241
  offset: this.offset,
198
242
  customShader: this.customShader,
243
+ attributeProvider: this._attributeProvider,
199
244
  };
200
245
  }
201
246
 
@@ -284,6 +329,10 @@ class CesiumTilesetLayer extends FeatureLayer<CesiumTilesetCesiumImpl> {
284
329
  config.offset = this.offset.slice();
285
330
  }
286
331
 
332
+ if (this._attributeProvider) {
333
+ config.attributeProvider = this._attributeProvider.toJSON();
334
+ }
335
+
287
336
  return config;
288
337
  }
289
338
 
@@ -291,6 +340,7 @@ class CesiumTilesetLayer extends FeatureLayer<CesiumTilesetCesiumImpl> {
291
340
  * disposes of this layer, removes instances from the current maps and the framework
292
341
  */
293
342
  destroy(): void {
343
+ this.attributeProvider?.destroy();
294
344
  super.destroy();
295
345
  }
296
346
  }
@@ -0,0 +1,343 @@
1
+ import { Cartesian3, Color } from '@vcmap-cesium/engine';
2
+ import type { Cesium3DTileset } from '@vcmap-cesium/engine';
3
+ import { parseBoolean, parseInteger } from '@vcsuite/parsers';
4
+ import { check, is, maybe, oneOf } from '@vcsuite/check';
5
+ import AbstractFeatureProvider from '../featureProvider/abstractFeatureProvider.js';
6
+ import I3SCesiumImpl from './cesium/i3sCesiumImpl.js';
7
+ import FeatureLayer from './featureLayer.js';
8
+ import type { LayerOptions } from './layer.js';
9
+ import type FeatureVisibility from './featureVisibility.js';
10
+ import type { FeatureLayerImplementationOptions } from './featureLayer.js';
11
+ import { layerClassRegistry } from '../classRegistry.js';
12
+ import type VcsMap from '../map/vcsMap.js';
13
+ import CesiumMap from '../map/cesiumMap.js';
14
+ import BaseCesiumMap from '../map/baseCesiumMap.js';
15
+ import PanoramaMap from '../map/panoramaMap.js';
16
+ import type { VcsObjectOptions } from '../vcsObject.js';
17
+ import Extent from '../util/extent.js';
18
+ import { isMobile } from '../util/isMobile.js';
19
+ import { mercatorProjection } from '../util/projection.js';
20
+ import { rectangleToMercatorExtent } from '../util/math.js';
21
+ import { cesiumColorToColor, getStringColor } from '../style/styleHelpers.js';
22
+ import type { VectorStyleItemOptions } from '../style/vectorStyleItem.js';
23
+ import VectorStyleItem from '../style/vectorStyleItem.js';
24
+ import I3SAttributeProvider from '../featureProvider/i3sAttributeProvider.js';
25
+ import type { AttributeProvider } from '../featureProvider/abstractAttributeProvider.js';
26
+ import AbstractAttributeProvider from '../featureProvider/abstractAttributeProvider.js';
27
+ import CompositeFeatureProvider from '../featureProvider/compositeFeatureProvider.js';
28
+ import { getProviderForOption } from '../featureProvider/featureProviderFactory.js';
29
+
30
+ export type I3SOptions = LayerOptions & {
31
+ adjustMaterialAlphaMode?: boolean;
32
+ applySymbology?: boolean;
33
+ calculateNormals?: boolean;
34
+ showFeatures?: boolean;
35
+ cesium3dTilesetOptions?: Cesium3DTileset.ConstructorOptions;
36
+ lightColor?: { x: number; y: number; z: number };
37
+ outlineColor?: string;
38
+ screenSpaceError?: number;
39
+ screenSpaceErrorMobile?: number;
40
+ highlightStyle?: VectorStyleItem | VectorStyleItemOptions;
41
+ featureVisibility?: FeatureVisibility;
42
+ /** A flag to indicate if the layer has batch tables, in which case features attributes are loaded on load */
43
+ hasBatchTable?: boolean;
44
+ /** an optional attribute provider to provide custom attributes for the tileset features on load */
45
+ attributeProvider?: AttributeProvider | VcsObjectOptions;
46
+ };
47
+
48
+ export type I3SImplementationOptions = FeatureLayerImplementationOptions & {
49
+ allowPicking: boolean;
50
+ adjustMaterialAlphaMode?: boolean;
51
+ applySymbology?: boolean;
52
+ calculateNormals?: boolean;
53
+ showFeatures?: boolean;
54
+ cesium3dTilesetOptions?: Cesium3DTileset.ConstructorOptions;
55
+ hasBatchTable?: boolean;
56
+ attributeProvider?: AttributeProvider;
57
+ };
58
+
59
+ class I3SLayer extends FeatureLayer<I3SCesiumImpl> {
60
+ static get className(): string {
61
+ return 'I3SLayer';
62
+ }
63
+
64
+ static getDefaultOptions(): I3SOptions {
65
+ return {
66
+ ...FeatureLayer.getDefaultOptions(),
67
+ adjustMaterialAlphaMode: false,
68
+ applySymbology: false,
69
+ calculateNormals: false,
70
+ showFeatures: false,
71
+ cesium3dTilesetOptions: undefined,
72
+ lightColor: undefined,
73
+ outlineColor: undefined,
74
+ screenSpaceError: 16,
75
+ screenSpaceErrorMobile: 32,
76
+ highlightStyle: undefined,
77
+ hasBatchTable: true,
78
+ };
79
+ }
80
+
81
+ adjustMaterialAlphaMode: boolean;
82
+ applySymbology: boolean;
83
+ calculateNormals: boolean;
84
+ showFeatures: boolean;
85
+ cesium3dTilesetOptions:
86
+ | Partial<Cesium3DTileset.ConstructorOptions>
87
+ | undefined;
88
+ lightColor: { x: number; y: number; z: number } | undefined;
89
+ outlineColor: string | undefined;
90
+ screenSpaceError: number;
91
+ screenSpaceErrorMobile: number;
92
+ highlightStyle: VectorStyleItem | null = null;
93
+ hasBatchTable: boolean;
94
+ protected _supportedMaps = [CesiumMap.className, PanoramaMap.className];
95
+ private _attributeProvider?: AttributeProvider;
96
+
97
+ constructor(options: I3SOptions) {
98
+ const defaultOptions = I3SLayer.getDefaultOptions();
99
+ super({ ...defaultOptions, ...options });
100
+
101
+ this.adjustMaterialAlphaMode = parseBoolean(
102
+ options.adjustMaterialAlphaMode ?? defaultOptions.adjustMaterialAlphaMode,
103
+ );
104
+ this.applySymbology = parseBoolean(
105
+ options.applySymbology ?? defaultOptions.applySymbology,
106
+ );
107
+ this.calculateNormals = parseBoolean(
108
+ options.calculateNormals ?? defaultOptions.calculateNormals,
109
+ );
110
+ this.showFeatures = parseBoolean(
111
+ options.showFeatures ?? defaultOptions.showFeatures,
112
+ );
113
+
114
+ this.screenSpaceError = parseInteger(
115
+ options.screenSpaceError,
116
+ defaultOptions.screenSpaceError,
117
+ );
118
+
119
+ this.screenSpaceErrorMobile = parseInteger(
120
+ options.screenSpaceErrorMobile,
121
+ defaultOptions.screenSpaceErrorMobile,
122
+ );
123
+
124
+ this.hasBatchTable = parseBoolean(
125
+ options.hasBatchTable ?? defaultOptions.hasBatchTable,
126
+ );
127
+
128
+ if (options.highlightStyle) {
129
+ this.highlightStyle =
130
+ options.highlightStyle instanceof VectorStyleItem
131
+ ? options.highlightStyle
132
+ : new VectorStyleItem(options.highlightStyle);
133
+ }
134
+
135
+ const cesium3dTilesetOptions =
136
+ options.cesium3dTilesetOptions || defaultOptions.cesium3dTilesetOptions;
137
+
138
+ this.cesium3dTilesetOptions = {
139
+ maximumScreenSpaceError: isMobile()
140
+ ? this.screenSpaceErrorMobile
141
+ : this.screenSpaceError,
142
+ ...cesium3dTilesetOptions,
143
+ ...(options.lightColor && {
144
+ lightColor: new Cartesian3(
145
+ options.lightColor.x,
146
+ options.lightColor.y,
147
+ options.lightColor.z,
148
+ ),
149
+ }),
150
+ ...(options.outlineColor && {
151
+ outlineColor: Color.fromCssColorString(options.outlineColor),
152
+ }),
153
+ };
154
+
155
+ const attributeProvider = getProviderForOption(options.attributeProvider);
156
+ if (this.hasBatchTable) {
157
+ if (
158
+ is(
159
+ attributeProvider,
160
+ oneOf(CompositeFeatureProvider, AbstractAttributeProvider),
161
+ )
162
+ ) {
163
+ this._attributeProvider = attributeProvider;
164
+ } else {
165
+ this._attributeProvider = new I3SAttributeProvider({});
166
+ }
167
+ } else if (this.allowPicking) {
168
+ if (is(this.featureProvider, AbstractFeatureProvider)) {
169
+ this.attributeProvider = new CompositeFeatureProvider({
170
+ featureProviders: [this.featureProvider],
171
+ attributeProviders: [new I3SAttributeProvider({})],
172
+ });
173
+ } else {
174
+ this.featureProvider = new I3SAttributeProvider({});
175
+ }
176
+ }
177
+ }
178
+
179
+ get attributeProvider(): AttributeProvider | undefined {
180
+ return this._attributeProvider;
181
+ }
182
+
183
+ set attributeProvider(provider: AttributeProvider | undefined) {
184
+ check(
185
+ provider,
186
+ maybe(oneOf(AbstractAttributeProvider, CompositeFeatureProvider)),
187
+ );
188
+
189
+ if (this._attributeProvider !== provider) {
190
+ this._attributeProvider = provider;
191
+ this.forceRedraw().catch((e: unknown) => {
192
+ this.getLogger().error(
193
+ `Error forcing redraw after setting attribute provider: ${String(e)}`,
194
+ );
195
+ });
196
+ }
197
+ }
198
+
199
+ getImplementationOptions(): I3SImplementationOptions {
200
+ return {
201
+ ...super.getImplementationOptions(),
202
+ allowPicking: this.allowPicking,
203
+ adjustMaterialAlphaMode: this.adjustMaterialAlphaMode,
204
+ applySymbology: this.applySymbology,
205
+ calculateNormals: this.calculateNormals,
206
+ showFeatures: this.showFeatures,
207
+ cesium3dTilesetOptions: this.cesium3dTilesetOptions,
208
+ hasBatchTable: this.hasBatchTable,
209
+ attributeProvider: this._attributeProvider,
210
+ };
211
+ }
212
+
213
+ createImplementationsForMap(map: VcsMap): I3SCesiumImpl[] {
214
+ if (map instanceof BaseCesiumMap) {
215
+ return [new I3SCesiumImpl(map, this.getImplementationOptions())];
216
+ }
217
+ return [];
218
+ }
219
+
220
+ getZoomToExtent(): Extent | null {
221
+ const metaExtent = super.getZoomToExtent();
222
+ if (metaExtent) {
223
+ return metaExtent;
224
+ }
225
+ const impl = this.getImplementations()[0];
226
+ if (impl?.data) {
227
+ const coordinates = rectangleToMercatorExtent(impl.data.extent);
228
+ const extent = new Extent({
229
+ projection: mercatorProjection.toJSON(),
230
+ coordinates,
231
+ });
232
+ if (extent.isValid()) {
233
+ return extent;
234
+ }
235
+ }
236
+ return null;
237
+ }
238
+
239
+ /**
240
+ * set the maximum screenspace error of this layer
241
+ */
242
+ setMaximumScreenSpaceError(value: number): void {
243
+ this.getImplementations().forEach((impl) => {
244
+ if (impl.data) {
245
+ impl.data.layers.forEach(({ tileset }) => {
246
+ if (tileset) {
247
+ tileset.maximumScreenSpaceError = value;
248
+ }
249
+ });
250
+ }
251
+ });
252
+ }
253
+
254
+ toJSON(defaultOptions = I3SLayer.getDefaultOptions()): I3SOptions {
255
+ const config: I3SOptions = super.toJSON(defaultOptions);
256
+ if (
257
+ this.adjustMaterialAlphaMode !== defaultOptions.adjustMaterialAlphaMode
258
+ ) {
259
+ config.adjustMaterialAlphaMode = this.adjustMaterialAlphaMode;
260
+ }
261
+ if (this.applySymbology !== defaultOptions.applySymbology) {
262
+ config.applySymbology = this.applySymbology;
263
+ }
264
+ if (this.calculateNormals !== defaultOptions.calculateNormals) {
265
+ config.calculateNormals = this.calculateNormals;
266
+ }
267
+ if (this.showFeatures !== defaultOptions.showFeatures) {
268
+ config.showFeatures = this.showFeatures;
269
+ }
270
+
271
+ if (this.screenSpaceError !== defaultOptions.screenSpaceError) {
272
+ config.screenSpaceError = this.screenSpaceError;
273
+ }
274
+ if (this.screenSpaceErrorMobile !== defaultOptions.screenSpaceErrorMobile) {
275
+ config.screenSpaceErrorMobile = this.screenSpaceErrorMobile;
276
+ }
277
+ if (this.hasBatchTable !== defaultOptions.hasBatchTable) {
278
+ config.hasBatchTable = this.hasBatchTable;
279
+ }
280
+ if (this.highlightStyle) {
281
+ config.highlightStyle = this.highlightStyle.toJSON();
282
+ }
283
+
284
+ const tilesetOptions = { ...this.cesium3dTilesetOptions };
285
+ if (tilesetOptions.outlineColor) {
286
+ config.outlineColor = getStringColor(
287
+ cesiumColorToColor(tilesetOptions.outlineColor),
288
+ );
289
+ }
290
+ delete tilesetOptions.outlineColor;
291
+
292
+ if (tilesetOptions.lightColor) {
293
+ config.lightColor = {
294
+ x: tilesetOptions.lightColor.x,
295
+ y: tilesetOptions.lightColor.y,
296
+ z: tilesetOptions.lightColor.z,
297
+ };
298
+ }
299
+ delete tilesetOptions.lightColor;
300
+
301
+ const usedScreenSpaceError = isMobile()
302
+ ? this.screenSpaceErrorMobile
303
+ : this.screenSpaceError;
304
+ if (tilesetOptions.maximumScreenSpaceError === usedScreenSpaceError) {
305
+ delete tilesetOptions.maximumScreenSpaceError;
306
+ }
307
+
308
+ if (Object.keys(tilesetOptions).length > 0) {
309
+ config.cesium3dTilesetOptions = structuredClone(tilesetOptions);
310
+ }
311
+
312
+ if (
313
+ this._attributeProvider &&
314
+ !(this._attributeProvider instanceof I3SAttributeProvider) &&
315
+ !(this._attributeProvider instanceof AbstractFeatureProvider)
316
+ ) {
317
+ config.attributeProvider = this._attributeProvider.toJSON();
318
+ if (this._attributeProvider instanceof CompositeFeatureProvider) {
319
+ const { featureProviders, attributeProviders } =
320
+ this._attributeProvider.toJSON();
321
+ config.featureProvider = featureProviders[0];
322
+ if (!(attributeProviders[0] instanceof I3SAttributeProvider)) {
323
+ config.attributeProvider = attributeProviders[0];
324
+ }
325
+ } else {
326
+ config.attributeProvider = this._attributeProvider.toJSON();
327
+ }
328
+ }
329
+
330
+ return config;
331
+ }
332
+
333
+ /**
334
+ * disposes of this layer, removes instances from the current maps and the framework
335
+ */
336
+ destroy(): void {
337
+ this.attributeProvider?.destroy();
338
+ super.destroy();
339
+ }
340
+ }
341
+
342
+ layerClassRegistry.registerClass(I3SLayer.className, I3SLayer);
343
+ export default I3SLayer;
@@ -11,7 +11,16 @@ import { layerClassRegistry } from '../classRegistry.js';
11
11
  import GlobalHider from './globalHider.js';
12
12
  import type VcsMap from '../map/vcsMap.js';
13
13
  import type LayerImplementation from './layerImplementation.js';
14
- import type AbstractFeatureProvider from '../featureProvider/abstractFeatureProvider.js';
14
+ import {
15
+ type default as AbstractFeatureProvider,
16
+ type AbstractFeatureProviderOptions,
17
+ } from '../featureProvider/abstractFeatureProvider.js';
18
+ import type {
19
+ // eslint-disable-next-line import/no-named-default
20
+ default as AbstractAttributeProvider,
21
+ AbstractAttributeProviderOptions,
22
+ } from '../featureProvider/abstractAttributeProvider.js';
23
+ import { getProviderForOption } from '../featureProvider/featureProviderFactory.js';
15
24
 
16
25
  export type CopyrightOptions = {
17
26
  provider?: string;
@@ -62,6 +71,14 @@ export type LayerOptions = VcsObjectOptions & {
62
71
  * if true, the layer types of the map will be ignored when checking if the layer is supported
63
72
  */
64
73
  ignoreMapLayerTypes?: boolean;
74
+ /**
75
+ * An optional feature or attribute provider to provide or augment features on click events.
76
+ */
77
+ featureProvider?:
78
+ | AbstractFeatureProvider
79
+ | AbstractAttributeProvider
80
+ | AbstractFeatureProviderOptions
81
+ | AbstractAttributeProviderOptions;
65
82
  };
66
83
 
67
84
  export type LayerImplementationOptions = {
@@ -98,6 +115,7 @@ class Layer<
98
115
  headers: undefined,
99
116
  ignoreMapLayerTypes: false,
100
117
  zIndex: 0,
118
+ featureProvider: undefined,
101
119
  };
102
120
  }
103
121
 
@@ -160,9 +178,12 @@ class Layer<
160
178
  stateChanged: VcsEvent<LayerState>;
161
179
 
162
180
  /**
163
- * An optional feature provider to provider features based on click events.
181
+ * An optional feature or attribute provider to provide or augment features on click events.
164
182
  */
165
- featureProvider: AbstractFeatureProvider | undefined;
183
+ featureProvider:
184
+ | AbstractFeatureProvider
185
+ | AbstractAttributeProvider
186
+ | undefined;
166
187
 
167
188
  private _locale: string;
168
189
 
@@ -235,6 +256,8 @@ class Layer<
235
256
  options.ignoreMapLayerTypes,
236
257
  defaultOptions.ignoreMapLayerTypes,
237
258
  );
259
+
260
+ this.featureProvider = getProviderForOption(options.featureProvider);
238
261
  }
239
262
 
240
263
  /**
@@ -812,6 +835,10 @@ class Layer<
812
835
  config.ignoreMapLayerTypes = this._ignoreMapLayerTypes;
813
836
  }
814
837
 
838
+ if (this.featureProvider) {
839
+ config.featureProvider = this.featureProvider.toJSON();
840
+ }
841
+
815
842
  return config;
816
843
  }
817
844
 
@@ -7,3 +7,8 @@ export const vcsLayerName: unique symbol = Symbol('vcsLayerName');
7
7
  * Symbol added to Cesium3DTilesets to suppress picking.
8
8
  */
9
9
  export const allowPicking: unique symbol = Symbol('allowPicking');
10
+
11
+ /**
12
+ * Symbol to store the I3SNode and the cartesian position on features created from non Cesium3DTileset sources.
13
+ */
14
+ export const i3sData: unique symbol = Symbol('i3sData');
@@ -9,7 +9,10 @@ import VectorTileLayer, {
9
9
  import PanoramaDatasetPanoramaImpl from './panorama/panoramaDatasetPanoramaImpl.js';
10
10
  import type VcsMap from '../map/vcsMap.js';
11
11
  import PanoramaMap from '../map/panoramaMap.js';
12
- import VectorProperties, { PrimitiveOptionsType } from './vectorProperties.js';
12
+ import VectorProperties, {
13
+ PrimitiveOptionsType,
14
+ type VectorPropertiesOptions,
15
+ } from './vectorProperties.js';
13
16
  import { maxZIndexMin50 } from '../util/layerCollection.js';
14
17
  import { layerClassRegistry } from '../classRegistry.js';
15
18
  import FlatGeobufTileProvider from './tileProvider/flatGeobufTileProvider.js';
@@ -30,6 +33,7 @@ export type PanoramaDatasetOptions = Omit<
30
33
  url: string;
31
34
  baseLevel?: number;
32
35
  cameraOffset?: number;
36
+ panoramaVectorProperties?: VectorPropertiesOptions;
33
37
  };
34
38
 
35
39
  export type PanoramaDatasetFeatureProperties = {
@@ -53,6 +57,17 @@ export default class PanoramaDatasetLayer extends VectorTileLayer<PanoramaDatase
53
57
  maxLevel: 22,
54
58
  zIndex: maxZIndexMin50,
55
59
  ignoreMapLayerTypes: true,
60
+ panoramaVectorProperties: {
61
+ altitudeMode: 'absolute',
62
+ primitiveOptions: {
63
+ type: PrimitiveOptionsType.CYLINDER,
64
+ geometryOptions: {
65
+ topRadius: 1,
66
+ bottomRadius: 1,
67
+ length: 0.01,
68
+ },
69
+ },
70
+ },
56
71
  };
57
72
  }
58
73
 
@@ -115,18 +130,20 @@ export default class PanoramaDatasetLayer extends VectorTileLayer<PanoramaDatase
115
130
  defaultOptions.cameraOffset,
116
131
  );
117
132
 
118
- this._panoramaVectorProperties = new VectorProperties({
119
- altitudeMode: 'absolute',
120
- primitiveOptions: {
121
- type: PrimitiveOptionsType.CYLINDER,
122
- geometryOptions: {
123
- topRadius: 1,
124
- bottomRadius: 1,
125
- length: 0.01,
126
- },
127
- offset: [0, 0, this.cameraOffset],
128
- },
129
- });
133
+ defaultOptions.panoramaVectorProperties!.primitiveOptions!.offset = [
134
+ 0,
135
+ 0,
136
+ this.cameraOffset,
137
+ ];
138
+
139
+ this._panoramaVectorProperties = new VectorProperties(
140
+ defaultOptions.panoramaVectorProperties!,
141
+ );
142
+ if (options.panoramaVectorProperties) {
143
+ this._panoramaVectorProperties.setValues(
144
+ options.panoramaVectorProperties,
145
+ );
146
+ }
130
147
 
131
148
  this._supportedMaps.push(PanoramaMap.className);
132
149
  }
@@ -272,6 +289,20 @@ export default class PanoramaDatasetLayer extends VectorTileLayer<PanoramaDatase
272
289
  delete config.zIndex;
273
290
  }
274
291
 
292
+ defaultOptions.panoramaVectorProperties!.primitiveOptions!.offset = [
293
+ 0,
294
+ 0,
295
+ this.cameraOffset,
296
+ ];
297
+ const vectorPropertiesConfig = this._panoramaVectorProperties.getVcsMeta({
298
+ ...VectorProperties.getDefaultOptions(),
299
+ ...defaultOptions.panoramaVectorProperties,
300
+ });
301
+
302
+ if (Object.keys(vectorPropertiesConfig).length > 0) {
303
+ config.panoramaVectorProperties = vectorPropertiesConfig;
304
+ }
305
+
275
306
  const thisDefaultStyle = getStyleOrDefaultStyle(defaultOptions.style);
276
307
  if (this.style.equals(thisDefaultStyle)) {
277
308
  delete config.style;