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

deleted unnecessary code

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