Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
3DClient4SimStadtAPI
Commits
5f7d44be
Commit
5f7d44be
authored
Nov 25, 2021
by
BujarMuharemi
Browse files
added attributes to surfaceview
parent
9b02ecb7
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/js/connectToAPI.js
View file @
5f7d44be
var
coordinatesBB
=
[]
var
coordinatesBB
=
[]
//var url = "https://simstadt-api.iaf-ex.hft-stuttgart.de:8080/workflow/execute" //old link
//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:808
3
/workflow/timedShadowValueByDay/
"
var
url2
=
"
http://vm24.fkc.hft-stuttgart.de:808
2
/workflow/timedShadowValueByDay/
"
/*TODO#1: -get current data from the api and create local test data (apiData foler)
/*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)
-add connection handeling (error messages when there isnt a connection and then using the local test data)
*/
*/
...
@@ -21,7 +21,7 @@ async function fetchshadowDataJSON() {
...
@@ -21,7 +21,7 @@ async function fetchshadowDataJSON() {
var
leftLng
=
coordinatesBB
[
0
]
var
leftLng
=
coordinatesBB
[
0
]
var
rightLng
=
coordinatesBB
[
2
]
var
rightLng
=
coordinatesBB
[
2
]
var
topLat
=
coordinatesBB
[
3
]
//
var
topLat
=
coordinatesBB
[
3
]
//
var
day
=
5
;
var
day
=
"
1
"
;
const
response
=
await
fetch
(
url2
+
day
,
{
const
response
=
await
fetch
(
url2
+
day
,
{
method
:
"
POST
"
,
method
:
"
POST
"
,
body
:
JSON
.
stringify
({
body
:
JSON
.
stringify
({
...
@@ -38,15 +38,14 @@ async function fetchshadowDataJSON() {
...
@@ -38,15 +38,14 @@ async function fetchshadowDataJSON() {
"
Content-Type
"
:
"
application/json
"
,
"
Content-Type
"
:
"
application/json
"
,
"
Authorization
"
:
"
Basic YWRtaW46YWRtaW4xMjM=
"
"
Authorization
"
:
"
Basic YWRtaW46YWRtaW4xMjM=
"
}
}
}).
then
(
function
()
{
console
.
log
(
"
ok
"
);
}).
catch
(
function
()
{
alert
(
"
Connetion error to server, use local data
"
)
})
})
const
data
=
await
response
.
json
()
const
data
=
await
response
.
json
();
return
data
return
data
}
}
async
function
fetchDataJSON
()
{
async
function
fetchDataJSON
()
{
var
bottomLat
=
coordinatesBB
[
1
]
var
bottomLat
=
coordinatesBB
[
1
]
var
leftLng
=
coordinatesBB
[
0
]
var
leftLng
=
coordinatesBB
[
0
]
...
@@ -71,8 +70,8 @@ const response = await fetch(url, {
...
@@ -71,8 +70,8 @@ const response = await fetch(url, {
"
heatedVolume
"
,
"
heatedVolume
"
,
"
yearOfConstruction
"
,
"
yearOfConstruction
"
,
"
buildingFunction
"
,
"
buildingFunction
"
,
//
"monthlyHeating",
"
monthlyHeating
"
,
//
"monthlyCooling",
"
monthlyCooling
"
,
"
pvPotential
"
,
"
pvPotential
"
,
"
roofType
"
,
"
roofType
"
,
"
totalSurfaceArea
"
"
totalSurfaceArea
"
...
@@ -97,9 +96,18 @@ function processData() {
...
@@ -97,9 +96,18 @@ function processData() {
console
.
log
(
coordinatesBB
)
console
.
log
(
coordinatesBB
)
console
.
log
(
"
Waiting for data....
"
)
console
.
log
(
"
Waiting for data....
"
)
fetchshadowDataJSON
().
then
(
data
=>
{
console
.
log
(
data
)
})
timeout
(
25000
,
fetchshadowDataJSON
()).
then
((
response
)
=>
{
console
.
log
(
response
)
}).
catch
((
error
)
=>
{
//catching the error(no connection)/ timeout and displaying an alert for the user
swal
({
text
:
"
Could not connect to Server. Using now: local data
"
,
icon
:
"
info
"
}
);
console
.
log
(
"
Using local test data
"
);
//loadLocalAPIshadowData here...
})
fetchDataJSON
().
then
(
data
=>
{
fetchDataJSON
().
then
(
data
=>
{
console
.
log
(
data
);
console
.
log
(
data
);
document
.
getElementById
(
"
cesiumContainer
"
).
style
.
opacity
=
"
1
"
;
document
.
getElementById
(
"
cesiumContainer
"
).
style
.
opacity
=
"
1
"
;
...
...
public/js/globe.js
View file @
5f7d44be
...
@@ -286,7 +286,6 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
...
@@ -286,7 +286,6 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
}
}
//set feature infobox description
//set feature infobox description
var
featureName
=
pickedFeature
.
getProperty
(
"
name
"
);
var
featureName
=
pickedFeature
.
getProperty
(
"
name
"
);
selectedEntity
.
name
=
featureName
;
selectedEntity
.
name
=
featureName
;
...
@@ -296,7 +295,10 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
...
@@ -296,7 +295,10 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
'
<table class="cesium-infoBox-defaultTable"><tbody>
'
+
'
<table class="cesium-infoBox-defaultTable"><tbody>
'
+
"
<tr><th>Surface_ID</th><td>
"
+
pickedFeature
.
getProperty
(
"
gml_id
"
)
+
"
</td></tr>
"
+
"
<tr><th>Surface_ID</th><td>
"
+
pickedFeature
.
getProperty
(
"
gml_id
"
)
+
"
</td></tr>
"
+
"
<tr><th>u_Value</th><td>
"
+
pickUValue
+
"
</td></tr>
"
+
"
<tr><th>u_Value</th><td>
"
+
pickUValue
+
"
</td></tr>
"
+
"
<tr><th>description</th><td>
"
+
pickedFeature
.
getProperty
(
"
description
"
)
+
"
</td></tr>
"
+
"
<tr><th>feature_type</th><td>
"
+
pickedFeature
.
getProperty
(
"
feature_type
"
)
+
"
</td></tr>
"
+
"
</tbody></table>
"
;
"
</tbody></table>
"
;
}
}
else
{
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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