@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.
- package/LICENSE.md +21 -0
- package/README.md +44 -0
- package/build/postinstall.js +44 -0
- package/index.js +139 -0
- package/package.json +92 -0
- package/src/cesium/cesium3DTileFeature.js +9 -0
- package/src/cesium/cesium3DTilePointFeature.js +9 -0
- package/src/cesium/cesiumVcsCameraPrimitive.js +146 -0
- package/src/cesium/wallpaperMaterial.js +64 -0
- package/src/ol/feature.js +47 -0
- package/src/ol/geom/circle.js +24 -0
- package/src/ol/geom/geometryCollection.js +33 -0
- package/src/ol/render/canvas/canvasTileRenderer.js +179 -0
- package/src/ol/source/ClusterEnhancedVectorSource.js +39 -0
- package/src/ol/source/VcsCluster.js +37 -0
- package/src/vcs/vcm/classRegistry.js +106 -0
- package/src/vcs/vcm/event/vcsEvent.js +89 -0
- package/src/vcs/vcm/globalCollections.js +11 -0
- package/src/vcs/vcm/interaction/abstractInteraction.js +149 -0
- package/src/vcs/vcm/interaction/coordinateAtPixel.js +102 -0
- package/src/vcs/vcm/interaction/eventHandler.js +425 -0
- package/src/vcs/vcm/interaction/featureAtPixelInteraction.js +286 -0
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +54 -0
- package/src/vcs/vcm/interaction/interactionChain.js +124 -0
- package/src/vcs/vcm/interaction/interactionType.js +114 -0
- package/src/vcs/vcm/layer/buildings.js +17 -0
- package/src/vcs/vcm/layer/cesium/cesiumTilesetCesium.js +359 -0
- package/src/vcs/vcm/layer/cesium/clusterContext.js +95 -0
- package/src/vcs/vcm/layer/cesium/dataSourceCesium.js +171 -0
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +29 -0
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +58 -0
- package/src/vcs/vcm/layer/cesium/rasterLayerCesium.js +110 -0
- package/src/vcs/vcm/layer/cesium/singleImageCesium.js +49 -0
- package/src/vcs/vcm/layer/cesium/terrainCesium.js +80 -0
- package/src/vcs/vcm/layer/cesium/tmsCesium.js +54 -0
- package/src/vcs/vcm/layer/cesium/vectorCesium.js +255 -0
- package/src/vcs/vcm/layer/cesium/vectorContext.js +167 -0
- package/src/vcs/vcm/layer/cesium/vectorRasterTileCesium.js +116 -0
- package/src/vcs/vcm/layer/cesium/vectorTileImageryProvider.js +246 -0
- package/src/vcs/vcm/layer/cesium/wmsCesium.js +71 -0
- package/src/vcs/vcm/layer/cesium/wmtsCesium.js +101 -0
- package/src/vcs/vcm/layer/cesium/x3dmHelper.js +22 -0
- package/src/vcs/vcm/layer/cesiumTileset.js +376 -0
- package/src/vcs/vcm/layer/czml.js +141 -0
- package/src/vcs/vcm/layer/dataSource.js +259 -0
- package/src/vcs/vcm/layer/featureLayer.js +261 -0
- package/src/vcs/vcm/layer/featureStore.js +647 -0
- package/src/vcs/vcm/layer/featureStoreChanges.js +360 -0
- package/src/vcs/vcm/layer/featureStoreState.js +19 -0
- package/src/vcs/vcm/layer/featureVisibility.js +435 -0
- package/src/vcs/vcm/layer/geojson.js +185 -0
- package/src/vcs/vcm/layer/geojsonHelpers.js +450 -0
- package/src/vcs/vcm/layer/globalHider.js +157 -0
- package/src/vcs/vcm/layer/layer.js +752 -0
- package/src/vcs/vcm/layer/layerImplementation.js +102 -0
- package/src/vcs/vcm/layer/layerState.js +17 -0
- package/src/vcs/vcm/layer/layerSymbols.js +6 -0
- package/src/vcs/vcm/layer/oblique/layerOblique.js +76 -0
- package/src/vcs/vcm/layer/oblique/obliqueHelpers.js +175 -0
- package/src/vcs/vcm/layer/oblique/vectorOblique.js +469 -0
- package/src/vcs/vcm/layer/openStreetMap.js +194 -0
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +79 -0
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +27 -0
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +121 -0
- package/src/vcs/vcm/layer/openlayers/singleImageOpenlayers.js +49 -0
- package/src/vcs/vcm/layer/openlayers/tileDebugOpenlayers.js +39 -0
- package/src/vcs/vcm/layer/openlayers/tmsOpenlayers.js +62 -0
- package/src/vcs/vcm/layer/openlayers/vectorOpenlayers.js +118 -0
- package/src/vcs/vcm/layer/openlayers/vectorTileOpenlayers.js +177 -0
- package/src/vcs/vcm/layer/openlayers/wmsOpenlayers.js +55 -0
- package/src/vcs/vcm/layer/openlayers/wmtsOpenlayers.js +141 -0
- package/src/vcs/vcm/layer/pointCloud.js +162 -0
- package/src/vcs/vcm/layer/rasterLayer.js +294 -0
- package/src/vcs/vcm/layer/singleImage.js +119 -0
- package/src/vcs/vcm/layer/terrain.js +122 -0
- package/src/vcs/vcm/layer/terrainHelpers.js +123 -0
- package/src/vcs/vcm/layer/tileLoadedHelper.js +72 -0
- package/src/vcs/vcm/layer/tileProvider/mvtTileProvider.js +104 -0
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +67 -0
- package/src/vcs/vcm/layer/tileProvider/tileProvider.js +584 -0
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +28 -0
- package/src/vcs/vcm/layer/tileProvider/urlTemplateTileProvider.js +106 -0
- package/src/vcs/vcm/layer/tms.js +121 -0
- package/src/vcs/vcm/layer/vector.js +632 -0
- package/src/vcs/vcm/layer/vectorHelpers.js +206 -0
- package/src/vcs/vcm/layer/vectorProperties.js +1391 -0
- package/src/vcs/vcm/layer/vectorSymbols.js +40 -0
- package/src/vcs/vcm/layer/vectorTile.js +480 -0
- package/src/vcs/vcm/layer/wfs.js +165 -0
- package/src/vcs/vcm/layer/wms.js +270 -0
- package/src/vcs/vcm/layer/wmsHelpers.js +65 -0
- package/src/vcs/vcm/layer/wmts.js +235 -0
- package/src/vcs/vcm/maps/baseOLMap.js +257 -0
- package/src/vcs/vcm/maps/cameraLimiter.js +219 -0
- package/src/vcs/vcm/maps/cesium.js +1192 -0
- package/src/vcs/vcm/maps/map.js +511 -0
- package/src/vcs/vcm/maps/mapState.js +17 -0
- package/src/vcs/vcm/maps/oblique.js +536 -0
- package/src/vcs/vcm/maps/openlayers.js +205 -0
- package/src/vcs/vcm/object.js +92 -0
- package/src/vcs/vcm/oblique/ObliqueCollection.js +572 -0
- package/src/vcs/vcm/oblique/ObliqueDataSet.js +357 -0
- package/src/vcs/vcm/oblique/ObliqueImage.js +247 -0
- package/src/vcs/vcm/oblique/ObliqueImageMeta.js +126 -0
- package/src/vcs/vcm/oblique/ObliqueProvider.js +433 -0
- package/src/vcs/vcm/oblique/ObliqueView.js +130 -0
- package/src/vcs/vcm/oblique/ObliqueViewDirection.js +40 -0
- package/src/vcs/vcm/oblique/helpers.js +483 -0
- package/src/vcs/vcm/oblique/parseImageJson.js +248 -0
- package/src/vcs/vcm/util/clipping/clippingObject.js +386 -0
- package/src/vcs/vcm/util/clipping/clippingObjectManager.js +312 -0
- package/src/vcs/vcm/util/clipping/clippingPlaneHelper.js +413 -0
- package/src/vcs/vcm/util/collection.js +193 -0
- package/src/vcs/vcm/util/dateTime.js +60 -0
- package/src/vcs/vcm/util/exclusiveManager.js +135 -0
- package/src/vcs/vcm/util/extent.js +124 -0
- package/src/vcs/vcm/util/featureProvider/abstractFeatureProvider.js +196 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +51 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderSymbols.js +11 -0
- package/src/vcs/vcm/util/featureProvider/tileProviderFeatureProvider.js +62 -0
- package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +280 -0
- package/src/vcs/vcm/util/featureconverter/circleToCesium.js +215 -0
- package/src/vcs/vcm/util/featureconverter/convert.js +83 -0
- package/src/vcs/vcm/util/featureconverter/extent3d.js +154 -0
- package/src/vcs/vcm/util/featureconverter/featureconverterHelper.js +591 -0
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +171 -0
- package/src/vcs/vcm/util/featureconverter/pointToCesium.js +359 -0
- package/src/vcs/vcm/util/featureconverter/polygonToCesium.js +229 -0
- package/src/vcs/vcm/util/geometryHelpers.js +172 -0
- package/src/vcs/vcm/util/indexedCollection.js +158 -0
- package/src/vcs/vcm/util/isMobile.js +12 -0
- package/src/vcs/vcm/util/layerCollection.js +216 -0
- package/src/vcs/vcm/util/locale.js +53 -0
- package/src/vcs/vcm/util/mapCollection.js +363 -0
- package/src/vcs/vcm/util/math.js +71 -0
- package/src/vcs/vcm/util/projection.js +348 -0
- package/src/vcs/vcm/util/splitScreen.js +233 -0
- package/src/vcs/vcm/util/style/declarativeStyleItem.js +631 -0
- package/src/vcs/vcm/util/style/shapesCategory.js +67 -0
- package/src/vcs/vcm/util/style/styleFactory.js +48 -0
- package/src/vcs/vcm/util/style/styleHelpers.js +555 -0
- package/src/vcs/vcm/util/style/styleItem.js +226 -0
- package/src/vcs/vcm/util/style/vectorStyleItem.js +927 -0
- package/src/vcs/vcm/util/style/writeStyle.js +48 -0
- package/src/vcs/vcm/util/urlHelpers.js +16 -0
- package/src/vcs/vcm/util/viewpoint.js +333 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import("@vcmap/cesium").Cesium3DTileFeature|import("@vcmap/cesium").Cesium3DTilePointFeature} feature
|
|
3
|
+
* @returns {Object}
|
|
4
|
+
*/
|
|
5
|
+
export default function getJSONObjectFromObject(feature) {
|
|
6
|
+
const properties = feature.getPropertyNames();
|
|
7
|
+
const JSONObject = {};
|
|
8
|
+
for (let i = 0; i < properties.length; i++) {
|
|
9
|
+
JSONObject[properties[i]] = feature.getProperty(properties[i]);
|
|
10
|
+
}
|
|
11
|
+
if (JSONObject.id == null) {
|
|
12
|
+
JSONObject.id = `${feature.content.url}${feature._batchId}`;
|
|
13
|
+
}
|
|
14
|
+
if (JSONObject.attributes) {
|
|
15
|
+
JSONObject.attributes.gmlId = JSONObject.id;
|
|
16
|
+
} else if (JSONObject.gmlId == null) {
|
|
17
|
+
JSONObject.gmlId = JSONObject.id;
|
|
18
|
+
}
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
JSONObject.clickedPosition = feature.clickedPosition ? feature.clickedPosition : {};
|
|
21
|
+
return JSONObject;
|
|
22
|
+
}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { ImagerySplitDirection, Matrix4 } from '@vcmap/cesium';
|
|
2
|
+
|
|
3
|
+
import { checkMaybe } from '@vcsuite/check';
|
|
4
|
+
import { parseInteger } from '@vcsuite/parsers';
|
|
5
|
+
import getJSONObjectFromObject from './cesium/x3dmHelper.js';
|
|
6
|
+
import VectorStyleItem from '../util/style/vectorStyleItem.js';
|
|
7
|
+
import FeatureLayer from './featureLayer.js';
|
|
8
|
+
import CesiumTilesetCesium, { getExtentFromTileset } from './cesium/cesiumTilesetCesium.js';
|
|
9
|
+
import CesiumMap from '../maps/cesium.js';
|
|
10
|
+
import VcsEvent from '../event/vcsEvent.js';
|
|
11
|
+
import Extent from '../util/extent.js';
|
|
12
|
+
import { mercatorProjection } from '../util/projection.js';
|
|
13
|
+
import { isMobile } from '../util/isMobile.js';
|
|
14
|
+
import { referenceableStyleSymbol } from '../util/style/styleItem.js';
|
|
15
|
+
import { VcsClassRegistry } from '../classRegistry.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {LayerOptions} CesiumTilesetOptions
|
|
19
|
+
* @property {number|undefined} [screenSpaceError=16] - relates inversely to the depth over which the layer is activated
|
|
20
|
+
* @property {number|undefined} [screenSpaceErrorMobile=32] - relates inversely to the depth over which the layer is activated
|
|
21
|
+
* @property {number|undefined} [maximumMemoryUsage=16] - sets the cesium maximumMemoryUsage Parameter (Is when the cached tiles exceed this value cesium starts to clear the cached tiles)
|
|
22
|
+
* @property {Object|undefined} tilesetOptions
|
|
23
|
+
* @property {import("@vcmap/core").VectorStyleItem|VectorStyleItemOptions|undefined} highlightStyle
|
|
24
|
+
* @property {import("@vcmap/core").FeatureVisibility|undefined} featureVisibility
|
|
25
|
+
* @property {string|undefined} splitDirection - either 'left' or 'right', if omitted none is applied
|
|
26
|
+
* @property {import("ol/coordinate").Coordinate|undefined} offset - an offset of x, y, z. x and y in degrees longitude/latitude respectively
|
|
27
|
+
* @api
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {Object} CesiumTilesetTilesetProperties
|
|
32
|
+
* @property {string|symbol} key
|
|
33
|
+
* @property {*} value
|
|
34
|
+
* @api
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @typedef {FeatureLayerImplementationOptions} CesiumTilesetImplementationOptions
|
|
39
|
+
* @property {Object|undefined} tilesetOptions
|
|
40
|
+
* @property {import("@vcmap/cesium").ImagerySplitDirection} splitDirection
|
|
41
|
+
* @property {Array<CesiumTilesetTilesetProperties>|undefined} tilesetProperties
|
|
42
|
+
* @property {import("@vcmap/cesium").Matrix4|undefined} modelMatrix
|
|
43
|
+
* @property {import("ol/coordinate").Coordinate|undefined} offset
|
|
44
|
+
* @api
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* represents a specific Building layer for cesium.
|
|
49
|
+
* @class
|
|
50
|
+
* @extends {FeatureLayer}
|
|
51
|
+
* @implements {SplitLayer}
|
|
52
|
+
* @api stable
|
|
53
|
+
* @export
|
|
54
|
+
*/
|
|
55
|
+
class CesiumTileset extends FeatureLayer {
|
|
56
|
+
/** @type {string} */
|
|
57
|
+
static get className() { return 'vcs.vcm.layer.CesiumTileset'; }
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @returns {CesiumTilesetOptions}
|
|
61
|
+
*/
|
|
62
|
+
static getDefaultOptions() {
|
|
63
|
+
return {
|
|
64
|
+
...FeatureLayer.getDefaultOptions(),
|
|
65
|
+
highlightStyle: undefined,
|
|
66
|
+
screenSpaceError: 16,
|
|
67
|
+
screenSpaceErrorMobile: 32,
|
|
68
|
+
maximumMemoryUsage: 16,
|
|
69
|
+
tilesetOptions: {},
|
|
70
|
+
splitDirection: undefined,
|
|
71
|
+
offset: undefined,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param {CesiumTilesetOptions} options
|
|
77
|
+
*/
|
|
78
|
+
constructor(options) {
|
|
79
|
+
super(options);
|
|
80
|
+
this._supportedMaps = [
|
|
81
|
+
CesiumMap.className,
|
|
82
|
+
];
|
|
83
|
+
const defaultOptions = CesiumTileset.getDefaultOptions();
|
|
84
|
+
if (this.url && !/\.json$/.test(this.url)) {
|
|
85
|
+
this.url = `${this.url.replace(/\/$/, '')}/tileset.json`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** @type {VectorStyleItem} */
|
|
89
|
+
this.highlightStyle = null;
|
|
90
|
+
if (options.highlightStyle) {
|
|
91
|
+
this.highlightStyle = options.highlightStyle instanceof VectorStyleItem ?
|
|
92
|
+
options.highlightStyle :
|
|
93
|
+
new VectorStyleItem(/** @type {VectorStyleItemOptions} */ (options.highlightStyle));
|
|
94
|
+
}
|
|
95
|
+
/** @type {number} */
|
|
96
|
+
this.screenSpaceError = parseInteger(options.screenSpaceError, defaultOptions.screenSpaceError);
|
|
97
|
+
|
|
98
|
+
/** @type {number} */
|
|
99
|
+
this.screenSpaceErrorMobile = parseInteger(options.screenSpaceErrorMobile, defaultOptions.screenSpaceErrorMobile);
|
|
100
|
+
|
|
101
|
+
/** @type {number} */
|
|
102
|
+
this.maximumMemoryUsage = parseInteger(options.maximumMemoryUsage, defaultOptions.maximumMemoryUsage);
|
|
103
|
+
|
|
104
|
+
const tilesetOptions = options.tilesetOptions || defaultOptions.tilesetOptions;
|
|
105
|
+
|
|
106
|
+
/** @type {!Object} */
|
|
107
|
+
this.tilesetOptions = {
|
|
108
|
+
url: this.url,
|
|
109
|
+
maximumScreenSpaceError: isMobile() ? this.screenSpaceErrorMobile : this.screenSpaceError,
|
|
110
|
+
maximumMemoryUsage: this.maximumMemoryUsage,
|
|
111
|
+
...tilesetOptions,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** @type {import("@vcmap/cesium").ImagerySplitDirection} */
|
|
115
|
+
this._splitDirection = ImagerySplitDirection.NONE;
|
|
116
|
+
|
|
117
|
+
if (options.splitDirection) {
|
|
118
|
+
this._splitDirection = options.splitDirection === 'left' ?
|
|
119
|
+
ImagerySplitDirection.LEFT :
|
|
120
|
+
ImagerySplitDirection.RIGHT;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* raised if the split direction changes, is passed the split direction as its only argument
|
|
125
|
+
* @type {VcsEvent<import("@vcmap/cesium").ImagerySplitDirection>}
|
|
126
|
+
* @api
|
|
127
|
+
*/
|
|
128
|
+
this.splitDirectionChanged = new VcsEvent();
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @type {import("@vcmap/cesium").Matrix4|undefined}
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
this._modelMatrix = undefined;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @type {import("ol/coordinate").Coordinate|undefined}
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
this._offset = options.offset || defaultOptions.offset;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A model matrix to apply to each cesium3DTileset created from this layer.
|
|
145
|
+
* This will overwrite any modelMatrix calculated by the offset property.
|
|
146
|
+
* @api
|
|
147
|
+
* @returns {import("@vcmap/cesium").Matrix4|undefined}
|
|
148
|
+
*/
|
|
149
|
+
get modelMatrix() {
|
|
150
|
+
return this._modelMatrix;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @param {import("@vcmap/cesium").Matrix4|undefined} modelMatrix
|
|
155
|
+
*/
|
|
156
|
+
set modelMatrix(modelMatrix) {
|
|
157
|
+
checkMaybe(modelMatrix, Matrix4);
|
|
158
|
+
|
|
159
|
+
this._modelMatrix = modelMatrix;
|
|
160
|
+
this.getImplementations()
|
|
161
|
+
.forEach(/** @param {CesiumTilesetCesium} impl */ (impl) => {
|
|
162
|
+
impl.updateModelMatrix(modelMatrix);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* An offset in x, y, z. x and y are in degrees longitude latitude respectively.
|
|
168
|
+
* If a modelMatrix is defined on this layer, setting an offset will not take effect until you
|
|
169
|
+
* set the modelMatrix to undefined.
|
|
170
|
+
* @api
|
|
171
|
+
* @type {import("ol/coordinate").Coordinate|undefined}
|
|
172
|
+
*/
|
|
173
|
+
get offset() {
|
|
174
|
+
return this._offset;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @param {import("ol/coordinate").Coordinate|undefined} offset
|
|
179
|
+
*/
|
|
180
|
+
set offset(offset) {
|
|
181
|
+
checkMaybe(offset, [Number]);
|
|
182
|
+
|
|
183
|
+
this._offset = offset;
|
|
184
|
+
this.getImplementations()
|
|
185
|
+
.forEach(/** @param {CesiumTilesetCesium} impl */ (impl) => {
|
|
186
|
+
impl.updateOffset(offset);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @api
|
|
192
|
+
* @type {import("@vcmap/cesium").ImagerySplitDirection}
|
|
193
|
+
*/
|
|
194
|
+
get splitDirection() { return this._splitDirection; }
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @param {import("@vcmap/cesium").ImagerySplitDirection} direction
|
|
198
|
+
*/
|
|
199
|
+
set splitDirection(direction) {
|
|
200
|
+
if (direction !== this._splitDirection) {
|
|
201
|
+
this.getImplementations().forEach((impl) => {
|
|
202
|
+
/** @type {CesiumTilesetCesium} */ (impl).updateSplitDirection(direction);
|
|
203
|
+
});
|
|
204
|
+
this._splitDirection = direction;
|
|
205
|
+
this.splitDirectionChanged.raiseEvent(this._splitDirection);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @inheritDoc
|
|
211
|
+
* @returns {CesiumTilesetImplementationOptions}
|
|
212
|
+
*/
|
|
213
|
+
getImplementationOptions() {
|
|
214
|
+
return {
|
|
215
|
+
...super.getImplementationOptions(),
|
|
216
|
+
tilesetOptions: this.tilesetOptions,
|
|
217
|
+
splitDirection: this.splitDirection,
|
|
218
|
+
modelMatrix: this.modelMatrix,
|
|
219
|
+
offset: this.offset,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @inheritDoc
|
|
225
|
+
* @param {import("@vcmap/core").VcsMap} map
|
|
226
|
+
* @returns {Array<CesiumTilesetCesium>}
|
|
227
|
+
*/
|
|
228
|
+
createImplementationsForMap(map) {
|
|
229
|
+
if (map instanceof CesiumMap) {
|
|
230
|
+
return [new CesiumTilesetCesium(map, this.getImplementationOptions())];
|
|
231
|
+
}
|
|
232
|
+
return [];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @inheritDoc
|
|
237
|
+
* @param {import("@vcmap/cesium").Cesium3DTileFeature|import("@vcmap/cesium").Cesium3DTilePointFeature} object
|
|
238
|
+
* @returns {?Object}
|
|
239
|
+
*/
|
|
240
|
+
objectClickedHandler(object) {
|
|
241
|
+
if (this.allowPicking) {
|
|
242
|
+
const jsonObject = getJSONObjectFromObject(object);
|
|
243
|
+
if (jsonObject) {
|
|
244
|
+
return {
|
|
245
|
+
id: jsonObject.id,
|
|
246
|
+
feature: jsonObject,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Returns the configured Extent of this layer or tries to calculate the extent based on tileset.
|
|
255
|
+
* Returns null of no extent was configured and the layers tileset is not yet loaded or ready.
|
|
256
|
+
* @returns {Extent|null}
|
|
257
|
+
* @api
|
|
258
|
+
*/
|
|
259
|
+
getZoomToExtent() {
|
|
260
|
+
const metaExtent = super.getZoomToExtent();
|
|
261
|
+
if (metaExtent) {
|
|
262
|
+
return metaExtent;
|
|
263
|
+
}
|
|
264
|
+
const impl = /** @type {CesiumTilesetCesium} */ (this.getImplementations()[0]);
|
|
265
|
+
if (impl) {
|
|
266
|
+
const threeDimExtent = getExtentFromTileset(impl.cesium3DTileset);
|
|
267
|
+
|
|
268
|
+
const actualExtent = new Extent({
|
|
269
|
+
...mercatorProjection.getConfigObject(),
|
|
270
|
+
coordinates: threeDimExtent,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
if (actualExtent.isValid()) {
|
|
274
|
+
return actualExtent;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// TODO type params
|
|
282
|
+
getGenericFeatureFromClickedObject(object) {
|
|
283
|
+
const attributes = { ...this.genericFeatureProperties, ...object.attributes || object };
|
|
284
|
+
return {
|
|
285
|
+
layerName: this.name,
|
|
286
|
+
layerClass: this.className,
|
|
287
|
+
attributes,
|
|
288
|
+
longitude: object.clickedPosition.longitude,
|
|
289
|
+
latitude: object.clickedPosition.latitude,
|
|
290
|
+
height: object.clickedPosition.height + this.balloonHeightOffset,
|
|
291
|
+
relativeToGround: false,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* set the maximum screenspace error of this layer
|
|
297
|
+
* @param {number} value
|
|
298
|
+
* @api stable
|
|
299
|
+
*/
|
|
300
|
+
setMaximumScreenSpaceError(value) {
|
|
301
|
+
this.getImplementations()
|
|
302
|
+
.forEach(/** @param {CesiumTilesetCesium} impl */(impl) => {
|
|
303
|
+
if (impl.cesium3DTileset) {
|
|
304
|
+
impl.cesium3DTileset.maximumScreenSpaceError = value;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @returns {CesiumTilesetOptions}
|
|
311
|
+
*/
|
|
312
|
+
getConfigObject() {
|
|
313
|
+
/** @type {CesiumTilesetOptions} */
|
|
314
|
+
const config = super.getConfigObject();
|
|
315
|
+
const defaultOptions = CesiumTileset.getDefaultOptions();
|
|
316
|
+
if (this.highlightStyle) {
|
|
317
|
+
config.highlightStyle = this.highlightStyle[referenceableStyleSymbol] ?
|
|
318
|
+
this.highlightStyle.getReference() :
|
|
319
|
+
this.highlightStyle.getOptions();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (this.screenSpaceError !== defaultOptions.screenSpaceError) {
|
|
323
|
+
config.screenSpaceError = this.screenSpaceError;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (this.screenSpaceErrorMobile !== defaultOptions.screenSpaceErrorMobile) {
|
|
327
|
+
config.screenSpaceErrorMobile = this.screenSpaceErrorMobile;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (this.maximumMemoryUsage !== defaultOptions.maximumMemoryUsage) {
|
|
331
|
+
config.maximumMemoryUsage = this.maximumMemoryUsage;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const tilesetOptions = { ...this.tilesetOptions };
|
|
335
|
+
if (tilesetOptions.url === this.url) {
|
|
336
|
+
delete tilesetOptions.url;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const usedScreenSpaceError = isMobile() ? this.screenSpaceErrorMobile : this.screenSpaceError;
|
|
340
|
+
if (tilesetOptions.maximumScreenSpaceError === usedScreenSpaceError) {
|
|
341
|
+
delete tilesetOptions.maximumScreenSpaceError;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (tilesetOptions.maximumMemoryUsage === this.maximumMemoryUsage) {
|
|
345
|
+
delete tilesetOptions.maximumMemoryUsage;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (Object.keys(tilesetOptions).length > 0) {
|
|
349
|
+
config.tilesetOptions = tilesetOptions;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (this._splitDirection !== ImagerySplitDirection.NONE) {
|
|
353
|
+
config.splitDirection = this._splitDirection === ImagerySplitDirection.RIGHT ?
|
|
354
|
+
'right' :
|
|
355
|
+
'left';
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (Array.isArray(this.offset)) {
|
|
359
|
+
config.offset = this.offset.slice();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return config;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* disposes of this layer, removes instances from the current maps and the framework
|
|
367
|
+
* @api stable
|
|
368
|
+
*/
|
|
369
|
+
destroy() {
|
|
370
|
+
super.destroy();
|
|
371
|
+
this.splitDirectionChanged.destroy();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
VcsClassRegistry.registerClass(CesiumTileset.className, CesiumTileset);
|
|
376
|
+
export default CesiumTileset;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CzmlDataSource } from '@vcmap/cesium';
|
|
2
|
+
|
|
3
|
+
import DataSource from './dataSource.js';
|
|
4
|
+
import { vcsLayerName } from './layerSymbols.js';
|
|
5
|
+
import { VcsClassRegistry } from '../classRegistry.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {DataSourceOptions} CzmlOptions
|
|
9
|
+
* @property {string|undefined} sourceUri
|
|
10
|
+
* @api
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @class
|
|
15
|
+
* @export
|
|
16
|
+
* @extends {DataSource}
|
|
17
|
+
*/
|
|
18
|
+
class Czml extends DataSource {
|
|
19
|
+
static get className() { return 'vcs.vcm.layer.Czml'; }
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @returns {CzmlOptions}
|
|
23
|
+
*/
|
|
24
|
+
static getDefaultOptions() {
|
|
25
|
+
return {
|
|
26
|
+
...DataSource.getDefaultOptions(),
|
|
27
|
+
sourceUri: undefined,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {CzmlOptions} options
|
|
33
|
+
*/
|
|
34
|
+
constructor(options) {
|
|
35
|
+
super(options);
|
|
36
|
+
this.dataSource = new CzmlDataSource();
|
|
37
|
+
this.entities = this.dataSource.entities;
|
|
38
|
+
|
|
39
|
+
const defaultOptions = Czml.getDefaultOptions();
|
|
40
|
+
/** @type {string|null} */
|
|
41
|
+
this.sourceUri = options.sourceUri || defaultOptions.sourceUri;
|
|
42
|
+
/** @type {Function} */
|
|
43
|
+
this._loadedResolve = () => {};
|
|
44
|
+
/** @type {Function} */
|
|
45
|
+
this._loadedReject = () => {};
|
|
46
|
+
/**
|
|
47
|
+
* A Promise resolving with the DataSource on load
|
|
48
|
+
* @type {Promise<void>}
|
|
49
|
+
* @api stable
|
|
50
|
+
*/
|
|
51
|
+
this.loaded = new Promise(((resolve, reject) => {
|
|
52
|
+
this._loadedResolve = resolve;
|
|
53
|
+
this._loadedReject = reject;
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @inheritDoc
|
|
59
|
+
* @returns {Promise<void>}
|
|
60
|
+
*/
|
|
61
|
+
initialize() {
|
|
62
|
+
if (!this._initializedPromise) {
|
|
63
|
+
this._initializedPromise = this._loadData()
|
|
64
|
+
.then(() => super.initialize())
|
|
65
|
+
.then(() => {
|
|
66
|
+
this._loadedResolve();
|
|
67
|
+
})
|
|
68
|
+
.catch((err) => {
|
|
69
|
+
this._loadedReject(err);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return this._initializedPromise;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @returns {Promise<void>}
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
async _loadData() {
|
|
80
|
+
const loaded = /** @type {import("@vcmap/cesium").CzmlDataSource} */ (this.dataSource)
|
|
81
|
+
.load(this.url, this.sourceUri ? { sourceUri: this.sourceUri } : undefined);
|
|
82
|
+
await new Promise((resolve, reject) => {
|
|
83
|
+
loaded.then(resolve, reject);
|
|
84
|
+
});
|
|
85
|
+
this.entities.values.forEach((entity) => {
|
|
86
|
+
entity[vcsLayerName] = this.name;
|
|
87
|
+
});
|
|
88
|
+
this.clock = this.dataSource.clock;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @inheritDoc
|
|
93
|
+
* @returns {Promise<void>}
|
|
94
|
+
*/
|
|
95
|
+
async reload() {
|
|
96
|
+
this.entities.removeAll();
|
|
97
|
+
await this._loadData();
|
|
98
|
+
await this.forceRedraw();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @inheritDoc
|
|
103
|
+
* @returns {CzmlOptions}
|
|
104
|
+
*/
|
|
105
|
+
getConfigObject() {
|
|
106
|
+
const config = /** @type {CzmlOptions} */ (super.getConfigObject());
|
|
107
|
+
if (this.sourceUri) {
|
|
108
|
+
config.sourceUri = this.sourceUri;
|
|
109
|
+
}
|
|
110
|
+
return config;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @inheritDoc
|
|
115
|
+
*/
|
|
116
|
+
destroy() {
|
|
117
|
+
super.destroy();
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
120
|
+
this.dataSource._entityCluster.destroy();
|
|
121
|
+
// @ts-ignore
|
|
122
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
123
|
+
this.dataSource._entityCluster = null;
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
126
|
+
this.dataSource._entityCollection = null;
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
129
|
+
this.dataSource._changed = null;
|
|
130
|
+
// @ts-ignore
|
|
131
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
132
|
+
this.dataSource._error = null;
|
|
133
|
+
// @ts-ignore
|
|
134
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
135
|
+
this.dataSource._loading = null;
|
|
136
|
+
this.dataSource = null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
VcsClassRegistry.registerClass(Czml.className, Czml);
|
|
141
|
+
export default Czml;
|