Commits (4)
......@@ -103,181 +103,188 @@ function processData() {
shadowdata = 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";
document.getElementById("loader").style.visibility = "hidden"
console.log("....received data")
var buildingsMAP = new Map()
data.buildings.forEach(bu => {
var partsArray = []
var surefacesArray = []
bu.parts.forEach(p =>
p.surfaces.forEach(s =>
surefacesArray.push(new Surface(s.id,
s.attributes.uValue,
s.attributes.totalSurfaceArea))))
bu.parts.forEach(p => partsArray.push(new Part(p.id,
surefacesArray,
p.attributes.volume,
p.attributes.height,
p.attributes.heatedVolume,
p.attributes.yearOfConstruction,
p.attributes.buildingFunction,
p.attributes.monthlyHeating,
p.attributes.monthlyCooling,
p.attributes.roofType)))
buildingsMAP.set(bu.id, new Building(bu.id, partsArray)) //puts buildings with parts and surfaces in a map
timeout(1000, fetchDataJSON()).then((response)=>{
calculateData(response);
}).catch((error) => {
console.log(error)
fetch("/3dclient4simstadtapi/public/test/APIdata/buildingInformation.json")
.then(response => response.text())
.then(text => calculateData( JSON.parse(text)))
})
}
})
var partHeightMAP = new Map()
var partVolumeMAP = new Map()
var partHeatedVolumeMAP = new Map()
var partConstructionYearMAP = new Map()
var partBuildingTypeMAP = new Map()
var partMonthlyHeatingMAP = new Map()
var partMonthlyCoolingMAP = new Map()
var surfaceUValueMAP = new Map()
var partRoofTypeMAP = new Map()
var surfaceTotalSurfaceAreaMAP = new Map()
//fill height, heated volume and construction year map
buildingsMAP.forEach(b => {
b.parts.forEach(part => {
if (part.height !== undefined) {
partHeightMAP.set(part.id, part.height)
}
if (part.volume !== undefined) {
partVolumeMAP.set(part.id, part.volume)
}
if (part.heatedVolume !== undefined) {
partHeatedVolumeMAP.set(part.id, part.heatedVolume)
}
if (part.yearOfConstruction !== undefined && part.yearOfConstruction <= "2020") {
partConstructionYearMAP.set(part.id, part.yearOfConstruction)
}
if (part.buildingFunction !== undefined) {
partBuildingTypeMAP.set(part.id, part.buildingFunction)
}
if (part.monthlyHeating !== undefined) {
partMonthlyHeatingMAP.set(part.id, part.monthlyHeating)
}
if (part.monthlyCooling !== undefined) {
partMonthlyCoolingMAP.set(part.id, part.monthlyCooling)
}
if (part.roofType !== undefined) {
partRoofTypeMAP.set(part.id, part.roofType)
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 = []
bu.parts.forEach(p =>
p.surfaces.forEach(s =>
surefacesArray.push(new Surface(s.id,
s.attributes.uValue,
s.attributes.totalSurfaceArea))))
bu.parts.forEach(p => partsArray.push(new Part(p.id,
surefacesArray,
p.attributes.volume,
p.attributes.height,
p.attributes.heatedVolume,
p.attributes.yearOfConstruction,
p.attributes.buildingFunction,
p.attributes.monthlyHeating,
p.attributes.monthlyCooling,
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()
var partVolumeMAP = new Map()
var partHeatedVolumeMAP = new Map()
var partConstructionYearMAP = new Map()
var partBuildingTypeMAP = new Map()
var partMonthlyHeatingMAP = new Map()
var partMonthlyCoolingMAP = new Map()
var surfaceUValueMAP = new Map()
var partRoofTypeMAP = new Map()
var surfaceTotalSurfaceAreaMAP = new Map()
//fill height, heated volume and construction year map
buildingsMAP.forEach(b => {
b.parts.forEach(part => {
if (part.height !== undefined) {
partHeightMAP.set(part.id, part.height)
}
if (part.volume !== undefined) {
partVolumeMAP.set(part.id, part.volume)
}
if (part.heatedVolume !== undefined) {
partHeatedVolumeMAP.set(part.id, part.heatedVolume)
}
if (part.yearOfConstruction !== undefined && part.yearOfConstruction <= "2020") {
partConstructionYearMAP.set(part.id, part.yearOfConstruction)
}
if (part.buildingFunction !== undefined) {
partBuildingTypeMAP.set(part.id, part.buildingFunction)
}
if (part.monthlyHeating !== undefined) {
partMonthlyHeatingMAP.set(part.id, part.monthlyHeating)
}
if (part.monthlyCooling !== undefined) {
partMonthlyCoolingMAP.set(part.id, part.monthlyCooling)
}
if (part.roofType !== undefined) {
partRoofTypeMAP.set(part.id, part.roofType)
}
part.surfaces.forEach(s => {
if (s.uValue !== undefined) {
surfaceUValueMAP.set(s.id, s.uValue)
}
part.surfaces.forEach(s => {
if (s.uValue !== undefined) {
surfaceUValueMAP.set(s.id, s.uValue)
}
})
//totalSurfaceArea
surfaceTotalSurfaceAreaMAP.set(part.id, part.surfaces)
})
//totalSurfaceArea
surfaceTotalSurfaceAreaMAP.set(part.id, part.surfaces)
})
})
//sort maps
const heightSort = new Map([...partHeightMAP.entries()].sort((a, b) => b[1] - a[1]));
const heatedVolumeSort = new Map([...partHeatedVolumeMAP.entries()].sort((a, b) => b[1] - a[1]));
const constructionYearSort = new Map([...partConstructionYearMAP.entries()].sort((a, b) => a[1] - b[1]));
const uValueSort = new Map([...surfaceUValueMAP.entries()].sort((a, b) => b[1] - a[1]));
//for Properties Single Buildings
buildingFunctionSortPick = new Map([...partBuildingTypeMAP.entries()].sort((a, b) => b[1] - a[1]));
constructionYearSortPick = new Map([...partConstructionYearMAP.entries()].sort((a, b) => a[1] - b[1]));
heightSortPick = new Map([...partHeightMAP.entries()].sort((a, b) => b[1] - a[1]));
heatedVolumeSortPick = new Map([...partHeatedVolumeMAP.entries()].sort((a, b) => b[1] - a[1]));
totalSurfaceAreaSortPick = new Map([...surfaceTotalSurfaceAreaMAP.entries()].sort((a, b) => b[1] - a[1]));
roofTypeSortPick = new Map([...partRoofTypeMAP.entries()].sort((a, b) => b[1] - a[1]));
uValueSortPick = new Map([...surfaceUValueMAP.entries()].sort((a, b) => b[1] - a[1]));
//fill arrays needed for charts
heightSort.forEach((value, key) => addHeightInfosToArrays(key, value))
heatedVolumeSort.forEach((value, key) => addHeatedVolumeInfosToArrays(key, value))
constructionYearSort.forEach((value) => yearOfConstructionValues.push(value))
partBuildingTypeMAP.forEach((value) => buildingTypeValues.push(value))
partMonthlyHeatingMAP.forEach((valueArray, key) => yearlyHeatingDemand(key, valueArray))
partMonthlyCoolingMAP.forEach((valueArray, key) => yearlyCoolingDemand(key, valueArray))
uValueSort.forEach((value, key) => {
uValueSurfaces(key, value)
uValuesAll.push(value)
})
//sort maps
const heightSort = new Map([...partHeightMAP.entries()].sort((a, b) => b[1] - a[1]));
const heatedVolumeSort = new Map([...partHeatedVolumeMAP.entries()].sort((a, b) => b[1] - a[1]));
const constructionYearSort = new Map([...partConstructionYearMAP.entries()].sort((a, b) => a[1] - b[1]));
const uValueSort = new Map([...surfaceUValueMAP.entries()].sort((a, b) => b[1] - a[1]));
//for Properties Single Buildings
buildingFunctionSortPick = new Map([...partBuildingTypeMAP.entries()].sort((a, b) => b[1] - a[1]));
constructionYearSortPick = new Map([...partConstructionYearMAP.entries()].sort((a, b) => a[1] - b[1]));
heightSortPick = new Map([...partHeightMAP.entries()].sort((a, b) => b[1] - a[1]));
heatedVolumeSortPick = new Map([...partHeatedVolumeMAP.entries()].sort((a, b) => b[1] - a[1]));
totalSurfaceAreaSortPick = new Map([...surfaceTotalSurfaceAreaMAP.entries()].sort((a, b) => b[1] - a[1]));
roofTypeSortPick = new Map([...partRoofTypeMAP.entries()].sort((a, b) => b[1] - a[1]));
uValueSortPick = new Map([...surfaceUValueMAP.entries()].sort((a, b) => b[1] - a[1]));
//fill arrays needed for charts
heightSort.forEach((value, key) => addHeightInfosToArrays(key, value))
heatedVolumeSort.forEach((value, key) => addHeatedVolumeInfosToArrays(key, value))
constructionYearSort.forEach((value) => yearOfConstructionValues.push(value))
partBuildingTypeMAP.forEach((value) => buildingTypeValues.push(value))
partMonthlyHeatingMAP.forEach((valueArray, key) => yearlyHeatingDemand(key, valueArray))
partMonthlyCoolingMAP.forEach((valueArray, key) => yearlyCoolingDemand(key, valueArray))
uValueSort.forEach((value, key) => {
uValueSurfaces(key, value)
uValuesAll.push(value)
})
partMonthlyHeatingMAP.forEach((value, key) => addmonthlyHeatingInfosToArrays(key, value))
partMonthlyCoolingMAP.forEach((value, key) => addmonthlyCoolingInfosToArrays(key, value))
partVolumeMAP.forEach((value, key) => addVolumeValues(key, value))
//calculates year of construction frequency
yearFrequency()
//calculates building type frequency
buildingTypeFrequency()
//calculates uValue frequency
uValueFrequency()
//sorts yearly heating & cooling demand for charts
sortMap()
//disables attributes in chart without values
availableAttributes()
//color buildings with heating demand
document.getElementById("checkbox2").addEventListener("change", function () {
if (this.checked) {
tileContent.forEach(t => {
let tileID = t.getProperty("gml_parent_id")
let tileColor = heatingIDColorMAP.get(tileID)
if (tileColor !== undefined) {
t.color = Cesium.Color.fromCssColorString(tileColor)
} else {
t.color = new Cesium.Color(1, 1, 1, 1)
}
})
console.log("colored")
} else {
tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
console.log("not colored")
}
})
partMonthlyHeatingMAP.forEach((value, key) => addmonthlyHeatingInfosToArrays(key, value))
partMonthlyCoolingMAP.forEach((value, key) => addmonthlyCoolingInfosToArrays(key, value))
partVolumeMAP.forEach((value, key) => addVolumeValues(key, value))
//color surfaces with uValue
document.getElementById("checkbox1").addEventListener("change", function () {
if (this.checked) {
tileContent.forEach(t => {
let tileID = t.getProperty("gml_id")
let tileColor = surfaceIDColorMAP.get(tileID)
if (tileColor !== undefined) {
t.color = Cesium.Color.fromCssColorString(tileColor)
} else {
t.color = new Cesium.Color(1, 1, 1, 1)
}
})
console.log("colored")
} else {
tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
console.log("not colored")
}
})
//calculates year of construction frequency
yearFrequency()
}).catch((err) => {
console.log(err)
//calculates building type frequency
buildingTypeFrequency()
//calculates uValue frequency
uValueFrequency()
//sorts yearly heating & cooling demand for charts
sortMap()
//disables attributes in chart without values
availableAttributes()
//color buildings with heating demand
document.getElementById("checkbox2").addEventListener("change", function () {
if (this.checked) {
tileContent.forEach(t => {
let tileID = t.getProperty("gml_parent_id")
let tileColor = heatingIDColorMAP.get(tileID)
if (tileColor !== undefined) {
t.color = Cesium.Color.fromCssColorString(tileColor)
} else {
t.color = new Cesium.Color(1, 1, 1, 1)
}
})
console.log("colored")
} else {
tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
console.log("not colored")
}
})
//color surfaces with uValue
document.getElementById("checkbox1").addEventListener("change", function () {
if (this.checked) {
tileContent.forEach(t => {
let tileID = t.getProperty("gml_id")
let tileColor = surfaceIDColorMAP.get(tileID)
if (tileColor !== undefined) {
t.color = Cesium.Color.fromCssColorString(tileColor)
} else {
t.color = new Cesium.Color(1, 1, 1, 1)
}
})
console.log("colored")
} else {
tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
console.log("not colored")
}
})
}
......
This diff is collapsed.
......@@ -8,136 +8,136 @@
"description" : {},
"feature_type" : {}
},
"geometricError" : 84.70330502116121,
"geometricError" : 84.7033050210448,
"root" : {
"boundingVolume" : {
"box" : [ 4157183.4193600416, 671263.025354151, 4774688.139831595, 209.53922537481412, 0, 0, 0, 226.20286488952115, 0, 0, 0, 159.76538479793817 ]
"box" : [ 4157183.4193600416, 671263.025354151, 4774688.139831596, 209.53922537481412, 0, 0, 0, 226.20286488952115, 0, 0, 0, 159.76538479700685 ]
},
"geometricError" : 84.70330502116121,
"geometricError" : 84.7033050210448,
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157183.4193600416, 671270.4825546426, 4774688.139831595, 209.53922537481412, 0, 0, 0, 127.40903120744042, 0, 0, 0, 159.76538479793817 ]
"box" : [ 4157183.0913853333, 671276.9167505095, 4774688.139831596, 208.88327595870942, 0, 0, 0, 198.420072172652, 0, 0, 0, 159.76538479700685 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data0.b3dm"
},
"children" : [
{
"boundingVolume" : {
"box" : [ 4157259.0075245854, 671237.0161895597, 4774633.671508186, 58.3628962864168, 0, 0, 0, 60.476301041664556, 0, 0, 0, 50.82873797789216 ]
"box" : [ 4157228.114850776, 671251.5544893676, 4774660.327885907, 43.80110447667539, 0, 0, 0, 12.856712591368705, 0, 0, 0, 53.52015439514071 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157259.0075245854, 671237.0161895597, 4774633.671508186, 58.3628962864168, 0, 0, 0, 60.476301041664556, 0, 0, 0, 50.82873797789216 ]
"box" : [ 4157228.114850776, 671251.5544893676, 4774660.327885907, 43.80110447667539, 0, 0, 0, 12.856712591368705, 0, 0, 0, 53.52015439514071 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data1.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157264.5454970878, 671264.7944576879, 4774639.053918136, 4.804305506404489, 0, 0, 0, 2.147513223113492, 0, 0, 0, 5.241957767866552 ]
"box" : [ 4157259.0075245854, 671237.0161895596, 4774633.671508187, 58.36289628734812, 0, 0, 0, 60.476301041897386, 0, 0, 0, 50.82873797882348 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157264.5454970878, 671264.7944576879, 4774639.053918136, 4.804305506404489, 0, 0, 0, 2.147513223113492, 0, 0, 0, 5.241957767866552 ]
"box" : [ 4157259.0075245854, 671237.0161895596, 4774633.671508187, 58.36289628734812, 0, 0, 0, 60.476301041897386, 0, 0, 0, 50.82873797882348 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data2.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157271.7478251206, 671261.0646106068, 4774633.3457075525, 4.269025307614356, 0, 0, 0, 4.564049106091261, 0, 0, 0, 3.9737667804583907 ]
"box" : [ 4157260.196087419, 671251.9858865617, 4774636.8328062985, 25.79576786607504, 0, 0, 0, 29.950261512654833, 0, 0, 0, 44.506141755729914 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157271.7478251206, 671261.0646106068, 4774633.3457075525, 4.269025307614356, 0, 0, 0, 4.564049106091261, 0, 0, 0, 3.9737667804583907 ]
"box" : [ 4157260.196087419, 671251.9858865617, 4774636.8328062985, 25.79576786607504, 0, 0, 0, 29.950261512654833, 0, 0, 0, 44.506141755729914 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data3.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157269.666790006, 671242.1711963416, 4774620.168381745, 18.48172607459128, 0, 0, 0, 15.025834774365649, 0, 0, 0, 18.37874110136181 ]
"box" : [ 4157223.877246985, 671278.8423610204, 4774660.5079447515, 20.377759689930826, 0, 0, 0, 193.8928428903455, 0, 0, 0, 22.34141970332712 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157269.666790006, 671242.1711963416, 4774620.168381745, 18.48172607459128, 0, 0, 0, 15.025834774365649, 0, 0, 0, 18.37874110136181 ]
"box" : [ 4157223.877246985, 671278.8423610204, 4774660.5079447515, 20.377759689930826, 0, 0, 0, 193.8928428903455, 0, 0, 0, 22.34141970332712 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data4.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157260.68975647, 671264.3242054185, 4774624.871435814, 19.25886470079422, 0, 0, 0, 4.519255034159869, 0, 0, 0, 20.583400790579617 ]
"box" : [ 4157211.0689755557, 671179.0722945668, 4774667.161378037, 61.64202992897481, 0, 0, 0, 58.29674572101794, 0, 0, 0, 57.427568226121366 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157260.68975647, 671264.3242054185, 4774624.871435814, 19.25886470079422, 0, 0, 0, 4.519255034159869, 0, 0, 0, 20.583400790579617 ]
"box" : [ 4157211.0689755557, 671179.0722945668, 4774667.161378037, 61.64202992897481, 0, 0, 0, 58.29674572101794, 0, 0, 0, 57.427568226121366 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data5.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157172.530755616, 671207.1977614365, 4774696.57353464, 138.71846980927512, 0, 0, 0, 114.54767946049105, 0, 0, 0, 116.25188143644482 ]
"box" : [ 4157225.063591961, 671175.3949235276, 4774673.084528787, 21.286791074555367, 0, 0, 0, 20.521639954065904, 0, 0, 0, 20.94711357820779 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157172.530755616, 671207.1977614365, 4774696.57353464, 138.71846980927512, 0, 0, 0, 114.54767946049105, 0, 0, 0, 116.25188143644482 ]
"box" : [ 4157225.063591961, 671175.3949235276, 4774673.084528787, 21.286791074555367, 0, 0, 0, 20.521639954065904, 0, 0, 0, 20.94711357820779 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data6.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157214.173438959, 671345.0541383316, 4774655.342074862, 37.477705544326454, 0, 0, 0, 62.14529652846977, 0, 0, 0, 51.50954015459865 ]
"box" : [ 4157172.530755615, 671226.8655617537, 4774696.573534641, 138.71846981020644, 0, 0, 0, 106.83504467795137, 0, 0, 0, 116.25188143644482 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157214.173438959, 671345.0541383316, 4774655.342074862, 37.477705544326454, 0, 0, 0, 62.14529652846977, 0, 0, 0, 51.50954015459865 ]
"box" : [ 4157172.530755615, 671226.8655617537, 4774696.573534641, 138.71846981020644, 0, 0, 0, 106.83504467795137, 0, 0, 0, 116.25188143644482 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data7.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157182.683947933, 671336.9473289275, 4774687.03334116, 11.211912735830992, 0, 0, 0, 12.544089487171732, 0, 0, 0, 4.31426614522934 ]
"box" : [ 4157234.735237984, 671184.0981509301, 4774663.504809576, 1.9434990277513862, 0, 0, 0, 3.1151851491304114, 0, 0, 0, 1.7876751571893692 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157182.683947933, 671336.9473289275, 4774687.03334116, 11.211912735830992, 0, 0, 0, 12.544089487171732, 0, 0, 0, 4.31426614522934 ]
"box" : [ 4157234.735237984, 671184.0981509301, 4774663.504809576, 1.9434990277513862, 0, 0, 0, 3.1151851491304114, 0, 0, 0, 1.7876751571893692 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data8.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157181.173513483, 671326.7337885841, 4774674.725270944, 33.30119850020856, 0, 0, 0, 32.9711701736087, 0, 0, 0, 28.930406578816473 ]
"box" : [ 4157192.6996459886, 671343.1874950464, 4774673.3595239995, 76.89431473286822, 0, 0, 0, 65.87858309876174, 0, 0, 0, 87.54443842731416 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157181.173513483, 671326.7337885841, 4774674.725270944, 33.30119850020856, 0, 0, 0, 32.9711701736087, 0, 0, 0, 28.930406578816473 ]
"box" : [ 4157192.6996459886, 671343.1874950464, 4774673.3595239995, 76.89431473286822, 0, 0, 0, 65.87858309876174, 0, 0, 0, 87.54443842731416 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data9.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157193.1721887705, 671343.1874950465, 4774659.388889508, 57.298549075610936, 0, 0, 0, 65.87858309841249, 0, 0, 0, 59.603169448673725 ]
"box" : [ 4157146.0018855724, 671293.6001087409, 4774719.744891234, 134.70427643693984, 0, 0, 0, 99.23852986039128, 0, 0, 0, 96.55526552256197 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157193.1721887705, 671343.1874950465, 4774659.388889508, 57.298549075610936, 0, 0, 0, 65.87858309841249, 0, 0, 0, 59.603169448673725 ]
"box" : [ 4157146.0018855724, 671293.6001087409, 4774719.744891234, 134.70427643693984, 0, 0, 0, 99.23852986039128, 0, 0, 0, 96.55526552256197 ]
},
"url" : "/3dclient4simstadtapi/public/test/tileset/data/data10.b3dm"
}
......