@masterportal/masterportalapi 2.2.0 → 2.5.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/.eslintignore +0 -1
- package/.eslintrc +4 -1
- package/CHANGELOG.md +49 -4
- package/example/config/localGeoJSON.js +24 -24
- package/example/config/portal.json +1 -1
- package/example/config/services.json +190 -1
- package/example/index.js +65 -67
- package/package.json +18 -17
- package/src/defaults.js +18 -2
- package/src/index.js +4 -0
- package/src/layer/entities.js +179 -0
- package/src/layer/geojson/index.js +7 -0
- package/src/layer/geojson/style.js +1 -0
- package/src/layer/terrain.js +1 -8
- package/src/layer/tileset.js +1 -8
- package/src/layer/vectorTile.js +3 -3
- package/src/layer/wms.js +4 -0
- package/src/layer/wmts.js +194 -0
- package/src/maps/ol/olMap.js +2 -0
- package/src/maps/olcs/3dUtils/wmsRasterSynchronizer.js +88 -52
- package/src/maps/olcs/olcsMap.js +115 -99
- package/test/layer/entities.test.js +277 -0
- package/test/layer/terrain.test.js +1 -14
- package/test/layer/tileset.test.js +3 -10
- package/test/layer/vectorTile.test.js +2 -2
- package/test/layer/wmts.test.js +26 -0
- package/test/map.test.js +34 -1
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import olLayerGroup from "ol/layer/Group.js";
|
|
5
5
|
import {getUid} from "olcs/util.js";
|
|
6
6
|
import TileWMS from "ol/source/TileWMS.js";
|
|
7
|
+
import ImageWMS from "ol/source/ImageWMS.js";
|
|
8
|
+
import WMTS from "ol/source/WMTS.js";
|
|
7
9
|
import olcsAbstractSynchronizer from "olcs/AbstractSynchronizer.js";
|
|
8
10
|
import olcsCore from "olcs/core.js";
|
|
9
11
|
import {Tile, Image as ImageLayer} from "ol/layer.js";
|
|
@@ -40,7 +42,6 @@ class WMSRasterSynchronizer extends olcsAbstractSynchronizer {
|
|
|
40
42
|
* @type {!Cesium.ImageryLayerCollection}
|
|
41
43
|
* @private
|
|
42
44
|
*/
|
|
43
|
-
/* eslint-disable no-undef */
|
|
44
45
|
this.ourLayers = new Cesium.ImageryLayerCollection();
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -87,17 +88,17 @@ class WMSRasterSynchronizer extends olcsAbstractSynchronizer {
|
|
|
87
88
|
* May be overriden by child classes to implement custom behavior.
|
|
88
89
|
* The default implementation handles tiled imageries in EPSG:4326 or
|
|
89
90
|
* EPSG:3859.
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
92
|
-
* @return {?Array.<!Cesium.ImageryLayer>}
|
|
91
|
+
* @param {module:ol/layer/Base~BaseLayer } olLayer The raster layer.
|
|
92
|
+
* @param {module:ol/proj} viewProj Projection of the view.
|
|
93
|
+
* @return {?Array.<!Cesium.ImageryLayer>} Array or null if not possible.
|
|
93
94
|
* (or supported)
|
|
94
95
|
* @protected
|
|
95
96
|
*/
|
|
96
97
|
convertLayerToCesiumImageries (olLayer, viewProj) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
const layerOptions = {
|
|
99
|
+
"show": false
|
|
100
|
+
};
|
|
101
|
+
let source = {},
|
|
101
102
|
cesiumLayer = {},
|
|
102
103
|
provider = null;
|
|
103
104
|
|
|
@@ -108,61 +109,98 @@ class WMSRasterSynchronizer extends olcsAbstractSynchronizer {
|
|
|
108
109
|
source = olLayer.getSource();
|
|
109
110
|
|
|
110
111
|
if (source instanceof TileWMS) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
"layers": params.LAYERS,
|
|
116
|
-
"show": false
|
|
117
|
-
},
|
|
118
|
-
tileGrid = source.getTileGrid();
|
|
119
|
-
|
|
120
|
-
if (tileGrid) {
|
|
121
|
-
const ext = olLayer.getExtent();
|
|
122
|
-
|
|
123
|
-
if (ext && viewProj) {
|
|
124
|
-
options.rectangle = olcsCore.extentToRectangle(ext, viewProj);
|
|
125
|
-
const minMax = this.getMinMaxLevelFromTileGrid(tileGrid, ext, viewProj);
|
|
126
|
-
|
|
127
|
-
options.tileWidth = tileGrid.getTileSize(0)[0];
|
|
128
|
-
options.tileHeight = tileGrid.getTileSize(0)[1];
|
|
129
|
-
options.minimumLevel = minMax[0];
|
|
130
|
-
options.maximumLevel = minMax[1];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/* eslint-disable no-undef */
|
|
134
|
-
provider = new Cesium.WebMapServiceImageryProvider(options);
|
|
112
|
+
provider = this.createProviderForTileWMS(source, viewProj, olLayer);
|
|
113
|
+
}
|
|
114
|
+
else if (source instanceof ImageWMS) {
|
|
115
|
+
return [this.createImageryLayerForImageWMS(olLayer, viewProj)];
|
|
135
116
|
}
|
|
136
117
|
else if (source instanceof StaticImageSource) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
118
|
+
provider = this.createProviderForStaticImageSource(source);
|
|
119
|
+
}
|
|
120
|
+
else if (source instanceof WMTS) {
|
|
121
|
+
provider = new Cesium.WebMapTileServiceImageryProvider({
|
|
122
|
+
url: source.getUrls()[0],
|
|
123
|
+
format: source.getFormat(),
|
|
124
|
+
layer: source.getLayer(),
|
|
125
|
+
style: source.getStyle(),
|
|
126
|
+
tileMatrixSetID: source.getMatrixSet(),
|
|
127
|
+
tileMatrixLabels: source.getTileGrid().getMatrixIds(),
|
|
128
|
+
credit: source.getAttributions()
|
|
129
|
+
});
|
|
150
130
|
}
|
|
151
131
|
else {
|
|
152
132
|
console.warn("Sources other than TileImage are currently not supported.");
|
|
153
133
|
return null;
|
|
154
134
|
}
|
|
155
135
|
|
|
156
|
-
// the provider is always non-null if we got this far
|
|
157
|
-
layerOptions = {
|
|
158
|
-
"show": false
|
|
159
|
-
};
|
|
160
|
-
/* eslint-disable no-undef */
|
|
161
136
|
cesiumLayer = new Cesium.ImageryLayer(provider, layerOptions);
|
|
162
137
|
|
|
163
138
|
return cesiumLayer ? [cesiumLayer] : null;
|
|
164
139
|
}
|
|
165
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Creates an Cesium.WebMapServiceImageryProvider for RasterLayer of the type TileWMS.
|
|
143
|
+
* @param {module:ol/source/TileWMS} source The raster layer source.
|
|
144
|
+
* @param {module:ol/proj} viewProj Projection of the view.
|
|
145
|
+
* @param {module:ol/layer/Base~BaseLayer } olLayer The raster layer.
|
|
146
|
+
* @returns {WebMapServiceImageryProvider} The imagery provider.
|
|
147
|
+
*/
|
|
148
|
+
createProviderForTileWMS (source, viewProj, olLayer) {
|
|
149
|
+
const params = source.getParams(),
|
|
150
|
+
options = {
|
|
151
|
+
"url": source.getUrls()[0],
|
|
152
|
+
"parameters": params,
|
|
153
|
+
"layers": params.LAYERS,
|
|
154
|
+
"show": false
|
|
155
|
+
},
|
|
156
|
+
tileGrid = source.getTileGrid();
|
|
157
|
+
|
|
158
|
+
if (tileGrid) {
|
|
159
|
+
const ext = olLayer.getExtent();
|
|
160
|
+
|
|
161
|
+
if (ext && viewProj) {
|
|
162
|
+
options.rectangle = olcsCore.extentToRectangle(ext, viewProj);
|
|
163
|
+
const minMax = this.getMinMaxLevelFromTileGrid(tileGrid, ext, viewProj);
|
|
164
|
+
|
|
165
|
+
options.tileWidth = tileGrid.getTileSize(0)[0];
|
|
166
|
+
options.tileHeight = tileGrid.getTileSize(0)[1];
|
|
167
|
+
options.minimumLevel = minMax[0];
|
|
168
|
+
options.maximumLevel = minMax[1];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return new Cesium.WebMapServiceImageryProvider(options);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Creates an Cesium.ImageryLayer for RasterLayer of the type ImageWMS.
|
|
177
|
+
* @param {module:ol/layer/Base~BaseLayer } olLayer The raster layer.
|
|
178
|
+
* @param {module:ol/proj} viewProj Projection of the view.
|
|
179
|
+
* @returns {Cesium.ImageryLayer} The imagery layer.
|
|
180
|
+
*/
|
|
181
|
+
createImageryLayerForImageWMS (olLayer, viewProj) {
|
|
182
|
+
return olcsCore.tileLayerToImageryLayer(this.map, olLayer, viewProj);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Creates an Cesium.SingleTileImageryProvider for RasterLayer of the type StaticImageSource.
|
|
187
|
+
* @param {module:ol/source/ImageStatic} source The raster layer source.
|
|
188
|
+
* @returns {SingleTileImageryProvider} The imagery provider.
|
|
189
|
+
*/
|
|
190
|
+
createProviderForStaticImageSource (source) {
|
|
191
|
+
const extent = source.getImageExtent(),
|
|
192
|
+
options = {
|
|
193
|
+
"url": source.getUrl(),
|
|
194
|
+
"show": false
|
|
195
|
+
},
|
|
196
|
+
bottomLeftCorner = proj4(source.getProjection().getCode(), "EPSG:4326", getBottomLeft(extent)),
|
|
197
|
+
topRightCorner = proj4(source.getProjection().getCode(), "EPSG:4326", getTopRight(extent));
|
|
198
|
+
|
|
199
|
+
options.rectangle = Cesium.Rectangle.fromDegrees(bottomLeftCorner[0], bottomLeftCorner[1], topRightCorner[0], topRightCorner[1]);
|
|
200
|
+
|
|
201
|
+
return new Cesium.SingleTileImageryProvider(options);
|
|
202
|
+
}
|
|
203
|
+
|
|
166
204
|
/**
|
|
167
205
|
*
|
|
168
206
|
* @param {ol.Extent} extent -
|
|
@@ -179,7 +217,6 @@ class WMSRasterSynchronizer extends olcsAbstractSynchronizer {
|
|
|
179
217
|
getTopLeft(wgs84Extent)
|
|
180
218
|
];
|
|
181
219
|
|
|
182
|
-
/* eslint-disable no-undef */
|
|
183
220
|
return olCoords.map(coord => Cesium.Cartographic.fromDegrees(coord[0], coord[1]));
|
|
184
221
|
}
|
|
185
222
|
/**
|
|
@@ -201,7 +238,6 @@ class WMSRasterSynchronizer extends olcsAbstractSynchronizer {
|
|
|
201
238
|
distanceLocalX = Math.abs(tileCoordsLocal[0][1] - tileCoordsLocal[1][1]),
|
|
202
239
|
distanceLocalY = Math.abs(tileCoordsLocal[0][2] - tileCoordsLocal[3][2]),
|
|
203
240
|
extentCoords = this.getExtentPoints(extent, projection),
|
|
204
|
-
/* eslint-disable no-undef */
|
|
205
241
|
tilingScheme = new Cesium.GeographicTilingScheme({});
|
|
206
242
|
let minLevel = 0,
|
|
207
243
|
maxLevel = 20;
|
package/src/maps/olcs/olcsMap.js
CHANGED
|
@@ -1,42 +1,35 @@
|
|
|
1
1
|
import OLCesium from "olcs/OLCesium.js";
|
|
2
|
+
import {transform, get} from "ol/proj.js";
|
|
2
3
|
import VectorSynchronizer from "olcs/VectorSynchronizer.js";
|
|
4
|
+
|
|
3
5
|
import FixedOverlaySynchronizer from "./3dUtils/fixedOverlaySynchronizer.js";
|
|
4
6
|
import WMSRasterSynchronizer from "./3dUtils/wmsRasterSynchronizer.js";
|
|
5
|
-
import
|
|
7
|
+
import defaults from "../../defaults";
|
|
6
8
|
|
|
7
9
|
let mapIdCounter = 0;
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
|
-
* Sets the cesium scene
|
|
11
|
-
* @param {Cesium.scene} scene
|
|
12
|
-
* @param {Object}
|
|
12
|
+
* Sets the cesium default scene params.
|
|
13
|
+
* @param {Cesium.scene} scene The cesium scene.
|
|
14
|
+
* @param {Object} params Optional configuration parameters.
|
|
13
15
|
* @returns {void}
|
|
14
16
|
*/
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
export function setCesiumSceneParams (scene, params) {
|
|
18
|
+
Object.keys(params).forEach(paramKey => {
|
|
19
|
+
const paramValue = params[paramKey];
|
|
20
|
+
|
|
21
|
+
if (typeof paramValue === "object") {
|
|
22
|
+
Object.keys(paramValue).forEach(paramSubKey => {
|
|
23
|
+
if (paramSubKey !== "heading" && paramSubKey !== "tilt" && paramSubKey !== "altitude") {
|
|
24
|
+
scene[paramKey][paramSubKey] = paramValue[paramSubKey];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
scene.shadowMap.darkness = 0.6;
|
|
30
|
-
scene.shadowMap.size = 2048;
|
|
31
|
-
scene.fxaa = params?.fxaa ? params.fxaa : scene.fxaa;
|
|
32
|
-
scene.globe.enableLighting = params?.enableLighting ? params.enableLighting : scene.globe.enableLighting;
|
|
33
|
-
scene.globe.depthTestAgainstTerrain = true;
|
|
34
|
-
scene.highDynamicRange = false;
|
|
35
|
-
scene.pickTranslucentDepth = true;
|
|
36
|
-
scene.camera.enableTerrainAdjustmentWhenLoading = true;
|
|
37
|
-
}
|
|
28
|
+
else {
|
|
29
|
+
scene[paramKey] = paramValue;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
38
32
|
}
|
|
39
|
-
|
|
40
33
|
/**
|
|
41
34
|
* Sets the camera parameters either from config or from an trigger.
|
|
42
35
|
* @param {Object} params Params.
|
|
@@ -47,37 +40,91 @@ function setCesiumSceneDefaults (scene, config) {
|
|
|
47
40
|
export function setCameraParameter (params, map3D, cesium) {
|
|
48
41
|
let camera,
|
|
49
42
|
destination,
|
|
50
|
-
orientation
|
|
51
|
-
|
|
52
|
-
// if the cameraPosition is given, directly set the cesium camera position, otherwise use olcesium Camera
|
|
53
|
-
if (map3D && params.cameraPosition) {
|
|
54
|
-
camera = map3D.getCesiumScene().camera;
|
|
55
|
-
destination = cesium.Cartesian3.fromDegrees(params.cameraPosition[0], params.cameraPosition[1], params.cameraPosition[2]);
|
|
56
|
-
orientation = {
|
|
57
|
-
heading: cesium.Math.toRadians(parseFloat(params.heading)),
|
|
58
|
-
pitch: cesium.Math.toRadians(parseFloat(params.pitch)),
|
|
59
|
-
roll: cesium.Math.toRadians(parseFloat(params.roll))
|
|
60
|
-
};
|
|
43
|
+
orientation,
|
|
44
|
+
heading;
|
|
61
45
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
else if (map3D !== undefined && params !== null) {
|
|
68
|
-
camera = map3D.getCamera();
|
|
69
|
-
if (params?.tilt) {
|
|
70
|
-
camera.setTilt(parseFloat(params.tilt));
|
|
46
|
+
if (params && map3D) {
|
|
47
|
+
if (typeof params.heading !== "undefined") {
|
|
48
|
+
heading = parseFloat(params.heading);
|
|
71
49
|
}
|
|
72
|
-
if (params?.heading) {
|
|
73
|
-
|
|
50
|
+
else if (typeof params.camera?.heading !== "undefined") {
|
|
51
|
+
heading = parseFloat(params.camera?.heading);
|
|
74
52
|
}
|
|
75
|
-
if
|
|
76
|
-
|
|
53
|
+
// if the cameraPosition is given, directly set the cesium camera position, otherwise use olcesium Camera
|
|
54
|
+
if (params.cameraPosition) {
|
|
55
|
+
camera = map3D.getCesiumScene().camera;
|
|
56
|
+
destination = cesium.Cartesian3.fromDegrees(params.cameraPosition[0], params.cameraPosition[1], params.cameraPosition[2]);
|
|
57
|
+
orientation = {
|
|
58
|
+
heading: cesium.Math.toRadians(heading),
|
|
59
|
+
pitch: cesium.Math.toRadians(parseFloat(params.pitch)),
|
|
60
|
+
roll: cesium.Math.toRadians(parseFloat(params.roll))
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
camera.setView({
|
|
64
|
+
destination,
|
|
65
|
+
orientation
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
let tilt,
|
|
70
|
+
altitude;
|
|
71
|
+
|
|
72
|
+
if (typeof params.tilt !== "undefined") {
|
|
73
|
+
tilt = parseFloat(params.tilt);
|
|
74
|
+
}
|
|
75
|
+
else if (typeof params.camera?.tilt !== "undefined") {
|
|
76
|
+
tilt = parseFloat(params.camera?.tilt);
|
|
77
|
+
}
|
|
78
|
+
if (typeof params.altitude !== "undefined") {
|
|
79
|
+
altitude = parseFloat(params.altitude);
|
|
80
|
+
}
|
|
81
|
+
else if (typeof params.camera?.altitude !== "undefined") {
|
|
82
|
+
altitude = parseFloat(params.camera?.altitude);
|
|
83
|
+
}
|
|
84
|
+
camera = map3D.getCamera();
|
|
85
|
+
|
|
86
|
+
if (tilt) {
|
|
87
|
+
camera.setTilt(tilt);
|
|
88
|
+
}
|
|
89
|
+
if (heading) {
|
|
90
|
+
camera.setHeading(heading);
|
|
91
|
+
}
|
|
92
|
+
if (altitude) {
|
|
93
|
+
camera.setAltitude(altitude);
|
|
94
|
+
}
|
|
77
95
|
}
|
|
78
96
|
}
|
|
79
97
|
}
|
|
80
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Creates a 3D-map.
|
|
101
|
+
* @param {object} [settings] The settings for the 3D-map.
|
|
102
|
+
* @param {module:ol/PluggableMap~PluggableMap} [settings.map2D] The 2D-Map
|
|
103
|
+
* @param {Cesium.JulianDate} [settings.shadowTime] The shadow time in julian date format if undefined olcs default is Cesium.JulianDate.now().
|
|
104
|
+
* @returns {module:OLCesium} the 3d-map
|
|
105
|
+
*/
|
|
106
|
+
export function createMap (settings) {
|
|
107
|
+
const map3D = new OLCesium({
|
|
108
|
+
map: settings.map2D,
|
|
109
|
+
time: settings?.shadowTime,
|
|
110
|
+
stopOpenLayersEventsPropagation: true,
|
|
111
|
+
createSynchronizers: (olMap, scene) => {
|
|
112
|
+
return [new WMSRasterSynchronizer(olMap, scene), new VectorSynchronizer(olMap, scene), new FixedOverlaySynchronizer(olMap, scene)];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
map3D.id = `map3D_${mapIdCounter++}`;
|
|
117
|
+
map3D.mapMode = "3D";
|
|
118
|
+
|
|
119
|
+
setCesiumSceneParams(map3D.getCesiumScene(), defaults.sceneOptions);
|
|
120
|
+
if (settings?.cesiumParameter) {
|
|
121
|
+
setCesiumSceneParams(map3D.getCesiumScene(), settings.cesiumParameter);
|
|
122
|
+
setCameraParameter(settings.cesiumParameter, map3D, Cesium);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return map3D;
|
|
126
|
+
}
|
|
127
|
+
|
|
81
128
|
/**
|
|
82
129
|
* Reacts to 3D click event in cesium scene.
|
|
83
130
|
* @param {Event} event The cesium event.
|
|
@@ -104,22 +151,29 @@ function reactTo3DClickEvent (event) {
|
|
|
104
151
|
document.querySelector(".nav li").classList.remove("open");
|
|
105
152
|
}
|
|
106
153
|
cartographic = scene.globe.ellipsoid.cartesianToCartographic(cartesian);
|
|
107
|
-
coords = [
|
|
154
|
+
coords = [Cesium.Math.toDegrees(cartographic.longitude), Cesium.Math.toDegrees(cartographic.latitude)];
|
|
108
155
|
height = scene.globe.getHeight(cartographic);
|
|
109
156
|
if (height) {
|
|
110
157
|
coords = coords.concat([height]);
|
|
111
158
|
}
|
|
112
159
|
|
|
113
|
-
distance =
|
|
160
|
+
distance = Cesium.Cartesian3.distance(cartesian, scene.camera.position);
|
|
114
161
|
resolution = this.map3D.getCamera().calcResolutionForDistance(distance, cartographic.latitude);
|
|
115
162
|
transformedCoords = transform(coords, get("EPSG:4326"), mapProjection);
|
|
116
163
|
transformedPickedPosition = null;
|
|
117
164
|
|
|
118
165
|
if (scene.pickPositionSupported) {
|
|
166
|
+
const pickedObject = scene.pick(event.position);
|
|
167
|
+
|
|
119
168
|
pickedPositionCartesian = scene.pickPosition(event.position);
|
|
169
|
+
|
|
170
|
+
if (!pickedPositionCartesian && pickedObject?.primitive instanceof window.Cesium.Billboard) {
|
|
171
|
+
pickedPositionCartesian = pickedObject.primitive?.position;
|
|
172
|
+
}
|
|
173
|
+
|
|
120
174
|
if (pickedPositionCartesian) {
|
|
121
175
|
cartographicPickedPosition = scene.globe.ellipsoid.cartesianToCartographic(pickedPositionCartesian);
|
|
122
|
-
transformedPickedPosition = transform([
|
|
176
|
+
transformedPickedPosition = transform([Cesium.Math.toDegrees(cartographicPickedPosition.longitude), Cesium.Math.toDegrees(cartographicPickedPosition.latitude)], get("EPSG:4326"), mapProjection);
|
|
123
177
|
transformedPickedPosition.push(cartographicPickedPosition.height);
|
|
124
178
|
}
|
|
125
179
|
}
|
|
@@ -142,51 +196,23 @@ function reactTo3DClickEvent (event) {
|
|
|
142
196
|
* @param {Object} map3DObject Contains the scene, 3D map and a callback function.
|
|
143
197
|
* @returns {void}
|
|
144
198
|
*/
|
|
145
|
-
function handle3DEvents (map3DObject) {
|
|
199
|
+
export function handle3DEvents (map3DObject) {
|
|
146
200
|
let eventHandler;
|
|
147
201
|
|
|
148
|
-
if (
|
|
149
|
-
eventHandler = new
|
|
150
|
-
eventHandler.setInputAction(reactTo3DClickEvent.bind(map3DObject),
|
|
202
|
+
if (Cesium) {
|
|
203
|
+
eventHandler = new Cesium.ScreenSpaceEventHandler(map3DObject.scene.canvas);
|
|
204
|
+
eventHandler.setInputAction(reactTo3DClickEvent.bind(map3DObject), Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
151
205
|
}
|
|
152
206
|
}
|
|
153
207
|
|
|
154
|
-
/**
|
|
155
|
-
* Creates a 3D-map.
|
|
156
|
-
* @param {object} [settings] The settings for the 3D-map.
|
|
157
|
-
* @param {module:ol/PluggableMap~PluggableMap} [settings.map2D] The 2D-Map
|
|
158
|
-
* @param {Cesium.JulianDate} [settings.shadowTime] The shadow time in julian date format if undefined olcs default is Cesium.JulianDate.now().
|
|
159
|
-
* @returns {module:OLCesium} the 3d-map
|
|
160
|
-
*/
|
|
161
|
-
export function createMap (settings) {
|
|
162
|
-
const map3D = new OLCesium({
|
|
163
|
-
map: settings.map2D,
|
|
164
|
-
time: settings.shadowTime ? settings.shadowTime : undefined,
|
|
165
|
-
sceneOptions: {
|
|
166
|
-
shadows: false
|
|
167
|
-
},
|
|
168
|
-
stopOpenLayersEventsPropagation: true,
|
|
169
|
-
createSynchronizers: (olMap, scene) => {
|
|
170
|
-
return [new WMSRasterSynchronizer(olMap, scene), new VectorSynchronizer(olMap, scene), new FixedOverlaySynchronizer(olMap, scene)];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
map3D.id = `map3D_${mapIdCounter++}`;
|
|
175
|
-
map3D.mapMode = "3D";
|
|
176
|
-
|
|
177
|
-
return map3D;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
208
|
/**
|
|
181
209
|
* Prepares the camera and listens to camera changed events.
|
|
182
210
|
* @param {Cesium.scene} scene Cesium scene.
|
|
183
211
|
* @param {Object} urlParams optional urlParams for camera.
|
|
184
|
-
* @param {Object} map3D olcs map.
|
|
185
212
|
* @param {Object} config optional configuration parameters.
|
|
186
|
-
* @param {Cesium} cesium optional cesium.
|
|
187
213
|
* @returns {Cesium.scene.camera} Cesium camera.
|
|
188
214
|
*/
|
|
189
|
-
export function prepareCamera (scene, urlParams,
|
|
215
|
+
export function prepareCamera (scene, urlParams, config) {
|
|
190
216
|
const camera = scene.camera;
|
|
191
217
|
let cameraParameter = Object.prototype.hasOwnProperty.call(config, "cameraParameter") ? config.cameraParameter : {};
|
|
192
218
|
|
|
@@ -195,18 +221,8 @@ export function prepareCamera (scene, urlParams, map3D, config, cesium) {
|
|
|
195
221
|
cameraParameter = urlParams?.tilt ? Object.assign(cameraParameter || {}, {tilt: urlParams?.tilt}) : cameraParameter;
|
|
196
222
|
|
|
197
223
|
if (Object.keys(cameraParameter).length > 0) {
|
|
198
|
-
|
|
224
|
+
setCesiumSceneParams(scene, {camera: cameraParameter});
|
|
199
225
|
}
|
|
200
|
-
return camera;
|
|
201
|
-
}
|
|
202
226
|
|
|
203
|
-
|
|
204
|
-
* Prepares the cesium scene.
|
|
205
|
-
* @param {Object} map3DObject Contains the scene, 3D map and a callback function.
|
|
206
|
-
* @param {Object} config optional configuration parameters.
|
|
207
|
-
* @returns {void}
|
|
208
|
-
*/
|
|
209
|
-
export function prepareScene (map3DObject, config) {
|
|
210
|
-
handle3DEvents(map3DObject);
|
|
211
|
-
setCesiumSceneDefaults(map3DObject.scene, config);
|
|
227
|
+
return camera;
|
|
212
228
|
}
|