@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,79 @@
|
|
|
1
|
+
import { vcsLayerName } from '../layerSymbols.js';
|
|
2
|
+
import LayerImplementation from '../layerImplementation.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Layer implementation for {@link CesiumMap}.
|
|
6
|
+
* @class
|
|
7
|
+
* @export
|
|
8
|
+
* @extends {LayerImplementation<import("@vcmap/core").Openlayers>}}
|
|
9
|
+
*/
|
|
10
|
+
class LayerOpenlayers extends LayerImplementation {
|
|
11
|
+
static get className() { return 'vcs.vcm.layer.openlayers.LayerOpenlayers'; }
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {import("@vcmap/core").Openlayers} map
|
|
15
|
+
* @param {LayerImplementationOptions} options
|
|
16
|
+
*/
|
|
17
|
+
constructor(map, options) {
|
|
18
|
+
super(map, options);
|
|
19
|
+
/**
|
|
20
|
+
* @type {import("ol/layer").Layer<import("ol/source/Source").default>|null}
|
|
21
|
+
*/
|
|
22
|
+
this.olLayer = null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
initialize() {
|
|
30
|
+
if (!this.initialized) {
|
|
31
|
+
this.olLayer = this.getOLLayer();
|
|
32
|
+
this.olLayer[vcsLayerName] = this.name;
|
|
33
|
+
this.map.addOLLayer(this.olLayer);
|
|
34
|
+
}
|
|
35
|
+
return super.initialize();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
* @returns {Promise<void>}
|
|
41
|
+
*/
|
|
42
|
+
async activate() {
|
|
43
|
+
await super.activate();
|
|
44
|
+
if (this.active) {
|
|
45
|
+
this.olLayer.setVisible(true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @inheritDoc
|
|
51
|
+
*/
|
|
52
|
+
deactivate() {
|
|
53
|
+
super.deactivate();
|
|
54
|
+
if (this.olLayer) {
|
|
55
|
+
this.olLayer.setVisible(false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// eslint-disable-next-line jsdoc/require-returns-check
|
|
60
|
+
/**
|
|
61
|
+
* returns the ol Layer
|
|
62
|
+
* @returns {import("ol/layer").Layer<import("ol/source/Source").default>}
|
|
63
|
+
*/
|
|
64
|
+
// eslint-disable-next-line class-methods-use-this
|
|
65
|
+
getOLLayer() { throw new Error(); }
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @inheritDoc
|
|
69
|
+
*/
|
|
70
|
+
destroy() {
|
|
71
|
+
if (this.olLayer) {
|
|
72
|
+
this.map.removeOLLayer(this.olLayer);
|
|
73
|
+
}
|
|
74
|
+
this.olLayer = null;
|
|
75
|
+
super.destroy();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default LayerOpenlayers;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Tile from 'ol/layer/Tile.js';
|
|
2
|
+
import OSM from 'ol/source/OSM.js';
|
|
3
|
+
import RasterLayerOpenlayers from './rasterLayerOpenlayers.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* represents a specific OpenStreetMap layer for openlayers.
|
|
7
|
+
* @class
|
|
8
|
+
* @export
|
|
9
|
+
* @extends {RasterLayerOpenlayers}
|
|
10
|
+
*/
|
|
11
|
+
class OpenStreetMapOpenlayers extends RasterLayerOpenlayers {
|
|
12
|
+
static get className() { return 'vcs.vcm.layer.openlayers.OpenStreetMapOpenlayers'; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @returns {import("ol/layer/Tile").default}
|
|
16
|
+
*/
|
|
17
|
+
getOLLayer() {
|
|
18
|
+
return new Tile({
|
|
19
|
+
opacity: this.opacity,
|
|
20
|
+
source: new OSM({
|
|
21
|
+
maxZoom: this.maxLevel,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default OpenStreetMapOpenlayers;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ImagerySplitDirection } from '@vcmap/cesium';
|
|
2
|
+
import { unByKey } from 'ol/Observable.js';
|
|
3
|
+
import LayerOpenlayers from './layerOpenlayers.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* RasterLayer implementation for {@link Openlayers}
|
|
7
|
+
* @class
|
|
8
|
+
* @extends {LayerOpenlayers}
|
|
9
|
+
* @implements {RasterLayerImplementation}
|
|
10
|
+
* @abstract
|
|
11
|
+
*/
|
|
12
|
+
class RasterLayerOpenlayers extends LayerOpenlayers {
|
|
13
|
+
static get className() { return 'vcs.vcm.layer.openlayers.RasterLayerOpenlayers'; }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {import("@vcmap/core").Openlayers} map
|
|
17
|
+
* @param {RasterLayerImplementationOptions} options
|
|
18
|
+
*/
|
|
19
|
+
constructor(map, options) {
|
|
20
|
+
super(map, options);
|
|
21
|
+
/** @type {import("@vcmap/cesium").ImagerySplitDirection} */
|
|
22
|
+
this.splitDirection = options.splitDirection;
|
|
23
|
+
/** @type {number} */
|
|
24
|
+
this.minLevel = options.minLevel;
|
|
25
|
+
/** @type {number} */
|
|
26
|
+
this.maxLevel = options.maxLevel;
|
|
27
|
+
/** @type {string} */
|
|
28
|
+
this.tilingSchema = options.tilingSchema;
|
|
29
|
+
/** @type {import("@vcmap/core").Extent} */
|
|
30
|
+
this.extent = options.extent;
|
|
31
|
+
/** @type {number} */
|
|
32
|
+
this.opacity = options.opacity;
|
|
33
|
+
/**
|
|
34
|
+
* @type {Array<import("ol/events").EventsKey>|null}
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
this._splitDirectionRenderListeners = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @inheritDoc
|
|
42
|
+
* @returns {Promise<void>}
|
|
43
|
+
*/
|
|
44
|
+
initialize() {
|
|
45
|
+
return super.initialize()
|
|
46
|
+
.then(() => {
|
|
47
|
+
this.updateSplitDirection(this.splitDirection);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {number} opacity
|
|
53
|
+
*/
|
|
54
|
+
updateOpacity(opacity) {
|
|
55
|
+
this.opacity = opacity;
|
|
56
|
+
if (this.initialized) {
|
|
57
|
+
this.olLayer.setOpacity(this.opacity);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {import("@vcmap/cesium").ImagerySplitDirection} splitDirection
|
|
63
|
+
*/
|
|
64
|
+
updateSplitDirection(splitDirection) {
|
|
65
|
+
this.splitDirection = splitDirection;
|
|
66
|
+
if (this.initialized) {
|
|
67
|
+
if (this.splitDirection === ImagerySplitDirection.NONE && this._splitDirectionRenderListeners) {
|
|
68
|
+
unByKey(this._splitDirectionRenderListeners);
|
|
69
|
+
this._splitDirectionRenderListeners = null;
|
|
70
|
+
this.olLayer.changed();
|
|
71
|
+
} else if (splitDirection !== ImagerySplitDirection.NONE && !this._splitDirectionRenderListeners) {
|
|
72
|
+
this._splitDirectionRenderListeners = [];
|
|
73
|
+
this._splitDirectionRenderListeners
|
|
74
|
+
.push(/** @type {import("ol/events").EventsKey} */
|
|
75
|
+
(this.olLayer.on('prerender', this._splitPreCompose.bind(this))),
|
|
76
|
+
);
|
|
77
|
+
this._splitDirectionRenderListeners
|
|
78
|
+
.push(/** @type {import("ol/events").EventsKey} */
|
|
79
|
+
(this.olLayer.on('postrender', (/** @type {import("ol/render/Event").default} */ event) => {
|
|
80
|
+
event.context.restore();
|
|
81
|
+
})),
|
|
82
|
+
);
|
|
83
|
+
this.olLayer.changed();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {import("ol/render/Event").default} event
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
_splitPreCompose(event) {
|
|
93
|
+
if (!this.map.splitScreen) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const { context } = event;
|
|
97
|
+
const width = context.canvas.width * this.map.splitScreen.position;
|
|
98
|
+
context.save();
|
|
99
|
+
context.beginPath();
|
|
100
|
+
|
|
101
|
+
if (this.splitDirection === ImagerySplitDirection.LEFT) {
|
|
102
|
+
context.rect(0, 0, width, context.canvas.height);
|
|
103
|
+
} else {
|
|
104
|
+
context.rect(width, 0, context.canvas.width - width, context.canvas.height);
|
|
105
|
+
}
|
|
106
|
+
context.clip();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @inheritDoc
|
|
111
|
+
*/
|
|
112
|
+
destroy() {
|
|
113
|
+
if (this._splitDirectionRenderListeners) {
|
|
114
|
+
unByKey(this._splitDirectionRenderListeners);
|
|
115
|
+
this._splitDirectionRenderListeners = null;
|
|
116
|
+
}
|
|
117
|
+
super.destroy();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default RasterLayerOpenlayers;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import ImageLayer from 'ol/layer/Image.js';
|
|
2
|
+
import ImageStatic from 'ol/source/ImageStatic.js';
|
|
3
|
+
import RasterLayerOpenlayers from './rasterLayerOpenlayers.js';
|
|
4
|
+
import { wgs84Projection } from '../../util/projection.js';
|
|
5
|
+
import { isSameOrigin } from '../../util/urlHelpers.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* represents a specific OpenLayers SingleImageLayer Layer class.
|
|
9
|
+
* @class
|
|
10
|
+
* @export
|
|
11
|
+
* @extends {RasterLayerOpenlayers}
|
|
12
|
+
*/
|
|
13
|
+
class SingleImageOpenlayers extends RasterLayerOpenlayers {
|
|
14
|
+
static get className() { return 'vcs.vcm.layer.openlayers.SingleImageOpenlayers'; }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {import("@vcmap/core").Openlayers} map
|
|
18
|
+
* @param {SingleImageImplementationOptions} options
|
|
19
|
+
*/
|
|
20
|
+
constructor(map, options) {
|
|
21
|
+
super(map, options);
|
|
22
|
+
|
|
23
|
+
/** @type {string} */
|
|
24
|
+
this.credit = options.credit;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* returns the ol Layer
|
|
29
|
+
* @returns {import("ol/layer/Layer").default}
|
|
30
|
+
*/
|
|
31
|
+
getOLLayer() {
|
|
32
|
+
const options = {
|
|
33
|
+
attributions: this.credit,
|
|
34
|
+
url: this.url,
|
|
35
|
+
projection: 'EPSG:4326',
|
|
36
|
+
imageExtent: this.extent.getCoordinatesInProjection(wgs84Projection),
|
|
37
|
+
};
|
|
38
|
+
if (!isSameOrigin(this.url)) {
|
|
39
|
+
options.crossOrigin = 'anonymous';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return new ImageLayer({
|
|
43
|
+
source: new ImageStatic(options),
|
|
44
|
+
opacity: this.opacity,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default SingleImageOpenlayers;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Tile from 'ol/layer/Tile.js';
|
|
2
|
+
import TileDebug from 'ol/source/TileDebug.js';
|
|
3
|
+
import LayerOpenlayers from './layerOpenlayers.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* layer Implementation to render tile boundaries.
|
|
7
|
+
* @class
|
|
8
|
+
* @export
|
|
9
|
+
* @extends {LayerOpenlayers}
|
|
10
|
+
* @implements {VectorTileImplementation}
|
|
11
|
+
*/
|
|
12
|
+
class TileDebugOpenlayers extends LayerOpenlayers {
|
|
13
|
+
static get className() { return 'vcs.vcm.layer.openlayers.TileDebugOpenlayers'; }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @returns {import("ol/layer/Tile").default}
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line class-methods-use-this
|
|
19
|
+
getOLLayer() {
|
|
20
|
+
return new Tile({
|
|
21
|
+
source: new TileDebug(),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {import("@vcmap/core").StyleItem} styleItem
|
|
27
|
+
* @param {boolean} silent
|
|
28
|
+
*/
|
|
29
|
+
// eslint-disable-next-line class-methods-use-this,no-unused-vars
|
|
30
|
+
updateStyle(styleItem, silent) {}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {Array<string>} args
|
|
34
|
+
*/
|
|
35
|
+
// eslint-disable-next-line class-methods-use-this,no-unused-vars
|
|
36
|
+
updateTiles(args) {}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default TileDebugOpenlayers;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import XYZ from 'ol/source/XYZ.js';
|
|
2
|
+
import Tile from 'ol/layer/Tile.js';
|
|
3
|
+
import { mercatorProjection } from '../../util/projection.js';
|
|
4
|
+
import RasterLayerOpenlayers from './rasterLayerOpenlayers.js';
|
|
5
|
+
import { TilingScheme } from '../rasterLayer.js';
|
|
6
|
+
import { isSameOrigin } from '../../util/urlHelpers.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* TMS implementation for {@link Openlayers}.
|
|
10
|
+
* @class
|
|
11
|
+
* @export
|
|
12
|
+
* @extends {RasterLayerOpenlayers}
|
|
13
|
+
*/
|
|
14
|
+
class TMSOpenlayers extends RasterLayerOpenlayers {
|
|
15
|
+
static get className() { return 'vcs.vcm.layer.openlayers.TMSOpenlayers'; }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {import("@vcmap/core").Openlayers} map
|
|
19
|
+
* @param {TMSImplementationOptions} options
|
|
20
|
+
*/
|
|
21
|
+
constructor(map, options) {
|
|
22
|
+
super(map, options);
|
|
23
|
+
/** @type {string} */
|
|
24
|
+
this.format = options.format;
|
|
25
|
+
/** @type {import("ol/size").Size} */
|
|
26
|
+
this.tileSize = options.tileSize;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @returns {import("ol/layer/Tile").default}
|
|
31
|
+
*/
|
|
32
|
+
getOLLayer() {
|
|
33
|
+
const sourceOptions = {
|
|
34
|
+
tileUrlFunction: (tileCoord) => {
|
|
35
|
+
const baseUrl = this.url.replace(/\/$/, '');
|
|
36
|
+
const y = (1 << tileCoord[0]) - (tileCoord[2]) - 1;
|
|
37
|
+
return `${baseUrl}/${tileCoord[0]}/${tileCoord[1]}/${y}.${this.format}`;
|
|
38
|
+
},
|
|
39
|
+
tileSize: this.tileSize,
|
|
40
|
+
minZoom: this.minLevel,
|
|
41
|
+
maxZoom: this.maxLevel,
|
|
42
|
+
wrapX: false,
|
|
43
|
+
};
|
|
44
|
+
if (!isSameOrigin(this.url)) {
|
|
45
|
+
sourceOptions.crossOrigin = 'anonymous';
|
|
46
|
+
}
|
|
47
|
+
if (this.tilingSchema === TilingScheme.GEOGRAPHIC) {
|
|
48
|
+
sourceOptions.projection = 'EPSG:4326';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const tileOptions = {
|
|
52
|
+
source: new XYZ(sourceOptions),
|
|
53
|
+
opacity: this.opacity,
|
|
54
|
+
};
|
|
55
|
+
if (this.extent && this.extent.isValid()) {
|
|
56
|
+
tileOptions.extent = this.extent.getCoordinatesInProjection(mercatorProjection);
|
|
57
|
+
}
|
|
58
|
+
return new Tile(tileOptions);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default TMSOpenlayers;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import OLVectorLayer from 'ol/layer/Vector.js';
|
|
2
|
+
import LayerOpenlayers from './layerOpenlayers.js';
|
|
3
|
+
import { synchronizeFeatureVisibilityWithSource } from '../vectorHelpers.js';
|
|
4
|
+
import { getGlobalHider } from '../globalHider.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* represents a specific vectorlayer for openlayers.
|
|
8
|
+
* @class
|
|
9
|
+
* @export
|
|
10
|
+
* @implements {FeatureLayerImplementation}
|
|
11
|
+
* @extends {LayerOpenlayers}
|
|
12
|
+
*/
|
|
13
|
+
class VectorOpenlayers extends LayerOpenlayers {
|
|
14
|
+
static get className() { return 'vcs.vcm.layer.openlayers.VectorOpenlayers'; }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {import("@vcmap/core").Openlayers} map
|
|
18
|
+
* @param {VectorImplementationOptions} options
|
|
19
|
+
*/
|
|
20
|
+
constructor(map, options) {
|
|
21
|
+
super(map, options);
|
|
22
|
+
/** @type {import("ol/source").Vector<import("ol/geom/Geometry").default>} */
|
|
23
|
+
this.source = options.source;
|
|
24
|
+
/** @type {import("@vcmap/core").StyleItem} */
|
|
25
|
+
this.style = options.style;
|
|
26
|
+
/** @type {number} */
|
|
27
|
+
this.maxResolution = options.maxResolution;
|
|
28
|
+
/** @type {number} */
|
|
29
|
+
this.minResolution = options.minResolution;
|
|
30
|
+
/** @type {import("@vcmap/core").FeatureVisibility} */
|
|
31
|
+
this.featureVisibility = options.featureVisibility;
|
|
32
|
+
/**
|
|
33
|
+
* @type {Array<Function>}
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
this._featureVisibilityListeners = [];
|
|
37
|
+
/** @type {import("ol/layer/Vector").default<import("ol/source").Vector<import("ol/geom/Geometry").default>>|null} */
|
|
38
|
+
this.olLayer = null;
|
|
39
|
+
this.globalHider = getGlobalHider();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {import("@vcmap/core").StyleItem} style
|
|
44
|
+
* @param {boolean=} silent
|
|
45
|
+
*/
|
|
46
|
+
// eslint-disable-next-line no-unused-vars
|
|
47
|
+
updateStyle(style, silent) {
|
|
48
|
+
this.style = style;
|
|
49
|
+
if (this.initialized) {
|
|
50
|
+
this.olLayer.setStyle(this.style.style);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @inheritDoc
|
|
56
|
+
* @returns {import("ol/layer/Vector").default<import("ol/source").Vector<import("ol/geom/Geometry").default>>}
|
|
57
|
+
*/
|
|
58
|
+
getOLLayer() {
|
|
59
|
+
const olLayer = new OLVectorLayer({
|
|
60
|
+
visible: false,
|
|
61
|
+
source: this.source,
|
|
62
|
+
style: this.style.style,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (this.minResolution) {
|
|
66
|
+
olLayer.setMinResolution(this.minResolution);
|
|
67
|
+
}
|
|
68
|
+
if (this.maxResolution) {
|
|
69
|
+
olLayer.setMaxResolution(this.maxResolution);
|
|
70
|
+
}
|
|
71
|
+
return olLayer;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @inheritDoc
|
|
76
|
+
* @returns {Promise<void>}
|
|
77
|
+
*/
|
|
78
|
+
async activate() {
|
|
79
|
+
if (!this.active) {
|
|
80
|
+
await super.activate();
|
|
81
|
+
if (this.active) {
|
|
82
|
+
if (this._featureVisibilityListeners.length === 0) {
|
|
83
|
+
this._featureVisibilityListeners =
|
|
84
|
+
synchronizeFeatureVisibilityWithSource(this.featureVisibility, this.source, this.globalHider);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @inheritDoc
|
|
92
|
+
*/
|
|
93
|
+
deactivate() {
|
|
94
|
+
super.deactivate();
|
|
95
|
+
this._featureVisibilityListeners.forEach((cb) => { cb(); });
|
|
96
|
+
this._featureVisibilityListeners = [];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param {boolean} visibility
|
|
101
|
+
*/
|
|
102
|
+
setVisibility(visibility) {
|
|
103
|
+
if (this.initialized) {
|
|
104
|
+
this.olLayer.setVisible(visibility);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @inheritDoc
|
|
110
|
+
*/
|
|
111
|
+
destroy() {
|
|
112
|
+
this._featureVisibilityListeners.forEach((cb) => { cb(); });
|
|
113
|
+
this._featureVisibilityListeners = [];
|
|
114
|
+
super.destroy();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export default VectorOpenlayers;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import OLVectorTileLayer from 'ol/layer/VectorTile.js';
|
|
2
|
+
import VectorTileSource from 'ol/source/VectorTile.js';
|
|
3
|
+
import TileState from 'ol/TileState.js';
|
|
4
|
+
import LayerOpenlayers from './layerOpenlayers.js';
|
|
5
|
+
import { mercatorProjection } from '../../util/projection.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* represents a specific vectorTileLayer for openlayers.
|
|
9
|
+
* @class
|
|
10
|
+
* @export
|
|
11
|
+
* @implements {VectorTileImplementation}
|
|
12
|
+
* @extends {LayerOpenlayers}
|
|
13
|
+
*/
|
|
14
|
+
class VectorTileOpenlayers extends LayerOpenlayers {
|
|
15
|
+
static get className() { return 'vcs.vcm.layer.openlayers.VectorTileOpenlayers'; }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {import("@vcmap/core").Openlayers} map
|
|
19
|
+
* @param {VectorTileImplementationOptions} options
|
|
20
|
+
*/
|
|
21
|
+
constructor(map, options) {
|
|
22
|
+
super(map, options);
|
|
23
|
+
|
|
24
|
+
/** @type {import("@vcmap/core").TileProvider} */
|
|
25
|
+
this.tileProvider = options.tileProvider;
|
|
26
|
+
|
|
27
|
+
/** @type {import("ol/source").VectorTile} */
|
|
28
|
+
this.source = null;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @type {import("ol/size").Size}
|
|
32
|
+
*/
|
|
33
|
+
this.tileSize = options.tileSize;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* tiles to update on next TileRedraw
|
|
37
|
+
* @type {Set<string>}
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
this._tilesToUpdate = new Set();
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @type {number|null}
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
this._reloadTimeout = null;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @type {number|undefined}
|
|
50
|
+
*/
|
|
51
|
+
this.minLevel = options.minLevel;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @type {number|undefined}
|
|
55
|
+
*/
|
|
56
|
+
this.maxLevel = options.maxLevel;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @type {import("@vcmap/core").Extent|undefined}
|
|
60
|
+
*/
|
|
61
|
+
this.extent = options.extent;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @inheritDoc
|
|
66
|
+
* @returns {import("ol/layer/VectorTile").default}
|
|
67
|
+
*/
|
|
68
|
+
getOLLayer() {
|
|
69
|
+
this.source = new VectorTileSource({
|
|
70
|
+
minZoom: 0,
|
|
71
|
+
maxZoom: 26,
|
|
72
|
+
tileSize: this.tileSize,
|
|
73
|
+
/**
|
|
74
|
+
* @param {import("ol/VectorTile").default} tile
|
|
75
|
+
* @returns {Promise<void>}
|
|
76
|
+
*/
|
|
77
|
+
tileLoadFunction: async (tile) => {
|
|
78
|
+
const features =
|
|
79
|
+
await this.tileProvider.getFeaturesForTile(tile.tileCoord[1], tile.tileCoord[2], tile.tileCoord[0]);
|
|
80
|
+
if (features.length > 0) {
|
|
81
|
+
tile.setFeatures(features);
|
|
82
|
+
} else {
|
|
83
|
+
tile.setFeatures([]);
|
|
84
|
+
tile.setState(TileState.EMPTY);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
// url needs to be set for the tileLoadFunction to work.
|
|
88
|
+
url: '/{z}/{x}/{y}',
|
|
89
|
+
});
|
|
90
|
+
const extent = this.extent && this.extent.isValid() ?
|
|
91
|
+
this.extent.getCoordinatesInProjection(mercatorProjection) : undefined;
|
|
92
|
+
// make it so that openlayers and cesium zoom level fit together
|
|
93
|
+
const minZoom = this.minLevel ? this.minLevel : undefined;
|
|
94
|
+
const maxZoom = this.maxLevel ? this.maxLevel + 1 : undefined;
|
|
95
|
+
const olLayer = new OLVectorTileLayer({
|
|
96
|
+
visible: false,
|
|
97
|
+
source: this.source,
|
|
98
|
+
renderBuffer: 200,
|
|
99
|
+
renderMode: 'image',
|
|
100
|
+
declutter: true,
|
|
101
|
+
extent,
|
|
102
|
+
minZoom,
|
|
103
|
+
maxZoom,
|
|
104
|
+
});
|
|
105
|
+
return olLayer;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* rerenders the specified tiles
|
|
110
|
+
* rendering happens async
|
|
111
|
+
* @param {Array<string>} tileIds
|
|
112
|
+
* @api
|
|
113
|
+
*/
|
|
114
|
+
updateTiles(tileIds) {
|
|
115
|
+
if (tileIds.length > 0) {
|
|
116
|
+
tileIds.forEach((tileId) => {
|
|
117
|
+
this._tilesToUpdate.add(tileId);
|
|
118
|
+
});
|
|
119
|
+
if (this.source) {
|
|
120
|
+
if (!this._reloadTimeout) {
|
|
121
|
+
this._reloadTimeout = window.setTimeout(() => {
|
|
122
|
+
this._tilesToUpdate.forEach((tileId) => {
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
const { tileCache } = this.source;
|
|
125
|
+
if (tileCache.containsKey(tileId)) {
|
|
126
|
+
// change of key of tile (will trigger a reload)
|
|
127
|
+
const tile = tileCache.get(tileId);
|
|
128
|
+
tile.key = false;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
this.source.changed();
|
|
132
|
+
this._tilesToUpdate.clear();
|
|
133
|
+
this._reloadTimeout = null;
|
|
134
|
+
}, 0);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @param {import("@vcmap/core").StyleItem} style
|
|
142
|
+
* @param {boolean=} silent
|
|
143
|
+
* @api
|
|
144
|
+
*/
|
|
145
|
+
// eslint-disable-next-line no-unused-vars
|
|
146
|
+
updateStyle(style, silent) {
|
|
147
|
+
if (this.initialized) {
|
|
148
|
+
window.clearTimeout(this._reloadTimeout);
|
|
149
|
+
this._reloadTimeout = null;
|
|
150
|
+
this._tilesToUpdate.clear();
|
|
151
|
+
this.source.refresh();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @param {boolean} visibility
|
|
157
|
+
*/
|
|
158
|
+
setVisibility(visibility) {
|
|
159
|
+
if (this.initialized) {
|
|
160
|
+
this.olLayer.setVisible(visibility);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @inheritDoc
|
|
166
|
+
*/
|
|
167
|
+
destroy() {
|
|
168
|
+
if (this.source) {
|
|
169
|
+
this.source.clear();
|
|
170
|
+
this.source = null;
|
|
171
|
+
}
|
|
172
|
+
this.tileProvider = null;
|
|
173
|
+
super.destroy();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export default VectorTileOpenlayers;
|