From 96a7ddb7604b4f422e2fdff3078e80109efed4dd Mon Sep 17 00:00:00 2001 From: jim-p Date: Sun, 3 Mar 2013 20:02:34 -0500 Subject: [PATCH] Fix GPS lat/lon code to properly convert to the format Google wants for the link. --- usr/local/www/status_ntpd.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/usr/local/www/status_ntpd.php b/usr/local/www/status_ntpd.php index 2b9ac72cf2..30cf18e7fe 100644 --- a/usr/local/www/status_ntpd.php +++ b/usr/local/www/status_ntpd.php @@ -100,8 +100,14 @@ foreach ($ntpq_clockvar_output as $line) { if (substr($tmp, 0, 6) == '$GPRMC') { $gps_vars = explode(",", $tmp); $gps_ok = ($gps_vars[2] == "A"); - $gps_lat = $gps_vars[3] / 100.0 . $gps_vars[4]; - $gps_lon = $gps_vars[5] / 100.0 . $gps_vars[6]; + $gps_lat_deg = substr($gps_vars[3], 0, 2); + $gps_lat_min = substr($gps_vars[3], 2) / 60.0; + $gps_lon_deg = substr($gps_vars[5], 0, 3); + $gps_lon_min = substr($gps_vars[5], 3) / 60.0; + $gps_lat = $gps_lat_deg + $gps_lat_min; + $gps_lat = $gps_lat * (($gps_vars[4] == "N") ? 1 : -1); + $gps_lon = $gps_lon_deg + $gps_lon_min; + $gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1); } } } @@ -188,8 +194,8 @@ include("head.inc"); - - + (° ) + (° ) Google Maps Link