Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
3DClient4SimStadtAPI
Commits
613d4534
Commit
613d4534
authored
3 years ago
by
BujarMuharemi
Browse files
Options
Download
Email Patches
Plain Diff
pvPotential data can be fetched from the API
parent
3e74ace5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/js/connectToAPI.js
+47
-3
public/js/connectToAPI.js
with
47 additions
and
3 deletions
+47
-3
public/js/connectToAPI.js
+
47
-
3
View file @
613d4534
...
...
@@ -2,6 +2,8 @@ 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:8082/workflow/execute
"
// URL to API
var
url2
=
"
http://vm24.fkc.hft-stuttgart.de:8082/workflow/timedShadowValueByDay/
"
var
pvURL
=
"
http://vm24.fkc.hft-stuttgart.de:8082/workflow/readPVPotential
"
/*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)
*/
...
...
@@ -16,6 +18,35 @@ var roofTypeSortPick
var
uValueSortPick
var
shadowdata
async
function
fetchPvPotentialJSON
()
{
var
bottomLat
=
coordinatesBB
[
1
]
var
leftLng
=
coordinatesBB
[
0
]
var
rightLng
=
coordinatesBB
[
2
]
var
topLat
=
coordinatesBB
[
3
]
const
response
=
await
fetch
(
pvURL
,
{
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
fetchshadowDataJSON
()
{
var
bottomLat
=
coordinatesBB
[
1
]
var
leftLng
=
coordinatesBB
[
0
]
...
...
@@ -45,7 +76,6 @@ async function fetchshadowDataJSON() {
}
async
function
fetchDataJSON
()
{
var
bottomLat
=
coordinatesBB
[
1
]
var
leftLng
=
coordinatesBB
[
0
]
...
...
@@ -104,6 +134,7 @@ async function getLocalShadowdata(){
function
processData
()
{
console
.
log
(
coordinatesBB
)
console
.
log
(
"
Waiting for data....
"
)
timeout
(
25000
,
fetchshadowDataJSON
()).
then
((
response
)
=>
{
console
.
log
(
response
)
shadowdata
=
response
;
...
...
@@ -112,16 +143,28 @@ function processData() {
console
.
log
(
shadowdata
);
//loadLocalAPIshadowData here...
})
timeout
(
10000
,
fetchPvPotentialJSON
()).
then
((
response
)
=>
{
console
.
log
(
response
)
}).
catch
((
error
)
=>
{
console
.
log
(
error
)
})
timeout
(
1000
,
fetchDataJSON
()).
then
((
response
)
=>
{
timeout
(
1000
0
,
fetchDataJSON
()).
then
((
response
)
=>
{
calculateData
(
response
);
}).
catch
((
error
)
=>
{
console
.
log
(
error
)
/*
fetch("/3dclient4simstadtapi/public/test/APIdata/buildingInformation.json")
.then(response => response.text())
.then(text => calculateData( JSON.parse(text)))
*/
})
}
...
...
@@ -407,7 +450,8 @@ function loadAndZoomToTileset(url){
tileset
=
viewer
.
scene
.
primitives
.
add
(
new
Cesium
.
Cesium3DTileset
({
url
:
url
}));
viewer
.
zoomTo
(
tileset
,
new
Cesium
.
HeadingPitchRange
(
0
,
-
0.5
,
0
));
modal
.
style
.
display
=
"
none
"
;
saveTilesetContent
(
tileset
)
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets