From 5f7d44be8020196552340d2efc31845062bb2a48 Mon Sep 17 00:00:00 2001 From: BujarMuharemi Date: Thu, 25 Nov 2021 13:59:51 +0100 Subject: [PATCH] added attributes to surfaceview --- public/js/connectToAPI.js | 34 +++++++++++++++++++++------------- public/js/globe.js | 4 +++- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/public/js/connectToAPI.js b/public/js/connectToAPI.js index 1035d2a..4cc024f 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 035c0b6..74b5dc4 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") + "
"; + } else { -- GitLab