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
39b61e30
Commit
39b61e30
authored
Nov 24, 2021
by
Izairi
Browse files
add fetch function and print output console
parent
f971529d
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/js/connectToAPI.js
View file @
39b61e30
var
coordinatesBB
=
[]
//var url = "https://simstadt-api.iaf-ex.hft-stuttgart.de:8080/workflow/execute" //old link
var
url
=
"
http://vm24.fkc.hft-stuttgart.de:808
0
/workflow/execute
"
// URL to API
var
url
=
"
http://vm24.fkc.hft-stuttgart.de:808
2
/workflow/execute
"
// URL to API
var
url2
=
"
http://vm24.fkc.hft-stuttgart.de:8082/workflow/timedShadowValueByDay/
"
/*TODO#1: -get current data from the api and create local test data (apiData foler)
-add connection handeling (error messages when there isnt a connection and then using the local test data)
*/
...
...
@@ -15,13 +15,41 @@ var totalSurfaceAreaSortPick
var
roofTypeSortPick
var
uValueSortPick
async
function
fetchshadowDataJSON
()
{
var
bottomLat
=
coordinatesBB
[
1
]
var
leftLng
=
coordinatesBB
[
0
]
var
rightLng
=
coordinatesBB
[
2
]
var
topLat
=
coordinatesBB
[
3
]
//
var
day
=
5
;
const
response
=
await
fetch
(
url2
+
day
,
{
method
:
"
POST
"
,
body
:
JSON
.
stringify
({
"
boundingBox
"
:
{
"
bottomLat
"
:
bottomLat
,
//48.779004965,
"
leftLng
"
:
leftLng
,
//9.1686843081,
"
lodType
"
:
"
LOD2
"
,
"
rightLng
"
:
rightLng
,
//9.175336684,
"
topLat
"
:
topLat
//48.7822869656
},
"
cityGMLRef
"
:
"
campusLOD2
"
}),
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
"
Authorization
"
:
"
Basic YWRtaW46YWRtaW4xMjM=
"
}
})
const
data
=
await
response
.
json
()
return
data
}
async
function
fetchDataJSON
()
{
var
bottomLat
=
coordinatesBB
[
1
]
var
leftLng
=
coordinatesBB
[
0
]
var
rightLng
=
coordinatesBB
[
2
]
var
topLat
=
coordinatesBB
[
3
]
//
const
response
=
await
fetch
(
url
,
{
const
response
=
await
fetch
(
url
,
{
method
:
"
POST
"
,
body
:
JSON
.
stringify
({
"
boundingBox
"
:
{
...
...
@@ -39,8 +67,8 @@ async function fetchDataJSON() {
"
heatedVolume
"
,
"
yearOfConstruction
"
,
"
buildingFunction
"
,
"
monthlyHeating
"
,
"
monthlyCooling
"
,
//
"monthlyHeating",
//
"monthlyCooling",
"
pvPotential
"
,
"
roofType
"
,
"
totalSurfaceArea
"
...
...
@@ -57,6 +85,7 @@ async function fetchDataJSON() {
const
data
=
await
response
.
json
()
return
data
}
document
.
getElementById
(
"
loader
"
).
style
.
visibility
=
"
hidden
"
...
...
@@ -64,7 +93,9 @@ function processData() {
console
.
log
(
coordinatesBB
)
console
.
log
(
"
Waiting for data....
"
)
fetchshadowDataJSON
().
then
(
data
=>
{
console
.
log
(
data
)
})
fetchDataJSON
().
then
(
data
=>
{
console
.
log
(
data
);
document
.
getElementById
(
"
cesiumContainer
"
).
style
.
opacity
=
"
1
"
;
...
...
@@ -293,7 +324,7 @@ window.onclick = function (event) {
//-------------------------------------------------------------------------------
var
tileData
=
null
;
var
tileset
=
null
;
var
tilesetURL
=
'
http://vm24.fkc.hft-stuttgart.de:8081/CampusLOD2
/CityModel
/tileset.json
'
;
var
tilesetURL
=
'
http://vm24.fkc.hft-stuttgart.de:8081/CampusLOD2
Old
/tileset.json
'
;
var
localTestTileset
=
'
/3dclient4simstadtapi/public/test/gmlTileset_v1.json
'
;
...
...
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