From 626e3238f27d972614ad3c0e978605facf0f9bd2 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Wed, 11 Dec 2019 00:49:32 +0100 Subject: [PATCH] details page: differentiate between spheric distance and distance in meters --- lib/template/details-html.php | 39 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/template/details-html.php b/lib/template/details-html.php index cfba6eb3..f0798773 100644 --- a/lib/template/details-html.php +++ b/lib/template/details-html.php @@ -20,20 +20,25 @@ } - function format_distance($fDistance) + function format_distance($fDistance, $bInMeters = false) { - // $fDistance is in meters - if ($fDistance < 1) - { - return '0'; - } - elseif ($fDistance < 1000) - { - return'~'.(round($fDistance,0)).' m'; - } - else - { - return'~'.(round($fDistance/1000,1)).' km'; + if ($bInMeters) { + // $fDistance is in meters + if ($fDistance < 1) { + return '0'; + } + elseif ($fDistance < 1000) { + return '~'.(round($fDistance,0)).' m'; + } + else { + return '~'.(round($fDistance/1000,1)).' km'; + } + } else { + if ($fDistance == 0) { + return '0'; + } else { + return ''.(round($fDistance,4)).''; + } } } @@ -60,7 +65,7 @@ } - function _one_row($aAddressLine){ + function _one_row($aAddressLine, $bDistanceInMeters = false){ $bNotUsed = isset($aAddressLine['isaddress']) && !$aAddressLine['isaddress']; echo ''."\n"; @@ -69,7 +74,7 @@ echo ' ' . osmLink($aAddressLine) . "\n"; echo ' ' . (isset($aAddressLine['rank_address']) ? $aAddressLine['rank_address'] : '') . "\n"; echo ' ' . ($aAddressLine['admin_level'] < 15 ? $aAddressLine['admin_level'] : '') . "\n"; - echo ' ' . format_distance($aAddressLine['distance'])."\n"; + echo ' ' . format_distance($aAddressLine['distance'], $bDistanceInMeters)."\n"; echo ' ' . detailsLink($aAddressLine,'details >') . "\n"; echo "\n"; } @@ -173,7 +178,7 @@ { headline('Linked Places'); foreach ($aLinkedLines as $aAddressLine) { - _one_row($aAddressLine); + _one_row($aAddressLine, true); } } @@ -212,7 +217,7 @@ headline3($sGroupHeading); foreach ($aHierarchyLines as $aAddressLine) { - _one_row($aAddressLine); + _one_row($aAddressLine, true); } } if (count($aHierarchyLines) >= 500) { -- 2.39.5