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
2 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Human readable area
parent
05caa4b2
Pipeline
#7323
passed with stage
in 34 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
+1
-2
...stadt/regionchooser/website/script/simstadt_openlayers.js
src/main/resources/eu/simstadt/regionchooser/website/script/utils.js
+10
-0
...sources/eu/simstadt/regionchooser/website/script/utils.js
with
11 additions
and
2 deletions
+11
-2
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
+
1
-
2
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
'
+
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/eu/simstadt/regionchooser/website/script/utils.js
+
10
-
0
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²
"
;
}
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