@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,119 @@
|
|
|
1
|
+
import { check } from '@vcsuite/check';
|
|
2
|
+
import RasterLayer from './rasterLayer.js';
|
|
3
|
+
import SingleImageCesium from './cesium/singleImageCesium.js';
|
|
4
|
+
import SingleImageOpenlayers from './openlayers/singleImageOpenlayers.js';
|
|
5
|
+
import CesiumMap from '../maps/cesium.js';
|
|
6
|
+
import Openlayers from '../maps/openlayers.js';
|
|
7
|
+
import Extent from '../util/extent.js';
|
|
8
|
+
import { VcsClassRegistry } from '../classRegistry.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {RasterLayerOptions} SingleImageOptions
|
|
12
|
+
* @property {string|undefined} credit - credit
|
|
13
|
+
* @api
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {RasterLayerImplementationOptions} SingleImageImplementationOptions
|
|
18
|
+
* @property {string|undefined} credit
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Image layer for Cesium and Openlayers
|
|
23
|
+
* @class
|
|
24
|
+
* @export
|
|
25
|
+
* @extends {RasterLayer}
|
|
26
|
+
* @api stable
|
|
27
|
+
*/
|
|
28
|
+
class SingleImage extends RasterLayer {
|
|
29
|
+
static get className() { return 'vcs.vcm.layer.SingleImage'; }
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @returns {SingleImageOptions}
|
|
33
|
+
*/
|
|
34
|
+
static getDefaultOptions() {
|
|
35
|
+
return {
|
|
36
|
+
...RasterLayer.getDefaultOptions(),
|
|
37
|
+
credit: undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {SingleImageOptions} options
|
|
43
|
+
*/
|
|
44
|
+
constructor(options) {
|
|
45
|
+
super(options);
|
|
46
|
+
const defaultOptions = SingleImage.getDefaultOptions();
|
|
47
|
+
/** @type {string} */
|
|
48
|
+
this.credit = options.credit || defaultOptions.credit;
|
|
49
|
+
|
|
50
|
+
if (!this.extent.isValid()) {
|
|
51
|
+
this.getLogger().warning(`layer ${this.name} was constructed with an invalid extent, defaulting to global extent`);
|
|
52
|
+
this.extent = new Extent({
|
|
53
|
+
epsg: 'EPSG:4326',
|
|
54
|
+
coordinates: [-180, -90, 180, 90],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this._supportedMaps = [
|
|
59
|
+
CesiumMap.className,
|
|
60
|
+
Openlayers.className,
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @returns {SingleImageImplementationOptions}
|
|
66
|
+
*/
|
|
67
|
+
getImplementationOptions() {
|
|
68
|
+
return {
|
|
69
|
+
...super.getImplementationOptions(),
|
|
70
|
+
credit: this.credit,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {import("@vcmap/core").VcsMap} map
|
|
76
|
+
* @returns {Array<SingleImageOpenlayers|SingleImageCesium>}
|
|
77
|
+
*/
|
|
78
|
+
createImplementationsForMap(map) {
|
|
79
|
+
if (map instanceof CesiumMap) {
|
|
80
|
+
return [new SingleImageCesium(map, this.getImplementationOptions())];
|
|
81
|
+
} else if (map instanceof Openlayers) {
|
|
82
|
+
return [new SingleImageOpenlayers(map, this.getImplementationOptions())];
|
|
83
|
+
}
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* sets the image extent
|
|
89
|
+
* @param {Extent} extent
|
|
90
|
+
* @api
|
|
91
|
+
*/
|
|
92
|
+
setExtent(extent) {
|
|
93
|
+
check(extent, Extent);
|
|
94
|
+
if (!extent.isValid()) {
|
|
95
|
+
throw new Error('Cannot set invalid extent');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.extent = extent;
|
|
99
|
+
this.forceRedraw();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @inheritDoc
|
|
104
|
+
* @returns {SingleImageOptions}
|
|
105
|
+
*/
|
|
106
|
+
getConfigObject() {
|
|
107
|
+
const config = /** @type {SingleImageOptions} */ (super.getConfigObject());
|
|
108
|
+
delete config.tilingSchema;
|
|
109
|
+
|
|
110
|
+
if (this.credit) {
|
|
111
|
+
config.credit = this.credit;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return config;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
VcsClassRegistry.registerClass(SingleImage.className, SingleImage);
|
|
119
|
+
export default SingleImage;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { parseBoolean } from '@vcsuite/parsers';
|
|
2
|
+
import Layer from './layer.js';
|
|
3
|
+
import { getHeightFromTerrainProvider, getTerrainProviderForUrl } from './terrainHelpers.js';
|
|
4
|
+
import CesiumMap from '../maps/cesium.js';
|
|
5
|
+
import TerrainCesium from './cesium/terrainCesium.js';
|
|
6
|
+
import { VcsClassRegistry } from '../classRegistry.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {LayerOptions} TerrainOptions
|
|
10
|
+
* @property {boolean} [requestVertexNormals=true] - if the terrain should be shaded
|
|
11
|
+
* @property {boolean} [requestWaterMask=false] - if a watermask should be requested
|
|
12
|
+
* @api
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {LayerImplementationOptions} TerrainImplementationOptions
|
|
17
|
+
* @property {boolean} requestVertexNormals
|
|
18
|
+
* @property {boolean} requestWaterMask
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* represents a terrain layer.
|
|
23
|
+
* @class
|
|
24
|
+
* @export
|
|
25
|
+
* @extends {Layer}
|
|
26
|
+
* @api stable
|
|
27
|
+
*/
|
|
28
|
+
class Terrain extends Layer {
|
|
29
|
+
static get className() { return 'vcs.vcm.layer.Terrain'; }
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @returns {TerrainOptions}
|
|
33
|
+
*/
|
|
34
|
+
static getDefaultOptions() {
|
|
35
|
+
return {
|
|
36
|
+
...Layer.getDefaultOptions(),
|
|
37
|
+
requestVertexNormals: true,
|
|
38
|
+
requestWaterMask: false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {TerrainOptions} options
|
|
44
|
+
*/
|
|
45
|
+
constructor(options) {
|
|
46
|
+
super(options);
|
|
47
|
+
const defaultOptions = Terrain.getDefaultOptions();
|
|
48
|
+
|
|
49
|
+
this._supportedMaps = [
|
|
50
|
+
CesiumMap.className,
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @type {boolean}
|
|
55
|
+
* @api
|
|
56
|
+
*/
|
|
57
|
+
this.requestVertexNormals = parseBoolean(options.requestVertexNormals, defaultOptions.requestVertexNormals);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @type {boolean}
|
|
61
|
+
* @api
|
|
62
|
+
*/
|
|
63
|
+
this.requestWaterMask = parseBoolean(options.requestWaterMask, defaultOptions.requestWaterMask);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @returns {TerrainImplementationOptions}
|
|
68
|
+
*/
|
|
69
|
+
getImplementationOptions() {
|
|
70
|
+
return {
|
|
71
|
+
...super.getImplementationOptions(),
|
|
72
|
+
requestVertexNormals: this.requestVertexNormals,
|
|
73
|
+
requestWaterMask: this.requestWaterMask,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @inheritDoc
|
|
79
|
+
* @param {import("@vcmap/core").VcsMap} map
|
|
80
|
+
* @returns {Array<TerrainCesium>}
|
|
81
|
+
*/
|
|
82
|
+
createImplementationsForMap(map) {
|
|
83
|
+
if (map instanceof CesiumMap) {
|
|
84
|
+
return [new TerrainCesium(map, this.getImplementationOptions())];
|
|
85
|
+
}
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* getHeight for coordinates
|
|
91
|
+
* @param {Array<import("ol/coordinate").Coordinate>} coords - the height is added to the coordinates in place
|
|
92
|
+
* @returns {Promise<Array<import("ol/coordinate").Coordinate>>}
|
|
93
|
+
* @api stable
|
|
94
|
+
*/
|
|
95
|
+
getHeightForWGS84Coordinates(coords) {
|
|
96
|
+
const terrainProvider = getTerrainProviderForUrl({
|
|
97
|
+
url: this.url,
|
|
98
|
+
requestVertexNormals: this.requestVertexNormals,
|
|
99
|
+
requestWaterMask: this.requestWaterMask,
|
|
100
|
+
});
|
|
101
|
+
return getHeightFromTerrainProvider(terrainProvider, coords, null, coords);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @returns {TerrainOptions}
|
|
106
|
+
*/
|
|
107
|
+
getConfigObject() {
|
|
108
|
+
const config = /** @type {TerrainOptions} */ (super.getConfigObject());
|
|
109
|
+
const defaultOptions = Terrain.getDefaultOptions();
|
|
110
|
+
|
|
111
|
+
if (this.requestVertexNormals !== defaultOptions.requestVertexNormals) {
|
|
112
|
+
config.requestVertexNormals = this.requestVertexNormals;
|
|
113
|
+
}
|
|
114
|
+
if (this.requestWaterMask !== defaultOptions.requestWaterMask) {
|
|
115
|
+
config.requestWaterMask = this.requestWaterMask;
|
|
116
|
+
}
|
|
117
|
+
return config;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
VcsClassRegistry.registerClass(Terrain.className, Terrain);
|
|
122
|
+
export default Terrain;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { CesiumTerrainProvider, Cartographic, Cartesian2, sampleTerrainMostDetailed, sampleTerrain } from '@vcmap/cesium';
|
|
2
|
+
import { getTransform } from 'ol/proj.js';
|
|
3
|
+
import Projection, { wgs84Projection } from '../util/projection.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} TerrainProviderOptions
|
|
7
|
+
* @property {!string} url
|
|
8
|
+
* @property {boolean|undefined} requestVertexNormals
|
|
9
|
+
* @property {boolean|undefined} requestWaterMask
|
|
10
|
+
* @api
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @type {Object<string, import("@vcmap/cesium").CesiumTerrainProvider>}
|
|
15
|
+
*/
|
|
16
|
+
const terrainProviders = {};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {TerrainProviderOptions} options
|
|
20
|
+
* @returns {import("@vcmap/cesium").CesiumTerrainProvider}
|
|
21
|
+
*/
|
|
22
|
+
export function getTerrainProviderForUrl(options) {
|
|
23
|
+
if (!terrainProviders[options.url]) {
|
|
24
|
+
terrainProviders[options.url] = new CesiumTerrainProvider(options);
|
|
25
|
+
return terrainProviders[options.url];
|
|
26
|
+
}
|
|
27
|
+
let terrainProvider = terrainProviders[options.url];
|
|
28
|
+
if ((options.requestVertexNormals !== undefined &&
|
|
29
|
+
terrainProvider.requestVertexNormals !== options.requestVertexNormals) ||
|
|
30
|
+
(options.requestWaterMask !== undefined &&
|
|
31
|
+
terrainProvider.requestWaterMask !== options.requestWaterMask)) {
|
|
32
|
+
terrainProviders[options.url] = new CesiumTerrainProvider(options);
|
|
33
|
+
terrainProvider = terrainProviders[options.url];
|
|
34
|
+
}
|
|
35
|
+
return terrainProvider;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {import("@vcmap/cesium").CesiumTerrainProvider} terrainProvider
|
|
40
|
+
* @param {Array<import("@vcmap/cesium").Cartographic>} positions
|
|
41
|
+
* @returns {Promise<Array<import("@vcmap/cesium").Cartographic>>}
|
|
42
|
+
*/
|
|
43
|
+
export function sampleCesiumTerrainMostDetailed(terrainProvider, positions) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
sampleTerrainMostDetailed(terrainProvider, positions)
|
|
46
|
+
.then((updatedPositions) => {
|
|
47
|
+
resolve(updatedPositions);
|
|
48
|
+
}, reject);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* updates the height of the positions in place.
|
|
54
|
+
* @param {import("@vcmap/cesium").CesiumTerrainProvider} terrainProvider
|
|
55
|
+
* @param {number} level
|
|
56
|
+
* @param {Array<import("@vcmap/cesium").Cartographic>} positions
|
|
57
|
+
* @returns {Promise<Array<import("@vcmap/cesium").Cartographic>>}
|
|
58
|
+
*/
|
|
59
|
+
export function sampleCesiumTerrain(terrainProvider, level, positions) {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
sampleTerrain(terrainProvider, level, positions)
|
|
62
|
+
.then((updatedPositions) => {
|
|
63
|
+
resolve(updatedPositions);
|
|
64
|
+
}, reject);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* changes input coordinate Array in place, new height can also be accessed by coordinates[x][2]
|
|
70
|
+
* @param {import("@vcmap/cesium").CesiumTerrainProvider} terrainProvider
|
|
71
|
+
* @param {Array<import("ol/coordinate").Coordinate>} coordinates
|
|
72
|
+
* @param {(import("@vcmap/core").Projection|import("ol/proj/Projection").default)=} optSourceProjection - if input is not WGS84
|
|
73
|
+
* @param {Array<import("ol/coordinate").Coordinate>=} result
|
|
74
|
+
* @returns {Promise<Array<import("ol/coordinate").Coordinate>>}
|
|
75
|
+
*/
|
|
76
|
+
export function getHeightFromTerrainProvider(terrainProvider, coordinates, optSourceProjection, result) {
|
|
77
|
+
const usedProj = optSourceProjection instanceof Projection ?
|
|
78
|
+
optSourceProjection.proj :
|
|
79
|
+
optSourceProjection;
|
|
80
|
+
|
|
81
|
+
const sourceTransformer = usedProj ?
|
|
82
|
+
getTransform(
|
|
83
|
+
usedProj,
|
|
84
|
+
wgs84Projection.proj,
|
|
85
|
+
) :
|
|
86
|
+
null;
|
|
87
|
+
|
|
88
|
+
const positions = coordinates.map((coord) => {
|
|
89
|
+
const wgs84 = sourceTransformer ?
|
|
90
|
+
sourceTransformer(coord, coord.slice(), coord.length) :
|
|
91
|
+
coord;
|
|
92
|
+
return Cartographic.fromDegrees(wgs84[0], wgs84[1]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const outArray = result || coordinates.map(c => c.slice());
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
sampleTerrainMostDetailed(terrainProvider, positions)
|
|
98
|
+
.then((updatedPositions) => {
|
|
99
|
+
updatedPositions.forEach((position, index) => {
|
|
100
|
+
outArray[index][2] = position.height || 0;
|
|
101
|
+
});
|
|
102
|
+
resolve(outArray);
|
|
103
|
+
}, reject);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* checks, whether a terrain tile is available at given position or not
|
|
109
|
+
* @param {import("@vcmap/cesium").CesiumTerrainProvider} terrainProvider
|
|
110
|
+
* @param {number} level
|
|
111
|
+
* @param {import("@vcmap/cesium").Cartographic} position
|
|
112
|
+
* @returns {boolean}
|
|
113
|
+
*/
|
|
114
|
+
export function isTerrainTileAvailable(terrainProvider, level, position) {
|
|
115
|
+
if (!terrainProvider.ready) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const tileXY = terrainProvider.tilingScheme.positionToTileXY(
|
|
119
|
+
position, level, new Cartesian2(),
|
|
120
|
+
);
|
|
121
|
+
return terrainProvider.getTileDataAvailable(tileXY.x, tileXY.y, level);
|
|
122
|
+
}
|
|
123
|
+
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import CesiumTilesetCesium from './cesium/cesiumTilesetCesium.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {CesiumTilesetCesium} impl
|
|
5
|
+
* @param {number=} timeout
|
|
6
|
+
* @returns {Promise<void>}
|
|
7
|
+
*/
|
|
8
|
+
function waitForImplTilesLoaded(impl, timeout) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
let timeoutNr;
|
|
11
|
+
const remover = impl.cesium3DTileset.allTilesLoaded.addEventListener(() => {
|
|
12
|
+
if (timeoutNr) {
|
|
13
|
+
clearTimeout(timeoutNr);
|
|
14
|
+
}
|
|
15
|
+
remover();
|
|
16
|
+
resolve();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (timeout != null) {
|
|
20
|
+
timeoutNr = setTimeout(() => {
|
|
21
|
+
remover();
|
|
22
|
+
resolve();
|
|
23
|
+
}, timeout);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {import("@vcmap/core").CesiumTileset|import("@vcmap/core").FeatureStore} layer
|
|
30
|
+
* @param {number=} timeout
|
|
31
|
+
* @returns {Promise<void>}
|
|
32
|
+
*/
|
|
33
|
+
export async function tiledLayerLoaded(layer, timeout) {
|
|
34
|
+
const impls = /** @type {Array<CesiumTilesetCesium>} */
|
|
35
|
+
(layer.getImplementations().filter(i => i instanceof CesiumTilesetCesium));
|
|
36
|
+
if (!layer.active || impls.every(i => i.cesium3DTileset.tilesLoaded)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
await Promise.all(impls.map(i => waitForImplTilesLoaded(i, timeout)));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {import("@vcmap/cesium").Globe} globe
|
|
45
|
+
* @param {number=} timeout
|
|
46
|
+
* @returns {Promise<void>}
|
|
47
|
+
*/
|
|
48
|
+
export function globeLoaded(globe, timeout) {
|
|
49
|
+
if (globe.tilesLoaded) {
|
|
50
|
+
return Promise.resolve();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return new Promise((resolve) => {
|
|
54
|
+
let timeoutNr;
|
|
55
|
+
const remover = globe.tileLoadProgressEvent.addEventListener((count) => {
|
|
56
|
+
if (count < 1) {
|
|
57
|
+
if (timeoutNr) {
|
|
58
|
+
clearTimeout(timeoutNr);
|
|
59
|
+
}
|
|
60
|
+
remover();
|
|
61
|
+
resolve();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (timeout != null) {
|
|
66
|
+
timeoutNr = setTimeout(() => {
|
|
67
|
+
remover();
|
|
68
|
+
resolve();
|
|
69
|
+
}, timeout);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import MVT from 'ol/format/MVT.js';
|
|
3
|
+
import Feature from 'ol/Feature.js';
|
|
4
|
+
import { getCenter } from 'ol/extent.js';
|
|
5
|
+
import TileProvider, { rectangleToExtent } from './tileProvider.js';
|
|
6
|
+
import { getURL } from './urlTemplateTileProvider.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {TileProviderOptions} MVTTileProviderOptions
|
|
10
|
+
* @property {string} url to pbf tiled datasource {x}, {y}, {z} are placeholders for x, y, zoom
|
|
11
|
+
* @property {string|undefined} idProperty if property exists will be used to set the ID of the feature
|
|
12
|
+
* @api
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Loads the pbf tiles
|
|
17
|
+
*
|
|
18
|
+
* @class
|
|
19
|
+
* @extends {TileProvider}
|
|
20
|
+
* @export
|
|
21
|
+
* @api
|
|
22
|
+
*/
|
|
23
|
+
class MVTTileProvider extends TileProvider {
|
|
24
|
+
/**
|
|
25
|
+
* @readonly
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
static get className() { return 'vcs.vcm.layer.tileProvider.MVTTileProvider'; }
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @returns {MVTTileProviderOptions}
|
|
32
|
+
*/
|
|
33
|
+
static getDefaultOptions() {
|
|
34
|
+
return {
|
|
35
|
+
...TileProvider.getDefaultOptions(),
|
|
36
|
+
url: undefined,
|
|
37
|
+
idProperty: undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {MVTTileProviderOptions} options
|
|
43
|
+
*/
|
|
44
|
+
constructor(options) {
|
|
45
|
+
const defaultOptions = MVTTileProvider.getDefaultOptions();
|
|
46
|
+
super(options);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @type {string}
|
|
50
|
+
*/
|
|
51
|
+
this.url = options.url || defaultOptions.url;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @type {string|undefined}
|
|
55
|
+
*/
|
|
56
|
+
this.idProperty = options.idProperty || defaultOptions.idProperty;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @type {import("ol/format/MVT").default}
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
this._MVTFormat = new MVT({ featureClass: Feature });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @inheritDoc
|
|
67
|
+
* @param {number} x
|
|
68
|
+
* @param {number} y
|
|
69
|
+
* @param {number} z
|
|
70
|
+
* @returns {Promise<Array<import("ol").Feature<import("ol/geom/Geometry").default>>>}
|
|
71
|
+
*/
|
|
72
|
+
async loader(x, y, z) {
|
|
73
|
+
const rectangle = this.tilingScheme.tileXYToRectangle(x, y, z);
|
|
74
|
+
const url = getURL(this.url, x, y, z, rectangle);
|
|
75
|
+
const extent = rectangleToExtent(rectangle);
|
|
76
|
+
const center = getCenter(extent);
|
|
77
|
+
const response = await axios.get(url, { responseType: 'arraybuffer' });
|
|
78
|
+
const features = /** @type {Array<import("ol").Feature<import("ol/geom/Geometry").default>>} */
|
|
79
|
+
(this._MVTFormat.readFeatures(response.data));
|
|
80
|
+
const sx = ((extent[2] - extent[0]) / 4096);
|
|
81
|
+
const sy = -((extent[3] - extent[1]) / 4096);
|
|
82
|
+
features.forEach((feature) => {
|
|
83
|
+
const idToUse = feature.get(this.idProperty);
|
|
84
|
+
if (idToUse != null) {
|
|
85
|
+
feature.setId(String(idToUse));
|
|
86
|
+
}
|
|
87
|
+
const geom = feature.getGeometry();
|
|
88
|
+
const flatCoordinates = geom.getFlatCoordinates();
|
|
89
|
+
const flatCoordinatesLength = flatCoordinates.length;
|
|
90
|
+
for (let i = 0; i < flatCoordinatesLength; i++) {
|
|
91
|
+
if (i % 2) {
|
|
92
|
+
flatCoordinates[i] = (flatCoordinates[i] - 2048) * sy;
|
|
93
|
+
flatCoordinates[i] += center[1];
|
|
94
|
+
} else {
|
|
95
|
+
flatCoordinates[i] = (flatCoordinates[i] - 2048) * sx;
|
|
96
|
+
flatCoordinates[i] += center[0];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return features;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default MVTTileProvider;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { parseGeoJSON } from '../geojsonHelpers.js';
|
|
3
|
+
import TileProvider from './tileProvider.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {TileProviderOptions} StaticGeojsonTileProviderOptions
|
|
7
|
+
* @property {string} url geojson
|
|
8
|
+
* @api
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Loads the provided geojson url and tiles the content in memory, data is only requested once
|
|
13
|
+
*
|
|
14
|
+
* @class
|
|
15
|
+
* @extends {TileProvider}
|
|
16
|
+
* @export
|
|
17
|
+
* @api
|
|
18
|
+
*/
|
|
19
|
+
class StaticGeojsonTileProvider extends TileProvider {
|
|
20
|
+
/**
|
|
21
|
+
* @readonly
|
|
22
|
+
* @returns {string}
|
|
23
|
+
*/
|
|
24
|
+
static get className() { return 'vcs.vcm.layer.tileProvider.StaticGeojsonTileProvider'; }
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @returns {StaticGeojsonTileProviderOptions}
|
|
28
|
+
*/
|
|
29
|
+
static getDefaultOptions() {
|
|
30
|
+
return {
|
|
31
|
+
...TileProvider.getDefaultOptions(),
|
|
32
|
+
url: undefined,
|
|
33
|
+
baseLevels: [0],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {StaticGeojsonTileProviderOptions} options
|
|
39
|
+
*/
|
|
40
|
+
constructor(options) {
|
|
41
|
+
const defaultOptions = StaticGeojsonTileProvider.getDefaultOptions();
|
|
42
|
+
options.baseLevels = defaultOptions.baseLevels;
|
|
43
|
+
super(options);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @type {string}
|
|
47
|
+
*/
|
|
48
|
+
this.url = options.url || defaultOptions.url;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @inheritDoc
|
|
54
|
+
* @param {number} x
|
|
55
|
+
* @param {number} y
|
|
56
|
+
* @param {number} z
|
|
57
|
+
* @returns {Promise<Array<import("ol").Feature<import("ol/geom/Geometry").default>>>}
|
|
58
|
+
*/
|
|
59
|
+
// eslint-disable-next-line no-unused-vars
|
|
60
|
+
async loader(x, y, z) {
|
|
61
|
+
const response = await axios.get(this.url);
|
|
62
|
+
const { features } = parseGeoJSON(response.data, { dynamicStyle: true });
|
|
63
|
+
return features;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default StaticGeojsonTileProvider;
|