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
d4bb5b19
Commit
d4bb5b19
authored
Nov 11, 2021
by
BujarMuharemi
Browse files
gml tileset can be loaded
parent
e238b100
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/js/connectToAPI.js
View file @
d4bb5b19
...
@@ -284,31 +284,64 @@ window.onclick = function (event) {
...
@@ -284,31 +284,64 @@ window.onclick = function (event) {
}
}
}
}
//-------------------------------------------------------------------------------
var
tileData
=
null
var
tileData
=
null
var
tileset
=
null
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
;
}
fetch
(
'
https://boxofcare.de/3DContainerTile/collections/
'
)
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
tileData
=
data
});
function
loadTileset
()
{
//loads tileset after submit button is clicked
/*
FIXME: -load the models but the are in the too high in the "air"
-building view doesn´t work because all buildings are grouped together
-surfaces are also broken
? maybe add old menu back and the option to also load the new ones
*/
function
loadTileset
()
{
viewer
.
scene
.
primitives
.
remove
(
tileset
)
viewer
.
scene
.
primitives
.
remove
(
tileset
)
tileContent
=
[]
tileContent
=
[]
modal
.
style
.
display
=
"
block
"
;
modal
.
style
.
display
=
"
block
"
;
console
.
log
(
tileData
)
fetchTileset
().
then
(
tilesetJSON
=>
{
tileData
=
tilesetJSON
;
});
var
userurl
=
document
.
getElementById
(
"
3Durl
"
).
value
;
var
userurl
=
document
.
getElementById
(
"
3Durl
"
).
value
;
console
.
log
(
userurl
);
tileset
=
viewer
.
scene
.
primitives
.
add
(
new
Cesium
.
Cesium3DTileset
({
url
:
tilesetURL
}));
console
.
log
(
tileset
);
viewer
.
zoomTo
(
tileset
,
new
Cesium
.
HeadingPitchRange
(
0
,
-
0.5
,
0
));
modal
.
style
.
display
=
"
none
"
;
saveTilesetContent
(
tileset
)
deleteTilesetButtons
()
/*
tileData.collections.forEach(c => {
tileData.collections.forEach(c => {
if (userurl === 'hftcampus' && c.id === "HftCampus") useContent(c.content)
if (userurl === 'hftcampus' && c.id === "HftCampus") useContent(c.content)
if (userurl === 'paderborn' && c.id === "Paderborn") useContent(c.content)
if (userurl === 'paderborn' && c.id === "Paderborn") useContent(c.content)
})
})*/
console
.
log
(
tileData
);
}
}
function
useContent
(
content
)
{
function
useContent
(
content
)
{
content
.
forEach
(
cont
=>
{
content
.
forEach
(
cont
=>
{
var
element
=
document
.
createElement
(
"
input
"
)
var
element
=
document
.
createElement
(
"
input
"
)
element
.
type
=
"
button
"
element
.
type
=
"
button
"
...
@@ -343,9 +376,13 @@ function saveTilesetContent(tileset) {
...
@@ -343,9 +376,13 @@ function saveTilesetContent(tileset) {
function
deleteTilesetButtons
()
{
function
deleteTilesetButtons
()
{
var
x
=
document
.
getElementsByName
(
"
individualTileset
"
)
var
x
=
document
.
getElementsByName
(
"
individualTileset
"
)
var
len
=
x
.
length
var
len
=
x
.
length
parentNode
=
x
[
0
].
parentNode
;
//checking if there are even tileset to delete
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
if
(
x
.
length
>
0
){
parentNode
.
removeChild
(
x
[
0
]);
parentNode
=
x
[
0
].
parentNode
;
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
parentNode
.
removeChild
(
x
[
0
]);
}
}
}
}
}
public/js/globe.js
View file @
d4bb5b19
Cesium
.
Ion
.
defaultAccessToken
=
'
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjNjM5YzFjNC03NWNmLTQ2M2YtOWJiNC0xODNmMTY2ZjkwNTkiLCJpZCI6MzY3NjEsImlhdCI6MTYwMzk4NTU3Nn0.G3fnwzZ50towP1Nv9goyvu0JxJW5GtiudTR7X67Zo84
'
;
Cesium
.
Ion
.
defaultAccessToken
=
'
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjNjM5YzFjNC03NWNmLTQ2M2YtOWJiNC0xODNmMTY2ZjkwNTkiLCJpZCI6MzY3NjEsImlhdCI6MTYwMzk4NTU3Nn0.G3fnwzZ50towP1Nv9goyvu0JxJW5GtiudTR7X67Zo84
'
;
var
roofTiles
=
[
"
PolyIDGeo755601
"
,
"
PolyIDGeo787622
"
,
"
PolyIDGeo135906
"
,
"
PolyIDGeo534180
"
,
"
PolyIDGeo1597157
"
,
"
PolyIDGeo1628130
"
,
"
PolyIDGeo570789
"
,
"
PolyIDGeo206785
"
,
"
PolyIDGeo785307
"
,
"
PolyIDGeo1096586
"
,
"
PolyIDGeo25714307
"
,
"
PolyIDGeo772461
"
,
"
PolyIDGeo25430590
"
];
var
viewer
=
new
Cesium
.
Viewer
(
'
cesiumContainer
'
,
{
var
viewer
=
new
Cesium
.
Viewer
(
'
cesiumContainer
'
,
{
homeButton
:
false
,
homeButton
:
false
,
...
@@ -47,21 +45,16 @@ var highlightedFeatures = [];
...
@@ -47,21 +45,16 @@ var highlightedFeatures = [];
//conatins currently selected features
//conatins currently selected features
var
selectedFeatures
=
[];
var
selectedFeatures
=
[];
var
hoverpid
;
var
hoverpid
;
var
selectpid
;
var
selectpid
;
var
pickedselect
=
true
;
var
pickedselect
=
true
;
var
pickedhigh
=
false
;
var
pickedhigh
=
false
;
var
pickedalreadyselect
=
false
;
var
pickedalreadyselect
=
false
;
var
radio
=
document
.
getElementById
(
'
radio-group
'
);
var
radio
=
document
.
getElementById
(
'
radio-group
'
);
//selected gmlID
//selected gmlID
var
gmlID
var
gmlID
;
radio
.
addEventListener
(
'
click
'
,
function
()
{
radio
.
addEventListener
(
'
click
'
,
function
()
{
//hide chart for individual buildings
//hide chart for individual buildings
...
@@ -105,6 +98,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
...
@@ -105,6 +98,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
return
;
return
;
}
}
//SURFACE-VIEW
if
(
document
.
getElementById
(
"
surface
"
).
checked
)
{
if
(
document
.
getElementById
(
"
surface
"
).
checked
)
{
// A feature was picked, so show it's overlay content
// A feature was picked, so show it's overlay content
...
@@ -117,7 +111,6 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
...
@@ -117,7 +111,6 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
return
;
return
;
}
}
var
name
=
pickedFeature
.
getProperty
(
"
gml_id
"
);
var
name
=
pickedFeature
.
getProperty
(
"
gml_id
"
);
nameOverlay
.
textContent
=
name
;
nameOverlay
.
textContent
=
name
;
...
@@ -133,42 +126,26 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
...
@@ -133,42 +126,26 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
if
(
pickedselect
)
{
if
(
pickedselect
)
{
tileContent
.
forEach
(
t
=>
{
tileContent
.
forEach
(
t
=>
{
if
(
t
===
pickedFeature
)
{
if
(
t
===
pickedFeature
)
{
highlightedFeatures
.
push
(
new
featurevar
(
t
,
t
.
color
));
if
(
t
.
getProperty
(
"
feature_type
"
)
===
"
RoofSurface
"
){
t
.
color
=
Cesium
.
Color
.
YELLOW
;
highlightedFeatures
.
push
(
new
featurevar
(
t
,
t
.
color
));
}
//t.color = randomRoofColor();
});
t
.
color
=
Cesium
.
Color
.
GREEN
;
}
}
//TODO: add roof selection
else
if
(
document
.
getElementById
(
"
roof
"
).
checked
){
tileContent
.
forEach
(
t
=>
{
if
(
t
===
pickedFeature
)
{
console
.
log
(
t
.
getProperty
(
"
gml_id
"
));
console
.
log
(
t
);
}
roofTiles
.
forEach
(
rt
=>
{
if
(
t
.
getProperty
(
"
gml_id
"
)
===
rt
){
var
a
=
Math
.
floor
(
Math
.
random
()
*
3
);
if
(
a
==
1
){
t
.
color
=
Cesium
.
Color
.
RED
;
}
else
if
(
0
){
t
.
color
=
Cesium
.
Color
.
YELLOW
;
}
else
{
}
else
{
t
.
color
=
Cesium
.
Color
.
GREEN
;
highlightedFeatures
.
push
(
new
featurevar
(
t
,
t
.
color
));
t
.
color
=
Cesium
.
Color
.
YELLOW
;
}
}
}
})
});
}
//debugging - getting all info of the clicked surface
//console.log(t.getPropertyNames());
console
.
log
(
t
.
getProperty
(
"
description
"
)
+
"
\n
"
+
t
.
getProperty
(
"
feature_type
"
)
+
"
\n
"
+
t
.
getProperty
(
"
gml_id
"
)
+
"
\n
"
+
t
.
getProperty
(
"
gml_parent_id
"
));
}
});
}
}
else
{
else
{
// A feature was picked, so show it's overlay content
// A feature was picked, so show it's overlay content
...
@@ -183,7 +160,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
...
@@ -183,7 +160,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
name
=
pickedFeature
.
getProperty
(
"
gml_parent_id
"
);
name
=
pickedFeature
.
getProperty
(
"
gml_parent_id
"
);
hoverpid
=
name
hoverpid
=
name
;
nameOverlay
.
textContent
=
name
;
nameOverlay
.
textContent
=
name
;
// Highlight the feature if it's not already selected.
// Highlight the feature if it's not already selected.
...
@@ -199,6 +176,8 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
...
@@ -199,6 +176,8 @@ viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
},
},
Cesium
.
ScreenSpaceEventType
.
MOUSE_MOVE
);
Cesium
.
ScreenSpaceEventType
.
MOUSE_MOVE
);
//-----------------------------------------------------------------------------------------------
var
pickBuildingFunction
var
pickBuildingFunction
var
pickYearOfConstruction
var
pickYearOfConstruction
var
pickHeight
var
pickHeight
...
@@ -322,7 +301,6 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
...
@@ -322,7 +301,6 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
}
}
else
{
else
{
//save the selected feature's original color
//save the selected feature's original color
if
(
pickedhigh
)
{
if
(
pickedhigh
)
{
highlightedFeatures
.
forEach
(
h
=>
{
highlightedFeatures
.
forEach
(
h
=>
{
...
@@ -374,13 +352,11 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
...
@@ -374,13 +352,11 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
}
}
},
},
Cesium
.
ScreenSpaceEventType
.
LEFT_CLICK
);
Cesium
.
ScreenSpaceEventType
.
LEFT_CLICK
);
//filling the table in the info sidebar with data
function
fillTableProperties
(
gID
,
sID
)
{
function
fillTableProperties
(
gID
,
sID
)
{
if
(
drawBox
===
false
)
{
if
(
drawBox
===
false
)
{
...
@@ -445,3 +421,13 @@ function fillTableProperties(gID, sID) {
...
@@ -445,3 +421,13 @@ function fillTableProperties(gID, sID) {
}
}
}
}
function
randomRoofColor
(){
var
r
=
Math
.
floor
(
Math
.
random
()
*
10
);
var
shade
=
29
*
r
;
var
color
=
new
Cesium
.
Color
;
Cesium
.
Color
.
fromBytes
(
shade
,
shade
,
shade
,
255
,
color
);
//console.log(color);
return
color
;
}
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