Commit 613d4534 authored by BujarMuharemi's avatar BujarMuharemi
Browse files

pvPotential data can be fetched from the API

parent 3e74ace5
......@@ -2,6 +2,8 @@ var coordinatesBB = []
//var url = "https://simstadt-api.iaf-ex.hft-stuttgart.de:8080/workflow/execute" //old link
var url = "http://vm24.fkc.hft-stuttgart.de:8082/workflow/execute" // URL to API
var url2 = "http://vm24.fkc.hft-stuttgart.de:8082/workflow/timedShadowValueByDay/"
var pvURL = "http://vm24.fkc.hft-stuttgart.de:8082/workflow/readPVPotential"
/*TODO#1: -get current data from the api and create local test data (apiData foler)
-add connection handeling (error messages when there isnt a connection and then using the local test data)
*/
......@@ -16,6 +18,35 @@ var roofTypeSortPick
var uValueSortPick
var shadowdata
async function fetchPvPotentialJSON() {
var bottomLat = coordinatesBB[1]
var leftLng = coordinatesBB[0]
var rightLng = coordinatesBB[2]
var topLat = coordinatesBB[3]
const response = await fetch(pvURL, {
method: "POST",
body: JSON.stringify({
"boundingBox": {
"bottomLat": bottomLat, //48.779004965,
"leftLng": leftLng, //9.1686843081,
"lodType": "LOD2",
"rightLng": rightLng, //9.175336684,
"topLat": topLat //48.7822869656
},
"cityGMLRef": "campusLOD2"
}),
headers: {
"Content-Type": "application/json",
"Authorization": "Basic YWRtaW46YWRtaW4xMjM="
}
})
const data = await response.json();
return data
}
async function fetchshadowDataJSON() {
var bottomLat = coordinatesBB[1]
var leftLng = coordinatesBB[0]
......@@ -45,7 +76,6 @@ async function fetchshadowDataJSON() {
}
async function fetchDataJSON() {
var bottomLat = coordinatesBB[1]
var leftLng = coordinatesBB[0]
......@@ -104,6 +134,7 @@ async function getLocalShadowdata(){
function processData() {
console.log(coordinatesBB)
console.log("Waiting for data....")
timeout(25000, fetchshadowDataJSON()).then((response)=>{
console.log(response)
shadowdata = response ;
......@@ -112,16 +143,28 @@ function processData() {
console.log(shadowdata);
//loadLocalAPIshadowData here...
})
timeout(10000, fetchPvPotentialJSON()).then((response)=>{
console.log(response)
}).catch((error) => {
console.log(error)
})
timeout(1000, fetchDataJSON()).then((response)=>{
timeout(10000, fetchDataJSON()).then((response)=>{
calculateData(response);
}).catch((error) => {
console.log(error)
/*
fetch("/3dclient4simstadtapi/public/test/APIdata/buildingInformation.json")
.then(response => response.text())
.then(text => calculateData( JSON.parse(text)))
*/
})
}
......@@ -407,7 +450,8 @@ function loadAndZoomToTileset(url){
tileset=viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: url
}));
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0, -0.5, 0));
modal.style.display = "none";
saveTilesetContent(tileset)
......
Supports Markdown
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