diff --git a/public/js/connectToAPI.js b/public/js/connectToAPI.js index 9fce79228f3f532c53a72d8c498b3faa494af772..4ffe90abe59215f60db377da36ed4ccef28beb4e 100644 --- a/public/js/connectToAPI.js +++ b/public/js/connectToAPI.js @@ -134,7 +134,7 @@ async function getLocalShadowdata() { async function processData() { console.log(coordinatesBB) console.log("Waiting for data....") - shadowdata= await getLocalShadowdata() + shadowdata = await getLocalShadowdata() timeout(25000, getLocalShadowdata()).then((response) => { console.log(response) @@ -145,30 +145,25 @@ async function processData() { }) timeout(10000, fetchPvPotentialJSON()).then((response) => { - console.log(response) + //console.log("fetchPvPotentialJSON:", response); + getPvPotentialOfSurfaces(response["buildings"]); }).catch((error) => { console.log(error) }) - + timeout(10000, fetchDataJSON()).then((response) => { calculateData(response); }).catch((error) => { console.log(error) - + fetch(localPvpotentialData) - .then(response => response.text()) - .then(text => calculateData( JSON.parse(text))) - + .then(response => response.text()) + .then(text => calculateData(JSON.parse(text))) }) - - - - } - function calculateData(data) { console.log(data); document.getElementById("cesiumContainer").style.opacity = "1"; @@ -409,9 +404,23 @@ function timeout(ms, promise) { }) } +function getPvPotentialOfSurfaces(pvPotentialarray){ + var pvPotentialArray=[]; + + pvPotentialarray.forEach( + building => building["parts"].forEach( + parts => parts["surfaces"].forEach( + surface => pvPotentialArray.push(surface) + //console.log(surface) + ) + ) + ); + console.log(pvPotentialArray); +} + //fetching the tileset and handling the connection -async function fetchTileset() { +function fetchTileset() { timeout(1000, fetch(tilesetURL)).then((response) => { loadAndZoomToTileset(tilesetURL); }).catch((error) => { //catching the error(no connection)/ timeout and displaying an alert for the user @@ -422,8 +431,6 @@ async function fetchTileset() { }) } - - /* NOTE #1: -load the models but the are in the too high in the "air" -building view doesn´t work because all buildings are grouped together @@ -432,7 +439,6 @@ async function fetchTileset() { -->this fixme is the problem of the backendteam ! ? maybe add old menu back and the option to also load the new ones - */ @@ -508,15 +514,17 @@ function deleteTilesetButtons() { //expects path to test data, from the 'public' folder as origin // for example: getAbsoulteTestPath("/test/gmlTileset_v1.json") -function getAbsoulteTestPath(path){ +function getAbsoulteTestPath(testdataPath) { var a = window.location.pathname.split("/") - a.pop();a.reverse();a.pop(); + a.pop(); + a.reverse(); + a.pop(); + a.reverse() + + var path = ""; + a.forEach(element => path += "/" + element); - var path; - a.forEach(element => path+"/"+element); - var path = window.location.origin+"/"+a[0]+path; - console.log(path); + var path = window.location.origin + "/" + path + testdataPath; return path; } - diff --git a/public/js/globe.js b/public/js/globe.js index c1a63676675a4438f30828dd8a3cc03b46454864..30df0d95f19ee6eca510409dd37bd88390545c69 100644 --- a/public/js/globe.js +++ b/public/js/globe.js @@ -16,7 +16,7 @@ viewer.scene.globe.depthTestAgainstTerrain = true; //--------------------hover over surfaces-------------------- var singleChart = document.getElementById('singleChartContainer'); -console.log(viewer.ShadowMap); +//console.log(viewer.ShadowMap); // HTML overlay for showing feature name on mouseover var nameOverlay = document.createElement("div");