@vcmap/core 5.0.0-rc.28 → 5.0.0-rc.29
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/README.md +9 -3
- package/build/postinstall.js +13 -2
- package/index.d.ts +155 -106
- package/package.json +9 -4
- package/src/category/category.js +71 -32
- package/src/category/categoryCollection.js +27 -18
- package/src/cesium/cesiumVcsCameraPrimitive.js +13 -5
- package/src/cesium/entity.js +3 -1
- package/src/cesium/wallpaperMaterial.js +4 -2
- package/src/classRegistry.js +11 -4
- package/src/featureProvider/abstractFeatureProvider.js +43 -22
- package/src/featureProvider/tileProviderFeatureProvider.js +11 -5
- package/src/featureProvider/wmsFeatureProvider.js +37 -15
- package/src/interaction/abstractInteraction.js +5 -1
- package/src/interaction/coordinateAtPixel.js +34 -12
- package/src/interaction/eventHandler.js +63 -23
- package/src/interaction/featureAtPixelInteraction.js +96 -32
- package/src/interaction/featureProviderInteraction.js +23 -8
- package/src/interaction/interactionChain.js +19 -9
- package/src/interaction/interactionType.js +23 -26
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +45 -15
- package/src/layer/cesium/clusterContext.js +10 -3
- package/src/layer/cesium/dataSourceCesiumImpl.js +13 -4
- package/src/layer/cesium/openStreetMapCesiumImpl.js +7 -3
- package/src/layer/cesium/rasterLayerCesiumImpl.js +6 -2
- package/src/layer/cesium/singleImageCesiumImpl.js +14 -3
- package/src/layer/cesium/terrainCesiumImpl.js +3 -2
- package/src/layer/cesium/tmsCesiumImpl.js +15 -3
- package/src/layer/cesium/vectorCesiumImpl.js +69 -25
- package/src/layer/cesium/vectorContext.js +25 -5
- package/src/layer/cesium/vectorRasterTileCesiumImpl.js +15 -5
- package/src/layer/cesium/vectorTileImageryProvider.js +51 -13
- package/src/layer/cesium/wmsCesiumImpl.js +15 -3
- package/src/layer/cesium/wmtsCesiumImpl.js +18 -6
- package/src/layer/cesium/x3dmHelper.js +4 -1
- package/src/layer/cesiumTilesetLayer.js +55 -26
- package/src/layer/czmlLayer.js +11 -5
- package/src/layer/dataSourceLayer.js +25 -17
- package/src/layer/featureLayer.js +33 -18
- package/src/layer/featureStoreLayer.js +161 -99
- package/src/layer/featureStoreLayerChanges.js +57 -17
- package/src/layer/featureVisibility.js +89 -59
- package/src/layer/geojsonHelpers.js +70 -29
- package/src/layer/geojsonLayer.js +17 -11
- package/src/layer/globalHider.js +14 -4
- package/src/layer/layer.js +77 -44
- package/src/layer/layerImplementation.js +12 -4
- package/src/layer/oblique/layerObliqueImpl.js +3 -1
- package/src/layer/oblique/obliqueHelpers.js +75 -30
- package/src/layer/oblique/vectorObliqueImpl.js +175 -69
- package/src/layer/openStreetMapLayer.js +34 -20
- package/src/layer/openlayers/layerOpenlayersImpl.js +37 -15
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/singleImageOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tileDebugOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tmsOpenlayersImpl.js +6 -3
- package/src/layer/openlayers/vectorOpenlayersImpl.js +14 -4
- package/src/layer/openlayers/vectorTileOpenlayersImpl.js +12 -5
- package/src/layer/openlayers/wmsOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/wmtsOpenlayersImpl.js +12 -5
- package/src/layer/pointCloudLayer.js +21 -10
- package/src/layer/rasterLayer.js +73 -22
- package/src/layer/singleImageLayer.js +10 -7
- package/src/layer/terrainHelpers.js +30 -19
- package/src/layer/terrainLayer.js +16 -7
- package/src/layer/tileLoadedHelper.js +9 -4
- package/src/layer/tileProvider/mvtTileProvider.js +10 -4
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +10 -4
- package/src/layer/tileProvider/tileProvider.js +163 -87
- package/src/layer/tileProvider/urlTemplateTileProvider.js +10 -4
- package/src/layer/tmsLayer.js +7 -6
- package/src/layer/vectorHelpers.js +34 -25
- package/src/layer/vectorLayer.js +77 -36
- package/src/layer/vectorProperties.js +245 -74
- package/src/layer/vectorSymbols.js +3 -1
- package/src/layer/vectorTileLayer.js +121 -70
- package/src/layer/wfsLayer.js +19 -8
- package/src/layer/wmsHelpers.js +11 -6
- package/src/layer/wmsLayer.js +36 -14
- package/src/layer/wmtsLayer.js +35 -20
- package/src/map/baseOLMap.js +57 -31
- package/src/map/cameraLimiter.js +67 -18
- package/src/map/cesiumMap.js +307 -95
- package/src/map/obliqueMap.js +84 -34
- package/src/map/openlayersMap.js +40 -19
- package/src/map/vcsMap.js +21 -8
- package/src/oblique/helpers.js +212 -64
- package/src/oblique/obliqueCollection.js +111 -48
- package/src/oblique/obliqueDataSet.js +53 -21
- package/src/oblique/obliqueImage.js +50 -17
- package/src/oblique/obliqueImageMeta.js +7 -6
- package/src/oblique/obliqueProvider.js +75 -27
- package/src/oblique/obliqueView.js +18 -7
- package/src/oblique/obliqueViewDirection.js +3 -2
- package/src/oblique/parseImageJson.js +57 -23
- package/src/ol/feature.js +8 -3
- package/src/ol/geom/circle.js +12 -3
- package/src/ol/geom/geometryCollection.js +11 -4
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -9
- package/src/overrideClassRegistry.js +13 -3
- package/src/style/arcStyle.js +129 -36
- package/src/style/arrowStyle.js +57 -22
- package/src/style/declarativeStyleItem.js +107 -62
- package/src/style/shapesCategory.js +8 -6
- package/src/style/styleFactory.js +4 -1
- package/src/style/styleHelpers.js +17 -8
- package/src/style/styleItem.js +28 -10
- package/src/style/vectorStyleItem.js +160 -74
- package/src/style/writeStyle.js +5 -7
- package/src/util/clipping/clippingObject.js +72 -38
- package/src/util/clipping/clippingObjectManager.js +53 -19
- package/src/util/clipping/clippingPlaneHelper.js +120 -53
- package/src/util/collection.js +12 -6
- package/src/util/editor/createFeatureSession.js +21 -6
- package/src/util/editor/editFeaturesSession.js +41 -15
- package/src/util/editor/editGeometrySession.js +55 -30
- package/src/util/editor/editorHelpers.js +114 -29
- package/src/util/editor/editorSessionHelpers.js +8 -3
- package/src/util/editor/interactions/createBBoxInteraction.js +11 -3
- package/src/util/editor/interactions/createCircleInteraction.js +7 -2
- package/src/util/editor/interactions/createLineStringInteraction.js +7 -2
- package/src/util/editor/interactions/createPolygonInteraction.js +7 -2
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +7 -5
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +8 -3
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +4 -2
- package/src/util/editor/interactions/insertVertexInteraction.js +17 -6
- package/src/util/editor/interactions/mapInteractionController.js +31 -14
- package/src/util/editor/interactions/removeVertexInteraction.js +4 -1
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +19 -10
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +33 -20
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +14 -8
- package/src/util/editor/selectFeaturesSession.js +37 -21
- package/src/util/editor/transformation/create2DHandlers.js +82 -37
- package/src/util/editor/transformation/create3DHandlers.js +187 -84
- package/src/util/editor/transformation/extrudeInteraction.js +20 -5
- package/src/util/editor/transformation/rotateInteraction.js +29 -16
- package/src/util/editor/transformation/scaleInteraction.js +31 -15
- package/src/util/editor/transformation/transformationHandler.js +23 -8
- package/src/util/editor/transformation/transformationTypes.js +8 -4
- package/src/util/editor/transformation/translateInteraction.js +86 -32
- package/src/util/editor/validateGeoemetry.js +3 -1
- package/src/util/exclusiveManager.js +6 -3
- package/src/util/extent.js +20 -10
- package/src/util/featureconverter/arcToCesium.js +46 -12
- package/src/util/featureconverter/circleToCesium.js +61 -27
- package/src/util/featureconverter/convert.js +85 -13
- package/src/util/featureconverter/extent3D.js +69 -28
- package/src/util/featureconverter/featureconverterHelper.js +232 -79
- package/src/util/featureconverter/lineStringToCesium.js +107 -35
- package/src/util/featureconverter/pointHelpers.js +117 -45
- package/src/util/featureconverter/pointToCesium.js +128 -31
- package/src/util/featureconverter/polygonToCesium.js +50 -16
- package/src/util/fetch.js +3 -1
- package/src/util/geometryHelpers.js +15 -10
- package/src/util/indexedCollection.js +7 -3
- package/src/util/isMobile.js +8 -2
- package/src/util/layerCollection.js +28 -12
- package/src/util/mapCollection.js +37 -18
- package/src/util/math.js +35 -19
- package/src/util/overrideCollection.js +57 -32
- package/src/util/projection.js +21 -5
- package/src/util/urlHelpers.js +5 -3
- package/src/util/viewpoint.js +66 -33
- package/src/vcsApp.js +133 -69
- package/src/vcsModule.js +3 -2
- package/src/vcsModuleHelpers.js +24 -9
- package/src/vcsObject.js +3 -2
- package/tests/data/dynamicPointCzml.json +24 -35
- package/tests/data/oblique/imageData/imagev34.json +56 -272
- package/tests/data/oblique/imageData/imagev35.json +272 -19
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +299 -19
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -1
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -1
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -1
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -1
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -1
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -1
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -1
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -1
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -1
- package/tests/data/oblique/tiledImageData/image.json +70 -1
- package/tests/data/terrain/layer.json +121 -130
- package/tests/data/testGeoJSON.json +4 -16
- package/tests/unit/helpers/cesiumHelpers.js +58 -33
- package/tests/unit/helpers/helpers.js +10 -2
- package/tests/unit/helpers/imageHelpers.js +8 -4
- package/tests/unit/helpers/obliqueData.js +39 -13
- package/tests/unit/helpers/obliqueHelpers.js +12 -9
- package/tests/unit/helpers/openlayersHelpers.js +4 -1
- package/tests/unit/helpers/terrain/terrainData.js +8 -7
|
@@ -11,7 +11,9 @@ import { mercatorProjection } from '../../util/projection.js';
|
|
|
11
11
|
* @extends {LayerOpenlayersImpl}
|
|
12
12
|
*/
|
|
13
13
|
class VectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
14
|
-
static get className() {
|
|
14
|
+
static get className() {
|
|
15
|
+
return 'VectorTileOpenlayersImpl';
|
|
16
|
+
}
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* @param {import("@vcmap/core").OpenlayersMap} map
|
|
@@ -74,8 +76,11 @@ class VectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
74
76
|
* @returns {Promise<void>}
|
|
75
77
|
*/
|
|
76
78
|
tileLoadFunction: async (tile) => {
|
|
77
|
-
const features =
|
|
78
|
-
|
|
79
|
+
const features = await this.tileProvider.getFeaturesForTile(
|
|
80
|
+
tile.tileCoord[1],
|
|
81
|
+
tile.tileCoord[2],
|
|
82
|
+
tile.tileCoord[0],
|
|
83
|
+
);
|
|
79
84
|
if (features.length > 0) {
|
|
80
85
|
tile.setFeatures(features);
|
|
81
86
|
} else {
|
|
@@ -86,8 +91,10 @@ class VectorTileOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
86
91
|
// url needs to be set for the tileLoadFunction to work.
|
|
87
92
|
url: '/{z}/{x}/{y}',
|
|
88
93
|
});
|
|
89
|
-
const extent =
|
|
90
|
-
this.extent.
|
|
94
|
+
const extent =
|
|
95
|
+
this.extent && this.extent.isValid()
|
|
96
|
+
? this.extent.getCoordinatesInProjection(mercatorProjection)
|
|
97
|
+
: undefined;
|
|
91
98
|
// make it so that openlayers and cesium zoom level fit together
|
|
92
99
|
const minZoom = this.minLevel ? this.minLevel : undefined;
|
|
93
100
|
const maxZoom = this.maxLevel ? this.maxLevel + 1 : undefined;
|
|
@@ -8,7 +8,9 @@ import { getWMSSource } from '../wmsHelpers.js';
|
|
|
8
8
|
* @extends {RasterLayerOpenlayersImpl}
|
|
9
9
|
*/
|
|
10
10
|
class WmsOpenlayersImpl extends RasterLayerOpenlayersImpl {
|
|
11
|
-
static get className() {
|
|
11
|
+
static get className() {
|
|
12
|
+
return 'WmsOpenlayersImpl';
|
|
13
|
+
}
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* @param {import("@vcmap/core").OpenlayersMap} map
|
|
@@ -13,7 +13,9 @@ import { isSameOrigin } from '../../util/urlHelpers.js';
|
|
|
13
13
|
* @extends {RasterLayerOpenlayersImpl}
|
|
14
14
|
*/
|
|
15
15
|
class WmtsOpenlayersImpl extends RasterLayerOpenlayersImpl {
|
|
16
|
-
static get className() {
|
|
16
|
+
static get className() {
|
|
17
|
+
return 'WmtsOpenlayersImpl';
|
|
18
|
+
}
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* @param {import("@vcmap/core").OpenlayersMap} map
|
|
@@ -72,7 +74,10 @@ class WmtsOpenlayersImpl extends RasterLayerOpenlayersImpl {
|
|
|
72
74
|
* @returns {import("ol/layer/Tile").default}
|
|
73
75
|
*/
|
|
74
76
|
getOLLayer() {
|
|
75
|
-
const projection =
|
|
77
|
+
const projection =
|
|
78
|
+
this.tilingSchema === TilingScheme.GEOGRAPHIC
|
|
79
|
+
? wgs84Projection
|
|
80
|
+
: mercatorProjection;
|
|
76
81
|
const projectionExtent = projection.proj.getExtent();
|
|
77
82
|
let size = getWidth(projectionExtent) / this.tileSize[0];
|
|
78
83
|
if (this.numberOfLevelZeroTilesX > 1) {
|
|
@@ -83,9 +88,11 @@ class WmtsOpenlayersImpl extends RasterLayerOpenlayersImpl {
|
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
const maxZoom = this.maxLevel + 1;
|
|
86
|
-
const resolutions = new Array(maxZoom)
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
const resolutions = new Array(maxZoom)
|
|
92
|
+
.fill(undefined)
|
|
93
|
+
.map((value, index) => {
|
|
94
|
+
return size / 2 ** index;
|
|
95
|
+
});
|
|
89
96
|
|
|
90
97
|
const extent = this.extent.getCoordinatesInProjection(projection);
|
|
91
98
|
const tileGridOptions = {
|
|
@@ -36,7 +36,9 @@ export const defaultPointCloudStyle = new DeclarativeStyleItem({});
|
|
|
36
36
|
* @api stable
|
|
37
37
|
*/
|
|
38
38
|
class PointCloudLayer extends CesiumTilesetLayer {
|
|
39
|
-
static get className() {
|
|
39
|
+
static get className() {
|
|
40
|
+
return 'PointCloudLayer';
|
|
41
|
+
}
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
44
|
* @returns {PointCloudOptions}
|
|
@@ -60,13 +62,12 @@ class PointCloudLayer extends CesiumTilesetLayer {
|
|
|
60
62
|
* @api
|
|
61
63
|
* @type {number|string|null}
|
|
62
64
|
*/
|
|
63
|
-
this.defaultPointSize =
|
|
65
|
+
this.defaultPointSize =
|
|
66
|
+
options.pointSize != null ? options.pointSize : defaultOptions.pointSize;
|
|
64
67
|
/** @type {number|string|null} */
|
|
65
68
|
this._pointSize = this.defaultPointSize;
|
|
66
69
|
|
|
67
|
-
this._supportedMaps = [
|
|
68
|
-
CesiumMap.className,
|
|
69
|
-
];
|
|
70
|
+
this._supportedMaps = [CesiumMap.className];
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
/**
|
|
@@ -76,14 +77,19 @@ class PointCloudLayer extends CesiumTilesetLayer {
|
|
|
76
77
|
* @returns {import("@vcmap/core").StyleItem}
|
|
77
78
|
*/
|
|
78
79
|
getStyleOrDefaultStyle(styleOptions, defaultStyle) {
|
|
79
|
-
return super.getStyleOrDefaultStyle(
|
|
80
|
+
return super.getStyleOrDefaultStyle(
|
|
81
|
+
styleOptions,
|
|
82
|
+
defaultStyle || defaultPointCloudStyle,
|
|
83
|
+
);
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
/**
|
|
83
87
|
* @type {number|string|null}
|
|
84
88
|
* @api
|
|
85
89
|
*/
|
|
86
|
-
get pointSize() {
|
|
90
|
+
get pointSize() {
|
|
91
|
+
return this._pointSize;
|
|
92
|
+
}
|
|
87
93
|
|
|
88
94
|
/**
|
|
89
95
|
* @param {string|number|undefined} size
|
|
@@ -91,7 +97,8 @@ class PointCloudLayer extends CesiumTilesetLayer {
|
|
|
91
97
|
set pointSize(size) {
|
|
92
98
|
checkMaybe(size, [Number, String]);
|
|
93
99
|
this._pointSize = size;
|
|
94
|
-
/** @type {DeclarativeStyleItem} */ (this.style).pointSize =
|
|
100
|
+
/** @type {DeclarativeStyleItem} */ (this.style).pointSize =
|
|
101
|
+
size?.toString();
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
async initialize() {
|
|
@@ -105,7 +112,9 @@ class PointCloudLayer extends CesiumTilesetLayer {
|
|
|
105
112
|
*/
|
|
106
113
|
createImplementationsForMap(map) {
|
|
107
114
|
if (map instanceof CesiumMap) {
|
|
108
|
-
return [
|
|
115
|
+
return [
|
|
116
|
+
new CesiumTilesetCesiumImpl(map, this.getImplementationOptions()),
|
|
117
|
+
];
|
|
109
118
|
}
|
|
110
119
|
|
|
111
120
|
return [];
|
|
@@ -128,7 +137,9 @@ class PointCloudLayer extends CesiumTilesetLayer {
|
|
|
128
137
|
*/
|
|
129
138
|
setStyle(style, silent) {
|
|
130
139
|
if (style instanceof VectorStyleItem) {
|
|
131
|
-
this.getLogger().warning(
|
|
140
|
+
this.getLogger().warning(
|
|
141
|
+
'trying to apply vector style to point cloud layer.',
|
|
142
|
+
);
|
|
132
143
|
} else {
|
|
133
144
|
super.setStyle(style, silent);
|
|
134
145
|
}
|
package/src/layer/rasterLayer.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
SplitDirection,
|
|
3
|
+
WebMercatorTilingScheme,
|
|
4
|
+
GeographicTilingScheme,
|
|
5
|
+
Cartographic,
|
|
6
|
+
} from '@vcmap-cesium/engine';
|
|
7
|
+
import {
|
|
8
|
+
getBottomLeft,
|
|
9
|
+
getBottomRight,
|
|
10
|
+
getTopLeft,
|
|
11
|
+
getTopRight,
|
|
12
|
+
} from 'ol/extent.js';
|
|
3
13
|
|
|
4
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
parseInteger,
|
|
16
|
+
parseNumberRange,
|
|
17
|
+
parseEnumValue,
|
|
18
|
+
} from '@vcsuite/parsers';
|
|
5
19
|
import { wgs84Projection } from '../util/projection.js';
|
|
6
20
|
import Layer from './layer.js';
|
|
7
21
|
import VcsEvent from '../vcsEvent.js';
|
|
@@ -54,11 +68,19 @@ export const TilingScheme = {
|
|
|
54
68
|
*/
|
|
55
69
|
export function getTilingScheme(layerOptions) {
|
|
56
70
|
const tilingSchemeOptions = {};
|
|
57
|
-
if (
|
|
58
|
-
|
|
71
|
+
if (
|
|
72
|
+
layerOptions.numberOfLevelZeroTilesX &&
|
|
73
|
+
layerOptions.numberOfLevelZeroTilesX > 1
|
|
74
|
+
) {
|
|
75
|
+
tilingSchemeOptions.numberOfLevelZeroTilesX =
|
|
76
|
+
layerOptions.numberOfLevelZeroTilesX;
|
|
59
77
|
}
|
|
60
|
-
if (
|
|
61
|
-
|
|
78
|
+
if (
|
|
79
|
+
layerOptions.numberOfLevelZeroTilesY &&
|
|
80
|
+
layerOptions.numberOfLevelZeroTilesY > 1
|
|
81
|
+
) {
|
|
82
|
+
tilingSchemeOptions.numberOfLevelZeroTilesY =
|
|
83
|
+
layerOptions.numberOfLevelZeroTilesY;
|
|
62
84
|
}
|
|
63
85
|
if (layerOptions.tilingSchema === TilingScheme.MERCATOR) {
|
|
64
86
|
return new WebMercatorTilingScheme(tilingSchemeOptions);
|
|
@@ -73,7 +95,12 @@ export function getTilingScheme(layerOptions) {
|
|
|
73
95
|
* @param {number} [minLevel=0]
|
|
74
96
|
* @returns {number}
|
|
75
97
|
*/
|
|
76
|
-
export function calculateMinLevel(
|
|
98
|
+
export function calculateMinLevel(
|
|
99
|
+
extent,
|
|
100
|
+
tilingScheme,
|
|
101
|
+
maxLevel,
|
|
102
|
+
minLevel = 0,
|
|
103
|
+
) {
|
|
77
104
|
if (!extent.isValid()) {
|
|
78
105
|
return minLevel;
|
|
79
106
|
}
|
|
@@ -90,11 +117,15 @@ export function calculateMinLevel(extent, tilingScheme, maxLevel, minLevel = 0)
|
|
|
90
117
|
getTopRight(wgs84Extent),
|
|
91
118
|
getTopLeft(wgs84Extent),
|
|
92
119
|
];
|
|
93
|
-
const extentCoords = olCoords.map(coord =>
|
|
120
|
+
const extentCoords = olCoords.map((coord) =>
|
|
121
|
+
Cartographic.fromDegrees(coord[0], coord[1]),
|
|
122
|
+
);
|
|
94
123
|
let usedMinLevel = minLevel;
|
|
95
124
|
while (usedMinLevel < maxLevel) {
|
|
96
125
|
// eslint-disable-next-line no-loop-func
|
|
97
|
-
const tileCoords = extentCoords.map(position =>
|
|
126
|
+
const tileCoords = extentCoords.map((position) =>
|
|
127
|
+
tilingScheme.positionToTileXY(position, usedMinLevel),
|
|
128
|
+
);
|
|
98
129
|
const distances = [];
|
|
99
130
|
distances.push(Math.abs(tileCoords[0].x - tileCoords[1].x));
|
|
100
131
|
distances.push(Math.abs(tileCoords[0].y - tileCoords[3].y));
|
|
@@ -116,7 +147,9 @@ export function calculateMinLevel(extent, tilingScheme, maxLevel, minLevel = 0)
|
|
|
116
147
|
* @abstract
|
|
117
148
|
*/
|
|
118
149
|
class RasterLayer extends Layer {
|
|
119
|
-
static get className() {
|
|
150
|
+
static get className() {
|
|
151
|
+
return 'RasterLayer';
|
|
152
|
+
}
|
|
120
153
|
|
|
121
154
|
/**
|
|
122
155
|
* @returns {RasterLayerOptions}
|
|
@@ -145,7 +178,11 @@ class RasterLayer extends Layer {
|
|
|
145
178
|
* @type {string}
|
|
146
179
|
* @api
|
|
147
180
|
*/
|
|
148
|
-
this.tilingSchema = parseEnumValue(
|
|
181
|
+
this.tilingSchema = parseEnumValue(
|
|
182
|
+
options.tilingSchema,
|
|
183
|
+
TilingScheme,
|
|
184
|
+
defaultOptions.tilingSchema,
|
|
185
|
+
);
|
|
149
186
|
/** @type {number} */
|
|
150
187
|
this.maxLevel = parseInteger(options.maxLevel, defaultOptions.maxLevel);
|
|
151
188
|
/**
|
|
@@ -156,21 +193,32 @@ class RasterLayer extends Layer {
|
|
|
156
193
|
|
|
157
194
|
const cesiumTilingScheme = getTilingScheme(options);
|
|
158
195
|
/** @type {number} */
|
|
159
|
-
this.minLevel = calculateMinLevel(
|
|
196
|
+
this.minLevel = calculateMinLevel(
|
|
197
|
+
this.extent,
|
|
198
|
+
cesiumTilingScheme,
|
|
199
|
+
this.maxLevel,
|
|
200
|
+
this._minLevel,
|
|
201
|
+
);
|
|
160
202
|
|
|
161
203
|
/**
|
|
162
204
|
* @type {number}
|
|
163
205
|
* @private
|
|
164
206
|
*/
|
|
165
|
-
this._opacity = parseNumberRange(
|
|
207
|
+
this._opacity = parseNumberRange(
|
|
208
|
+
options.opacity,
|
|
209
|
+
defaultOptions.opacity,
|
|
210
|
+
0.0,
|
|
211
|
+
1.0,
|
|
212
|
+
);
|
|
166
213
|
|
|
167
214
|
/** @type {import("@vcmap-cesium/engine").SplitDirection} */
|
|
168
215
|
this._splitDirection = SplitDirection.NONE;
|
|
169
216
|
|
|
170
217
|
if (options.splitDirection) {
|
|
171
|
-
this._splitDirection =
|
|
172
|
-
|
|
173
|
-
|
|
218
|
+
this._splitDirection =
|
|
219
|
+
options.splitDirection === 'left'
|
|
220
|
+
? SplitDirection.LEFT
|
|
221
|
+
: SplitDirection.RIGHT;
|
|
174
222
|
}
|
|
175
223
|
|
|
176
224
|
/**
|
|
@@ -186,7 +234,9 @@ class RasterLayer extends Layer {
|
|
|
186
234
|
* @api
|
|
187
235
|
* @type {import("@vcmap-cesium/engine").SplitDirection}
|
|
188
236
|
*/
|
|
189
|
-
get splitDirection() {
|
|
237
|
+
get splitDirection() {
|
|
238
|
+
return this._splitDirection;
|
|
239
|
+
}
|
|
190
240
|
|
|
191
241
|
/**
|
|
192
242
|
* @param {import("@vcmap-cesium/engine").SplitDirection} direction
|
|
@@ -207,7 +257,9 @@ class RasterLayer extends Layer {
|
|
|
207
257
|
* @api
|
|
208
258
|
* @type {number}
|
|
209
259
|
*/
|
|
210
|
-
get opacity() {
|
|
260
|
+
get opacity() {
|
|
261
|
+
return this._opacity;
|
|
262
|
+
}
|
|
211
263
|
|
|
212
264
|
/**
|
|
213
265
|
* @param {number} opacity
|
|
@@ -271,9 +323,8 @@ class RasterLayer extends Layer {
|
|
|
271
323
|
}
|
|
272
324
|
|
|
273
325
|
if (this._splitDirection !== SplitDirection.NONE) {
|
|
274
|
-
config.splitDirection =
|
|
275
|
-
'right' :
|
|
276
|
-
'left';
|
|
326
|
+
config.splitDirection =
|
|
327
|
+
this._splitDirection === SplitDirection.RIGHT ? 'right' : 'left';
|
|
277
328
|
}
|
|
278
329
|
|
|
279
330
|
return config;
|
|
@@ -26,7 +26,9 @@ import { wgs84Projection } from '../util/projection.js';
|
|
|
26
26
|
* @api stable
|
|
27
27
|
*/
|
|
28
28
|
class SingleImageLayer extends RasterLayer {
|
|
29
|
-
static get className() {
|
|
29
|
+
static get className() {
|
|
30
|
+
return 'SingleImageLayer';
|
|
31
|
+
}
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* @returns {SingleImageOptions}
|
|
@@ -48,17 +50,16 @@ class SingleImageLayer extends RasterLayer {
|
|
|
48
50
|
this.credit = options.credit || defaultOptions.credit;
|
|
49
51
|
|
|
50
52
|
if (!this.extent.isValid()) {
|
|
51
|
-
this.getLogger().warning(
|
|
53
|
+
this.getLogger().warning(
|
|
54
|
+
`layer ${this.name} was constructed with an invalid extent, defaulting to global extent`,
|
|
55
|
+
);
|
|
52
56
|
this.extent = new Extent({
|
|
53
57
|
projection: wgs84Projection.toJSON(),
|
|
54
58
|
coordinates: [-180, -90, 180, 90],
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
this._supportedMaps = [
|
|
59
|
-
CesiumMap.className,
|
|
60
|
-
OpenlayersMap.className,
|
|
61
|
-
];
|
|
62
|
+
this._supportedMaps = [CesiumMap.className, OpenlayersMap.className];
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
/**
|
|
@@ -79,7 +80,9 @@ class SingleImageLayer extends RasterLayer {
|
|
|
79
80
|
if (map instanceof CesiumMap) {
|
|
80
81
|
return [new SingleImageCesiumImpl(map, this.getImplementationOptions())];
|
|
81
82
|
} else if (map instanceof OpenlayersMap) {
|
|
82
|
-
return [
|
|
83
|
+
return [
|
|
84
|
+
new SingleImageOpenlayersImpl(map, this.getImplementationOptions()),
|
|
85
|
+
];
|
|
83
86
|
}
|
|
84
87
|
return [];
|
|
85
88
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CesiumTerrainProvider,
|
|
3
|
+
Cartographic,
|
|
4
|
+
Cartesian2,
|
|
5
|
+
sampleTerrainMostDetailed,
|
|
6
|
+
} from '@vcmap-cesium/engine';
|
|
2
7
|
import { getTransform } from 'ol/proj.js';
|
|
3
8
|
import { wgs84Projection } from '../util/projection.js';
|
|
4
9
|
|
|
@@ -25,10 +30,12 @@ export function getTerrainProviderForUrl(options) {
|
|
|
25
30
|
return terrainProviders[options.url];
|
|
26
31
|
}
|
|
27
32
|
let terrainProvider = terrainProviders[options.url];
|
|
28
|
-
if (
|
|
33
|
+
if (
|
|
34
|
+
(options.requestVertexNormals !== undefined &&
|
|
29
35
|
terrainProvider.requestVertexNormals !== options.requestVertexNormals) ||
|
|
30
36
|
(options.requestWaterMask !== undefined &&
|
|
31
|
-
terrainProvider.requestWaterMask !== options.requestWaterMask)
|
|
37
|
+
terrainProvider.requestWaterMask !== options.requestWaterMask)
|
|
38
|
+
) {
|
|
32
39
|
terrainProviders[options.url] = new CesiumTerrainProvider(options);
|
|
33
40
|
terrainProvider = terrainProviders[options.url];
|
|
34
41
|
}
|
|
@@ -43,29 +50,32 @@ export function getTerrainProviderForUrl(options) {
|
|
|
43
50
|
* @param {Array<import("ol/coordinate").Coordinate>=} result
|
|
44
51
|
* @returns {Promise<Array<import("ol/coordinate").Coordinate>>}
|
|
45
52
|
*/
|
|
46
|
-
export function getHeightFromTerrainProvider(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
export function getHeightFromTerrainProvider(
|
|
54
|
+
terrainProvider,
|
|
55
|
+
coordinates,
|
|
56
|
+
optSourceProjection,
|
|
57
|
+
result,
|
|
58
|
+
) {
|
|
59
|
+
const sourceTransformer = optSourceProjection
|
|
60
|
+
? getTransform(optSourceProjection.proj, wgs84Projection.proj)
|
|
61
|
+
: null;
|
|
53
62
|
|
|
54
63
|
const positions = coordinates.map((coord) => {
|
|
55
|
-
const wgs84 = sourceTransformer
|
|
56
|
-
sourceTransformer(coord, coord.slice(), coord.length)
|
|
57
|
-
coord;
|
|
64
|
+
const wgs84 = sourceTransformer
|
|
65
|
+
? sourceTransformer(coord, coord.slice(), coord.length)
|
|
66
|
+
: coord;
|
|
58
67
|
return Cartographic.fromDegrees(wgs84[0], wgs84[1]);
|
|
59
68
|
});
|
|
60
69
|
|
|
61
|
-
const outArray = result || coordinates.map(c => c.slice());
|
|
62
|
-
return sampleTerrainMostDetailed(terrainProvider, positions)
|
|
63
|
-
|
|
70
|
+
const outArray = result || coordinates.map((c) => c.slice());
|
|
71
|
+
return sampleTerrainMostDetailed(terrainProvider, positions).then(
|
|
72
|
+
(updatedPositions) => {
|
|
64
73
|
updatedPositions.forEach((position, index) => {
|
|
65
74
|
outArray[index][2] = position.height || 0;
|
|
66
75
|
});
|
|
67
76
|
return outArray;
|
|
68
|
-
}
|
|
77
|
+
},
|
|
78
|
+
);
|
|
69
79
|
}
|
|
70
80
|
|
|
71
81
|
/**
|
|
@@ -80,8 +90,9 @@ export function isTerrainTileAvailable(terrainProvider, level, position) {
|
|
|
80
90
|
return false;
|
|
81
91
|
}
|
|
82
92
|
const tileXY = terrainProvider.tilingScheme.positionToTileXY(
|
|
83
|
-
position,
|
|
93
|
+
position,
|
|
94
|
+
level,
|
|
95
|
+
new Cartesian2(),
|
|
84
96
|
);
|
|
85
97
|
return terrainProvider.getTileDataAvailable(tileXY.x, tileXY.y, level);
|
|
86
98
|
}
|
|
87
|
-
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { parseBoolean } from '@vcsuite/parsers';
|
|
2
2
|
import Layer from './layer.js';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getHeightFromTerrainProvider,
|
|
5
|
+
getTerrainProviderForUrl,
|
|
6
|
+
} from './terrainHelpers.js';
|
|
4
7
|
import CesiumMap from '../map/cesiumMap.js';
|
|
5
8
|
import TerrainCesiumImpl from './cesium/terrainCesiumImpl.js';
|
|
6
9
|
import { layerClassRegistry } from '../classRegistry.js';
|
|
@@ -25,7 +28,9 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
25
28
|
* @api stable
|
|
26
29
|
*/
|
|
27
30
|
class TerrainLayer extends Layer {
|
|
28
|
-
static get className() {
|
|
31
|
+
static get className() {
|
|
32
|
+
return 'TerrainLayer';
|
|
33
|
+
}
|
|
29
34
|
|
|
30
35
|
/**
|
|
31
36
|
* @returns {TerrainOptions}
|
|
@@ -45,21 +50,25 @@ class TerrainLayer extends Layer {
|
|
|
45
50
|
super(options);
|
|
46
51
|
const defaultOptions = TerrainLayer.getDefaultOptions();
|
|
47
52
|
|
|
48
|
-
this._supportedMaps = [
|
|
49
|
-
CesiumMap.className,
|
|
50
|
-
];
|
|
53
|
+
this._supportedMaps = [CesiumMap.className];
|
|
51
54
|
|
|
52
55
|
/**
|
|
53
56
|
* @type {boolean}
|
|
54
57
|
* @api
|
|
55
58
|
*/
|
|
56
|
-
this.requestVertexNormals = parseBoolean(
|
|
59
|
+
this.requestVertexNormals = parseBoolean(
|
|
60
|
+
options.requestVertexNormals,
|
|
61
|
+
defaultOptions.requestVertexNormals,
|
|
62
|
+
);
|
|
57
63
|
|
|
58
64
|
/**
|
|
59
65
|
* @type {boolean}
|
|
60
66
|
* @api
|
|
61
67
|
*/
|
|
62
|
-
this.requestWaterMask = parseBoolean(
|
|
68
|
+
this.requestWaterMask = parseBoolean(
|
|
69
|
+
options.requestWaterMask,
|
|
70
|
+
defaultOptions.requestWaterMask,
|
|
71
|
+
);
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
/**
|
|
@@ -31,13 +31,18 @@ function waitForImplTilesLoaded(impl, timeout) {
|
|
|
31
31
|
* @returns {Promise<void>}
|
|
32
32
|
*/
|
|
33
33
|
export async function tiledLayerLoaded(layer, timeout) {
|
|
34
|
-
const impls =
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const impls =
|
|
35
|
+
/** @type {Array<CesiumTilesetCesiumImpl>} */
|
|
36
|
+
(
|
|
37
|
+
layer
|
|
38
|
+
.getImplementations()
|
|
39
|
+
.filter((i) => i instanceof CesiumTilesetCesiumImpl)
|
|
40
|
+
);
|
|
41
|
+
if (!layer.active || impls.every((i) => i.cesium3DTileset.tilesLoaded)) {
|
|
37
42
|
return;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
|
-
await Promise.all(impls.map(i => waitForImplTilesLoaded(i, timeout)));
|
|
45
|
+
await Promise.all(impls.map((i) => waitForImplTilesLoaded(i, timeout)));
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
/**
|
|
@@ -25,7 +25,9 @@ class MVTTileProvider extends TileProvider {
|
|
|
25
25
|
* @readonly
|
|
26
26
|
* @returns {string}
|
|
27
27
|
*/
|
|
28
|
-
static get className() {
|
|
28
|
+
static get className() {
|
|
29
|
+
return 'MVTTileProvider';
|
|
30
|
+
}
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* @returns {MVTTileProviderOptions}
|
|
@@ -95,9 +97,10 @@ class MVTTileProvider extends TileProvider {
|
|
|
95
97
|
const extent = rectangleToExtent(rectangle);
|
|
96
98
|
const center = getCenter(extent);
|
|
97
99
|
const data = await requestArrayBuffer(url);
|
|
98
|
-
const features =
|
|
100
|
+
const features =
|
|
101
|
+
/** @type {Array<import("ol").Feature<import("ol/geom/Geometry").default>>} */
|
|
99
102
|
(this._MVTFormat.readFeatures(data));
|
|
100
|
-
const sx = (
|
|
103
|
+
const sx = (extent[2] - extent[0]) / 4096;
|
|
101
104
|
const sy = -((extent[3] - extent[1]) / 4096);
|
|
102
105
|
features.forEach((feature) => {
|
|
103
106
|
const idToUse = feature.get(this.idProperty);
|
|
@@ -138,4 +141,7 @@ class MVTTileProvider extends TileProvider {
|
|
|
138
141
|
}
|
|
139
142
|
|
|
140
143
|
export default MVTTileProvider;
|
|
141
|
-
tileProviderClassRegistry.registerClass(
|
|
144
|
+
tileProviderClassRegistry.registerClass(
|
|
145
|
+
MVTTileProvider.className,
|
|
146
|
+
MVTTileProvider,
|
|
147
|
+
);
|
|
@@ -21,7 +21,9 @@ class StaticGeoJSONTileProvider extends TileProvider {
|
|
|
21
21
|
* @readonly
|
|
22
22
|
* @returns {string}
|
|
23
23
|
*/
|
|
24
|
-
static get className() {
|
|
24
|
+
static get className() {
|
|
25
|
+
return 'StaticGeoJSONTileProvider';
|
|
26
|
+
}
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* @returns {StaticGeoJSONTileProviderOptions}
|
|
@@ -48,7 +50,6 @@ class StaticGeoJSONTileProvider extends TileProvider {
|
|
|
48
50
|
this.url = options.url || defaultOptions.url;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
|
|
52
53
|
/**
|
|
53
54
|
* @inheritDoc
|
|
54
55
|
* @param {number} x
|
|
@@ -67,7 +68,9 @@ class StaticGeoJSONTileProvider extends TileProvider {
|
|
|
67
68
|
* @returns {StaticGeoJSONTileProviderOptions}
|
|
68
69
|
*/
|
|
69
70
|
toJSON() {
|
|
70
|
-
const config = /** @type {StaticGeoJSONTileProviderOptions} */ (
|
|
71
|
+
const config = /** @type {StaticGeoJSONTileProviderOptions} */ (
|
|
72
|
+
super.toJSON()
|
|
73
|
+
);
|
|
71
74
|
delete config.baseLevels;
|
|
72
75
|
|
|
73
76
|
if (this.url) {
|
|
@@ -78,4 +81,7 @@ class StaticGeoJSONTileProvider extends TileProvider {
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
export default StaticGeoJSONTileProvider;
|
|
81
|
-
tileProviderClassRegistry.registerClass(
|
|
84
|
+
tileProviderClassRegistry.registerClass(
|
|
85
|
+
StaticGeoJSONTileProvider.className,
|
|
86
|
+
StaticGeoJSONTileProvider,
|
|
87
|
+
);
|