Commit b458258d authored by BujarMuharemi's avatar BujarMuharemi
Browse files

added connection handling to tileset loading

parent 4b24c962
......@@ -290,11 +290,25 @@ var tileset = null
var tilesetURL = 'http://vm24.fkc.hft-stuttgart.de:8081/CampusLOD2/CityModel/tileset.json';
//fetching the tileset
async function fetchTileset(){
const response = await fetch(tilesetURL);
const tilesetJSON = await response.json();
return tilesetJSON;
//fetching the tileset and handling the connection
async function fetchTileset(){
fetch(tilesetURL).then((response)=>{
if(response.status >= 200 && response.status<=299){ //successful connection
const tilesetJSON = response.json();
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
}
}).then((jsonResponse)=>{
console.log("Tileset"+jsonResponse);
}).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");
});
swal({text:"Connecting to Server ... Please wait !",icon:"info" ,buttons: false}); //displays waiting alert
}
......@@ -311,32 +325,26 @@ function loadTileset() {
viewer.scene.primitives.remove(tileset)
tileContent = []
modal.style.display = "block";
fetchTileset().then(tilesetJSON =>{
tileData = tilesetJSON;
});
var userurl = document.getElementById("3Durl").value;
console.log(userurl);
// console.log(userurl);
tileset=viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: tilesetURL
}));
console.log(tileset);
// console.log(tileset);
viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0, -0.5, 0));
modal.style.display = "none";
saveTilesetContent(tileset)
deleteTilesetButtons()
/*
tileData.collections.forEach(c => {
if (userurl === 'hftcampus' && c.id === "HftCampus") useContent(c.content)
if (userurl === 'paderborn' && c.id === "Paderborn") useContent(c.content)
})*/
console.log(tileData);
// console.log(tileData);
}
......
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