@vcmap/core 6.0.7 → 6.1.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 (146) hide show
  1. package/dist/cesium.d.ts +3 -0
  2. package/dist/index.d.ts +16 -1
  3. package/dist/index.js +16 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/ol.d.ts +8 -1
  6. package/dist/src/featureProvider/featureProviderSymbols.d.ts +5 -0
  7. package/dist/src/featureProvider/featureProviderSymbols.js +5 -1
  8. package/dist/src/featureProvider/featureProviderSymbols.js.map +1 -1
  9. package/dist/src/interaction/featureAtPixelInteraction.js +58 -62
  10. package/dist/src/interaction/featureAtPixelInteraction.js.map +1 -1
  11. package/dist/src/interaction/featureProviderInteraction.js +25 -13
  12. package/dist/src/interaction/featureProviderInteraction.js.map +1 -1
  13. package/dist/src/layer/cesium/sourceVectorContextSync.d.ts +27 -0
  14. package/dist/src/layer/cesium/sourceVectorContextSync.js +94 -0
  15. package/dist/src/layer/cesium/sourceVectorContextSync.js.map +1 -0
  16. package/dist/src/layer/cesium/vectorCesiumImpl.d.ts +4 -27
  17. package/dist/src/layer/cesium/vectorCesiumImpl.js +15 -107
  18. package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
  19. package/dist/src/layer/cesium/vectorContext.d.ts +12 -1
  20. package/dist/src/layer/cesium/vectorContext.js +6 -0
  21. package/dist/src/layer/cesium/vectorContext.js.map +1 -1
  22. package/dist/src/layer/layerSymbols.js +1 -1
  23. package/dist/src/layer/layerSymbols.js.map +1 -1
  24. package/dist/src/layer/oblique/sourceObliqueSync.d.ts +18 -0
  25. package/dist/src/layer/oblique/sourceObliqueSync.js +319 -0
  26. package/dist/src/layer/oblique/sourceObliqueSync.js.map +1 -0
  27. package/dist/src/layer/oblique/vectorObliqueImpl.d.ts +2 -40
  28. package/dist/src/layer/oblique/vectorObliqueImpl.js +8 -283
  29. package/dist/src/layer/oblique/vectorObliqueImpl.js.map +1 -1
  30. package/dist/src/layer/vectorLayer.d.ts +10 -1
  31. package/dist/src/layer/vectorLayer.js +23 -1
  32. package/dist/src/layer/vectorLayer.js.map +1 -1
  33. package/dist/src/map/baseOLMap.js +8 -1
  34. package/dist/src/map/baseOLMap.js.map +1 -1
  35. package/dist/src/map/cesiumMap.d.ts +2 -0
  36. package/dist/src/map/cesiumMap.js +26 -1
  37. package/dist/src/map/cesiumMap.js.map +1 -1
  38. package/dist/src/map/vcsMap.d.ts +24 -12
  39. package/dist/src/map/vcsMap.js +92 -38
  40. package/dist/src/map/vcsMap.js.map +1 -1
  41. package/dist/src/ol/source/ClusterEnhancedVectorSource.d.ts +6 -4
  42. package/dist/src/ol/source/ClusterEnhancedVectorSource.js +4 -9
  43. package/dist/src/ol/source/ClusterEnhancedVectorSource.js.map +1 -1
  44. package/dist/src/ol/source/VcsCluster.d.ts +10 -10
  45. package/dist/src/ol/source/VcsCluster.js +23 -7
  46. package/dist/src/ol/source/VcsCluster.js.map +1 -1
  47. package/dist/src/util/clipping/clippingPolygonHelper.d.ts +7 -0
  48. package/dist/src/util/clipping/clippingPolygonHelper.js +53 -0
  49. package/dist/src/util/clipping/clippingPolygonHelper.js.map +1 -0
  50. package/dist/src/util/clipping/clippingPolygonObject.d.ts +59 -0
  51. package/dist/src/util/clipping/clippingPolygonObject.js +158 -0
  52. package/dist/src/util/clipping/clippingPolygonObject.js.map +1 -0
  53. package/dist/src/util/clipping/clippingPolygonObjectCollection.d.ts +18 -0
  54. package/dist/src/util/clipping/clippingPolygonObjectCollection.js +167 -0
  55. package/dist/src/util/clipping/clippingPolygonObjectCollection.js.map +1 -0
  56. package/dist/src/util/layerCollection.d.ts +11 -1
  57. package/dist/src/util/layerCollection.js +67 -12
  58. package/dist/src/util/layerCollection.js.map +1 -1
  59. package/dist/src/util/mapCollection.d.ts +16 -1
  60. package/dist/src/util/mapCollection.js +37 -3
  61. package/dist/src/util/mapCollection.js.map +1 -1
  62. package/dist/src/util/renderScreenshot.d.ts +9 -0
  63. package/dist/src/util/renderScreenshot.js +162 -0
  64. package/dist/src/util/renderScreenshot.js.map +1 -0
  65. package/dist/src/util/rotation.d.ts +30 -0
  66. package/dist/src/util/rotation.js +145 -0
  67. package/dist/src/util/rotation.js.map +1 -0
  68. package/dist/src/util/vcsTemplate.d.ts +7 -0
  69. package/dist/src/util/vcsTemplate.js +248 -0
  70. package/dist/src/util/vcsTemplate.js.map +1 -0
  71. package/dist/src/vcsApp.d.ts +7 -0
  72. package/dist/src/vcsApp.js +29 -0
  73. package/dist/src/vcsApp.js.map +1 -1
  74. package/dist/src/vcsModule.d.ts +6 -2
  75. package/dist/src/vcsModule.js.map +1 -1
  76. package/dist/src/vectorCluster/vectorClusterCesiumContext.d.ts +18 -0
  77. package/dist/src/{layer/cesium/clusterContext.js → vectorCluster/vectorClusterCesiumContext.js} +28 -42
  78. package/dist/src/vectorCluster/vectorClusterCesiumContext.js.map +1 -0
  79. package/dist/src/vectorCluster/vectorClusterGroup.d.ts +96 -0
  80. package/dist/src/vectorCluster/vectorClusterGroup.js +320 -0
  81. package/dist/src/vectorCluster/vectorClusterGroup.js.map +1 -0
  82. package/dist/src/vectorCluster/vectorClusterGroupCesiumImpl.d.ts +20 -0
  83. package/dist/src/vectorCluster/vectorClusterGroupCesiumImpl.js +115 -0
  84. package/dist/src/vectorCluster/vectorClusterGroupCesiumImpl.js.map +1 -0
  85. package/dist/src/vectorCluster/vectorClusterGroupCollection.d.ts +19 -0
  86. package/dist/src/vectorCluster/vectorClusterGroupCollection.js +37 -0
  87. package/dist/src/vectorCluster/vectorClusterGroupCollection.js.map +1 -0
  88. package/dist/src/vectorCluster/vectorClusterGroupImpl.d.ts +31 -0
  89. package/dist/src/vectorCluster/vectorClusterGroupImpl.js +76 -0
  90. package/dist/src/vectorCluster/vectorClusterGroupImpl.js.map +1 -0
  91. package/dist/src/vectorCluster/vectorClusterGroupObliqueImpl.d.ts +17 -0
  92. package/dist/src/vectorCluster/vectorClusterGroupObliqueImpl.js +62 -0
  93. package/dist/src/vectorCluster/vectorClusterGroupObliqueImpl.js.map +1 -0
  94. package/dist/src/vectorCluster/vectorClusterGroupOpenlayersImpl.d.ts +17 -0
  95. package/dist/src/vectorCluster/vectorClusterGroupOpenlayersImpl.js +62 -0
  96. package/dist/src/vectorCluster/vectorClusterGroupOpenlayersImpl.js.map +1 -0
  97. package/dist/src/vectorCluster/vectorClusterStyleItem.d.ts +110 -0
  98. package/dist/src/vectorCluster/vectorClusterStyleItem.js +374 -0
  99. package/dist/src/vectorCluster/vectorClusterStyleItem.js.map +1 -0
  100. package/dist/src/vectorCluster/vectorClusterSymbols.d.ts +1 -0
  101. package/dist/src/vectorCluster/vectorClusterSymbols.js +3 -0
  102. package/dist/src/vectorCluster/vectorClusterSymbols.js.map +1 -0
  103. package/index.ts +42 -1
  104. package/package.json +3 -1
  105. package/src/cesium/cesium.d.ts +3 -0
  106. package/src/featureProvider/featureProviderSymbols.ts +6 -1
  107. package/src/interaction/featureAtPixelInteraction.ts +109 -84
  108. package/src/interaction/featureProviderInteraction.ts +42 -28
  109. package/src/layer/cesium/sourceVectorContextSync.ts +134 -0
  110. package/src/layer/cesium/vcsTile/vcsDebugTile.ts +1 -1
  111. package/src/layer/cesium/vcsTile/vcsVectorTile.ts +1 -1
  112. package/src/layer/cesium/vectorCesiumImpl.ts +30 -144
  113. package/src/layer/cesium/vectorContext.ts +17 -1
  114. package/src/layer/layerSymbols.ts +1 -1
  115. package/src/layer/oblique/sourceObliqueSync.ts +436 -0
  116. package/src/layer/oblique/vectorObliqueImpl.ts +11 -397
  117. package/src/layer/vectorLayer.ts +35 -2
  118. package/src/map/baseOLMap.ts +8 -1
  119. package/src/map/cesiumMap.ts +36 -3
  120. package/src/map/vcsMap.ts +121 -47
  121. package/src/ol/ol.d.ts +8 -1
  122. package/src/ol/source/{ClusterEnhancedVectorSource.js → ClusterEnhancedVectorSource.ts} +7 -10
  123. package/src/ol/source/VcsCluster.ts +58 -0
  124. package/src/util/clipping/clippingPolygonHelper.ts +86 -0
  125. package/src/util/clipping/clippingPolygonObject.ts +223 -0
  126. package/src/util/clipping/clippingPolygonObjectCollection.ts +249 -0
  127. package/src/util/layerCollection.ts +90 -12
  128. package/src/util/mapCollection.ts +53 -2
  129. package/src/util/renderScreenshot.ts +193 -0
  130. package/src/util/rotation.ts +215 -0
  131. package/src/util/vcsTemplate.ts +373 -0
  132. package/src/vcsApp.ts +65 -0
  133. package/src/vcsModule.ts +6 -2
  134. package/src/vectorCluster/vectorClusterCesiumContext.ts +123 -0
  135. package/src/vectorCluster/vectorClusterGroup.ts +463 -0
  136. package/src/vectorCluster/vectorClusterGroupCesiumImpl.ts +176 -0
  137. package/src/vectorCluster/vectorClusterGroupCollection.ts +43 -0
  138. package/src/vectorCluster/vectorClusterGroupImpl.ts +107 -0
  139. package/src/vectorCluster/vectorClusterGroupObliqueImpl.ts +84 -0
  140. package/src/vectorCluster/vectorClusterGroupOpenlayersImpl.ts +81 -0
  141. package/src/vectorCluster/vectorClusterStyleItem.ts +490 -0
  142. package/src/vectorCluster/vectorClusterSymbols.ts +2 -0
  143. package/dist/src/layer/cesium/clusterContext.d.ts +0 -20
  144. package/dist/src/layer/cesium/clusterContext.js.map +0 -1
  145. package/src/layer/cesium/clusterContext.ts +0 -140
  146. package/src/ol/source/VcsCluster.js +0 -37
@@ -1,12 +1,5 @@
1
- import { unByKey } from 'ol/Observable.js';
2
- import {
3
- PrimitiveCollection,
4
- type Scene,
5
- type SplitDirection,
6
- } from '@vcmap-cesium/engine';
1
+ import { PrimitiveCollection, type SplitDirection } from '@vcmap-cesium/engine';
7
2
  import type VectorSource from 'ol/source/Vector.js';
8
- import type { EventsKey } from 'ol/events.js';
9
- import type { Feature } from 'ol/index.js';
10
3
  import { vcsLayerName } from '../layerSymbols.js';
11
4
  import LayerImplementation from '../layerImplementation.js';
12
5
  import { synchronizeFeatureVisibilityWithSource } from '../vectorHelpers.js';
@@ -18,6 +11,10 @@ import type StyleItem from '../../style/styleItem.js';
18
11
  import type FeatureVisibility from '../featureVisibility.js';
19
12
  import type GlobalHider from '../globalHider.js';
20
13
  import VectorContext from './vectorContext.js';
14
+ import {
15
+ createSourceVectorContextSync,
16
+ SourceVectorContextSync,
17
+ } from './sourceVectorContextSync.js';
21
18
 
22
19
  /**
23
20
  * represents a specific vector layer for cesium.
@@ -42,21 +39,11 @@ class VectorCesiumImpl
42
39
 
43
40
  private _featureVisibilityListeners: (() => void)[] = [];
44
41
 
45
- // eslint-disable-next-line class-methods-use-this
46
- private _removeVectorPropertiesChangeHandler = (): void => {};
47
-
48
- protected _rootCollection: PrimitiveCollection;
42
+ private _rootCollection: PrimitiveCollection;
49
43
 
50
- private _olListeners: (EventsKey | EventsKey[])[] = [];
51
-
52
- /**
53
- * A set of ol.Features to add once the map is back to cesium
54
- */
55
- private _featureToAdd: Set<Feature> = new Set();
44
+ private _context: VectorContext | null = null;
56
45
 
57
- protected _context: VectorContext | null = null;
58
-
59
- private _scene: Scene | undefined = undefined;
46
+ private _sourceVectorContextSync: SourceVectorContextSync | undefined;
60
47
 
61
48
  globalHider: GlobalHider | undefined;
62
49
 
@@ -74,52 +61,21 @@ class VectorCesiumImpl
74
61
  this.globalHider = options.globalHider;
75
62
  }
76
63
 
77
- private _addListeners(): void {
78
- this._olListeners.push(
79
- this.source.on('addfeature', (event) => {
80
- this._addFeature(event.feature as Feature).catch(() => {
81
- this.getLogger().error('failed to convert feature');
82
- });
83
- }),
84
- );
85
-
86
- this._olListeners.push(
87
- this.source.on('removefeature', (event) => {
88
- this._removeFeature(event.feature as Feature);
89
- }),
90
- );
91
-
92
- this._olListeners.push(
93
- this.source.on('changefeature', (event) => {
94
- this._featureChanged(event.feature as Feature).catch((_e) => {
95
- this.getLogger().error('failed to convert feature');
96
- });
97
- }),
98
- );
99
-
100
- this._removeVectorPropertiesChangeHandler =
101
- this.vectorProperties.propertyChanged.addEventListener(
102
- this.refresh.bind(this),
103
- );
104
- }
105
-
106
- protected _setupContext(cesiumMap: CesiumMap): Promise<void> {
107
- const rootCollection = this._rootCollection;
108
- this._context = new VectorContext(
109
- cesiumMap,
110
- rootCollection,
111
- this.splitDirection,
112
- );
113
- cesiumMap.addPrimitiveCollection(rootCollection);
114
- return Promise.resolve();
115
- }
116
-
117
64
  async initialize(): Promise<void> {
118
65
  if (!this.initialized) {
119
- this._scene = this.map.getScene();
120
- this._addListeners();
121
- this._addFeatures(this.source.getFeatures());
122
- await this._setupContext(this.map);
66
+ this._context = new VectorContext(
67
+ this.map,
68
+ this._rootCollection,
69
+ this.splitDirection,
70
+ );
71
+ this.map.addPrimitiveCollection(this._rootCollection);
72
+ this._sourceVectorContextSync = createSourceVectorContextSync(
73
+ this.source,
74
+ this._context,
75
+ this.map.getScene()!,
76
+ this.style.style,
77
+ this.vectorProperties,
78
+ );
123
79
  }
124
80
  await super.initialize();
125
81
  if (this.splitDirection) {
@@ -127,62 +83,18 @@ class VectorCesiumImpl
127
83
  }
128
84
  }
129
85
 
130
- private _addFeatures(features: Feature[]): void {
131
- // TODO we should make this non-blocking to better handle larger data sets check in RIWA Impl
132
- features.forEach((f) => {
133
- this._addFeature(f).catch((err) => {
134
- this.getLogger().error('failed to convert feature', f, err);
135
- });
136
- });
137
- }
138
-
139
- /**
140
- * converts a feature and adds the associated primitives to the collection of primitives
141
- */
142
- private async _addFeature(feature: Feature): Promise<void> {
143
- if (this.active) {
144
- // XXX cluster check here? or on init?
145
- await this._context!.addFeature(
146
- feature,
147
- this.style.style,
148
- this.vectorProperties,
149
- this._scene as Scene,
150
- );
151
- } else {
152
- this._featureToAdd.add(feature);
153
- }
154
- }
155
-
156
86
  /**
157
87
  * Forces a complete re-render of all features.
158
88
  */
159
89
  refresh(): void {
160
- this._context?.clear();
161
- this._addFeatures(this.source.getFeatures());
162
- }
163
-
164
- /**
165
- * removes the primitive of the specified feature
166
- */
167
- private _removeFeature(feature: Feature): void {
168
- this._context?.removeFeature(feature);
169
- this._featureToAdd.delete(feature);
170
- }
171
-
172
- /**
173
- * called when a features property have changed
174
- */
175
- private async _featureChanged(feature: Feature): Promise<void> {
176
- this._featureToAdd.delete(feature);
177
- await this._addFeature(feature);
90
+ this._sourceVectorContextSync?.refresh();
178
91
  }
179
92
 
180
93
  async activate(): Promise<void> {
181
94
  if (!this.active) {
182
95
  await super.activate();
183
96
  if (this.active) {
184
- this._addFeatures([...this._featureToAdd]);
185
- this._featureToAdd.clear();
97
+ this._sourceVectorContextSync?.activate();
186
98
  this._rootCollection.show = true;
187
99
  if (this._featureVisibilityListeners.length === 0) {
188
100
  this._featureVisibilityListeners =
@@ -198,6 +110,7 @@ class VectorCesiumImpl
198
110
 
199
111
  deactivate(): void {
200
112
  super.deactivate();
113
+ this._sourceVectorContextSync?.deactivate();
201
114
  this._rootCollection.show = false;
202
115
  this._featureVisibilityListeners.forEach((cb) => {
203
116
  cb();
@@ -208,11 +121,10 @@ class VectorCesiumImpl
208
121
  updateStyle(style: StyleItem, silent?: boolean): void {
209
122
  this.style = style;
210
123
  if (this.initialized && !silent) {
211
- const features = this.source.getFeatures().filter((f) => !f.getStyle());
212
- features.forEach((f) => {
213
- // eslint-disable-next-line no-void
214
- void this._featureChanged(f);
215
- });
124
+ this.source
125
+ .getFeatures()
126
+ .filter((f) => !f.getStyle())
127
+ .forEach((f) => f.changed());
216
128
  }
217
129
  }
218
130
 
@@ -223,43 +135,17 @@ class VectorCesiumImpl
223
135
  }
224
136
  }
225
137
 
226
- protected _destroyCollection(): void {
227
- this.map.removePrimitiveCollection(this._rootCollection);
228
- }
229
-
230
138
  destroy(): void {
231
139
  if (this.initialized) {
140
+ this._sourceVectorContextSync?.destroy();
232
141
  this._context?.destroy();
233
- this._destroyCollection();
142
+ this.map.removePrimitiveCollection(this._rootCollection);
234
143
  }
235
144
  this._context = null;
236
- this._scene = undefined;
237
- this._removeVectorPropertiesChangeHandler();
238
- this._olListeners.forEach((listener) => {
239
- unByKey(listener);
240
- });
241
- this._olListeners = [];
242
- this._featureToAdd.clear();
243
145
  this._featureVisibilityListeners.forEach((cb) => {
244
146
  cb();
245
147
  });
246
148
  this._featureVisibilityListeners = [];
247
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
248
- // @ts-ignore
249
- this.source = null;
250
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
251
- // @ts-ignore
252
- this.vectorProperties = null;
253
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
254
- // @ts-ignore
255
- this.featureVisibility = null;
256
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
257
- // @ts-ignore
258
- this.style = null;
259
- this.globalHider = undefined;
260
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
261
- // @ts-ignore
262
- this._rootCollection = null;
263
149
  super.destroy();
264
150
  }
265
151
  }
@@ -124,6 +124,12 @@ export function setupScalingPrimitiveCollection(
124
124
  });
125
125
  }
126
126
 
127
+ /**
128
+ * The context for vector rendering in cesium.
129
+ * Creates 1 to N primitives / models / billboards / labels for each feature
130
+ * added to the context depending on its style & vector properties.
131
+ * Uses the feature converters convert function under the hood to create the primitives.
132
+ */
127
133
  export interface CesiumVectorContext {
128
134
  addFeature(
129
135
  feature: Feature,
@@ -131,15 +137,19 @@ export interface CesiumVectorContext {
131
137
  vectorProperties: VectorProperties,
132
138
  scene: Scene,
133
139
  ): Promise<void>;
140
+ hasFeature(feature: Feature): boolean;
134
141
  removeFeature(feature: Feature): void;
135
- updateSplitDirection(splitDirection: SplitDirection): void;
136
142
  clear(): void;
143
+ destroy(): void;
137
144
  }
138
145
 
139
146
  type ConvertedItemIndex = { type: 'primitive' | 'scaled'; index: number };
140
147
 
141
148
  type ConvertedIndices = { primitive?: number; scaled?: number };
142
149
 
150
+ /**
151
+ * The generic implementation of the vector context for Cesium
152
+ */
143
153
  export default class VectorContext implements CesiumVectorContext {
144
154
  primitives = new PrimitiveCollection();
145
155
 
@@ -359,6 +369,12 @@ export default class VectorContext implements CesiumVectorContext {
359
369
  }
360
370
  }
361
371
 
372
+ hasFeature(feature: Feature): boolean {
373
+ return (
374
+ this._featureItems.has(feature) || this._convertingFeatures.has(feature)
375
+ );
376
+ }
377
+
362
378
  removeFeature(feature: Feature): void {
363
379
  this._convertingFeatures.get(feature)?.(false);
364
380
  this._convertingFeatures.delete(feature);
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Symbol to declare a layers name on its visualizations, e.g. ol.layer.Layer, Cesium.Cesium3DTileset*
3
3
  */
4
- /* eslint-disable import/prefer-default-export */
4
+ // eslint-disable-next-line import/prefer-default-export
5
5
  export const vcsLayerName: unique symbol = Symbol('vcsLayerName');