Commit 581501af authored by Eric Duminil's avatar Eric Duminil
Browse files

Human readable area

parent 05caa4b2
Pipeline #7323 passed with stage
in 34 seconds
......@@ -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' +
......
......@@ -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) + "";
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment