@masterportal/masterportalapi 2.1.1 → 2.4.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.
@@ -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 {transform, get} from "ol/proj.js";
7
+ import defaults from "../../defaults";
6
8
 
7
9
  let mapIdCounter = 0;
8
10
 
9
11
  /**
10
- * Sets the cesium scene defaults from the config.js
11
- * @param {Cesium.scene} scene Cesium scene.
12
- * @param {Object} config optional configuration parameters.
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 setCesiumSceneDefaults (scene, config) {
16
- let params;
17
-
18
- if (Object.prototype.hasOwnProperty.call(config, "cesiumParameter")) {
19
- params = config.cesiumParameter;
20
- if (params?.fog) {
21
- scene.fog.enabled = params.fog?.enabled ? params.fog.enabled : scene.fog.enabled;
22
- scene.fog.density = params.fog?.density ? parseFloat(params.fog.density) : scene.fog.density;
23
- scene.fog.screenSpaceErrorFactor = params.fog?.screenSpaceErrorFactor ? parseFloat(params.fog.screenSpaceErrorFactor) : scene.fog.screenSpaceErrorFactor;
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
- scene.globe.tileCacheSize = params?.tileCacheSize ? parseInt(params.tileCacheSize, 10) : scene.globe.tileCacheSize;
27
- scene.globe.maximumScreenSpaceError = params?.maximumScreenSpaceError ? params.maximumScreenSpaceError : scene.globe.maximumScreenSpaceError;
28
- scene.shadowMap.maximumDistance = 5000.0;
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
- camera.setView({
63
- destination,
64
- orientation
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
- camera.setHeading(parseFloat(params.heading));
50
+ else if (typeof params.camera?.heading !== "undefined") {
51
+ heading = parseFloat(params.camera?.heading);
74
52
  }
75
- if (params?.altitude) {
76
- camera.setAltitude(parseFloat(params.altitude));
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 = [window.Cesium.Math.toDegrees(cartographic.longitude), window.Cesium.Math.toDegrees(cartographic.latitude)];
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 = window.Cesium.Cartesian3.distance(cartesian, scene.camera.position);
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([window.Cesium.Math.toDegrees(cartographicPickedPosition.longitude), window.Cesium.Math.toDegrees(cartographicPickedPosition.latitude)], get("EPSG:4326"), mapProjection);
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 (window.Cesium) {
149
- eventHandler = new window.Cesium.ScreenSpaceEventHandler(map3DObject.scene.canvas);
150
- eventHandler.setInputAction(reactTo3DClickEvent.bind(map3DObject), window.Cesium.ScreenSpaceEventType.LEFT_CLICK);
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, map3D, config, cesium) {
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
- setCameraParameter(cameraParameter, map3D, cesium);
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
  }
@@ -0,0 +1,277 @@
1
+ import * as entities from "../../src/layer/entities";
2
+
3
+ describe("entities.js", function () {
4
+ let attr,
5
+ map,
6
+ dataSources = [],
7
+ dataSourcesContent,
8
+ dataSourceValues,
9
+ cesiumCustomDataSourceSpy,
10
+ cesiumHeadingPitchRollSpy,
11
+ tick;
12
+
13
+ beforeEach(() => {
14
+ tick = () => {
15
+ return new Promise(resolve => {
16
+ setTimeout(resolve, 0);
17
+ });
18
+ };
19
+ dataSourcesContent = {};
20
+ dataSourceValues = [];
21
+ global.Cesium = {};
22
+ global.Cesium.Cartesian3 = {};
23
+ global.Cesium.Transforms = {};
24
+ global.Cesium.Cartesian3.fromDegrees = jest.fn();
25
+ global.Cesium.HeadingPitchRoll = jest.fn();
26
+ global.Cesium.Transforms.headingPitchRollQuaternion = jest.fn();
27
+ global.Cesium.CustomDataSource = function CustomDataSource (name) {
28
+ this.name = name;
29
+ this.entities = {
30
+ values: dataSourceValues,
31
+ add: (toAdd) => {
32
+ dataSourceValues.push(toAdd);
33
+ this.length++;
34
+ return toAdd;
35
+ },
36
+ contains: (value) => dataSourceValues.includes(value)
37
+ };
38
+ this.length = 0;
39
+ this.forEach = () => dataSourceValues.forEach;
40
+ };
41
+ attr = {
42
+ id: "4003",
43
+ name: "EntitiesLayer",
44
+ typ: "Entities3D",
45
+ entities: [
46
+ {
47
+ "url": "https://daten-hamburg.de/gdi3d/datasource-data/Simple_Building.glb",
48
+ "attributes": {
49
+ "name": "einfaches Haus in Planten und Blomen"
50
+ },
51
+ "latitude": 53.5631,
52
+ "longitude": 9.9800,
53
+ "height": 16,
54
+ "heading": 0,
55
+ "pitch": 0,
56
+ "roll": 0,
57
+ "scale": 5,
58
+ "allowPicking": true,
59
+ "show": true
60
+ }
61
+ ]
62
+ };
63
+ dataSources = {
64
+ getByName: (name) => {
65
+ return dataSourcesContent[name] ? [dataSourcesContent[name]] : [];
66
+ },
67
+ add: async (dataSource) => {
68
+ dataSourcesContent[dataSource.name] = dataSource;
69
+ return Promise.resolve(dataSource).then(function (value) {
70
+ return value;
71
+ });
72
+ }
73
+ };
74
+ map = {
75
+ getDataSources: () => {
76
+ return dataSources;
77
+ }
78
+ };
79
+ cesiumCustomDataSourceSpy = jest.spyOn(global.Cesium, "CustomDataSource");
80
+ cesiumHeadingPitchRollSpy = jest.spyOn(global.Cesium.Transforms, "headingPitchRollQuaternion");
81
+ });
82
+
83
+ afterEach(() => {
84
+ global.Cesium = null;
85
+ jest.clearAllMocks();
86
+ });
87
+
88
+ function checkAttributes (layer, attrs) {
89
+ expect(layer.get("name")).toEqual(attrs.name);
90
+ expect(layer.get("typ")).toEqual(attrs.typ);
91
+ expect(layer.get("id")).toEqual(attrs.id);
92
+ }
93
+
94
+ describe("createLayer", function () {
95
+ it("creates a wrapper for terrain layer without map", function () {
96
+ const layer = entities.createLayer(attr);
97
+
98
+ checkAttributes(layer, attr);
99
+ });
100
+ it("creates a wrapper for entities layer with map and show is false", async function () {
101
+ attr.entities[0].show = false;
102
+ const layer = entities.createLayer(attr, map);
103
+
104
+ await tick();
105
+
106
+ checkAttributes(layer, attr);
107
+ expect(dataSourceValues.length).toEqual(1);
108
+ expect(dataSourceValues[0].show).toEqual(false);
109
+ expect(Object.keys(dataSourcesContent).length).toEqual(1);
110
+ expect(cesiumCustomDataSourceSpy).toHaveBeenCalledTimes(1);
111
+ expect(cesiumHeadingPitchRollSpy).toHaveBeenCalledTimes(1);
112
+ });
113
+ it("creates a wrapper for terrain layer with map and show not set", async function () {
114
+ attr.entities[0].show = undefined;
115
+ const layer = entities.createLayer(attr, map);
116
+
117
+ await tick();
118
+
119
+ checkAttributes(layer, attr);
120
+ expect(dataSourceValues.length).toEqual(1);
121
+ expect(dataSourceValues[0].show).toEqual(false);
122
+ expect(Object.keys(dataSourcesContent).length).toEqual(1);
123
+ expect(cesiumCustomDataSourceSpy).toHaveBeenCalledTimes(1);
124
+ expect(cesiumHeadingPitchRollSpy).toHaveBeenCalledTimes(1);
125
+ });
126
+ it("creates a wrapper for terrain layer with map and show is true", async function () {
127
+ attr.entities[0].show = true;
128
+ const layer = entities.createLayer(attr, map);
129
+
130
+ await tick();
131
+
132
+ checkAttributes(layer, attr);
133
+ expect(dataSourceValues.length).toEqual(1);
134
+ expect(dataSourceValues[0].show).toEqual(true);
135
+ expect(Object.keys(dataSourcesContent).length).toEqual(1);
136
+ expect(cesiumCustomDataSourceSpy).toHaveBeenCalledTimes(1);
137
+ expect(cesiumHeadingPitchRollSpy).toHaveBeenCalledTimes(1);
138
+ });
139
+ });
140
+ describe("setVisible", function () {
141
+ let consoleWarnOrig;
142
+
143
+ beforeEach(() => {
144
+ consoleWarnOrig = console.warn;
145
+ console.warn = jest.fn();
146
+ });
147
+
148
+ afterEach(() => {
149
+ console.warn = consoleWarnOrig;
150
+ });
151
+
152
+ it("call setVisible without map shall not fail and shall do nothing", async function () {
153
+ attr.isSelected = false;
154
+ attr.entities[0].show = false;
155
+ const layer = entities.createLayer(attr, map);
156
+
157
+ entities.setVisible(true, attr);
158
+
159
+ await tick();
160
+
161
+ checkAttributes(layer, attr);
162
+ expect(dataSourceValues.length).toEqual(1);
163
+ expect(dataSourceValues[0].show).toEqual(false);
164
+ });
165
+ it("call setVisible without map and rawLayer shall not fail and shall do nothing", async function () {
166
+ attr.isSelected = false;
167
+ attr.entities[0].show = false;
168
+ const layer = entities.createLayer(attr, map);
169
+
170
+ entities.setVisible(true, null);
171
+
172
+ await tick();
173
+
174
+ checkAttributes(layer, attr);
175
+ expect(dataSourceValues.length).toEqual(1);
176
+ expect(dataSourceValues[0].show).toEqual(false);
177
+ });
178
+ it("call setVisible shall set show to true", async function () {
179
+ attr.isSelected = false;
180
+ attr.entities[0].show = false;
181
+ const layer = entities.createLayer(attr, map);
182
+
183
+ await tick();
184
+
185
+ expect(dataSourceValues[0].show).toEqual(false);
186
+
187
+ layer.setVisible(true, attr, map);
188
+
189
+ checkAttributes(layer, attr);
190
+ expect(dataSourceValues.length).toEqual(1);
191
+ expect(dataSourcesContent[attr.id].show).toEqual(true);
192
+ });
193
+ it("call setVisible shall only warn, if no dataSource found", async function () {
194
+ attr.isSelected = false;
195
+ attr.entities[0].show = false;
196
+ const layer = entities.createLayer(attr, map);
197
+
198
+ await tick();
199
+
200
+ checkAttributes(layer, attr);
201
+
202
+ attr.id = "notExist";
203
+ entities.setVisible(true, attr, map);
204
+
205
+ expect(dataSourceValues.length).toEqual(1);
206
+ expect(dataSourcesContent[attr.id]).toEqual(undefined);
207
+ expect(console.warn).toHaveBeenCalledTimes(1);
208
+ });
209
+ });
210
+ describe("get", function () {
211
+ it("calls get for attributes", async function () {
212
+ const layer = entities.createLayer(attr, map);
213
+
214
+ checkAttributes(layer, attr);
215
+ expect(layer.get(null)).toEqual(undefined);
216
+ expect(layer.get(undefined)).toEqual(undefined);
217
+ expect(layer.get("")).toEqual(undefined);
218
+ });
219
+ });
220
+ describe("addEntities", function () {
221
+ let consoleWarnOrig;
222
+
223
+ beforeEach(() => {
224
+ consoleWarnOrig = console.warn;
225
+ console.warn = jest.fn();
226
+ });
227
+
228
+ afterEach(() => {
229
+ console.warn = consoleWarnOrig;
230
+ });
231
+
232
+ it("addEntities without map shall not fail", async function () {
233
+ const layer = entities.createLayer(attr, map);
234
+
235
+ await tick();
236
+ layer.createDataSource(attr);
237
+ });
238
+ it("addEntities without rawLayer shall not fail", async function () {
239
+ const layer = entities.createLayer(attr, map);
240
+
241
+ await tick();
242
+ layer.createDataSource(null, map);
243
+ expect(console.warn).toHaveBeenCalledTimes(1);
244
+ });
245
+
246
+ it("addEntities shall add entity twice", async function () {
247
+ attr.entities[0].show = false;
248
+ const layer = entities.createLayer(attr, map);
249
+
250
+ await tick();
251
+
252
+ checkAttributes(layer, attr);
253
+ expect(dataSourceValues.length).toEqual(1);
254
+
255
+ layer.createDataSource(attr, map);
256
+ expect(dataSourceValues.length).toEqual(2);
257
+ expect(dataSourceValues[0].show).toEqual(false);
258
+ expect(dataSourceValues[1].show).toEqual(false);
259
+ });
260
+ it("addEntities shall add entity and set Visible", async function () {
261
+ attr.entities[0].show = true;
262
+ const layer = entities.createLayer(attr, map);
263
+
264
+ await tick();
265
+
266
+ checkAttributes(layer, attr);
267
+ expect(dataSourceValues.length).toEqual(1);
268
+ expect(dataSourceValues[0].show).toEqual(true);
269
+
270
+ layer.createDataSource(attr, map);
271
+ expect(dataSourceValues.length).toEqual(2);
272
+ expect(dataSourceValues[0].show).toEqual(true);
273
+ expect(dataSourceValues[1].show).toEqual(true);
274
+ });
275
+ });
276
+ });
277
+
@@ -36,25 +36,12 @@ describe("terrain.js", function () {
36
36
  }
37
37
 
38
38
  describe("createLayer", function () {
39
- it("creates a wrapper for terrain layer without map and not selected", function () {
40
- const layer = terrain.createLayer(attr);
41
-
42
- checkAttributes(layer, attr);
43
- });
44
- it("creates a wrapper for terrain layer with map and not selected", function () {
45
- attr.isSelected = false;
39
+ it("creates a wrapper for terrain layer with map", function () {
46
40
  const layer = terrain.createLayer(attr, map);
47
41
 
48
42
  checkAttributes(layer, attr);
49
43
  expect(cesiumTerrainProviderSpy).toHaveBeenCalledTimes(0);
50
44
  });
51
- it("creates a wrapper for terrain layer with map and selected", function () {
52
- attr.isSelected = true;
53
- const layer = terrain.createLayer(attr, map);
54
-
55
- checkAttributes(layer, attr);
56
- expect(cesiumTerrainProviderSpy).toHaveBeenCalledTimes(1);
57
- });
58
45
  });
59
46
  describe("setVisible", function () {
60
47
  it("calls setVisible without map shall not fail", function () {
@@ -45,22 +45,15 @@ describe("tileset.js", function () {
45
45
  }
46
46
 
47
47
  describe("createLayer", function () {
48
- it("creates tileset layer without map and not selected", function () {
48
+ it("creates tileset layer without map", function () {
49
49
  const layer = new Tileset(attr);
50
50
 
51
51
  checkAttributes(layer, attr);
52
52
  expect(layer.tileSet).toEqual(undefined);
53
+ expect(layer.tileset.show).toEqual(undefined);
53
54
  expect(cesium3DTilesetSpy).toHaveBeenCalledTimes(1);
54
55
  });
55
- it("creates tileset layer with map and selected", function () {
56
- attr.isSelected = true;
57
- const layer = new Tileset(attr, map);
58
-
59
- checkAttributes(layer, attr);
60
- expect(layer.tileset.show).toEqual(true);
61
- expect(cesium3DTilesetSpy).toHaveBeenCalledTimes(1);
62
- });
63
- it("creates 2 tileset layers with map and selected and checks attributes", function () {
56
+ it("creates 2 tileset layers with map and checks attributes", function () {
64
57
  const attr2 = {
65
58
  id: "4003",
66
59
  name: "name",