function SetNoiseDataWaiting(){ var resetBtn = document.getElementById("noiseStuff"); resetBtn.disabled = true; resetBtn.innerHTML = '<div id="loaderCar" class="LoaderNoise"></div>' } function setNoiseWaiting(){ // document.getElementById("infobtnNoise").classList.add('loaderN'); // console.log("arrived") // document.getElementById("infobtnNoise").classList.remove('infobtn'); // var resetBtn = document.getElementById("infobtnNoise"); // resetBtn.disabled = true; // resetBtn.innerHTML = '<div id="loaderCartest" class="loaderN"></div>' } var Sensor = { id:"49368" } function getNoiseData(sensorid) { // console.log("arrive") Sensor.id = sensorid // console.log(Sensor.id) try { $.ajax({ type: "GET", url: NoiseRealTimeUrl, data: Sensor }).done(function (newdata) { convertdata(newdata); }); function convertdata(data) { flow = data; // console.log(flow) for (var i = 0; i<= flow[0].sensordatavalues.length -1; i++){ if (flow[0].sensordatavalues[i].value_type == "noise_LAeq"){ document.getElementById("noise_laeq").innerHTML = flow[0].sensordatavalues[i].value; } else if(flow[0].sensordatavalues[i].value_type == "noise_LA_min") { document.getElementById("noise_lamin").innerHTML = flow[0].sensordatavalues[i].value; } else if(flow[0].sensordatavalues[i].value_type == "noise_LA_max") { document.getElementById("noise_lamax").innerHTML = flow[0].sensordatavalues[i].value; } } var resetBtn = document.getElementById("noiseStuff"); resetBtn.disabled = true; resetBtn.innerHTML = "<span>Get Noise Data</span>" } return flow } catch (err) { // console.log('loading Gas Values from DB failed!'); } } function noisemap(areatime){ var StreetD = false; var StreetN = false; var RailD = false; var RailN = false; var day = false; var night = false; var Air = false; var All = false; if (areatime == "offS"){ StreetD = false; StreetN = false; } else if (areatime == "offR") { RailD = false; RailN = false; } else if (areatime == "offAir"){ Air = false; } else if (areatime == "Airday"){ Air = true; day = true; night = false; } else if (areatime == "Airnight"){ Air = true; day = false; night = true; } else if (areatime == "offAll"){ All = false; } else if (areatime == "Allday"){ All = true; day = true; night = false; } else if (areatime == "Allnight"){ All = true; day = false; night = true; } else if (areatime == "Streetday") { StreetD = true; StreetN = false; RailD = false; RailN = false; day= true; night = false; } else if (areatime == "Streetnight") { StreetD = false; StreetN = true; RailD = false; RailN = false; night = true; day = false; } else if (areatime == "Railday") { StreetD = false; StreetN = false; RailD = true; RailN = false; day = true; night = false; } else if (areatime == "Railnight") { StreetD = false; StreetN = false; RailD = false; RailN = true; night = true; day = false; } var layerStreetD = ["Streetday"] var layerStreetN = ["Streetnight"] var layers = framework.getLayers(); for (var i = 0; i< layers.length; i++) { var layer = layers[i]; if(layerStreetD.indexOf(layer.name) >= 0){ layer.activate(true); } else if (layerStreetN.indexOf(layer.name) >= 0){ layer.activate(true); } } removenoisemap(); var layernameStuttgartTotal = ["Streetday"] var layernameStuttgartTotal2 = ["Streetnight"] var layerIndexStuttgartTotal if (StreetD == true || StreetN == true){ // layernameStuttgartTotal = ["Streetday"] } else if (RailD == true || RailN == true){ // layernameStuttgartTotal = ["Streetnight"] }; var frameworkSTU = vcs.vcm.Framework.getInstance(); var layersSTU = frameworkSTU.getLayers(); for (var i = 0; i< layersSTU.length; i++) { var layerst = layersSTU[i]; // console.log(i) if (day == true){ if(layernameStuttgartTotal.indexOf(layerst.name) >= 0) { layerIndexStuttgartTotal = i } } else if (night == true){ if(layernameStuttgartTotal2.indexOf(layerst.name) >= 0) { layerIndexStuttgartTotal = i } } } var layerSTU = layersSTU[layerIndexStuttgartTotal]; if(typeof layerSTU == 'undefined') { return;} var tilesetSTU = layerSTU.cesium3DTileset; var timeout = setInterval(function() { // console.log(layerSTU.active) if(layerSTU.active) { if (StreetD == true || StreetN == true){ tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["${DB_H_RD} > 80","color('#1A5784')"], ["${DB_H_RD} > 79","color('#3481B8')"], ["${DB_H_RD} > 70","color('#992572')"], ["${DB_H_RD} > 65","color('#8D1D2C')"], ["${DB_H_RD} > 60","color('#C1121C')"], ["${DB_H_RD} > 55","color('#FA842B')"], ["${DB_H_RD} > 50","color('#AF8A54')"], ["${DB_H_RD} > 45","color('#EAF044')"], ["${DB_H_RD} > 40","color('#026A52')"], ["${DB_H_RD} > 35","color('#48A43F')"], ["${DB_H_RD} <= 35","color('#B7D9B1','0')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); } else if (RailD == true || RailN == true){ tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["${DB_H_Rail} > 80","color('#1A5784')"], ["${DB_H_Rail} > 79","color('#3481B8')"], ["${DB_H_Rail} > 70","color('#992572')"], ["${DB_H_Rail} > 65","color('#8D1D2C')"], ["${DB_H_Rail} > 60","color('#C1121C')"], ["${DB_H_Rail} > 55","color('#FA842B')"], ["${DB_H_Rail} > 50","color('#AF8A54')"], ["${DB_H_Rail} > 45","color('#EAF044')"], ["${DB_H_Rail} > 40","color('#026A52')"], ["${DB_H_Rail} > 35","color('#48A43F')"], ["${DB_H_Rail} <= 35","color('#B7D9B1','0')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); } else if (Air == true){ tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["${DB_H_Air} > 80","color('#1A5784')"], ["${DB_H_Air} > 79","color('#3481B8')"], ["${DB_H_Air} > 70","color('#992572')"], ["${DB_H_Air} > 65","color('#8D1D2C')"], ["${DB_H_Air} > 60","color('#C1121C')"], ["${DB_H_Air} > 55","color('#FA842B')"], ["${DB_H_Air} > 50","color('#AF8A54')"], ["${DB_H_Air} > 45","color('#EAF044')"], ["${DB_H_Air} > 40","color('#026A52')"], ["${DB_H_Air} > 35","color('#48A43F')"], ["${DB_H_Air} <= 35","color('#B7D9B1','0')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); } else if (All == true & day == true){ tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["${DB_High_LD} > 80","color('#1A5784')"], ["${DB_High_LD} > 79","color('#3481B8')"], ["${DB_High_LD} > 70","color('#992572')"], ["${DB_High_LD} > 65","color('#8D1D2C')"], ["${DB_High_LD} > 60","color('#C1121C')"], ["${DB_High_LD} > 55","color('#FA842B')"], ["${DB_High_LD} > 50","color('#AF8A54')"], ["${DB_High_LD} > 45","color('#EAF044')"], ["${DB_High_LD} > 40","color('#026A52')"], ["${DB_High_LD} > 35","color('#48A43F')"], ["${DB_High_LD} <= 35","color('#B7D9B1','0')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); }else if (All == true & night == true){ tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["${DB_High_HN} > 80","color('#1A5784')"], ["${DB_High_HN} > 79","color('#3481B8')"], ["${DB_High_HN} > 70","color('#992572')"], ["${DB_High_HN} > 65","color('#8D1D2C')"], ["${DB_High_HN} > 60","color('#C1121C')"], ["${DB_High_HN} > 55","color('#FA842B')"], ["${DB_High_HN} > 50","color('#AF8A54')"], ["${DB_High_HN} > 45","color('#EAF044')"], ["${DB_High_HN} > 40","color('#026A52')"], ["${DB_High_HN} > 35","color('#48A43F')"], ["${DB_High_HN} <= 35","color('#B7D9B1','0')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); } // console.log("") clearInterval(timeout); } }, 1000); } function noisemap2(areatime){ if (areatime == "day"){ noisemap("Streetday") var layerIndexStuttgartTotal var layernameStuttgartTotal = ["Streetday"] var frameworkSTU = vcs.vcm.Framework.getInstance(); var layersSTU = frameworkSTU.getLayers(); for (var i = 0; i< layersSTU.length; i++) { var layerst = layersSTU[i]; if(layernameStuttgartTotal.indexOf(layerst.name) >= 0) { layerIndexStuttgartTotal = i }} var layerSTU = layersSTU[layerIndexStuttgartTotal]; var tilesetSTU = layerSTU.cesium3DTileset; var timeout = setInterval(function() { console.log(layerSTU.active) if(layerSTU.active) { console.log("") tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["${DB_High_LD} > 80","color('#1A5784')"], ["${DB_High_LD} > 79","color('#3481B8')"], ["${DB_High_LD} > 70","color('#992572')"], ["${DB_High_LD} > 65","color('#8D1D2C')"], ["${DB_High_LD} > 60","color('#C1121C')"], ["${DB_High_LD} > 55","color('#FA842B')"], ["${DB_High_LD} > 50","color('#AF8A54')"], ["${DB_High_LD} > 45","color('#EAF044')"], ["${DB_High_LD} > 40","color('#026A52')"], ["${DB_High_LD} > 35","color('#48A43F')"], ["${DB_High_LD} <= 35","color('#B7D9B1')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); clearInterval(timeout); } }, 1000); } else if (areatime == "night") { noisemap("Streetnight") var layerIndexStuttgartTotal var layernameStuttgartTotal = ["Streetnight"] var frameworkSTU = vcs.vcm.Framework.getInstance(); var layersSTU = frameworkSTU.getLayers(); for (var i = 0; i< layersSTU.length; i++) { var layerst = layersSTU[i]; if(layernameStuttgartTotal.indexOf(layerst.name) >= 0) { layerIndexStuttgartTotal = i }} var layerSTU = layersSTU[layerIndexStuttgartTotal]; var tilesetSTU = layerSTU.cesium3DTileset; var timeout = setInterval(function() { // console.log(layerSTU.active) if(layerSTU.active) { // console.log("") tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["${DB_High_HN} > 80","color('#1A5784')"], ["${DB_High_HN} > 79","color('#3481B8')"], ["${DB_High_HN} > 70","color('#992572')"], ["${DB_High_HN} > 65","color('#8D1D2C')"], ["${DB_High_HN} > 60","color('#C1121C')"], ["${DB_High_HN} > 55","color('#FA842B')"], ["${DB_High_HN} > 50","color('#AF8A54')"], ["${DB_High_HN} > 45","color('#EAF044')"], ["${DB_High_HN} > 40","color('#026A52')"], ["${DB_High_HN} > 35","color('#48A43F')"], ["${DB_High_HN} <= 35","color('#B7D9B1')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); clearInterval(timeout); } }, 1000); } else if (areatime == "off"){ noisemap("offS") } } function noisesens(status){ var layerOn = ["NoiseLocation"] var layerTwo = ["NoiseLocation53627"] var layerThree = ["NoiseLocation29212"] var layers = framework.getLayers(); for (var i = 0; i< layers.length; i++) { var layer = layers[i]; if(layerOn.indexOf(layer.name) >= 0){ if(status == "on"){ layer.activate(true); } else if (status == "off"){ layer.activate(false); } } else if(layerTwo.indexOf(layer.name) >= 0){ if(status == "on"){ layer.activate(true); } else if (status == "off"){ layer.activate(false); } } else if(layerThree.indexOf(layer.name) >= 0) { if(status == "on"){ layer.activate(true); } else if (status == "off"){ layer.activate(false); } } } } let histNoise function HistNoiseData(where, Sensor) { if (where == "Main"){ document.getElementById("chartNoiseMain").innerHTML = "<div style='width:100%;margin-top:10px;' id='chartNoise'></div>"; document.getElementById("chartNoiseExp").innerHTML = ""; } else if(where == "Exp"){ document.getElementById("chartNoiseExp").innerHTML = "<div style='width:100%;margin-top:10px;' id='chartNoise'></div>"; document.getElementById("chartNoiseMain").innerHTML = ""; } try { $.ajax({ async: true, type: "POST", url: getNoiseHistUrl, data: "", }).done(function (histwinddata) { convertdata(histwinddata); }); function convertdata(histwinddt) { histNoise = histwinddt; // console.log(histNoise[0]); showgraphNoise(); } } catch (err) { console.log('-> function gethistWind() failed!\n' + err); } } function showgraphNoise(){ var i; var noise_LA_max = 0 var noise_LA_maxnumb = 0 var noise_LA_min = 0 var noise_LAeq = 0 var datas = [] var datasMin = [] var dataseq = [] // console.log(histNoise.length) var sDay = new Date('1995-12-17T03:24:00'); for (i = 0; i < histNoise.length; i++) { // new Date(histNoise[i].timestamp) datas.push({x: new Date(histNoise[i].timestamp).getTime(), y: parseFloat(histNoise[i].noise_LA_max)}) datasMin.push({x: new Date(histNoise[i].timestamp).getTime(), y: parseFloat(histNoise[i].noise_LA_min)}) dataseq.push({x: new Date(histNoise[i].timestamp).getTime(), y: parseFloat(histNoise[i].noise_LAeq)}) // console.log(histNoise[i].timestamp) // console.log(new Date(histNoise[i].timestamp)) // if (sameDay(sDay,new Date(histNoise[i].timestamp))){ // noise_LA_max = noise_LA_max + parseFloat(histNoise[i].noise_LA_max) // noise_LA_min = noise_LA_min + parseFloat(histNoise[i].noise_LA_min) // noise_LAeq = noise_LAeq + parseFloat(histNoise[i].noise_LAeq) // noise_LA_maxnumb = noise_LA_maxnumb + 1 // // console.log(noise_LA_maxnumb) // } else if (noise_LA_maxnumb != 0){ // var valuestuff = noise_LA_max / noise_LA_maxnumb // var valuemin = noise_LA_min / noise_LA_maxnumb // var valueeq = noise_LAeq / noise_LA_maxnumb // console.log(sDay.getFullYear() +"-"+(parseInt(sDay.getMonth()) + 1 )+"-"+sDay.getHours()) // datas.push({x: new Date(sDay).getTime(), y: parseFloat(valuestuff.toFixed(2))}) // datasMin.push({x: new Date(sDay).getTime(), y: parseFloat(valuemin.toFixed(2))}) // dataseq.push({x: new Date(sDay).getTime(), y: parseFloat(valueeq.toFixed(2))}) // noise_LA_max = 0 // noise_LA_min = 0 // noise_LAeq = 0 // noise_LA_maxnumb = 0 // } // sDay = new Date(histNoise[i].timestamp) } // console.log(dataseq) // console.log("--------") console.log([{ x: new Date('2018-02-12').getTime(), y: 76 }, { x: new Date('2018-02-12').getTime(), y: 76 }]) var options = { chart: { type: "area", height: 300, foreColor: "#999", stacked: false, dropShadow: { enabled: true, enabledSeries: [0], top: -2, left: 2, blur: 5, opacity: 0.06 } }, colors: ['#7F0000','#00E396', '#0090FF'], stroke: { curve: "smooth", width: 3 }, dataLabels: { enabled: false }, series: [{ name: 'Noise_LA_max', data: datas }, { name: 'Noise_LAeq', data: dataseq }, { name: 'Noise_LA_min', data: datasMin }], markers: { size: 0, strokeColor: "#fff", strokeWidth: 3, strokeOpacity: 1, fillOpacity: 1, hover: { size: 6 } }, xaxis: { type: "datetime", labels: { datetimeUTC: false }, axisBorder: { show: false }, axisTicks: { show: false } }, yaxis: { labels: { offsetX: 14, offsetY: -5 }, tooltip: { enabled: true } }, grid: { padding: { left: -5, right: 5 } }, tooltip: { x: { format: "dd MMM yyyy" }, }, legend: { position: 'top', horizontalAlign: 'left' }, fill: { type: 'gradient', gradient: { shadeIntensity: 1, inverseColors: false, opacityFrom: 0.5, opacityTo: 0, stops: [0, 90, 100] }, } }; document.getElementById("chartNoise").innerHTML = ""; var chart = new ApexCharts(document.querySelector("#chartNoise"), options); // document.getElementById("infobtnNoise").classList.add('infobtn'); // document.getElementById("infobtnNoise").classList.remove('loaderN'); // console.log("end") chart.render(); } function sameDay(d1, d2) { // console.log(d1.getFullYear() + " // " + d1.getMonth() + " // " + d1.getDate() + " // " + d1.getHours()) // console.log(d2.getFullYear() + " // " + d2.getMonth() + " // " + d2.getDate() + " // " + d2.getHours()) return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate() && d1.getHours() === d2.getHours(); } function buildingSeeThrough(set){ var frameworkSTU = vcs.vcm.Framework.getInstance(); var layersSTU = frameworkSTU.getLayers(); var layerIndexStuttgartTotal var layernameStuttgartTotal = ["StuttgartLocal"] var layernameStuttgartTotal2 = ["StuttgartPart"] for (var i = 0; i< layersSTU.length; i++) { var layerst = layersSTU[i]; if (set == true){ if(layernameStuttgartTotal.indexOf(layerst.name) >= 0) { layerIndexStuttgartTotal = i } } else if (set == false){ if(layernameStuttgartTotal2.indexOf(layerst.name) >= 0) { layerIndexStuttgartTotal = i } } } var layerSTU = layersSTU[layerIndexStuttgartTotal]; if(typeof layerSTU == 'undefined') { return;} var tilesetSTU = layerSTU.cesium3DTileset; var timeout = setInterval(function() { // console.log(layerSTU.active) if(layerSTU.active) { if (set == true ){ tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["true","color('white','0.5')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); } else if (set == false){ tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["true","color('white','0.5')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); } } // console.log("") clearInterval(timeout); }, 1000); } function buildingSeeThroughfalse(set){ var frameworkSTU = vcs.vcm.Framework.getInstance(); var layersSTU = frameworkSTU.getLayers(); var layerIndexStuttgartTotal var layernameStuttgartTotal = ["StuttgartLocal"] var layernameStuttgartTotal2 = ["StuttgartPart"] for (var i = 0; i< layersSTU.length; i++) { var layerst = layersSTU[i]; if (set == true){ if(layernameStuttgartTotal.indexOf(layerst.name) >= 0) { layerIndexStuttgartTotal = i } } else if (set == false){ if(layernameStuttgartTotal2.indexOf(layerst.name) >= 0) { layerIndexStuttgartTotal = i } } } var layerSTU = layersSTU[layerIndexStuttgartTotal]; if(typeof layerSTU == 'undefined') { return;} var tilesetSTU = layerSTU.cesium3DTileset; var timeout = setInterval(function() { // console.log(layerSTU.active) if(layerSTU.active) { if (set == true ){ tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["true","color('white')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); } else if (set == false){ tilesetSTU.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["true","color('white')"]//, //["${DB_High_LD} === 35","color('#B7D9B1','1')"]//, // ["true", "color('#FFFFFF')"], ], }, }); } } // console.log("") removebuildings(); clearInterval(timeout); }, 1000); } // ---------------------------------------------------------------------------------- // Select Noise Sensor var menu = document.getElementById("sensors"); menu.addEventListener("change", generateData); function generateData(event) { if (menu.value == 'Sens') { } else if (menu.value == '49368') { getSTAHistNoise(); setNoiseWaiting(); HistNoiseData('Exp','49368') } else if (menu.value == '53627') { alert("noch nicht verfügbar"); } else if (menu.value == '29212'){ alert("noch nicht verfügbar"); } }