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
4d223fc2
Commit
4d223fc2
authored
Dec 23, 2021
by
BujarMuharemi
Browse files
finished issue#89 show pvPotentialData of surface
parent
a0a1c873
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/js/connectToAPI.js
View file @
4d223fc2
...
...
@@ -19,6 +19,8 @@ var roofTypeSortPick
var
uValueSortPick
var
shadowdata
var
pvPotentialSurfaces
;
//array which holds the pvpotential of all surfaces
async
function
fetchPvPotentialJSON
()
{
var
bottomLat
=
coordinatesBB
[
1
]
...
...
@@ -127,17 +129,17 @@ async function getLocalShadowdata() {
const
response
=
await
fetch
(
localShadowData
);
//the response have to be converted to json type file, so it can be used
const
data
=
await
response
.
json
();
console
.
log
(
data
)
//
console.log(data)
return
data
;
}
async
function
processData
()
{
console
.
log
(
coordinatesBB
)
console
.
log
(
"
Waiting for data....
"
)
shadowdata
=
await
getLocalShadowdata
()
timeout
(
25000
,
getLocalShadowdata
()).
then
((
response
)
=>
{
console
.
log
(
response
)
//
console.log(response)
shadowdata
=
response
;
}).
catch
((
error
)
=>
{
//catching the error(no connection)/ timeout and displaying an alert for the user
console
.
log
(
shadowdata
);
...
...
@@ -146,7 +148,8 @@ async function processData() {
timeout
(
10000
,
fetchPvPotentialJSON
()).
then
((
response
)
=>
{
//console.log("fetchPvPotentialJSON:", response);
getPvPotentialOfSurfaces
(
response
[
"
buildings
"
]);
pvPotentialSurfaces
=
getPvPotentialOfSurfaces
(
response
[
"
buildings
"
]);
//console.log("pvPotentialSurfaces:",pvPotentialSurfaces);
}).
catch
((
error
)
=>
{
console
.
log
(
error
)
})
...
...
@@ -165,7 +168,7 @@ async function processData() {
function
calculateData
(
data
)
{
console
.
log
(
data
);
//
console.log(data);
document
.
getElementById
(
"
cesiumContainer
"
).
style
.
opacity
=
"
1
"
;
document
.
getElementById
(
"
loader
"
).
style
.
visibility
=
"
hidden
"
console
.
log
(
"
....received data
"
)
...
...
@@ -404,6 +407,7 @@ function timeout(ms, promise) {
})
}
//getting the pvPotential of all surfaces from the pvPotential array, which the api returns
function
getPvPotentialOfSurfaces
(
pvPotentialarray
){
var
pvPotentialArray
=
[];
...
...
@@ -415,7 +419,8 @@ function getPvPotentialOfSurfaces(pvPotentialarray){
)
)
);
console
.
log
(
pvPotentialArray
);
//console.log(pvPotentialArray);
return
pvPotentialArray
;
}
...
...
public/js/globe.js
View file @
4d223fc2
...
...
@@ -199,7 +199,9 @@ var pickHeatedVolume
var
pickTotalSurfaceArea
=
0
var
pickRoofType
var
pickUValue
var
shadowHourValue
=
0
;
var
SurfacePvPotential
=
[];
//Color a feature on selection and show metadata in the InfoBox
...
...
@@ -286,7 +288,8 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
//highlight newly selected feature
tileContent
.
forEach
(
t
=>
{
if
(
t
===
pickedFeature
)
{
console
.
log
(
t
.
getProperty
(
"
description
"
)
+
"
\n
"
+
t
.
getProperty
(
"
feature_type
"
)
+
"
\n
"
+
t
.
getProperty
(
"
gml_id
"
)
+
"
\n
"
+
t
.
getProperty
(
"
gml_parent_id
"
));
//used for debugging, when clicking on a surface
//console.log(t.getProperty("description") + "\n" + t.getProperty("feature_type") + "\n" + t.getProperty("gml_id") + "\n" + t.getProperty("gml_parent_id"));
t
.
color
=
Cesium
.
Color
.
LIME
;
...
...
@@ -301,6 +304,15 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
}
}
//coloring surfaces on pv potential
for
(
const
[
key
,
value
]
of
Object
.
entries
(
pvPotentialSurfaces
))
{
//looping threw the shadowdata array
if
(
value
[
"
id
"
]
===
t
.
getProperty
(
"
gml_id
"
))
{
//checking if the ids of the current surface match the id in the shadowdata array
//console.log("hour:",chosenDate.hour);
console
.
log
(
value
);
SurfacePvPotential
=
value
[
"
attributes
"
][
"
pvPotential
"
][
"
totalInvestment
"
];
}
}
}
});
}
else
{
...
...
@@ -330,7 +342,7 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
"
<tr><th>description</th><td>
"
+
pickedFeature
.
getProperty
(
"
description
"
)
+
"
</td></tr>
"
+
"
<tr><th>feature_type</th><td>
"
+
pickedFeature
.
getProperty
(
"
feature_type
"
)
+
"
</td></tr>
"
+
"
<tr><th>shadow value</th><td>
"
+
shadowhourvaluepercent
.
toFixed
(
1
)
+
"
%
"
+
"
</td></tr>
"
+
"
<tr><th>totalInvestment</th><td>
"
+
SurfacePvPotential
+
"
</td></tr>
"
+
"
</tbody></table>
"
;
...
...
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