@vcmap/core 5.0.0-rc.0

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/LICENSE.md +21 -0
  2. package/README.md +44 -0
  3. package/build/postinstall.js +44 -0
  4. package/index.js +139 -0
  5. package/package.json +92 -0
  6. package/src/cesium/cesium3DTileFeature.js +9 -0
  7. package/src/cesium/cesium3DTilePointFeature.js +9 -0
  8. package/src/cesium/cesiumVcsCameraPrimitive.js +146 -0
  9. package/src/cesium/wallpaperMaterial.js +64 -0
  10. package/src/ol/feature.js +47 -0
  11. package/src/ol/geom/circle.js +24 -0
  12. package/src/ol/geom/geometryCollection.js +33 -0
  13. package/src/ol/render/canvas/canvasTileRenderer.js +179 -0
  14. package/src/ol/source/ClusterEnhancedVectorSource.js +39 -0
  15. package/src/ol/source/VcsCluster.js +37 -0
  16. package/src/vcs/vcm/classRegistry.js +106 -0
  17. package/src/vcs/vcm/event/vcsEvent.js +89 -0
  18. package/src/vcs/vcm/globalCollections.js +11 -0
  19. package/src/vcs/vcm/interaction/abstractInteraction.js +149 -0
  20. package/src/vcs/vcm/interaction/coordinateAtPixel.js +102 -0
  21. package/src/vcs/vcm/interaction/eventHandler.js +425 -0
  22. package/src/vcs/vcm/interaction/featureAtPixelInteraction.js +286 -0
  23. package/src/vcs/vcm/interaction/featureProviderInteraction.js +54 -0
  24. package/src/vcs/vcm/interaction/interactionChain.js +124 -0
  25. package/src/vcs/vcm/interaction/interactionType.js +114 -0
  26. package/src/vcs/vcm/layer/buildings.js +17 -0
  27. package/src/vcs/vcm/layer/cesium/cesiumTilesetCesium.js +359 -0
  28. package/src/vcs/vcm/layer/cesium/clusterContext.js +95 -0
  29. package/src/vcs/vcm/layer/cesium/dataSourceCesium.js +171 -0
  30. package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +29 -0
  31. package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +58 -0
  32. package/src/vcs/vcm/layer/cesium/rasterLayerCesium.js +110 -0
  33. package/src/vcs/vcm/layer/cesium/singleImageCesium.js +49 -0
  34. package/src/vcs/vcm/layer/cesium/terrainCesium.js +80 -0
  35. package/src/vcs/vcm/layer/cesium/tmsCesium.js +54 -0
  36. package/src/vcs/vcm/layer/cesium/vectorCesium.js +255 -0
  37. package/src/vcs/vcm/layer/cesium/vectorContext.js +167 -0
  38. package/src/vcs/vcm/layer/cesium/vectorRasterTileCesium.js +116 -0
  39. package/src/vcs/vcm/layer/cesium/vectorTileImageryProvider.js +246 -0
  40. package/src/vcs/vcm/layer/cesium/wmsCesium.js +71 -0
  41. package/src/vcs/vcm/layer/cesium/wmtsCesium.js +101 -0
  42. package/src/vcs/vcm/layer/cesium/x3dmHelper.js +22 -0
  43. package/src/vcs/vcm/layer/cesiumTileset.js +376 -0
  44. package/src/vcs/vcm/layer/czml.js +141 -0
  45. package/src/vcs/vcm/layer/dataSource.js +259 -0
  46. package/src/vcs/vcm/layer/featureLayer.js +261 -0
  47. package/src/vcs/vcm/layer/featureStore.js +647 -0
  48. package/src/vcs/vcm/layer/featureStoreChanges.js +360 -0
  49. package/src/vcs/vcm/layer/featureStoreState.js +19 -0
  50. package/src/vcs/vcm/layer/featureVisibility.js +435 -0
  51. package/src/vcs/vcm/layer/geojson.js +185 -0
  52. package/src/vcs/vcm/layer/geojsonHelpers.js +450 -0
  53. package/src/vcs/vcm/layer/globalHider.js +157 -0
  54. package/src/vcs/vcm/layer/layer.js +752 -0
  55. package/src/vcs/vcm/layer/layerImplementation.js +102 -0
  56. package/src/vcs/vcm/layer/layerState.js +17 -0
  57. package/src/vcs/vcm/layer/layerSymbols.js +6 -0
  58. package/src/vcs/vcm/layer/oblique/layerOblique.js +76 -0
  59. package/src/vcs/vcm/layer/oblique/obliqueHelpers.js +175 -0
  60. package/src/vcs/vcm/layer/oblique/vectorOblique.js +469 -0
  61. package/src/vcs/vcm/layer/openStreetMap.js +194 -0
  62. package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +79 -0
  63. package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +27 -0
  64. package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +121 -0
  65. package/src/vcs/vcm/layer/openlayers/singleImageOpenlayers.js +49 -0
  66. package/src/vcs/vcm/layer/openlayers/tileDebugOpenlayers.js +39 -0
  67. package/src/vcs/vcm/layer/openlayers/tmsOpenlayers.js +62 -0
  68. package/src/vcs/vcm/layer/openlayers/vectorOpenlayers.js +118 -0
  69. package/src/vcs/vcm/layer/openlayers/vectorTileOpenlayers.js +177 -0
  70. package/src/vcs/vcm/layer/openlayers/wmsOpenlayers.js +55 -0
  71. package/src/vcs/vcm/layer/openlayers/wmtsOpenlayers.js +141 -0
  72. package/src/vcs/vcm/layer/pointCloud.js +162 -0
  73. package/src/vcs/vcm/layer/rasterLayer.js +294 -0
  74. package/src/vcs/vcm/layer/singleImage.js +119 -0
  75. package/src/vcs/vcm/layer/terrain.js +122 -0
  76. package/src/vcs/vcm/layer/terrainHelpers.js +123 -0
  77. package/src/vcs/vcm/layer/tileLoadedHelper.js +72 -0
  78. package/src/vcs/vcm/layer/tileProvider/mvtTileProvider.js +104 -0
  79. package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +67 -0
  80. package/src/vcs/vcm/layer/tileProvider/tileProvider.js +584 -0
  81. package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +28 -0
  82. package/src/vcs/vcm/layer/tileProvider/urlTemplateTileProvider.js +106 -0
  83. package/src/vcs/vcm/layer/tms.js +121 -0
  84. package/src/vcs/vcm/layer/vector.js +632 -0
  85. package/src/vcs/vcm/layer/vectorHelpers.js +206 -0
  86. package/src/vcs/vcm/layer/vectorProperties.js +1391 -0
  87. package/src/vcs/vcm/layer/vectorSymbols.js +40 -0
  88. package/src/vcs/vcm/layer/vectorTile.js +480 -0
  89. package/src/vcs/vcm/layer/wfs.js +165 -0
  90. package/src/vcs/vcm/layer/wms.js +270 -0
  91. package/src/vcs/vcm/layer/wmsHelpers.js +65 -0
  92. package/src/vcs/vcm/layer/wmts.js +235 -0
  93. package/src/vcs/vcm/maps/baseOLMap.js +257 -0
  94. package/src/vcs/vcm/maps/cameraLimiter.js +219 -0
  95. package/src/vcs/vcm/maps/cesium.js +1192 -0
  96. package/src/vcs/vcm/maps/map.js +511 -0
  97. package/src/vcs/vcm/maps/mapState.js +17 -0
  98. package/src/vcs/vcm/maps/oblique.js +536 -0
  99. package/src/vcs/vcm/maps/openlayers.js +205 -0
  100. package/src/vcs/vcm/object.js +92 -0
  101. package/src/vcs/vcm/oblique/ObliqueCollection.js +572 -0
  102. package/src/vcs/vcm/oblique/ObliqueDataSet.js +357 -0
  103. package/src/vcs/vcm/oblique/ObliqueImage.js +247 -0
  104. package/src/vcs/vcm/oblique/ObliqueImageMeta.js +126 -0
  105. package/src/vcs/vcm/oblique/ObliqueProvider.js +433 -0
  106. package/src/vcs/vcm/oblique/ObliqueView.js +130 -0
  107. package/src/vcs/vcm/oblique/ObliqueViewDirection.js +40 -0
  108. package/src/vcs/vcm/oblique/helpers.js +483 -0
  109. package/src/vcs/vcm/oblique/parseImageJson.js +248 -0
  110. package/src/vcs/vcm/util/clipping/clippingObject.js +386 -0
  111. package/src/vcs/vcm/util/clipping/clippingObjectManager.js +312 -0
  112. package/src/vcs/vcm/util/clipping/clippingPlaneHelper.js +413 -0
  113. package/src/vcs/vcm/util/collection.js +193 -0
  114. package/src/vcs/vcm/util/dateTime.js +60 -0
  115. package/src/vcs/vcm/util/exclusiveManager.js +135 -0
  116. package/src/vcs/vcm/util/extent.js +124 -0
  117. package/src/vcs/vcm/util/featureProvider/abstractFeatureProvider.js +196 -0
  118. package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +51 -0
  119. package/src/vcs/vcm/util/featureProvider/featureProviderSymbols.js +11 -0
  120. package/src/vcs/vcm/util/featureProvider/tileProviderFeatureProvider.js +62 -0
  121. package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +280 -0
  122. package/src/vcs/vcm/util/featureconverter/circleToCesium.js +215 -0
  123. package/src/vcs/vcm/util/featureconverter/convert.js +83 -0
  124. package/src/vcs/vcm/util/featureconverter/extent3d.js +154 -0
  125. package/src/vcs/vcm/util/featureconverter/featureconverterHelper.js +591 -0
  126. package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +171 -0
  127. package/src/vcs/vcm/util/featureconverter/pointToCesium.js +359 -0
  128. package/src/vcs/vcm/util/featureconverter/polygonToCesium.js +229 -0
  129. package/src/vcs/vcm/util/geometryHelpers.js +172 -0
  130. package/src/vcs/vcm/util/indexedCollection.js +158 -0
  131. package/src/vcs/vcm/util/isMobile.js +12 -0
  132. package/src/vcs/vcm/util/layerCollection.js +216 -0
  133. package/src/vcs/vcm/util/locale.js +53 -0
  134. package/src/vcs/vcm/util/mapCollection.js +363 -0
  135. package/src/vcs/vcm/util/math.js +71 -0
  136. package/src/vcs/vcm/util/projection.js +348 -0
  137. package/src/vcs/vcm/util/splitScreen.js +233 -0
  138. package/src/vcs/vcm/util/style/declarativeStyleItem.js +631 -0
  139. package/src/vcs/vcm/util/style/shapesCategory.js +67 -0
  140. package/src/vcs/vcm/util/style/styleFactory.js +48 -0
  141. package/src/vcs/vcm/util/style/styleHelpers.js +555 -0
  142. package/src/vcs/vcm/util/style/styleItem.js +226 -0
  143. package/src/vcs/vcm/util/style/vectorStyleItem.js +927 -0
  144. package/src/vcs/vcm/util/style/writeStyle.js +48 -0
  145. package/src/vcs/vcm/util/urlHelpers.js +16 -0
  146. package/src/vcs/vcm/util/viewpoint.js +333 -0
@@ -0,0 +1,259 @@
1
+ import { EntityCollection } from '@vcmap/cesium';
2
+ import Layer from './layer.js';
3
+ import CesiumMap from '../maps/cesium.js';
4
+ import DataSourceCesium from './cesium/dataSourceCesium.js';
5
+ import { vcsLayerName } from './layerSymbols.js';
6
+ import FeatureVisibility, { FeatureVisibilityAction } from './featureVisibility.js';
7
+ import { getGlobalHider } from './globalHider.js';
8
+ import { VcsClassRegistry } from '../classRegistry.js';
9
+
10
+ /**
11
+ * @typedef {LayerOptions} DataSourceOptions
12
+ * @property {Object|undefined} genericFeatureProperties
13
+ * @api
14
+ */
15
+
16
+ /**
17
+ * @typedef {Object} DataSourcePickedObject
18
+ * @property {import("@vcmap/cesium").Entity} id
19
+ * @property {ClickPosition} clickedPosition
20
+ * @property {Object} attributes
21
+ */
22
+
23
+ /**
24
+ * @typedef {LayerImplementationOptions} DataSourceImplementationOptions
25
+ * @property {import("@vcmap/cesium").EntityCollection} entities
26
+ * @property {import("@vcmap/cesium").DataSourceClock|undefined} clock
27
+ * @api
28
+ */
29
+
30
+ /**
31
+ * Represents a layer of Cesium.Entity
32
+ * @class
33
+ * @export
34
+ * @extends {Layer}
35
+ * @api stable
36
+ */
37
+ class DataSource extends Layer {
38
+ static get className() { return 'vcs.vcm.layer.DataSource'; }
39
+
40
+ /**
41
+ * @returns {DataSourceOptions}
42
+ */
43
+ static getDefaultOptions() {
44
+ return {
45
+ ...Layer.getDefaultOptions(),
46
+ genericFeatureProperties: {},
47
+ };
48
+ }
49
+
50
+ /**
51
+ * @param {DataSourceOptions} options
52
+ */
53
+ constructor(options) {
54
+ super(options);
55
+ const defaultOptions = DataSource.getDefaultOptions();
56
+ /**
57
+ * The entities of this layer. Use the `addEntity` API to add Enitities to ensure interoperability with vcm interfaces
58
+ * @type {import("@vcmap/cesium").EntityCollection}
59
+ * @api
60
+ */
61
+ this.entities = new EntityCollection();
62
+ /**
63
+ * @type {import("@vcmap/cesium").DataSourceClock|undefined}
64
+ */
65
+ this.clock = undefined;
66
+ /**
67
+ * @type {Object}
68
+ * @private
69
+ */
70
+ this._genericFeatureProperties = options.genericFeatureProperties || defaultOptions.genericFeatureProperties;
71
+
72
+ /**
73
+ * The feature visibility of this layer. NOTE: Entities cannot be highlighted at this moment.
74
+ * @type {FeatureVisibility}
75
+ * @api
76
+ */
77
+ this.featureVisibility = new FeatureVisibility();
78
+ /**
79
+ * @type {Array<Function>}
80
+ * @private
81
+ */
82
+ this._featureVisibilityListeners = [];
83
+
84
+ this._supportedMaps = [
85
+ CesiumMap.className,
86
+ ];
87
+ }
88
+
89
+ /**
90
+ * Sets up listeners for featureVisibility and global hider
91
+ * @private
92
+ */
93
+ _setUpFeatureVisibility() {
94
+ const globalHider = getGlobalHider();
95
+ this._featureVisibilityListeners = [
96
+ this.featureVisibility.changed.addEventListener(({ action, ids }) => {
97
+ if (action === FeatureVisibilityAction.HIDE) {
98
+ ids.forEach((id) => {
99
+ const entity = this.entities.getById(id);
100
+ if (entity) {
101
+ this.featureVisibility.addHiddenFeature(id, entity);
102
+ }
103
+ });
104
+ } // highlight is _possible_ but very tricky with all the possible entity values with potential materials
105
+ }),
106
+ globalHider.changed.addEventListener(({ action, ids }) => {
107
+ if (action === FeatureVisibilityAction.HIDE) {
108
+ ids.forEach((id) => {
109
+ const entity = this.entities.getById(id);
110
+ if (entity) {
111
+ globalHider.addFeature(id, entity);
112
+ }
113
+ });
114
+ }
115
+ }),
116
+ this.entities.collectionChanged.addEventListener((c, added) => {
117
+ added.forEach((entity) => {
118
+ if (this.featureVisibility.hiddenObjects[entity.id]) {
119
+ this.featureVisibility.addHiddenFeature(entity.id, entity);
120
+ }
121
+
122
+ if (globalHider.hiddenObjects[entity.id]) {
123
+ globalHider.addFeature(entity.id, entity);
124
+ }
125
+ });
126
+ }),
127
+ ];
128
+ }
129
+
130
+ /**
131
+ * @inheritDoc
132
+ * @returns {Promise<void>}
133
+ */
134
+ initialize() {
135
+ if (!this.initialized) {
136
+ this._setUpFeatureVisibility();
137
+ }
138
+ return super.initialize();
139
+ }
140
+
141
+ /**
142
+ * @returns {DataSourceImplementationOptions}
143
+ */
144
+ getImplementationOptions() {
145
+ return {
146
+ ...super.getImplementationOptions(),
147
+ entities: this.entities,
148
+ clock: this.clock,
149
+ };
150
+ }
151
+
152
+ /**
153
+ * @param {CesiumMap} map
154
+ * @returns {Array<DataSourceCesium>}
155
+ */
156
+ createImplementationsForMap(map) {
157
+ if (map instanceof CesiumMap) {
158
+ return [new DataSourceCesium(map, this.getImplementationOptions())];
159
+ }
160
+ return [];
161
+ }
162
+
163
+ /**
164
+ * adds an entity
165
+ * @param {import("@vcmap/cesium").Entity.ConstructorOptions|import("@vcmap/cesium").Entity} options - Cesium Entity options or the entity
166
+ * @param {?Object=} attributes - a set of properties, typically used for rendering a balloon
167
+ * @param {boolean=} allowPicking - whether to override the layers allowPicking setting for this entity
168
+ * @returns {null|string} the entities id
169
+ * @api stable
170
+ */
171
+ addEntity(options, attributes, allowPicking) {
172
+ const entity = this.entities.add(options);
173
+ entity[vcsLayerName] = this.name;
174
+ entity.attributes = attributes;
175
+ entity.allowPicking = allowPicking;
176
+ return entity.id;
177
+ }
178
+
179
+ /**
180
+ * Zooms to an entity with the given id
181
+ * @param {string} id
182
+ * @api stable
183
+ */
184
+ flyToEntity(id) {
185
+ this.getImplementations().forEach((impl) => {
186
+ /** @type {DataSourceCesium} */ (impl).flyToEntity(id);
187
+ });
188
+ }
189
+
190
+ /**
191
+ * Removes an entity from this layer by id
192
+ * @param {string} id
193
+ * @api
194
+ */
195
+ removeEntityById(id) {
196
+ this.entities.removeById(id);
197
+ }
198
+
199
+ /**
200
+ * @param {DataSourcePickedObject} object
201
+ * @returns {?Object}
202
+ */
203
+ objectClickedHandler(object) {
204
+ if (this.allowPicking && object.id.allowPicking !== false) {
205
+ const model = object.id;
206
+ const { id } = model;
207
+ // @ts-ignore
208
+ model.clickedPosition = object.clickedPosition;
209
+ return {
210
+ id,
211
+ feature: object,
212
+ };
213
+ }
214
+ return null;
215
+ }
216
+
217
+ /**
218
+ * @param {DataSourcePickedObject} object
219
+ * @returns {GenericFeature}
220
+ */
221
+ getGenericFeatureFromClickedObject(object) {
222
+ const attributes = { ...this._genericFeatureProperties, ...object.attributes || {} };
223
+ return {
224
+ layerName: this.name,
225
+ layerClass: this.className,
226
+ attributes,
227
+ longitude: object.clickedPosition.longitude,
228
+ latitude: object.clickedPosition.latitude,
229
+ height: object.clickedPosition.height,
230
+ relativeToGround: false,
231
+ };
232
+ }
233
+
234
+ /**
235
+ * @inheritDoc
236
+ * @returns {DataSourceOptions}
237
+ */
238
+ getConfigObject() {
239
+ const config = /** @type {DataSourceOptions} */ (super.getConfigObject());
240
+ if (Object.keys(this._genericFeatureProperties).length > 0) {
241
+ config.genericFeatureProperties = { ...this._genericFeatureProperties };
242
+ }
243
+ return config;
244
+ }
245
+
246
+ /**
247
+ * @inheritDoc
248
+ */
249
+ destroy() {
250
+ this.entities.removeAll();
251
+ this._featureVisibilityListeners.forEach((cb) => { cb(); });
252
+ this._featureVisibilityListeners = [];
253
+ this.featureVisibility.destroy();
254
+ super.destroy();
255
+ }
256
+ }
257
+
258
+ VcsClassRegistry.registerClass(DataSource.className, DataSource);
259
+ export default DataSource;
@@ -0,0 +1,261 @@
1
+ import Style from 'ol/style/Style.js';
2
+
3
+ import { check } from '@vcsuite/check';
4
+ import { parseInteger } from '@vcsuite/parsers';
5
+ import Layer from './layer.js';
6
+ import StyleItem, { referenceableStyleSymbol } from '../util/style/styleItem.js';
7
+ import VectorStyleItem from '../util/style/vectorStyleItem.js';
8
+ import FeatureVisibility from './featureVisibility.js';
9
+ import { getStyleOrDefaultStyle } from '../util/style/styleFactory.js';
10
+ import VcsEvent from '../event/vcsEvent.js';
11
+ import { styleCollection } from '../globalCollections.js';
12
+ import { VcsClassRegistry } from '../classRegistry.js';
13
+
14
+ /**
15
+ * @typedef {LayerOptions} FeatureLayerOptions
16
+ * @property {DeclarativeStyleItemOptions|VectorStyleItemOptions|import("@vcmap/core").StyleItem|string|undefined} style
17
+ * @property {string|undefined} activeStyleName - vcs:undocumented
18
+ * @property {Object|undefined} genericFeatureProperties - properties to add to generic features, eg for display in the balloon
19
+ * @property {number} [balloonHeightOffset=10]
20
+ * @property {FeatureVisibility|undefined} featureVisibility - vcs:undocumented
21
+ * @api
22
+ */
23
+
24
+ /**
25
+ * @typedef {LayerImplementationOptions} FeatureLayerImplementationOptions
26
+ * @property {FeatureVisibility} featureVisibility
27
+ * @property {import("@vcmap/core").StyleItem} style
28
+ * @api
29
+ */
30
+
31
+ /**
32
+ * Event called on a layers <b>styleChanged</b> property, when a layers style changes, with the following parameters.
33
+ * @typedef {Object} FeatureLayer.StyleChangedEvent
34
+ * @property {import("@vcmap/core").StyleItem} newStyle
35
+ * @property {import("@vcmap/core").StyleItem|undefined} oldStyle
36
+ * @api
37
+ */
38
+
39
+ /**
40
+ * @typedef {import("@vcmap/core").LayerImplementation<import("@vcmap/core").VcsMap>} FeatureLayerImplementation
41
+ * @property {function(import("@vcmap/core").StyleItem, boolean=):void} updateStyle
42
+ */
43
+
44
+ /**
45
+ * Base class for all layers representing features, e.g. Vector, Buildings, POIs
46
+ * @class
47
+ * @abstract
48
+ * @extends {Layer}
49
+ * @export
50
+ * @api
51
+ */
52
+ class FeatureLayer extends Layer {
53
+ /** @type {string} */
54
+ static get className() { return 'vcs.vcm.layer.FeatureLayer'; }
55
+
56
+ /**
57
+ * @returns {FeatureLayerOptions}
58
+ */
59
+ static getDefaultOptions() {
60
+ return {
61
+ ...Layer.getDefaultOptions(),
62
+ style: undefined,
63
+ balloonHeightOffset: 10,
64
+ genericFeatureProperties: {},
65
+ };
66
+ }
67
+
68
+ /**
69
+ * @param {FeatureLayerOptions} options
70
+ */
71
+ constructor(options) {
72
+ super(options);
73
+ const defaultOptions = FeatureLayer.getDefaultOptions();
74
+
75
+ /**
76
+ * @type {import("@vcmap/core").StyleItem}
77
+ * @private
78
+ */
79
+ this._style = this.getStyleOrDefaultStyle(options.activeStyleName || options.style);
80
+ /**
81
+ * @type {import("@vcmap/core").StyleItem}
82
+ * @private
83
+ */
84
+ this._defaultStyle = this._style;
85
+ /**
86
+ * An event, called when the style of the layer changes. Is passed the new style item as its value.
87
+ * @type {VcsEvent<import("@vcmap/core").StyleItem>}
88
+ * @api
89
+ */
90
+ this.styleChanged = new VcsEvent();
91
+ /**
92
+ * @type {Object}
93
+ * @private
94
+ */
95
+ this._genericFeatureProperties = options.genericFeatureProperties || defaultOptions.genericFeatureProperties;
96
+
97
+ /**
98
+ * a height offset for rendering of a balloon for a feature of this layer.
99
+ * @type {number}
100
+ * @api
101
+ */
102
+ this.balloonHeightOffset = parseInteger(options.balloonHeightOffset, defaultOptions.balloonHeightOffset);
103
+
104
+ /**
105
+ * FeatureVisibility tracks the highlighting and hiding of features on this layer
106
+ * @type {FeatureVisibility}
107
+ */
108
+ this.featureVisibility = options.featureVisibility || new FeatureVisibility();
109
+ }
110
+
111
+ /**
112
+ * The style the layer had at construction
113
+ * @type {import("@vcmap/core").StyleItem}
114
+ * @api
115
+ * @readonly
116
+ */
117
+ get defaultStyle() {
118
+ return this._defaultStyle;
119
+ }
120
+
121
+ /**
122
+ * style, use setStyle to change
123
+ * @api
124
+ * @type {import("@vcmap/core").StyleItem}
125
+ * @readonly
126
+ */
127
+ get style() {
128
+ return this._style;
129
+ }
130
+
131
+ /**
132
+ * Generic properties to be added to each feature. Use assignGenericFeatureProperties to change them.
133
+ * @type {Object}
134
+ * @readonly
135
+ */
136
+ get genericFeatureProperties() {
137
+ return this._genericFeatureProperties;
138
+ }
139
+
140
+ /**
141
+ * @returns {FeatureLayerImplementationOptions}
142
+ */
143
+ getImplementationOptions() {
144
+ return {
145
+ ...super.getImplementationOptions(),
146
+ featureVisibility: this.featureVisibility,
147
+ style: this.style,
148
+ };
149
+ }
150
+
151
+ /**
152
+ * @param {Object|import("ol").Feature<import("ol/geom/Geometry").default>|import("@vcmap/cesium").Cesium3DTilePointFeature|import("@vcmap/cesium").Cesium3DTileFeature|DataSourcePickedObject} object
153
+ * @returns {?Object}
154
+ */
155
+ // eslint-disable-next-line no-unused-vars,class-methods-use-this
156
+ objectClickedHandler(object) { // XXX remove after event implementation
157
+ return null;
158
+ }
159
+
160
+ /**
161
+ * This is called by the selectBehavior to create generic features from clicked objects
162
+ * needs to be implemented by each layer which has clickable objects
163
+ * @param {Object|VectorClickedObject|import("ol").Feature<import("ol/geom/Geometry").default>} object
164
+ * @returns {GenericFeature}
165
+ */
166
+ // eslint-disable-next-line no-unused-vars
167
+ getGenericFeatureFromClickedObject(object) { // XXX remove after event implementation
168
+ this.getLogger().warning('This method should be implemented by any specific layers');
169
+ return null;
170
+ }
171
+
172
+ /**
173
+ * Set properties, which are always added to the generic object, eg. for use in balloons
174
+ * @param {Object} properties
175
+ * @api
176
+ */
177
+ assignGenericFeatureProperties(properties) {
178
+ check(properties, Object);
179
+ Object.assign(this._genericFeatureProperties, properties);
180
+ }
181
+
182
+ /**
183
+ * @param {(Reference|DeclarativeStyleItemOptions|VectorStyleItemOptions|import("@vcmap/core").StyleItem|string)=} styleOptions
184
+ * @param {(import("@vcmap/core").VectorStyleItem|import("@vcmap/core").DeclarativeStyleItem)=} defaultStyle
185
+ * @returns {import("@vcmap/core").StyleItem}
186
+ */
187
+ // eslint-disable-next-line class-methods-use-this
188
+ getStyleOrDefaultStyle(styleOptions, defaultStyle) {
189
+ return getStyleOrDefaultStyle(styleOptions, defaultStyle);
190
+ }
191
+
192
+ /**
193
+ * Sets the style based on a styleName on a layer
194
+ * @param {string|import("ol/style/Style").default|import("ol/style/Style").StyleFunction|import("@vcmap/core").StyleItem} style
195
+ * @param {boolean=} silent
196
+ * @api
197
+ */
198
+ setStyle(style, silent) {
199
+ check(style, [Style, StyleItem, Function, String]);
200
+
201
+ if (typeof style === 'string') {
202
+ const styleItem = styleCollection.getByKey(style);
203
+ if (!styleItem) {
204
+ this.getLogger().warning(`could not find style with name ${style}`);
205
+ return;
206
+ }
207
+ this._style = styleItem;
208
+ } else if (style instanceof StyleItem) {
209
+ this._style = style;
210
+ } else {
211
+ this._style = new VectorStyleItem({});
212
+ this._style.style = /** @type {import("ol/style/Style").default} */ (style);
213
+ }
214
+ this.getImplementations()
215
+ .forEach((impl) => {
216
+ /** @type {FeatureLayerImplementation} */ (impl).updateStyle(this._style, silent);
217
+ });
218
+ this.styleChanged.raiseEvent(this._style);
219
+ }
220
+
221
+ /**
222
+ * Clears the style of this layer
223
+ * @api stable
224
+ */
225
+ clearStyle() {
226
+ this.setStyle(this.defaultStyle);
227
+ }
228
+
229
+ /**
230
+ * @returns {FeatureLayerOptions}
231
+ */
232
+ getConfigObject() {
233
+ const config = /** @type {FeatureLayerOptions} */ (super.getConfigObject());
234
+ if (!this.getStyleOrDefaultStyle().equals(this._style)) {
235
+ if (this._style[referenceableStyleSymbol]) {
236
+ config.style = this.style.getReference();
237
+ } else {
238
+ config.style = this.style.getOptions();
239
+ }
240
+ }
241
+
242
+ if (Object.keys(this._genericFeatureProperties).length > 0) {
243
+ config.genericFeatureProperties = { ...this._genericFeatureProperties };
244
+ }
245
+ return config;
246
+ }
247
+
248
+ /**
249
+ * @inheritDoc
250
+ */
251
+ destroy() {
252
+ if (this.featureVisibility) {
253
+ this.featureVisibility.destroy();
254
+ }
255
+ this.styleChanged.destroy();
256
+ super.destroy();
257
+ }
258
+ }
259
+
260
+ VcsClassRegistry.registerClass(FeatureLayer.className, FeatureLayer);
261
+ export default FeatureLayer;