From: maxious Date: Wed, 16 Mar 2011 08:18:49 +0000 Subject: Round distances to 2 decimal place kilometers X-Git-Url: http://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=b5c5993a2a28a6141d107876b198f8e32c720fcd --- Round distances to 2 decimal place kilometers --- --- a/common-geo.inc.php +++ b/common-geo.inc.php @@ -51,7 +51,7 @@ if ($collapsible) $output.= ''; return $output; } -function distance($lat1, $lng1, $lat2, $lng2) +function distance($lat1, $lng1, $lat2, $lng2, $roundLargeValues = false) { $pi80 = M_PI / 180; $lat1*= $pi80; @@ -64,7 +64,10 @@ $a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2); $c = 2 * atan2(sqrt($a) , sqrt(1 - $a)); $km = $r * $c; - return $km * 1000; + if ($roundLargeValues) { + if ($km < 1) return floor($km * 1000); + else return round($km,2)."k"; + } else return floor($km * 1000); } function decodePolylineToArray($encoded) { --- a/stopList.php +++ b/stopList.php @@ -63,7 +63,7 @@ timePlaceSettings(); } echo ' '; - var_dump ($stopsGrouped); } include_footer(); ?>