Commit 968f0786 authored by Rushikesh Padsala's avatar Rushikesh Padsala
Browse files

Upload New File

parent a3bec392
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkNjcyOWZhYi0xZmQ0LTQyYmMtYjQ0MS1hY2YxYzcxYWFmMWEiLCJpZCI6MTEwNzEsImlhdCI6MTYzMDk5MzEyNX0.fcsH4S5hE0ye9s-2cOFMyObiHlhu9vqjWdlYfGkv5gU';
var flatterrain = new Cesium.EllipsoidTerrainProvider();
var terrainProviderViewModels = [];
terrainProviderViewModels.push(new Cesium.ProviderViewModel({
name : 'Flat',
iconUrl : Cesium.buildModuleUrl('https://w2.iaf.hft-stuttgart.de/CesiumData/Images/TerrainProviders/Ellipsoid.png'),
creationFunction : function() {
return flatterrain;
}
}));
//////////////////////////////////////////////////////////////////////////
// Creating the Viewer
//////////////////////////////////////////////////////////////////////////
var viewer = new Cesium.Viewer('cesiumContainer', {
scene3DOnly: true,
selectionIndicator: false,
timeline: false,
animation: false,
shadow: false,
// // Set default basemap
imageryProvider : new Cesium.ArcGisMapServerImageryProvider({
url : 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer',
enablePickFeatures: false
}),
baseLayerPicker: true,
terrainProviderViewModels : terrainProviderViewModels
});
viewer.clock.shouldAnimate = false;
viewer.scene.globe.enableLighting = false;
viewer.clock.startTime = Cesium.JulianDate.fromIso8601("2019-08-20T12:00:00Z");
viewer.clock.stopTime = Cesium.JulianDate.fromIso8601("2019-08-20T12:20:00Z");
viewer.clock.currentTime = Cesium.JulianDate.fromIso8601("2019-08-20T12:00:00Z");
document.getElementById("legend").style.display = "none"; //defining legends hidden by default
document.getElementById("biolegend").style.display = "none";
document.getElementById("foodlegend").style.display = "none";
//////////////////////////////////////////////////////////////////////////
// Configuring the camera
//////////////////////////////////////////////////////////////////////////
var initialPosition = Cesium.Cartesian3.fromDegrees(9.306042, 48.919172, 350);
var initialOrientation = new Cesium.HeadingPitchRoll.fromDegrees(78, -25, 0);
var homeCameraView = {
destination : initialPosition,
orientation : {
heading : initialOrientation.heading,
pitch : initialOrientation.pitch,
roll : initialOrientation.roll
}
};
// // Set the initial view
viewer.scene.camera.setView(homeCameraView);
// set home button to initial view
viewer.homeButton.viewModel.command.beforeExecute.addEventListener(function (e) {
e.cancel = true;
viewer.scene.camera.flyTo(homeCameraView);
document.getElementById("selectscenario").selectedIndex = 0;
});
viewer.camera.changed.addEventListener(function() {
var deg = Math.round( Cesium.Math.toDegrees(viewer.camera.heading))
console.log('Heading:', deg)
var deg = Math.round( Cesium.Math.toDegrees(viewer.camera.pitch))
console.log('Pitch:', deg)
var deg = Math.round( Cesium.Math.toDegrees(viewer.camera.roll))
console.log('Roll:', deg)
});
var geocoder = viewer.geocoder.viewModel;
var selectscenario = document.getElementById('selectscenario');
function setscenario() {
var selectedscenario = selectscenario.options[selectscenario.selectedIndex].value;
if (selectedscenario === 'Affalterbach') {
geocoder.searchText = "9.322672, 48.920187, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Aldingen') {
geocoder.searchText = "9.252892, 48.865336, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Asperg') {
geocoder.searchText = "9.141226, 48.905069, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Aurich') {
geocoder.searchText = "8.946047, 48.913813, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Benningen') {
geocoder.searchText = "9.240017, 48.942798, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Besigheim') {
geocoder.searchText = "9.144831, 48.998353, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Bietigheim') {
geocoder.searchText = "9.124918, 48.957679, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Bissingen') {
geocoder.searchText = "9.099340, 48.943362, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Bönnigheim') {
geocoder.searchText = "9.094191, 49.039106, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Ditzingen') {
geocoder.searchText = "9.070072, 48.826701, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Eberdingen') {
geocoder.searchText = "8.966603, 48.878687, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Ensingen') {
geocoder.searchText = "8.949866, 48.968301, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Enzweihingen') {
geocoder.searchText = "8.983641, 48.917085, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Erdmannshausen') {
geocoder.searchText = "9.297180, 48.942601, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Erligheim') {
geocoder.searchText = "9.099255, 49.019982, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Freudental') {
geocoder.searchText = "9.060030, 49.007897, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Gemmrigheim') {
geocoder.searchText = "9.157791, 49.025488, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Gerlingen') {
geocoder.searchText = "9.066982, 48.799599, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Gronau') {
geocoder.searchText = "9.339477, 49.033306, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Großbottwar') {
geocoder.searchText = "9.297867, 49.001647, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Großingersheim') {
geocoder.searchText = "9.181308, 48.961557, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Großsachsenheim') {
geocoder.searchText = "9.069214, 48.959454, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Gündelbach') {
geocoder.searchText = "8.942785, 48.993594, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Häfnerhaslach') {
geocoder.searchText = "8.919954, 49.025206, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Heimerdingen') {
geocoder.searchText = "8.981667, 48.852009, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Hemmingen') {
geocoder.searchText = "9.035182, 48.864743, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Hessigheim') {
geocoder.searchText = "9.186587, 48.995087, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Hirschlanden') {
geocoder.searchText = "9.041362, 48.836701, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Hochberg') {
geocoder.searchText = "9.282289, 48.886279, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Hochdorf(Eberdingen)') {
geocoder.searchText = "9.000077, 48.886364, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Hochdorf(Remseck)') {
geocoder.searchText = "9.296408, 48.897932, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'HofundLembach') {
geocoder.searchText = "9.313488, 49.009558, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Hofen') {
geocoder.searchText = "9.120818, 49.024661, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Hohenhaslach') {
geocoder.searchText = "9.018874, 48.999817, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Hohenstein') {
geocoder.searchText = "9.121184, 49.039500, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Höpfigheim') {
geocoder.searchText = "9.243751, 48.980555, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Horrheim') {
geocoder.searchText = "8.988061, 48.977964, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Kirchheim') {
geocoder.searchText = "9.147062, 49.039922, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Kleinbottwar') {
geocoder.searchText = "9.288812, 48.979625, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Kleinglattbach') {
geocoder.searchText = "8.969779, 48.951254, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Kleiningersheim') {
geocoder.searchText = "9.200536, 48.974995, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Kleinsachsenheim') {
geocoder.searchText = "9.071403, 48.969794, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Löchgau') {
geocoder.searchText = "9.109511, 49.001534, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Marbach') {
geocoder.searchText = "9.261646, 48.938119, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Markgrönningen') {
geocoder.searchText = "9.084578, 48.903659, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Möglingen') {
geocoder.searchText = "9.130197, 48.888762, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Mundelsheim') {
geocoder.searchText = "9.209633, 48.996945, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Murr') {
geocoder.searchText = "9.255123, 48.960609, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Neckargröningen') {
geocoder.searchText = "9.273362, 48.877361, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Neckarrems') {
geocoder.searchText = "9.279370, 48.869994, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Nussdorf') {
geocoder.searchText = "8.940296, 48.894688, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Oberriexingen') {
geocoder.searchText = "9.024110, 48.927716, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Oberstenfeld') {
geocoder.searchText = "9.322629, 49.023433, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Ochsenbach') {
geocoder.searchText = "8.983254, 49.020450, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Ottmarsheim') {
geocoder.searchText = "9.204526, 49.016510, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Pleidelsheim') {
geocoder.searchText = "9.202638, 48.958017, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Rielingshausen') {
geocoder.searchText = "9.329710, 48.960638, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Riet') {
geocoder.searchText = "8.971796, 48.893531, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Roßwag') {
geocoder.searchText = "8.914676, 48.935272, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Schöckingen') {
geocoder.searchText = "9.028401, 48.846163, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Schwieberdingen') {
geocoder.searchText = "9.076896, 48.875046, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Sersheim') {
geocoder.searchText = "9.012909, 48.957735, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Spielberg') {
geocoder.searchText = "8.999734, 49.016876, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Steinheim') {
geocoder.searchText = "9.276237, 48.967372, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Vaihingen') {
geocoder.searchText = "8.962269, 48.932932, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Walheim') {
geocoder.searchText = "9.151869, 49.011246, 700";
geocoder.flightDuration = 5;
geocoder.search();}
else if (selectedscenario === 'Winzerhausen') {
geocoder.searchText = "9.265199, 49.023704, 700";
geocoder.flightDuration = 5;
geocoder.search();}
}
selectscenario.addEventListener('change', setscenario);
//////////////////////////////////////////////////////////////////////////
// Load 3D Tileset
//////////////////////////////////////////////////////////////////////////
var building = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({url:
'https://w2.iaf.hft-stuttgart.de/CesiumData/3DTiles/Buildings/BuildingSolid/LKRLudwigsburg/tileset.json'}));
var roofsurface = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({url:
'https://w2.iaf.hft-stuttgart.de/CesiumData/3DTiles/Buildings/RoofSurface/LKRLudwigsburg/tileset.json'}));
var roofdefaultstyle = new Cesium.Cesium3DTileStyle({color : "color('#990000')"});
roofsurface.style = roofdefaultstyle;
// set roof height and load roof tile
roofsurface.readyPromise.then(function(tileset) {
height = 0.02;
viewer.scene.primitives.add(tileset);
var cartographic = Cesium.Cartographic.fromCartesian(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());
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
console.log(error);
});
roofsurface.show =true;
var landuse = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({url: 'https://w2.iaf.hft-stuttgart.de/CesiumData/3DTiles/Landuse/LKRLudwigsburg/tileset.json'}));
landuse.show = false;
function showbuildings() {
if (document.getElementById('buildings').checked) {building.show = true;
roofsurface.show = true;
}
else {building.show = false;
roofsurface.show = false;}
}
// Style landuse Tileset
var landusestyle = new Cesium.Cesium3DTileStyle({
color : {
conditions : [
["${LU_Class} === 'Settlement Area'", "color('#FFFF008C')"],
["${LU_Class} === 'Open Plot'", "color('#FFC3008C')"],
["${LU_Class} === 'Traffic Area'", "color('#8888888C')"],
["${LU_Class} === 'Vegetation'", "color('#44EE0D8C')"],
["${LU_Class} === 'Water Body'", "color('#0DC2EE8C')"],
]
},
show: true
});
var bioenergystyle = new Cesium.Cesium3DTileStyle({
color : {
conditions : [
["(${t_bionrg_p} === 0)", "color('#8000008C')"],
["(${t_bionrg_p} > 0) && (${t_bionrg_p} < 50)", "color('#FF00008C')"],
["(${t_bionrg_p} >= 50) && (${t_bionrg_p} < 150)", "color('#FFA5008C')"],
["(${t_bionrg_p} >= 150) && (${t_bionrg_p} < 350)", "color('#FFFF008C')"],
["(${t_bionrg_p} >= 350) && (${t_bionrg_p} < 650)", "color('#00FF008C')"],
["(${t_bionrg_p} >= 650)", "color('#00A3008C')"]
]
},
show: true
});
var foodpotentialstyle = new Cesium.Cesium3DTileStyle({
color : {
conditions : [
["(${t_food_p} === 0)", "color('#A110598C')"],
["(${t_food_p} > 0) && (${t_food_p} < 50000)", "color('#FF00808C')"],
["(${t_food_p} >= 50000) && (${t_food_p} < 100000)", "color('#916D808C')"],
["(${t_food_p} >= 100000) && (${t_food_p} < 200000)", "color('#00FF808C')"],
["(${t_food_p} >= 200000) && (${t_food_p} < 300000)", "color('#0089BA8C')"],
["(${t_food_p} >= 300000)", "color('#0000FF8C')"]
]
},
show: true
});
function showlanduse() {
if (document.getElementById('landuse').checked) {
landuse.show = true;
landuse.style = landusestyle;
document.getElementById("legend").style.display = "block";
document.getElementById("biolegend").style.display = "none";
document.getElementById("foodlegend").style.display = "none";
}
else {
landuse.show = false;
document.getElementById("legend").style.display = "none";
document.getElementById("biolegend").style.display = "none";
document.getElementById("foodlegend").style.display = "none";
}
}
function showbioenergypotential(){
if (document.getElementById('foodpotential').checked) {
alert("At a time either food potential analysis or bioenergy potential analysis is possible. Please uncheck one of the two analysis selection first and then re-select this option.");
return false;
}
else {
if (document.getElementById('landuse').checked) {
if (document.getElementById('bioenergypotential').checked) {
landuse.show = true;
landuse.style = bioenergystyle;
document.getElementById("biolegend").style.display = "block";
document.getElementById("foodlegend").style.display = "none";
document.getElementById("legend").style.display = "none";
}
else {
landuse.show = true;
landuse.style = landusestyle;
document.getElementById("biolegend").style.display = "none";
document.getElementById("foodlegend").style.display = "none";
document.getElementById("legend").style.display = "block";
}
}
else {
alert("Please select the landuse layer under 3D city model first, and then re-select this option.");
return false;
}
}
}
function showfoodpotential(){
if (document.getElementById('bioenergypotential').checked) {
alert("At a time either food potential analysis or bioenergy potential analysis is possible. Please uncheck one of the two analysis selection first and then re-select this option.");
return false;
}
else {
if (document.getElementById('landuse').checked) {
if (document.getElementById('foodpotential').checked) {
landuse.show = true;
landuse.style = foodpotentialstyle;
document.getElementById("biolegend").style.display = "none";
document.getElementById("foodlegend").style.display = "block";
document.getElementById("legend").style.display = "none";
}
else {
landuse.show = true;
landuse.style = landusestyle;
document.getElementById("biolegend").style.display = "none";
document.getElementById("foodlegend").style.display = "none";
document.getElementById("legend").style.display = "block";
}
}
else {
alert("Please select the landuse layer under 3D city model first, and then re-select this option.");
return false;
}
}
}
//////////////////////////////////////////////////////////////////////////
// Style 3D Tileset
//////////////////////////////////////////////////////////////////////////
var buildingdefaultstyle = new Cesium.Cesium3DTileStyle({
color : "color('WHITE')",
show: true
});
var heatenergydemandstyle = new Cesium.Cesium3DTileStyle({
color : {
conditions : [
[' Number(${Sp_Ht_Dmnd}) >= 225', "color('red')"],
[' Number(${Sp_Ht_Dmnd}) >= 125', "mix(color('yellow'), color('red'), (Number(${Sp_Ht_Dmnd}) -125) / 125)"],
[' Number(${Sp_Ht_Dmnd}) >= 1', "mix(color('green'), color('yellow'), (Number(${Sp_Ht_Dmnd}) ) / 125)"],
[' Number(${Sp_Ht_Dmnd}) < 1', "color('#ffffff1A')"],
['true', "color('#ffffff1A')"]
]
},
show: true
});
var heatdemandstyle = document.getElementById('heatdemand');
function showheatdemand() {
if (document.getElementById('pvpotential').checked) {
alert("At a time either of food demand, water demand, heating energy demand or rooftop photovoltaic potential demand analysis is possible. Please uncheck the current analysis selection first and then re-select this option.");
return false;
}
else if (document.getElementById('fooddemand').checked) {
alert("At a time either of food demand, water demand, heating energy demand or rooftop photovoltaic potential demand analysis is possible. Please uncheck the current analysis selection first and then re-select this option.");
return false;
}
else if (document.getElementById('waterdemand').checked) {
alert("At a time either of food demand, water demand, heating energy demand or rooftop photovoltaic potential demand analysis is possible. Please uncheck the current analysis selection first and then re-select this option.");
return false;
}
else
{
if (document.getElementById('buildings').checked) {
if (heatdemandstyle.checked) {
roofsurface.show = false;
building.style = heatenergydemandstyle;
document.getElementById("heat-demand-legend").style.display = "block";
}
else {
roofsurface.show = true;
building.style = buildingdefaultstyle;
roofsurface.style = roofdefaultstyle;
document.getElementById("heat-demand-legend").style.display = "none";
}
}
else {
alert("Please select the buildings layer under 3D city model first, and then re-select this option.");
return false;
}
}
}
var totalfooddemandstyle = new Cesium.Cesium3DTileStyle({
color : {
conditions : [
["(${T_Fd_Dmnd} === 0)", "color('#ffffff1A')"],
["(${T_Fd_Dmnd} > 0) && (${T_Fd_Dmnd} < 5000)", "color('#00FF80')"],
["(${T_Fd_Dmnd} >= 5000) && (${T_Fd_Dmnd} < 10000)", "color('#00C49D')"],
["(${T_Fd_Dmnd} >= 10000) && (${T_Fd_Dmnd} < 15000)", "color('#0089BA')"],
["(${T_Fd_Dmnd} >= 15000) && (${T_Fd_Dmnd} < 20000)", "color('#0062CE')"],
["(${T_Fd_Dmnd} >= 20000)", "color('#0000FF')"]
]