Commit 4d223fc2 authored by BujarMuharemi's avatar BujarMuharemi
Browse files

finished issue#89 show pvPotentialData of surface

parent a0a1c873
...@@ -19,6 +19,8 @@ var roofTypeSortPick ...@@ -19,6 +19,8 @@ var roofTypeSortPick
var uValueSortPick var uValueSortPick
var shadowdata var shadowdata
var pvPotentialSurfaces; //array which holds the pvpotential of all surfaces
async function fetchPvPotentialJSON() { async function fetchPvPotentialJSON() {
var bottomLat = coordinatesBB[1] var bottomLat = coordinatesBB[1]
...@@ -127,17 +129,17 @@ async function getLocalShadowdata() { ...@@ -127,17 +129,17 @@ async function getLocalShadowdata() {
const response = await fetch(localShadowData); const response = await fetch(localShadowData);
//the response have to be converted to json type file, so it can be used //the response have to be converted to json type file, so it can be used
const data = await response.json(); const data = await response.json();
console.log(data) //console.log(data)
return data; return data;
} }
async function processData() { async function processData() {
console.log(coordinatesBB)
console.log("Waiting for data....") console.log("Waiting for data....")
shadowdata = await getLocalShadowdata() shadowdata = await getLocalShadowdata()
timeout(25000, getLocalShadowdata()).then((response) => { timeout(25000, getLocalShadowdata()).then((response) => {
console.log(response) //console.log(response)
shadowdata = response; shadowdata = response;
}).catch((error) => { //catching the error(no connection)/ timeout and displaying an alert for the user }).catch((error) => { //catching the error(no connection)/ timeout and displaying an alert for the user
console.log(shadowdata); console.log(shadowdata);
...@@ -146,7 +148,8 @@ async function processData() { ...@@ -146,7 +148,8 @@ async function processData() {
timeout(10000, fetchPvPotentialJSON()).then((response) => { timeout(10000, fetchPvPotentialJSON()).then((response) => {
//console.log("fetchPvPotentialJSON:", response); //console.log("fetchPvPotentialJSON:", response);
getPvPotentialOfSurfaces(response["buildings"]); pvPotentialSurfaces = getPvPotentialOfSurfaces(response["buildings"]);
//console.log("pvPotentialSurfaces:",pvPotentialSurfaces);
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}) })
...@@ -165,7 +168,7 @@ async function processData() { ...@@ -165,7 +168,7 @@ async function processData() {
function calculateData(data) { function calculateData(data) {
console.log(data); //console.log(data);
document.getElementById("cesiumContainer").style.opacity = "1"; document.getElementById("cesiumContainer").style.opacity = "1";
document.getElementById("loader").style.visibility = "hidden" document.getElementById("loader").style.visibility = "hidden"
console.log("....received data") console.log("....received data")
...@@ -404,6 +407,7 @@ function timeout(ms, promise) { ...@@ -404,6 +407,7 @@ function timeout(ms, promise) {
}) })
} }
//getting the pvPotential of all surfaces from the pvPotential array, which the api returns
function getPvPotentialOfSurfaces(pvPotentialarray){ function getPvPotentialOfSurfaces(pvPotentialarray){
var pvPotentialArray=[]; var pvPotentialArray=[];
...@@ -415,7 +419,8 @@ function getPvPotentialOfSurfaces(pvPotentialarray){ ...@@ -415,7 +419,8 @@ function getPvPotentialOfSurfaces(pvPotentialarray){
) )
) )
); );
console.log(pvPotentialArray); //console.log(pvPotentialArray);
return pvPotentialArray;
} }
......
...@@ -199,7 +199,9 @@ var pickHeatedVolume ...@@ -199,7 +199,9 @@ var pickHeatedVolume
var pickTotalSurfaceArea = 0 var pickTotalSurfaceArea = 0
var pickRoofType var pickRoofType
var pickUValue var pickUValue
var shadowHourValue = 0; var shadowHourValue = 0;
var SurfacePvPotential=[];
//Color a feature on selection and show metadata in the InfoBox //Color a feature on selection and show metadata in the InfoBox
...@@ -286,7 +288,8 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) { ...@@ -286,7 +288,8 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
//highlight newly selected feature //highlight newly selected feature
tileContent.forEach(t => { tileContent.forEach(t => {
if (t === pickedFeature) { if (t === pickedFeature) {
console.log(t.getProperty("description") + "\n" + t.getProperty("feature_type") + "\n" + t.getProperty("gml_id") + "\n" + t.getProperty("gml_parent_id")); //used for debugging, when clicking on a surface
//console.log(t.getProperty("description") + "\n" + t.getProperty("feature_type") + "\n" + t.getProperty("gml_id") + "\n" + t.getProperty("gml_parent_id"));
t.color = Cesium.Color.LIME; t.color = Cesium.Color.LIME;
...@@ -301,6 +304,15 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) { ...@@ -301,6 +304,15 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
} }
} }
//coloring surfaces on pv potential
for (const [key, value] of Object.entries(pvPotentialSurfaces)) { //looping threw the shadowdata array
if (value["id"] === t.getProperty("gml_id")) { //checking if the ids of the current surface match the id in the shadowdata array
//console.log("hour:",chosenDate.hour);
console.log(value);
SurfacePvPotential = value["attributes"]["pvPotential"]["totalInvestment"];
}
}
} }
}); });
} else { } else {
...@@ -330,7 +342,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) { ...@@ -330,7 +342,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
"<tr><th>description</th><td>" + pickedFeature.getProperty("description") + "</td></tr>" + "<tr><th>description</th><td>" + pickedFeature.getProperty("description") + "</td></tr>" +
"<tr><th>feature_type</th><td>" + pickedFeature.getProperty("feature_type") + "</td></tr>" + "<tr><th>feature_type</th><td>" + pickedFeature.getProperty("feature_type") + "</td></tr>" +
"<tr><th>shadow value</th><td>" + shadowhourvaluepercent.toFixed(1) + "%" + "</td></tr>" + "<tr><th>shadow value</th><td>" + shadowhourvaluepercent.toFixed(1) + "%" + "</td></tr>" +
"<tr><th>totalInvestment</th><td>" + SurfacePvPotential + "</td></tr>" +
"</tbody></table>"; "</tbody></table>";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment