Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
581501af
Commit
581501af
authored
Mar 23, 2023
by
Eric Duminil
Browse files
Human readable area
parent
05caa4b2
Pipeline
#7323
passed with stage
in 34 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
View file @
581501af
...
...
@@ -298,8 +298,7 @@ const regionChooser = (function(){
if
(
utils
.
is_polygon
(
geom
)){
// It could be a MultiPolygon, for example.
var
coordinates
=
geom
.
getLinearRing
(
0
).
getCoordinates
();
var
area
=
Math
.
abs
(
wgs84Sphere
.
geodesicArea
(
coordinates
));
//NOTE: Could show m², ha or km² depending on magnitude
dataPanel
.
append
(
"
<h3 class='clean'>Area :
"
+
(
area
/
10000
).
toFixed
(
1
)
+
"
ha
\n
"
);
dataPanel
.
append
(
"
<h3 class='clean'>Area :
"
+
utils
.
human_readable_area
(
area
)
+
"
\n
"
);
}
dataPanel
.
append
(
'
<div style="visibility:hidden" id="download_region">
'
+
'
<button type="button" onclick="regionChooser.downloadFromSelectedCityGMLs()" id="download_region_button" disabled>Download Region</button><br/>
\n
'
+
...
...
src/main/resources/eu/simstadt/regionchooser/website/script/utils.js
View file @
581501af
...
...
@@ -66,3 +66,13 @@ utils.polygon_style = function (color, alpha) {
}),
});
}
utils
.
human_readable_area
=
function
(
area
)
{
if
(
area
>
1
_000_000
)
{
return
(
area
/
1
_000_000
).
toFixed
(
1
)
+
"
km²
"
;
}
if
(
area
>
10
_000
)
{
return
(
area
/
10
_000
).
toFixed
(
1
)
+
"
ha
"
;
}
return
area
.
toFixed
(
1
)
+
"
m²
"
;
}
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