Testgebiete.js 14.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

// specifiy credentials and assets from Cesium ION account
Cesium.Ion.defaultAccessToken =
	"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiYjY5ZTAxNy03YTc0LTQyZTYtYjJlMC0xYzYwNTAzNDQ0ZjUiLCJpZCI6MjkwNCwiaWF0IjoxNjM1NDEzOTI0fQ.Xhmt0sD4Dda4Q46FBYew4wPbqlJ4T8U9n1nNNwGyH7o";

// setting up Cesium Viewer
var viewer = new Cesium.Viewer("cesiumContainer", {
	imageryProvider: new Cesium.IonImageryProvider({ assetId: 3 }), //3 bing maps with labels // use Sentinel2 imagery as default assetID:3954
	/////////////////////////////////////////
	// Note the next 3 lines specify that the Cesium Terrain should be used. ION account is needed
	// For a 'flat' Earth the z-offsets below for each of the tilesets needs to be adjusted
	// comment the next 3 lines to remove the Cesium terrain (Resulution approx. 30m)
	/////////////////////////////////////////
	terrainProvider: new Cesium.CesiumTerrainProvider({
		url: Cesium.IonResource.fromAssetId(1),
	}),
});


// set home button extend
// this is the HFT 
// var extent = Cesium.Rectangle.fromDegrees(9.162794728779428, 48.78605872069245, 9.181827683763427, 48.77616123564855);
var extent = Cesium.Rectangle.fromDegrees(9.29859441939518, 48.814434070664696, 9.30346531111649, 48.813176496066895);
Cesium.Camera.DEFAULT_VIEW_RECTANGLE = extent;
Cesium.Camera.DEFAULT_VIEW_FACTOR = 0;

viewer.scene.globe.enableLighting = true; // set lighting to true

// load 3d Tile set of HFT from Cesium ION.
30
31
32
33
34
// var tileset = viewer.scene.primitives.add(
// 	new Cesium.Cesium3DTileset({
// 		url: Cesium.IonResource.fromAssetId(656401),
// 	})
// );
35

36
37
38
39
40
41
var HFT_Tileset_LOD1 = viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
      url: "buildingTiles/HFTbuildingsLOD1/tileset.json",
      show: true,
    })
  );
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

//   var HFT_testbld = viewer.scene.primitives.add(
// 	new Cesium.Cesium3DTileset({
// 	  url: Cesium.IonResource.fromAssetId(905706),
// 	})
//   );
  
var HFT_testbld = viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
      url: "buildingTiles/HFT_testbld/tileset.json",
      show: true,
    })
  );


  HFT_testbld.readyPromise.then(function (HFT_testbld) {
	var height =55;
	var cartographic = Cesium.Cartographic.fromCartesian(
		HFT_testbld.boundingSphere.center
	);
	var surface = Cesium.Cartesian3.fromRadians(
		cartographic.longitude,
		cartographic.latitude,
		0.0
	);
	var offset = Cesium.Cartesian3.fromRadians(
		cartographic.longitude,
		cartographic.latitude,
		height
	);
	var translation = Cesium.Cartesian3.subtract(
		offset,
		surface,
		new Cesium.Cartesian3()
	);
	// now shift / translate the tileset by the translation vector defined above
	HFT_testbld.modelMatrix = Cesium.Matrix4.fromTranslation(translation);

	return zoomAll(HFT_testbld); // zoom or rather go to the translated tileset
});


84
85
	
	var load3DTiles = function () {
86
		tilesetLOD3 = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
87
88
89
90
91
			url: "https://steinbeis-3dps.eu/3DGeoVolumes/collections/Stuttgart/HFTBuildings_3DModel_noTexture/3dtiles/tileset.json", //Cesium.IonResource.fromAssetId(656401),
		}));
	
		
	
92
93
94
		Cesium.when(tilesetLOD3.readyPromise).then(function (tilesetLOD3) {
			viewer.flyTo(tilesetLOD3)
			tilesetLOD3.style = new Cesium.Cesium3DTileStyle({
95
96
97
98
99
100
101
102
103
104
105
				color: {
					conditions: [
						["${featureType} === 'Window'", "color('blue')"],
						["${featureType} === 'WallSurface'", "color('gray')"],
						["${featureType} === 'RoofSurface'", "color('red')"],
						["${featureType} === 'OuterFloorSurface'", "color('white')"],
						["true", "color('white')"],
					],
				},
				show: true
			});
106
			// tilesetLOD3.style = new Cesium.Cesium3DTileStyle({
107
108
109
110
			//     color: "color('BLACK', 0.3)",
			//     show: true
			// });
	
111
112
			var heightOffset = 49.0;
			var boundingSphere = tilesetLOD3.boundingSphere;
113
114
115
116
			var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
			var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
			var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, heightOffset);
			var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
117
			tilesetLOD3.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
118
119
120
121
122
123
124
125
126
127
		})
	
	}
	load3DTiles()



	

	//////// important value. to find the correct value trail and error is needed for a perfect fit
128
	const BUILDIG_TILESET_HEIGHT_OFFSET = 50;
129
	
130
	HFT_Tileset_LOD1.readyPromise.then(function (HFT_Tileset_LOD1) {
131
132
		var height = BUILDIG_TILESET_HEIGHT_OFFSET;
		var cartographic = Cesium.Cartographic.fromCartesian(
133
			HFT_Tileset_LOD1.boundingSphere.center
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
		);
		var surface = Cesium.Cartesian3.fromRadians(
			cartographic.longitude,
			cartographic.latitude,
			0.0
		);
		var offset = Cesium.Cartesian3.fromRadians(
			cartographic.longitude,
			cartographic.latitude,
			height
		);
		var translation = Cesium.Cartesian3.subtract(
			offset,
			surface,
			new Cesium.Cartesian3()
		);
		// now shift / translate the tileset by the translation vector defined above
151
		HFT_Tileset_LOD1.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
152

153
		// return zoomAll(HFT_Tileset_LOD1); // zoom or rather go to the translated tileset
154
155
	});

156
157
158
159
160
161
162
163
	HFT_Tileset_LOD1.show = false;


//////////////////////////////////////////////////////////////////////////////////////

var BHT_Tileset = viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
      url: "buildingTiles/BHT/tileset.json",
164
	//   url: "https://inspirer-pcs.pointcloudai.de/api/pointCloudData/DltFXCFL6cNTr6x/3dtiles/tileset.json",
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
      show: true,
    })
  );


  BHT_Tileset.readyPromise.then(function (HFBHT_Tileset_testbld) {
	var height =44;
	var cartographic = Cesium.Cartographic.fromCartesian(
		BHT_Tileset.boundingSphere.center
	);
	var surface = Cesium.Cartesian3.fromRadians(
		cartographic.longitude,
		cartographic.latitude,
		0.0
	);
	var offset = Cesium.Cartesian3.fromRadians(
		cartographic.longitude,
		cartographic.latitude,
		height
	);
	var translation = Cesium.Cartesian3.subtract(
		offset,
		surface,
		new Cesium.Cartesian3()
	);
	// now shift / translate the tileset by the translation vector defined above
	BHT_Tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);

	return zoomAll(BHT_Tileset); // zoom or rather go to the translated tileset
});
195
196


197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// Beuth HS PointCloud Tileset. Erstellt von PCT, virtuelle Befliegung (Sim)
////////////////////////////////////////////////////////////////////////////////////

var BHT_PC = viewer.scene.primitives.add(
	new Cesium.Cesium3DTileset({
		url: Cesium.IonResource.fromAssetId(1112349),
		show: false,
	})
);

BHT_PC.style = new Cesium.Cesium3DTileStyle({
	// color: "color('blue',0.3)",
	// color: "color('red')" ,
	pointSize: 2
});

////////////////////////////////////////////////


218
219
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
220
// HFT PointCloud Tileset. Von Eberhard Guelch, nur monochrome
221
222
////////////////////////////////////////////////////////////////////////////////////

223
// const PCOFFSET = 0;
224

225
226
227
228
229
230
// var hftLargePC = viewer.scene.primitives.add(
// 	new Cesium.Cesium3DTileset({
// 		url: Cesium.IonResource.fromAssetId(655879),  //
// 		show: false,
// 	})
// );
231

232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
// hftLargePC.readyPromise.then(function (hftLargePC) {
// 	var height = PCOFFSET;
// 	var cartographic = Cesium.Cartographic.fromCartesian(
// 		hftLargePC.boundingSphere.center
// 	);
// 	var surface = Cesium.Cartesian3.fromRadians(
// 		cartographic.longitude,
// 		cartographic.latitude,
// 		0.0
// 	);
// 	var offset = Cesium.Cartesian3.fromRadians(
// 		cartographic.longitude,
// 		cartographic.latitude,
// 		height
// 	);
// 	var translation = Cesium.Cartesian3.subtract(
// 		offset,
// 		surface,
// 		new Cesium.Cartesian3()
// 	);
// 	// now shift / translate the tileset by the translation vector defined above
// 	hftLargePC.modelMatrix = Cesium.Matrix4.fromTranslation(translation);

// 	// return zoomAll(hftLargePC); // zoom or rather go to the translated tileset
// });

// hftLargePC.style = new Cesium.Cesium3DTileStyle({
// 	color: "color('blue',0.3)",
// 	// color: "color('red')" ,
// 	pointSize: 3
// });




///////////////////////////// HFT Bau 1-3 Innenhof und Bau 1-3 aus RGB Point cloud
268
269
270

var hftInnehofRGB_PC = viewer.scene.primitives.add(
	new Cesium.Cesium3DTileset({
271
		url: Cesium.IonResource.fromAssetId(1109983),  //656854  small point cloud only inner courtyard
272
273
274
275
276
277
	})
);

hftInnehofRGB_PC.style = new Cesium.Cesium3DTileStyle({
	// color: "color('blue',0.3)",	
	// color: "color('red')" ,
278
	pointSize: 2
279
280
281
282
283
284
});



////////////////////////// Control Pointclouds and Tileset with switches

285
286
287
288
289
290
291
292
293
294
var toggleBHTpointcloud = function () {
	if (BHT_PC.show === true) {
		BHT_PC.show = false
	}
	else {
		BHT_PC.show = true
	}
}


295
296
297
298
299
300
301
302
303
304
305
306
307
308
var toggleLargePC = function () {
	if (hftLargePC.show === true) {
		hftLargePC.show = false
	}
	else {
		hftLargePC.show = true
	}
}
// or use tenrary operator as for the other two 
var toggleRGBPC = function () {
	hftInnehofRGB_PC.show = hftInnehofRGB_PC.show ? false : true;
}

var toggleBuildingTiles = function () {
309
310
	if (HFT_Tileset_LOD1.show === true) {
		HFT_Tileset_LOD1.show = false
311
312
	}
	else {
313
		HFT_Tileset_LOD1.show = true	
314
		if (tilesetLOD3.show === true){
315
			$('#prettyBuildingsCheckbox').prop('checked', false);
316
			tilesetLOD3.show = false
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
		}						
	}
}

var toggleFellbachTiles = function () {
	if (fellbachBuildings.show === true) {
		fellbachBuildings.show = false
	}
	else {
		fellbachBuildings.show = true;
		if (fellbachBuildingsTextured.show === true){
			$('#FellbachTexturedBuildingsCheckbox').prop('checked', false);
			fellbachBuildingsTextured.show = false;
		}							
	}
}


var toggleFellbachTexturedTiles = function () {
	if (fellbachBuildingsTextured.show === true) {
		fellbachBuildingsTextured.show = false
	}
	else {
		fellbachBuildingsTextured.show = true;	
		if (fellbachBuildings.show === true){
			$('#FellbachBuildingsCheckbox').prop('checked', false);
			fellbachBuildings.show = false;
		}					
	}
}

var togglePrettyBuildingTiles = function () {
349
350
351
	// tilesetLOD3.show = tilesetLOD3.show ? false : true;
	if (tilesetLOD3.show === true) {
		tilesetLOD3.show = false		
352
353
	}
	else {
354
		tilesetLOD3.show = true				
355
		if (HFT_Tileset_LOD1.show === true){
356
			$('#simpleBuildingsCheckbox').prop('checked', false);
357
			HFT_Tileset_LOD1.show = false
358
359
360
361
362
363
364
365
366
		}
	}
	// $('#prettyBuildingsCheckbox').prop('checked', true); // Checks it
//$('#myCheckbox').prop('checked', false); // Unchecks it
}




367
368
369
370
371
372
373
374
375
var toggleBHT_BuildingTiles = function () {
	if (BHT_Tileset.show === true) {
		BHT_Tileset.show = false
	}
	else {
		BHT_Tileset.show = true;				
	}
}

376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
////////////////////////////////////////////////////
	// Fellbach building tiles
	fellbachBuildings = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
		url: "https://3dps.gis.lrg.tum.de/geovolumes/collections/Fellbach/all_buildings_lod2/3dtiles/",
		// url: "https://3dps.gis.lrg.tum.de/geovolumes/collections/Fellbach/all_buildings_lod2_textured/3dtiles/tileset.json?bbox=9.27193208236,48.8200709939,-10,9.2900117958,48.8164019664,500",
		show: true,
	}));

	fellbachBuildings.readyPromise.then(function (fellbachBuildings) {
		var height = 51;
		var cartographic = Cesium.Cartographic.fromCartesian(
			fellbachBuildings.boundingSphere.center
		);
		var surface = Cesium.Cartesian3.fromRadians(
			cartographic.longitude,
			cartographic.latitude,
			0.0
		);
		var offset = Cesium.Cartesian3.fromRadians(
			cartographic.longitude,
			cartographic.latitude,
			height
		);
		var translation = Cesium.Cartesian3.subtract(
			offset,
			surface,
			new Cesium.Cartesian3()
		);
		// now shift / translate the tileset by the translation vector defined above
		fellbachBuildings.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
		return zoomAll(fellbachBuildings);

		
	});


	fellbachBuildings.show = false;
	////////////////////////////////////////////////////
	// Fellbach building tiles
	fellbachBuildingsTextured = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({		
		url: "https://3dps.gis.lrg.tum.de/geovolumes/collections/Fellbach/all_buildings_lod2_textured/3dtiles/tileset.json?bbox=9.27193208236,48.8200709939,-10,9.2900117958,48.8164019664,500",
		show: true,
	}));

	fellbachBuildingsTextured.readyPromise.then(function (fellbachBuildingsTextured) {
		var height = 51;
		var cartographic = Cesium.Cartographic.fromCartesian(
			fellbachBuildingsTextured.boundingSphere.center
		);
		var surface = Cesium.Cartesian3.fromRadians(
			cartographic.longitude,
			cartographic.latitude,
			0.0
		);
		var offset = Cesium.Cartesian3.fromRadians(
			cartographic.longitude,
			cartographic.latitude,
			height
		);
		var translation = Cesium.Cartesian3.subtract(
			offset,
			surface,
			new Cesium.Cartesian3()
		);
		// now shift / translate the tileset by the translation vector defined above
		fellbachBuildingsTextured.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
		return zoomAll(fellbachBuildingsTextured);

		
	});


448
449
450
451
452
453
454
455
456
457
458
459
460
461

	
	var gotoBHT = function () {
		

		var extent = Cesium.Rectangle.fromDegrees(13.3438353562,52.5410017572,13.3610358270,52.5474834537);
		Cesium.Camera.DEFAULT_VIEW_RECTANGLE = extent;
		Cesium.Camera.DEFAULT_VIEW_FACTOR = 0;

		viewer.flyTo(BHT_Tileset);


		
	}  
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495

	var gotoFellbach = function () {

		// var extent = Cesium.Rectangle.fromDegrees(9.26530042893943,48.818436808301705, 9.275552393133086,  48.81387520377022);
		// Cesium.Camera.DEFAULT_VIEW_RECTANGLE = extent;
		// Cesium.Camera.DEFAULT_VIEW_FACTOR = 0;


		viewer.camera.flyTo({
			destination : Cesium.Cartesian3.fromDegrees(9.269968312784966, 48.815644351028965, 600.0),
			orientation : {
				heading : Cesium.Math.toRadians(-30.0),
				pitch : Cesium.Math.toRadians(-45),
				roll : 0
			}
		});
		new Cesium.HeadingPitchRange(0, -0.5, 400)
		
		// viewer.camera.viewBoundingSphere(Cesium.Cartesian3.fromDegrees(9.26530042893943,48.818436808301705, 1500.0),		);
		// viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

		// viewer.canera.setView({
		// 	destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0)
		// });
		// zoomAll(fellbachBuildings);
		// viewer.scene.camera.lookAt(fellbachBuildings.position.getValue(viewer.clock.currentTime), new Cesium.Cartesian3(0,0,200));
	}

	var gotoHFT = function () {

		var extent = Cesium.Rectangle.fromDegrees(9.29859441939518, 48.814434070664696, 9.30346531111649, 48.813176496066895);
		Cesium.Camera.DEFAULT_VIEW_RECTANGLE = extent;
		Cesium.Camera.DEFAULT_VIEW_FACTOR = 0;

496
		viewer.flyTo(tilesetLOD3);
497
498
499
500


		
	}