@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,110 @@
|
|
|
1
|
+
import { vcsLayerName } from '../layerSymbols.js';
|
|
2
|
+
import LayerImplementation from '../layerImplementation.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* RasterLayer implementation for {@link Openlayers}
|
|
6
|
+
* @class
|
|
7
|
+
* @export
|
|
8
|
+
* @extends {LayerImplementation<import("@vcmap/core").CesiumMap>}}
|
|
9
|
+
* @implements {RasterLayerImplementation}
|
|
10
|
+
*/
|
|
11
|
+
class RasterLayerCesium extends LayerImplementation {
|
|
12
|
+
static get className() { return 'vcs.vcm.layer.cesium.RasterLayerCesium'; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {import("@vcmap/core").CesiumMap} map
|
|
16
|
+
* @param {RasterLayerImplementationOptions} options
|
|
17
|
+
*/
|
|
18
|
+
constructor(map, options) {
|
|
19
|
+
super(map, options);
|
|
20
|
+
/** @type {import("@vcmap/cesium").ImageryLayer|null} */
|
|
21
|
+
this.cesiumLayer = null;
|
|
22
|
+
/** @type {import("@vcmap/cesium").ImagerySplitDirection} */
|
|
23
|
+
this.splitDirection = options.splitDirection;
|
|
24
|
+
/** @type {number} */
|
|
25
|
+
this.minLevel = options.minLevel;
|
|
26
|
+
/** @type {number} */
|
|
27
|
+
this.maxLevel = options.maxLevel;
|
|
28
|
+
/** @type {string} */
|
|
29
|
+
this.tilingSchema = options.tilingSchema;
|
|
30
|
+
/** @type {import("@vcmap/core").Extent} */
|
|
31
|
+
this.extent = options.extent;
|
|
32
|
+
/** @type {number} */
|
|
33
|
+
this.opacity = options.opacity;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
* @returns {Promise<void>}
|
|
39
|
+
*/
|
|
40
|
+
initialize() {
|
|
41
|
+
if (!this.initialized) {
|
|
42
|
+
this.cesiumLayer = this.getCesiumLayer();
|
|
43
|
+
this.cesiumLayer[vcsLayerName] = this.name;
|
|
44
|
+
this.cesiumLayer.show = false;
|
|
45
|
+
this.map.addImageryLayer(this.cesiumLayer);
|
|
46
|
+
}
|
|
47
|
+
return super.initialize();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {import("@vcmap/cesium").ImagerySplitDirection} splitDirection
|
|
52
|
+
*/
|
|
53
|
+
updateSplitDirection(splitDirection) {
|
|
54
|
+
this.splitDirection = splitDirection;
|
|
55
|
+
if (this.initialized) {
|
|
56
|
+
this.cesiumLayer.splitDirection = splitDirection;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// eslint-disable-next-line jsdoc/require-returns-check
|
|
61
|
+
/**
|
|
62
|
+
* @returns {import("@vcmap/cesium").ImageryLayer}
|
|
63
|
+
*/
|
|
64
|
+
// eslint-disable-next-line class-methods-use-this
|
|
65
|
+
getCesiumLayer() { throw new Error('implementation error'); }
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @inheritDoc
|
|
69
|
+
* @returns {Promise<void>}
|
|
70
|
+
*/
|
|
71
|
+
async activate() {
|
|
72
|
+
await super.activate();
|
|
73
|
+
if (this.active) {
|
|
74
|
+
this.cesiumLayer.show = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @inheritDoc
|
|
80
|
+
*/
|
|
81
|
+
deactivate() {
|
|
82
|
+
super.deactivate();
|
|
83
|
+
if (this.cesiumLayer) {
|
|
84
|
+
this.cesiumLayer.show = false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {number} opacity
|
|
90
|
+
*/
|
|
91
|
+
updateOpacity(opacity) {
|
|
92
|
+
this.opacity = opacity;
|
|
93
|
+
if (this.initialized && this.cesiumLayer) {
|
|
94
|
+
this.cesiumLayer.alpha = opacity;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @inheritDoc
|
|
100
|
+
*/
|
|
101
|
+
destroy() {
|
|
102
|
+
if (this.cesiumLayer) {
|
|
103
|
+
this.map.removeImageryLayer(this.cesiumLayer);
|
|
104
|
+
}
|
|
105
|
+
this.cesiumLayer = null;
|
|
106
|
+
super.destroy();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default RasterLayerCesium;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Rectangle, SingleTileImageryProvider, ImageryLayer } from '@vcmap/cesium';
|
|
2
|
+
import RasterLayerCesium from './rasterLayerCesium.js';
|
|
3
|
+
import { wgs84Projection } from '../../util/projection.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* represents a specific Cesium SingleTileImagery Layer class.
|
|
7
|
+
* @class
|
|
8
|
+
* @export
|
|
9
|
+
* @extends {RasterLayerCesium}
|
|
10
|
+
*/
|
|
11
|
+
class SingleImageCesium extends RasterLayerCesium {
|
|
12
|
+
static get className() { return 'vcs.vcm.layer.cesium.singleImageLayer'; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {import("@vcmap/core").CesiumMap} map
|
|
16
|
+
* @param {SingleImageImplementationOptions} options
|
|
17
|
+
*/
|
|
18
|
+
constructor(map, options) {
|
|
19
|
+
super(map, options);
|
|
20
|
+
/** @type {string} */
|
|
21
|
+
this.credit = options.credit;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @returns {import("@vcmap/cesium").ImageryLayer}
|
|
26
|
+
*/
|
|
27
|
+
getCesiumLayer() {
|
|
28
|
+
const options = {
|
|
29
|
+
url: this.url,
|
|
30
|
+
credit: this.credit,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const extent = this.extent.getCoordinatesInProjection(wgs84Projection);
|
|
34
|
+
if (extent) {
|
|
35
|
+
options.rectangle = Rectangle.fromDegrees(extent[0], extent[1], extent[2], extent[3]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const imageryProvider = new SingleTileImageryProvider(options);
|
|
39
|
+
const layerOptions = {
|
|
40
|
+
rectangle: options.rectangle,
|
|
41
|
+
alpha: this.opacity,
|
|
42
|
+
defaultAlpha: 1.0,
|
|
43
|
+
splitDirection: this.splitDirection,
|
|
44
|
+
};
|
|
45
|
+
return new ImageryLayer(imageryProvider, layerOptions);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default SingleImageCesium;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import LayerImplementation from '../layerImplementation.js';
|
|
2
|
+
import { vcsLayerName } from '../layerSymbols.js';
|
|
3
|
+
import { getTerrainProviderForUrl } from '../terrainHelpers.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Terrain implementation for {@link CesiumMap}
|
|
8
|
+
* @class
|
|
9
|
+
* @export
|
|
10
|
+
* @extends {LayerImplementation<import("@vcmap/core").CesiumMap>}}
|
|
11
|
+
*/
|
|
12
|
+
class TerrainCesium extends LayerImplementation {
|
|
13
|
+
static get className() { return 'vcs.vcm.layer.cesium.TerrainCesium'; }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {import("@vcmap/core").CesiumMap} map
|
|
17
|
+
* @param {TerrainImplementationOptions} options
|
|
18
|
+
*/
|
|
19
|
+
constructor(map, options) {
|
|
20
|
+
super(map, options);
|
|
21
|
+
/**
|
|
22
|
+
* @type {boolean}
|
|
23
|
+
* @api
|
|
24
|
+
*/
|
|
25
|
+
this.requestVertexNormals = options.requestVertexNormals;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @type {boolean}
|
|
29
|
+
* @api
|
|
30
|
+
*/
|
|
31
|
+
this.requestWaterMask = options.requestWaterMask;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
* @returns {Promise<void>}
|
|
37
|
+
*/
|
|
38
|
+
initialize() {
|
|
39
|
+
if (!this.initialized) {
|
|
40
|
+
this.terrainProvider = getTerrainProviderForUrl({
|
|
41
|
+
url: this.url,
|
|
42
|
+
requestVertexNormals: this.requestVertexNormals,
|
|
43
|
+
requestWaterMask: this.requestWaterMask,
|
|
44
|
+
});
|
|
45
|
+
this.terrainProvider[vcsLayerName] = this.name;
|
|
46
|
+
}
|
|
47
|
+
return super.initialize();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @inheritDoc
|
|
52
|
+
* @returns {Promise<void>}
|
|
53
|
+
*/
|
|
54
|
+
async activate() {
|
|
55
|
+
await super.activate();
|
|
56
|
+
if (this.active) {
|
|
57
|
+
this.map.setTerrainProvider(this.terrainProvider);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @inheritDoc
|
|
63
|
+
*/
|
|
64
|
+
deactivate() {
|
|
65
|
+
super.deactivate();
|
|
66
|
+
if (this.terrainProvider) {
|
|
67
|
+
this.map.unsetTerrainProvider(this.terrainProvider);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @inheritDoc
|
|
73
|
+
*/
|
|
74
|
+
destroy() {
|
|
75
|
+
this.terrainProvider = null;
|
|
76
|
+
super.destroy();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default TerrainCesium;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Rectangle, GeographicTilingScheme, TileMapServiceImageryProvider, ImageryLayer as CesiumImageryLayer } from '@vcmap/cesium';
|
|
2
|
+
import RasterLayerCesium from './rasterLayerCesium.js';
|
|
3
|
+
import { wgs84Projection } from '../../util/projection.js';
|
|
4
|
+
import { TilingScheme } from '../rasterLayer.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* TMS implementation for {@link CesiumMap}.
|
|
8
|
+
* @class
|
|
9
|
+
* @export
|
|
10
|
+
* @extends {RasterLayerCesium}
|
|
11
|
+
*/
|
|
12
|
+
class TMSCesium extends RasterLayerCesium {
|
|
13
|
+
static get className() { return 'vcs.vcm.layer.cesium.TMSCesium'; }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {import("@vcmap/core").CesiumMap} map
|
|
17
|
+
* @param {TMSImplementationOptions} options
|
|
18
|
+
*/
|
|
19
|
+
constructor(map, options) {
|
|
20
|
+
super(map, options);
|
|
21
|
+
/** @type {string} */
|
|
22
|
+
this.format = options.format;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @returns {import("@vcmap/cesium").ImageryLayer}
|
|
27
|
+
*/
|
|
28
|
+
getCesiumLayer() {
|
|
29
|
+
const options = {
|
|
30
|
+
url: this.url,
|
|
31
|
+
fileExtension: this.format,
|
|
32
|
+
maximumLevel: this.maxLevel,
|
|
33
|
+
minimumLevel: this.minLevel,
|
|
34
|
+
show: false,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (this.extent && this.extent.isValid()) {
|
|
38
|
+
const extent = this.extent.getCoordinatesInProjection(wgs84Projection);
|
|
39
|
+
options.rectangle = Rectangle.fromDegrees(extent[0], extent[1], extent[2], extent[3]);
|
|
40
|
+
}
|
|
41
|
+
if (this.tilingSchema === TilingScheme.GEOGRAPHIC) {
|
|
42
|
+
options.tilingScheme = new GeographicTilingScheme();
|
|
43
|
+
}
|
|
44
|
+
const imageryProvider = new TileMapServiceImageryProvider(options);
|
|
45
|
+
const layerOptions = {
|
|
46
|
+
alpha: this.opacity,
|
|
47
|
+
splitDirection: this.splitDirection,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return new CesiumImageryLayer(imageryProvider, layerOptions);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default TMSCesium;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { unByKey } from 'ol/Observable.js';
|
|
2
|
+
import { PrimitiveCollection } from '@vcmap/cesium';
|
|
3
|
+
|
|
4
|
+
import convert from '../../util/featureconverter/convert.js';
|
|
5
|
+
import VectorContext from './vectorContext.js';
|
|
6
|
+
import { vcsLayerName } from '../layerSymbols.js';
|
|
7
|
+
import LayerImplementation from '../layerImplementation.js';
|
|
8
|
+
import { getGlobalHider } from '../globalHider.js';
|
|
9
|
+
import { synchronizeFeatureVisibilityWithSource } from '../vectorHelpers.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* represents a specific vector layer for cesium.
|
|
13
|
+
* @class
|
|
14
|
+
* @export
|
|
15
|
+
* @extends {LayerImplementation<import("@vcmap/core").CesiumMap>}}
|
|
16
|
+
* @implements {FeatureLayerImplementation}
|
|
17
|
+
*/
|
|
18
|
+
class VectorCesium extends LayerImplementation {
|
|
19
|
+
static get className() { return 'vcs.vcm.layer.cesium.VectorCesium'; }
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {import("@vcmap/core").CesiumMap} map
|
|
23
|
+
* @param {VectorImplementationOptions} options
|
|
24
|
+
*/
|
|
25
|
+
constructor(map, options) {
|
|
26
|
+
super(map, options);
|
|
27
|
+
|
|
28
|
+
/** @type {import("@vcmap/core").VectorProperties} */
|
|
29
|
+
this.vectorProperties = options.vectorProperties;
|
|
30
|
+
/** @type {import("ol/source").Vector<import("ol/geom/Geometry").default>} */
|
|
31
|
+
this.source = options.source;
|
|
32
|
+
/** @type {import("@vcmap/core").StyleItem} */
|
|
33
|
+
this.style = options.style;
|
|
34
|
+
/** @type {import("@vcmap/core").FeatureVisibility} */
|
|
35
|
+
this.featureVisibility = options.featureVisibility;
|
|
36
|
+
/**
|
|
37
|
+
* @type {Array<Function>}
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
this._featureVisibilityListeners = [];
|
|
41
|
+
/**
|
|
42
|
+
* @type {Function}
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
this._removeVectorPropertiesChangeHandler = () => {};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @type {import("@vcmap/cesium").PrimitiveCollection|import("@vcmap/cesium").CustomDataSource}
|
|
49
|
+
* @protected
|
|
50
|
+
*/
|
|
51
|
+
this._rootCollection = new PrimitiveCollection();
|
|
52
|
+
this._rootCollection[vcsLayerName] = options.name;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @type {Array<import("ol/events").EventsKey|Array<import("ol/events").EventsKey>>}
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
this._olListeners = [];
|
|
59
|
+
/**
|
|
60
|
+
* A set of ol.Features to add once the map is back to cesium
|
|
61
|
+
* @type {Set<import("ol").Feature<import("ol/geom/Geometry").default>>}
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
this._featureToAdd = new Set();
|
|
65
|
+
/**
|
|
66
|
+
* @type {import("@vcmap/core").VectorContext|import("@vcmap/core").ClusterContext|null}
|
|
67
|
+
* @protected
|
|
68
|
+
*/
|
|
69
|
+
this._context = null;
|
|
70
|
+
/**
|
|
71
|
+
* @type {import("@vcmap/cesium").Scene|null}
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
this._scene = null;
|
|
75
|
+
this.globalHider = getGlobalHider();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
_addListeners() {
|
|
82
|
+
this._olListeners.push(this.source
|
|
83
|
+
.on('addfeature', (event) => {
|
|
84
|
+
this._addFeature(/** @type {import("ol/source/Vector").VectorSourceEvent} */(event).feature);
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
this._olListeners.push(this.source
|
|
88
|
+
.on('removefeature', (event) => {
|
|
89
|
+
this._removeFeature(/** @type {import("ol/source/Vector").VectorSourceEvent} */(event).feature);
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
this._olListeners.push(this.source
|
|
93
|
+
.on('changefeature', (event) => {
|
|
94
|
+
this._featureChanged(/** @type {import("ol/source/Vector").VectorSourceEvent} */(event).feature);
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
this._removeVectorPropertiesChangeHandler =
|
|
98
|
+
this.vectorProperties.propertyChanged.addEventListener(this.refresh.bind(this));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {import("@vcmap/core").CesiumMap} cesiumMap
|
|
103
|
+
* @returns {Promise<void>}
|
|
104
|
+
* @protected
|
|
105
|
+
*/
|
|
106
|
+
async _setupContext(cesiumMap) {
|
|
107
|
+
const rootCollection = /** @type {import("@vcmap/cesium").PrimitiveCollection} */ (this._rootCollection);
|
|
108
|
+
this._context = new VectorContext(this._scene, rootCollection);
|
|
109
|
+
cesiumMap.addPrimitiveCollection(rootCollection);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @inheritDoc
|
|
114
|
+
* @returns {Promise<void>}
|
|
115
|
+
*/
|
|
116
|
+
async initialize() {
|
|
117
|
+
if (!this.initialized) {
|
|
118
|
+
this._scene = this.map.getScene();
|
|
119
|
+
await this._setupContext(this.map);
|
|
120
|
+
this._addListeners();
|
|
121
|
+
this._addFeatures(this.source.getFeatures());
|
|
122
|
+
}
|
|
123
|
+
await super.initialize();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @param {Array<import("ol").Feature<import("ol/geom/Geometry").default>>} features
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
_addFeatures(features) {
|
|
131
|
+
// TODO we should make this non-blocking to better handle larger data sets check in RIWA Impl
|
|
132
|
+
features.forEach((f) => { this._addFeature(f); });
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* converts a feature and adds the associated primitives to the collection of primitives
|
|
137
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
_addFeature(feature) {
|
|
141
|
+
if (this.active) { // XXX cluster check here? or on init?
|
|
142
|
+
convert(feature, this.style.style, this.vectorProperties, this._context, this._scene);
|
|
143
|
+
} else {
|
|
144
|
+
this._featureToAdd.add(feature);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Forces a complete re-render of all features.
|
|
150
|
+
* @api
|
|
151
|
+
*/
|
|
152
|
+
refresh() {
|
|
153
|
+
this._context.clear();
|
|
154
|
+
this._addFeatures(this.source.getFeatures());
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* removes the primitive of the specified feature
|
|
159
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
_removeFeature(feature) {
|
|
163
|
+
this._context.removeFeature(feature);
|
|
164
|
+
this._featureToAdd.delete(feature);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* called when a features property have changed
|
|
169
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
_featureChanged(feature) {
|
|
173
|
+
const cache = this._context.createFeatureCache(feature);
|
|
174
|
+
this._featureToAdd.delete(feature);
|
|
175
|
+
this._addFeature(feature);
|
|
176
|
+
this._context.clearFeatureCache(cache);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @inheritDoc
|
|
181
|
+
* @returns {Promise<void>}
|
|
182
|
+
*/
|
|
183
|
+
async activate() {
|
|
184
|
+
if (!this.active) {
|
|
185
|
+
await super.activate();
|
|
186
|
+
if (this.active) {
|
|
187
|
+
this._addFeatures([...this._featureToAdd]);
|
|
188
|
+
this._featureToAdd.clear();
|
|
189
|
+
this._rootCollection.show = true;
|
|
190
|
+
if (this._featureVisibilityListeners.length === 0) {
|
|
191
|
+
this._featureVisibilityListeners =
|
|
192
|
+
synchronizeFeatureVisibilityWithSource(this.featureVisibility, this.source, this.globalHider);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @inheritDoc
|
|
200
|
+
*/
|
|
201
|
+
deactivate() {
|
|
202
|
+
super.deactivate();
|
|
203
|
+
this._rootCollection.show = false;
|
|
204
|
+
this._featureVisibilityListeners.forEach((cb) => { cb(); });
|
|
205
|
+
this._featureVisibilityListeners = [];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @param {import("@vcmap/core").StyleItem} style
|
|
210
|
+
* @param {boolean=} silent
|
|
211
|
+
*/
|
|
212
|
+
updateStyle(style, silent) {
|
|
213
|
+
this.style = style;
|
|
214
|
+
if (this.initialized && !silent) {
|
|
215
|
+
const features = this.source.getFeatures().filter(f => !f.getStyle());
|
|
216
|
+
features.forEach((f) => {
|
|
217
|
+
this._featureChanged(f);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @protected
|
|
224
|
+
*/
|
|
225
|
+
_destroyCollection() {
|
|
226
|
+
this.map.removePrimitiveCollection(/** @type {undefined} */ (this._rootCollection)); // cast to undefined do to missing inheritance
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @inheritDoc
|
|
231
|
+
*/
|
|
232
|
+
destroy() {
|
|
233
|
+
if (this.initialized) {
|
|
234
|
+
this._context.clear();
|
|
235
|
+
this._destroyCollection();
|
|
236
|
+
}
|
|
237
|
+
this._context = null;
|
|
238
|
+
this._scene = null;
|
|
239
|
+
this._removeVectorPropertiesChangeHandler();
|
|
240
|
+
this._olListeners.forEach((listener) => { unByKey(listener); });
|
|
241
|
+
this._olListeners = [];
|
|
242
|
+
this._featureToAdd.clear();
|
|
243
|
+
this._featureVisibilityListeners.forEach((cb) => { cb(); });
|
|
244
|
+
this._featureVisibilityListeners = [];
|
|
245
|
+
this.source = null;
|
|
246
|
+
this.vectorProperties = null;
|
|
247
|
+
this.featureVisibility = null;
|
|
248
|
+
this.style = null;
|
|
249
|
+
this.globalHider = null;
|
|
250
|
+
this._rootCollection = null;
|
|
251
|
+
super.destroy();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export default VectorCesium;
|