From ff201c2e8e5ee49ab4493d8e15fcf9143825f776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Wed, 10 Jun 2020 23:51:09 +0200 Subject: [PATCH] MAPG-119 add more area categories --- src/Controller/MapsController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Controller/MapsController.php b/src/Controller/MapsController.php index 95b37a0..33da754 100644 --- a/src/Controller/MapsController.php +++ b/src/Controller/MapsController.php @@ -53,10 +53,18 @@ class MapsController private function formatMapAreaForHuman(float $area): array { - if ($area < 100000.0) { + if ($area < 100.0) { $digits = 0; $rounded = round($area, 0); $unit = 'm'; + } elseif ($area < 100000.0) { + $digits = 0; + $rounded = round($area, -2); + $unit = 'm'; + } elseif ($area < 1000000.0) { + $digits = 2; + $rounded = round($area / 1000000.0, 2); + $unit = 'km'; } elseif ($area < 100000000.0) { $digits = 0; $rounded = round($area / 1000000.0, 0);