diff --git a/public/js/connectToAPI.js b/public/js/connectToAPI.js index 1035d2ac0cccdbf00bcd19a3aacffee83fb953f9..4cc024f44e2b99bfa539e0607168c32ec0c56f5f 100644 --- a/public/js/connectToAPI.js +++ b/public/js/connectToAPI.js @@ -1,7 +1,7 @@ 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:8080/workflow/execute" // URL to API -var url2 = "http://vm24.fkc.hft-stuttgart.de:8083/workflow/timedShadowValueByDay/" +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/" /*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) */ @@ -21,7 +21,7 @@ async function fetchshadowDataJSON() { var leftLng = coordinatesBB[0] var rightLng = coordinatesBB[2] var topLat = coordinatesBB[3]// - var day = 5; + var day = "1"; const response = await fetch(url2 + day, { method: "POST", body: JSON.stringify({ @@ -38,15 +38,14 @@ async function fetchshadowDataJSON() { "Content-Type": "application/json", "Authorization": "Basic YWRtaW46YWRtaW4xMjM=" } - }).then(function() { - console.log("ok"); - }).catch(function() { - alert("Connetion error to server, use local data") }) - const data = await response.json() + + const data = await response.json(); return data } + + async function fetchDataJSON() { var bottomLat = coordinatesBB[1] var leftLng = coordinatesBB[0] @@ -71,8 +70,8 @@ const response = await fetch(url, { "heatedVolume", "yearOfConstruction", "buildingFunction", - // "monthlyHeating", - //"monthlyCooling", + "monthlyHeating", + "monthlyCooling", "pvPotential", "roofType", "totalSurfaceArea" @@ -97,9 +96,18 @@ function processData() { console.log(coordinatesBB) console.log("Waiting for data....") -fetchshadowDataJSON().then(data=> { - console.log(data) -}) + + + timeout(25000, fetchshadowDataJSON()).then((response)=>{ + console.log(response) + }).catch((error)=>{ //catching the error(no connection)/ timeout and displaying an alert for the user + + swal({text:"Could not connect to Server. Using now: local data",icon:"info" } ); + console.log("Using local test data"); + //loadLocalAPIshadowData here... + }) + + fetchDataJSON().then(data => { console.log(data); document.getElementById("cesiumContainer").style.opacity = "1"; diff --git a/public/js/globe.js b/public/js/globe.js index 035c0b64d811631fdd871cb959387754ebe7a884..74b5dc444749c9e5b70ba670978c43c6c164c814 100644 --- a/public/js/globe.js +++ b/public/js/globe.js @@ -286,7 +286,6 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) { } - //set feature infobox description var featureName = pickedFeature.getProperty("name"); selectedEntity.name = featureName; @@ -296,7 +295,10 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) { '
| Surface_ID | " + pickedFeature.getProperty("gml_id") + " |
|---|---|
| u_Value | " + pickUValue + " |
| description | " + pickedFeature.getProperty("description") + " |
| feature_type | " + pickedFeature.getProperty("feature_type") + " |