Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
3DClient4SimStadtAPI
Commits
b458258d
Commit
b458258d
authored
Nov 13, 2021
by
BujarMuharemi
Browse files
added connection handling to tileset loading
parent
4b24c962
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/js/connectToAPI.js
View file @
b458258d
...
...
@@ -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);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment