Commit 37365f2e authored by Kolokolnikova's avatar Kolokolnikova
Browse files

deleted unnecessary code

parent 61a2b52a
...@@ -132,32 +132,26 @@ async function getLocalShadowdata() { ...@@ -132,32 +132,26 @@ async function getLocalShadowdata() {
} }
async function processData() { async function processData() {
console.log("Waiting for data....") console.log("Waiting for data....")
shadowdata = await getLocalShadowdata() shadowdata = await getLocalShadowdata()
timeout(25000, getLocalShadowdata()).then((response) => { //waiting 25sec for the shadowData fetch from server: catching error if no answer in 25sec
//console.log(response) timeout(25000, fetchshadowDataJSON()).then((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);
//loadLocalAPIshadowData here...
}) })
timeout(10000, fetchPvPotentialJSON()).then((response) => { timeout(10000, fetchPvPotentialJSON()).then((response) => {
//console.log("fetchPvPotentialJSON:", response);
pvPotentialSurfaces = getPvPotentialOfSurfaces(response["buildings"]); pvPotentialSurfaces = getPvPotentialOfSurfaces(response["buildings"]);
//console.log("pvPotentialSurfaces:",pvPotentialSurfaces);
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}) })
timeout(10000, fetchDataJSON()).then((response) => { timeout(10000, fetchDataJSON()).then((response) => {
calculateData(response); calculateData(response);
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
fetch(localPvpotentialData) fetch(localPvpotentialData)
.then(response => response.text()) .then(response => response.text())
.then(text => calculateData(JSON.parse(text))) .then(text => calculateData(JSON.parse(text)))
...@@ -166,15 +160,11 @@ async function processData() { ...@@ -166,15 +160,11 @@ async function processData() {
function calculateData(data) { function calculateData(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")
var buildingsMAP = new Map() var buildingsMAP = new Map()
data.buildings.forEach(bu => { data.buildings.forEach(bu => {
var partsArray = [] var partsArray = []
var surefacesArray = [] var surefacesArray = []
...@@ -196,7 +186,6 @@ function calculateData(data) { ...@@ -196,7 +186,6 @@ function calculateData(data) {
p.attributes.roofType))) p.attributes.roofType)))
buildingsMAP.set(bu.id, new Building(bu.id, partsArray)) //puts buildings with parts and surfaces in a map buildingsMAP.set(bu.id, new Building(bu.id, partsArray)) //puts buildings with parts and surfaces in a map
}) })
var partHeightMAP = new Map() var partHeightMAP = new Map()
...@@ -389,10 +378,7 @@ window.onclick = function(event) { ...@@ -389,10 +378,7 @@ window.onclick = function(event) {
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
var tileData = null; var tileData = null;
var tileset = null; var tileset = null;
//var tilesetURL = 'http://vm24.fkc.hft-stuttgart.de:8081/CampusLOD2Old/tileset.json';
var tilesetURL = 'http://vm24.fkc.hft-stuttgart.de:8081/CampusLOD2/tileset.json'; var tilesetURL = 'http://vm24.fkc.hft-stuttgart.de:8081/CampusLOD2/tileset.json';
//var localTestTileset = '/3dclient4simstadtapi/public/test/gmlTileset_v1.json';
var localTestTileset = getAbsoulteTestPath("/test/gmlTileset_v1.json"); var localTestTileset = getAbsoulteTestPath("/test/gmlTileset_v1.json");
...@@ -406,31 +392,29 @@ function timeout(ms, promise) { ...@@ -406,31 +392,29 @@ function timeout(ms, promise) {
} }
//getting the pvPotential of all surfaces from the pvPotential array, which the api returns //getting the pvPotential of all surfaces from the pvPotential array, which the api returns
function getPvPotentialOfSurfaces(pvPotentialarray){ function getPvPotentialOfSurfaces(pvPotentialarray) {
var pvPotentialArray=[]; var pvPotentialArray = [];
pvPotentialarray.forEach( pvPotentialarray.forEach(
building => building["parts"].forEach( building => building["parts"].forEach(
parts => parts["surfaces"].forEach( parts => parts["surfaces"].forEach(
surface => pvPotentialArray.push(surface) surface => pvPotentialArray.push(surface)
//console.log(surface) )
) )
)
); );
//console.log(pvPotentialArray);
return pvPotentialArray; return pvPotentialArray;
} }
//fetching the tileset and handling the connection //fetching the tileset and handling the connection
//waiting 1sec for the tileSetData fetch from server: catching error if no answer in 1sec
function fetchTileset() { function fetchTileset() {
timeout(1000, fetch(tilesetURL)).then((response) => { timeout(1000, fetch(tilesetURL)).then((response) => {
loadAndZoomToTileset(tilesetURL); loadAndZoomToTileset(tilesetURL);
}).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
//var errorString = error["stack"]+"\n"+error["message"]; // formatting the error array
swal({ text: "Could not connect to Server. Using now: local data", icon: "info" }); swal({ text: "Could not connect to Server. Using now: local data", icon: "info" });
console.log("Using local test data"); console.log("Using local test data");
loadAndZoomToTileset(localTestTileset); loadAndZoomToTileset(localTestTileset);
}) })
} }
...@@ -450,18 +434,15 @@ function loadTileset() { ...@@ -450,18 +434,15 @@ function loadTileset() {
viewer.scene.primitives.remove(tileset); viewer.scene.primitives.remove(tileset);
tileContent = []; tileContent = [];
modal.style.display = "block"; modal.style.display = "block";
fetchTileset(); fetchTileset();
//var userurl = document.getElementById("3Durl").value; //returns the chosen area from the dropdown
} }
//loads the tileset from the url into the cesium viewer and zooms to it //loads the tileset from the url into the cesium viewer and zooms to it
function loadAndZoomToTileset(url) { function loadAndZoomToTileset(url) {
tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: url url: url
})); }));
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0, -0.5, 0)); viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0, -0.5, 0));
modal.style.display = "none"; modal.style.display = "none";
saveTilesetContent(tileset) saveTilesetContent(tileset)
...@@ -476,9 +457,7 @@ function useContent(content) { ...@@ -476,9 +457,7 @@ function useContent(content) {
element.value = cont.title element.value = cont.title
element.value = cont.title element.value = cont.title
element.name = "individualTileset" element.name = "individualTileset"
document.getElementById("myList").appendChild(element); document.getElementById("myList").appendChild(element);
element.onclick = function() { element.onclick = function() {
tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: cont.href url: cont.href
...@@ -504,7 +483,6 @@ function saveTilesetContent(tileset) { ...@@ -504,7 +483,6 @@ function saveTilesetContent(tileset) {
function deleteTilesetButtons() { function deleteTilesetButtons() {
var x = document.getElementsByName("individualTileset") var x = document.getElementsByName("individualTileset")
var len = x.length var len = x.length
//checking if there are even tileset to delete //checking if there are even tileset to delete
if (x.length > 0) { if (x.length > 0) {
parentNode = x[0].parentNode; parentNode = x[0].parentNode;
...@@ -512,7 +490,6 @@ function deleteTilesetButtons() { ...@@ -512,7 +490,6 @@ function deleteTilesetButtons() {
parentNode.removeChild(x[0]); parentNode.removeChild(x[0]);
} }
} }
} }
//expects path to test data, from the 'public' folder as origin //expects path to test data, from the 'public' folder as origin
...@@ -523,11 +500,8 @@ function getAbsoulteTestPath(testdataPath) { ...@@ -523,11 +500,8 @@ function getAbsoulteTestPath(testdataPath) {
a.reverse(); a.reverse();
a.pop(); a.pop();
a.reverse() a.reverse()
var path = ""; var path = "";
a.forEach(element => path += "/" + element); a.forEach(element => path += "/" + element);
var path = window.location.origin + "/" + path + testdataPath; var path = window.location.origin + "/" + path + testdataPath;
return path; return path;
} }
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