Commit b045e623 authored by BujarMuharemi's avatar BujarMuharemi
Browse files

added beautify extension and formated all files

parent 613d4534
{
"indent_size": 4,
"indent_char": " ",
"indent_level": 0,
"end-with-newline": true,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": false,
"space_after_anon_function": false,
"brace_style": "collapse,preserve-inline",
"keep_array_indentation": false,
"keep_function_indentation": false,
"space_before_conditional": true,
"break_chained_methods": false,
"eval_code": false,
"unescape_strings": false,
"wrap_line_length": 0,
"css": {
"selector_separator_newline": false
}
}
\ No newline at end of file
......@@ -19,23 +19,23 @@ var uValueSortPick
var shadowdata
async function fetchPvPotentialJSON() {
async function fetchPvPotentialJSON() {
var bottomLat = coordinatesBB[1]
var leftLng = coordinatesBB[0]
var rightLng = coordinatesBB[2]
var topLat = coordinatesBB[3]
const response = await fetch(pvURL, {
const response = await fetch(pvURL, {
method: "POST",
body: JSON.stringify({
"boundingBox": {
"bottomLat": bottomLat, //48.779004965,
"leftLng": leftLng, //9.1686843081,
"leftLng": leftLng, //9.1686843081,
"lodType": "LOD2",
"rightLng": rightLng, //9.175336684,
"topLat": topLat //48.7822869656
},
"cityGMLRef": "campusLOD2"
"rightLng": rightLng, //9.175336684,
"topLat": topLat //48.7822869656
},
"cityGMLRef": "campusLOD2"
}),
headers: {
"Content-Type": "application/json",
......@@ -51,17 +51,17 @@ async function fetchshadowDataJSON() {
var bottomLat = coordinatesBB[1]
var leftLng = coordinatesBB[0]
var rightLng = coordinatesBB[2]
var topLat = coordinatesBB[3]//
var topLat = coordinatesBB[3] //
var day = "1";
const response = await fetch(url2 + day, {
const response = await fetch(url2 + day, {
method: "POST",
body: JSON.stringify({
"boundingBox": {
"bottomLat": bottomLat, //48.779004965,
"leftLng": leftLng, //9.1686843081,
"leftLng": leftLng, //9.1686843081,
"lodType": "LOD2",
"rightLng": rightLng, //9.175336684,
"topLat": topLat //48.7822869656
"rightLng": rightLng, //9.175336684,
"topLat": topLat //48.7822869656
},
"cityGMLRef": "campusLOD2"
}),
......@@ -80,17 +80,17 @@ async function fetchDataJSON() {
var bottomLat = coordinatesBB[1]
var leftLng = coordinatesBB[0]
var rightLng = coordinatesBB[2]
var topLat = coordinatesBB[3]//
var topLat = coordinatesBB[3] //
const response = await fetch(url, {
const response = await fetch(url, {
method: "POST",
body: JSON.stringify({
"boundingBox": {
"bottomLat": bottomLat, //48.779004965,
"leftLng": leftLng, //9.1686843081,
"leftLng": leftLng, //9.1686843081,
"lodType": "LOD2",
"rightLng": rightLng, //9.175336684,
"topLat": topLat //48.7822869656
"rightLng": rightLng, //9.175336684,
"topLat": topLat //48.7822869656
},
"cityGMLRef": "campusLOD2",
"interestedAttributes": [
......@@ -104,7 +104,7 @@ const response = await fetch(url, {
"monthlyCooling",
"pvPotential",
"roofType",
"totalSurfaceArea"
"totalSurfaceArea"
],
"properies": {
"physicsUseScenario": false
......@@ -121,39 +121,39 @@ const response = await fetch(url, {
document.getElementById("loader").style.visibility = "hidden"
async function getLocalShadowdata(){
async function getLocalShadowdata() {
// gets the response from the api and put it inside a constant
const response = await fetch(localShadowData);
//the response have to be converted to json type file, so it can be used
const data = await response.json();
const data = await response.json();
console.log(data)
// shadowData=data;
// shadowData=data;
return data;
}
}
function processData() {
console.log(coordinatesBB)
console.log("Waiting for data....")
timeout(25000, fetchshadowDataJSON()).then((response)=>{
console.log(response)
shadowdata = response ;
}).catch((error)=>{ //catching the error(no connection)/ timeout and displaying an alert for the user
// shadowdata= getLocalShadowdata();
timeout(25000, fetchshadowDataJSON()).then((response) => {
console.log(response)
shadowdata = response;
}).catch((error) => { //catching the error(no connection)/ timeout and displaying an alert for the user
// shadowdata= getLocalShadowdata();
console.log(shadowdata);
//loadLocalAPIshadowData here...
})
})
timeout(10000, fetchPvPotentialJSON()).then((response)=>{
console.log(response)
}).catch((error) => {
timeout(10000, fetchPvPotentialJSON()).then((response) => {
console.log(response)
}).catch((error) => {
console.log(error)
})
timeout(10000, fetchDataJSON()).then((response)=>{
calculateData(response);
}).catch((error) => {
})
timeout(10000, fetchDataJSON()).then((response) => {
calculateData(response);
}).catch((error) => {
console.log(error)
/*
fetch("/3dclient4simstadtapi/public/test/APIdata/buildingInformation.json")
......@@ -162,14 +162,14 @@ function processData() {
*/
})
}
function calculateData(data){
function calculateData(data) {
console.log(data);
document.getElementById("cesiumContainer").style.opacity = "1";
document.getElementById("loader").style.visibility = "hidden"
......@@ -199,7 +199,7 @@ function calculateData(data){
p.attributes.monthlyCooling,
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
})
......@@ -299,7 +299,7 @@ function calculateData(data){
availableAttributes()
//color buildings with heating demand
document.getElementById("checkbox2").addEventListener("change", function () {
document.getElementById("checkbox2").addEventListener("change", function() {
if (this.checked) {
tileContent.forEach(t => {
let tileID = t.getProperty("gml_parent_id")
......@@ -318,7 +318,7 @@ function calculateData(data){
})
//color surfaces with uValue
document.getElementById("checkbox1").addEventListener("change", function () {
document.getElementById("checkbox1").addEventListener("change", function() {
if (this.checked) {
tileContent.forEach(t => {
let tileID = t.getProperty("gml_id")
......@@ -377,13 +377,13 @@ var modal = document.getElementById("myModal");
var span = document.getElementsByClassName("close")[0];
//close the modal
span.onclick = function () {
span.onclick = function() {
modal.style.display = "none";
deleteTilesetButtons()
}
// modal closes, when the user clicks anywhere outside of the modal
window.onclick = function (event) {
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
deleteTilesetButtons()
......@@ -401,24 +401,24 @@ var localTestTileset = '/3dclient4simstadtapi/public/test/gmlTileset_v1.json';
function timeout(ms, promise) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
reject(new Error("timeout"))
}, ms)
promise.then(resolve, reject)
setTimeout(function() {
reject(new Error("timeout"))
}, ms)
promise.then(resolve, reject)
})
}
//fetching the tileset and handling the connection
async 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
async 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" } );
swal({ text: "Could not connect to Server. Using now: local data", icon: "info" });
console.log("Using local test data");
loadAndZoomToTileset(localTestTileset); //TODO#3: fix the link so the local tileset can be loaded
})
})
}
......@@ -436,26 +436,26 @@ async function fetchTileset(){
//loads tileset after submit button is clicked
function loadTileset() {
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({
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)
deleteTilesetButtons()
modal.style.display = "none";
saveTilesetContent(tileset)
deleteTilesetButtons()
}
......@@ -469,7 +469,7 @@ function useContent(content) {
document.getElementById("myList").appendChild(element);
element.onclick = function () {
element.onclick = function() {
tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: cont.href
}));
......@@ -494,13 +494,13 @@ 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){
if (x.length > 0) {
parentNode = x[0].parentNode;
for (var i = 0; i < len; i++) {
parentNode.removeChild(x[0]);
}
}
}
This diff is collapsed.
//Shadow palette for coloring the roofs
//color pallet white->black
var colorPalette = ['#ffffff','#f0f0f0','#d9d9d9','#bdbdbd','#969696','#737373','#525252','#252525'];
const shadowPalette = colorPalette.reverse();
var colorPalette = ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525'];
const shadowPalette = colorPalette.reverse();
//returns the responding color from the shadowPalette, depending on the inputShadowValue(0 to 1 in float)
function getShadowPalette(inputShadowValue){
function getShadowPalette(inputShadowValue) {
//checking for the float values
var index = Math.ceil((shadowPalette.length-1)*inputShadowValue);
var index = Math.ceil((shadowPalette.length - 1) * inputShadowValue);
//console.log(inputShadowValue,"---",shadowPalette[index]);
return shadowPalette[index];
}
......@@ -4,75 +4,73 @@ var radio = document.getElementById('radio-group');
var filterswitches = document.getElementById('filterswitches');
//Show / hide chart
chartButton.addEventListener('click', function () {
//sets as default attribute building function
myChartArea("bar", "Building Function", 1, "Building Type", "Frequency", coloR);
addGlobalData(areaChart, buildingType, btFrequency, btFrequency.length)
chartButton.addEventListener('click', function() {
//sets as default attribute building function
myChartArea("bar", "Building Function", 1, "Building Type", "Frequency", coloR);
addGlobalData(areaChart, buildingType, btFrequency, btFrequency.length)
if (drawBox === false) {
swal("CAN'T LOAD DATA!", "mark an area first!", "error");
} else {
var x = document.getElementById('areaChartContainer');
if (x.style.visibility === 'visible') {
//button.firstChild.data = "Show chart";
x.style.visibility = 'hidden';
if (drawBox === false) {
swal("CAN'T LOAD DATA!", "mark an area first!", "error");
} else {
//button.firstChild.data = "Hide chart";
x.style.visibility = 'visible';
}
}
}, false);
var x = document.getElementById('areaChartContainer');
heatingdemand.addEventListener('click', function () {
var x = document.getElementById('heat-demand-legend');
if (!document.getElementById('checkbox2').checked) {
x.style.visibility = 'hidden';
} else {
x.style.visibility = 'visible';
}
if (x.style.visibility === 'visible') {
//button.firstChild.data = "Show chart";
x.style.visibility = 'hidden';
} else {
//button.firstChild.data = "Hide chart";
x.style.visibility = 'visible';
}
}
}, false);
radio.addEventListener('click', function () {
if (document.getElementById("surface").checked) {
document.getElementById("checkbox1").disabled = false;
document.getElementById("checkbox2").disabled = true;
if (document.getElementById("checkbox2").checked) {
document.getElementById("checkbox2").checked = false;
document.getElementById('heat-demand-legend').style.visibility = 'hidden';
tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
}
}
else {
document.getElementById("checkbox1").disabled = true;
document.getElementById("checkbox2").disabled = false;
if (document.getElementById("checkbox1").checked) {
document.getElementById("checkbox1").checked = false;
tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
heatingdemand.addEventListener('click', function() {
var x = document.getElementById('heat-demand-legend');
if (!document.getElementById('checkbox2').checked) {
x.style.visibility = 'hidden';
} else {
x.style.visibility = 'visible';
}
}
}, false);
filterswitches.addEventListener('click', function () {
if (drawBox === false) {
swal("CAN'T LOAD DATA!", "mark an area first!", "error");
document.getElementById("checkbox2").disabled = true;
document.getElementById("checkbox1").disabled = true;
} else {
radio.addEventListener('click', function() {
if (document.getElementById("surface").checked) {
document.getElementById("checkbox1").disabled = false;
document.getElementById("checkbox2").disabled = true;
document.getElementById("checkbox1").disabled = false;
document.getElementById("checkbox2").disabled = true;
if (document.getElementById("checkbox2").checked) {
document.getElementById("checkbox2").checked = false;
document.getElementById('heat-demand-legend').style.visibility = 'hidden';
tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
}
} else {
document.getElementById("checkbox1").disabled = true;
document.getElementById("checkbox2").disabled = false;
if (document.getElementById("checkbox1").checked) {
document.getElementById("checkbox1").checked = false;
tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
}
}
else {
document.getElementById("checkbox1").disabled = true;
document.getElementById("checkbox2").disabled = false;
}, false);
filterswitches.addEventListener('click', function() {
if (drawBox === false) {
swal("CAN'T LOAD DATA!", "mark an area first!", "error");
document.getElementById("checkbox2").disabled = true;
document.getElementById("checkbox1").disabled = true;
} else {
if (document.getElementById("surface").checked) {
document.getElementById("checkbox1").disabled = false;
document.getElementById("checkbox2").disabled = true;
} else {
document.getElementById("checkbox1").disabled = true;
document.getElementById("checkbox2").disabled = false;
}
}
}
}, false);
function toggleSidebar(ref) {
document.getElementById("sidebar").classList.toggle('active');
document.getElementById("sidebar").classList.toggle('active');
}
//loop through all dropdown buttons to toggle between hiding and showing its dropdown content
......@@ -80,13 +78,13 @@ var dropdown = document.getElementsByClassName("dropdown-btn");
var i;
for (i = 0; i < dropdown.length; i++) {
dropdown[i].addEventListener("click", function () {
this.classList.toggle("active");
var dropdownContent = this.nextElementSibling;
if (dropdownContent.style.display === "block") {
dropdownContent.style.display = "none";
} else {
dropdownContent.style.display = "block";
}
});
dropdown[i].addEventListener("click", function() {
this.classList.toggle("active");
var dropdownContent = this.nextElementSibling;
if (dropdownContent.style.display === "block") {
dropdownContent.style.display = "none";
} else {
dropdownContent.style.display = "block";
}
});
}
......@@ -27,7 +27,7 @@ function test() {
p.attributes.monthlyHeating,
p.attributes.monthlyCooling)))
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
})
......@@ -104,7 +104,7 @@ function test() {
sortMap()
//color buildings with heating demand
document.getElementById("checkbox2").addEventListener("change", function () {
document.getElementById("checkbox2").addEventListener("change", function() {
if (this.checked) {
tileContent.forEach(t => {
let tileID = t.getProperty("gml_parent_id")
......@@ -124,7 +124,7 @@ function test() {
})
//color surfaces with uValue
document.getElementById("checkbox1").addEventListener("change", function () {
document.getElementById("checkbox1").addEventListener("change", function() {
if (this.checked) {
tileContent.forEach(t => {
let tileID = t.getProperty("gml_id")
......@@ -143,4 +143,3 @@ function test() {
}
})
}
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