Commit b1a534a8 authored by BujarMuharemi's avatar BujarMuharemi
Browse files

added local test data; fixed connection handling

parent b458258d
......@@ -55,10 +55,14 @@ async function fetchDataJSON() {
}
document.getElementById("loader").style.visibility = "hidden"
/*TODO: -use local test data
-no connection handeling
*/
function processData() {
console.log(coordinatesBB)
console.log("Waiting for data....")
fetchDataJSON().then(data => {
console.log(data);
document.getElementById("cesiumContainer").style.opacity = "1";
......@@ -288,16 +292,17 @@ window.onclick = function (event) {
var tileData = null
var tileset = null
var tilesetURL = 'http://vm24.fkc.hft-stuttgart.de:8081/CampusLOD2/CityModel/tileset.json';
var localTestTileset = '/3dclient4simstadtapi/public/test/tileset/gmlTileset_v1.json';
//fetching the tileset and handling the connection
// TODO: cancel timemout when there isnt a connection
async function fetchTileset(){
fetch(tilesetURL).then((response)=>{
if(response.status >= 200 && response.status<=299){ //successful connection
const tilesetJSON = response.json();
//const tilesetJSON = response.json();
loadAndZoomTime(tilesetURL);
swal({text:"",timer:100}); //used to remove the waiting alert
return tilesetJSON; //returning the tileset
}else{
throw Error(response.statusText); //throwing an error when a connection is not possible
}
......@@ -306,6 +311,9 @@ async function fetchTileset(){
}).catch((error)=>{ //catching the error and displaying an alert for the user
var errorString = error["stack"]+"\n"+error["message"]; // formatting the error array
swal("Could not connect to Server",errorString , "error");
console.log("Using local test data");
loadAndZoomTime(localTestTileset); //TODO: fix loading local data
});
swal({text:"Connecting to Server ... Please wait !",icon:"info" ,buttons: false}); //displays waiting alert
......@@ -326,26 +334,20 @@ function loadTileset() {
tileContent = []
modal.style.display = "block";
fetchTileset().then(tilesetJSON =>{
tileData = tilesetJSON;
});
fetchTileset();
//var userurl = document.getElementById("3Durl").value; //returns the chosen area from the dropdown
}
var userurl = document.getElementById("3Durl").value;
// console.log(userurl);
function loadAndZoomTime(url){
tileset=viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: tilesetURL
url: url
}));
// console.log(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0, -0.5, 0));
modal.style.display = "none";
saveTilesetContent(tileset)
deleteTilesetButtons()
// console.log(tileData);
}
......
{
"asset" : {
"version" : "0.0"
},
"properties" : {
"gml_id" : {},
"gml_parent_id" : {},
"description" : {},
"feature_type" : {}
},
"geometricError" : 84.70330502116121,
"root" : {
"boundingVolume" : {
"box" : [ 4157183.4193600416, 671263.025354151, 4774688.139831595, 209.53922537481412, 0, 0, 0, 226.20286488952115, 0, 0, 0, 159.76538479793817 ]
},
"geometricError" : 84.70330502116121,
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157183.4193600416, 671270.4825546426, 4774688.139831595, 209.53922537481412, 0, 0, 0, 127.40903120744042, 0, 0, 0, 159.76538479793817 ]
},
"url" : "data/data0.b3dm"
},
"children" : [
{
"boundingVolume" : {
"box" : [ 4157259.0075245854, 671237.0161895597, 4774633.671508186, 58.3628962864168, 0, 0, 0, 60.476301041664556, 0, 0, 0, 50.82873797789216 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157259.0075245854, 671237.0161895597, 4774633.671508186, 58.3628962864168, 0, 0, 0, 60.476301041664556, 0, 0, 0, 50.82873797789216 ]
},
"url" : "data/data1.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157264.5454970878, 671264.7944576879, 4774639.053918136, 4.804305506404489, 0, 0, 0, 2.147513223113492, 0, 0, 0, 5.241957767866552 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157264.5454970878, 671264.7944576879, 4774639.053918136, 4.804305506404489, 0, 0, 0, 2.147513223113492, 0, 0, 0, 5.241957767866552 ]
},
"url" : "data/data2.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157271.7478251206, 671261.0646106068, 4774633.3457075525, 4.269025307614356, 0, 0, 0, 4.564049106091261, 0, 0, 0, 3.9737667804583907 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157271.7478251206, 671261.0646106068, 4774633.3457075525, 4.269025307614356, 0, 0, 0, 4.564049106091261, 0, 0, 0, 3.9737667804583907 ]
},
"url" : "data/data3.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157269.666790006, 671242.1711963416, 4774620.168381745, 18.48172607459128, 0, 0, 0, 15.025834774365649, 0, 0, 0, 18.37874110136181 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157269.666790006, 671242.1711963416, 4774620.168381745, 18.48172607459128, 0, 0, 0, 15.025834774365649, 0, 0, 0, 18.37874110136181 ]
},
"url" : "data/data4.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157260.68975647, 671264.3242054185, 4774624.871435814, 19.25886470079422, 0, 0, 0, 4.519255034159869, 0, 0, 0, 20.583400790579617 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157260.68975647, 671264.3242054185, 4774624.871435814, 19.25886470079422, 0, 0, 0, 4.519255034159869, 0, 0, 0, 20.583400790579617 ]
},
"url" : "data/data5.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157172.530755616, 671207.1977614365, 4774696.57353464, 138.71846980927512, 0, 0, 0, 114.54767946049105, 0, 0, 0, 116.25188143644482 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157172.530755616, 671207.1977614365, 4774696.57353464, 138.71846980927512, 0, 0, 0, 114.54767946049105, 0, 0, 0, 116.25188143644482 ]
},
"url" : "data/data6.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157214.173438959, 671345.0541383316, 4774655.342074862, 37.477705544326454, 0, 0, 0, 62.14529652846977, 0, 0, 0, 51.50954015459865 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157214.173438959, 671345.0541383316, 4774655.342074862, 37.477705544326454, 0, 0, 0, 62.14529652846977, 0, 0, 0, 51.50954015459865 ]
},
"url" : "data/data7.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157182.683947933, 671336.9473289275, 4774687.03334116, 11.211912735830992, 0, 0, 0, 12.544089487171732, 0, 0, 0, 4.31426614522934 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157182.683947933, 671336.9473289275, 4774687.03334116, 11.211912735830992, 0, 0, 0, 12.544089487171732, 0, 0, 0, 4.31426614522934 ]
},
"url" : "data/data8.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157181.173513483, 671326.7337885841, 4774674.725270944, 33.30119850020856, 0, 0, 0, 32.9711701736087, 0, 0, 0, 28.930406578816473 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157181.173513483, 671326.7337885841, 4774674.725270944, 33.30119850020856, 0, 0, 0, 32.9711701736087, 0, 0, 0, 28.930406578816473 ]
},
"url" : "data/data9.b3dm"
}
},
{
"boundingVolume" : {
"box" : [ 4157193.1721887705, 671343.1874950465, 4774659.388889508, 57.298549075610936, 0, 0, 0, 65.87858309841249, 0, 0, 0, 59.603169448673725 ]
},
"refine" : "ADD",
"content" : {
"boundingVolume" : {
"box" : [ 4157193.1721887705, 671343.1874950465, 4774659.388889508, 57.298549075610936, 0, 0, 0, 65.87858309841249, 0, 0, 0, 59.603169448673725 ]
},
"url" : "data/data10.b3dm"
}
}
]
}
}
\ No newline at end of file
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