From 44b41c32d2739ec8b28ee3d2d0cdb352b49dab34 Mon Sep 17 00:00:00 2001 From: stac Date: Sun, 5 Sep 2010 23:10:36 +0000 Subject: [PATCH] gpsdisplay: correct lat/lon minute calculation for 3/4 of earth The computation of the minutes portion of the lat/lon was wrong for any negative values. lat-deg was effectively doubling the whole degree part rather than removing it for any negative whole degree part so you would get huge whole minute parts. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1542 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/gpsdisplay/gpsdisplaywidget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ground/src/plugins/gpsdisplay/gpsdisplaywidget.cpp b/ground/src/plugins/gpsdisplay/gpsdisplaywidget.cpp index 5c07cf011..79ba21a70 100644 --- a/ground/src/plugins/gpsdisplay/gpsdisplaywidget.cpp +++ b/ground/src/plugins/gpsdisplay/gpsdisplaywidget.cpp @@ -113,8 +113,8 @@ void GpsDisplayWidget::setPosition(double lat, double lon, double alt) { //lat *= 1E-7; //lon *= 1E-7; - double deg = (lat>0) ? floor(lat):ceil(lat); - double min = fabs(lat-deg)*60; + double deg = floor(fabs(lat)); + double min = (fabs(lat)-deg)*60; QString str1; str1.sprintf("%.0f%c%.3f' ", deg,0x00b0, min); if (lat>0) @@ -122,8 +122,8 @@ void GpsDisplayWidget::setPosition(double lat, double lon, double alt) else str1.append("S"); coord_value->setText(str1); - deg = floor(fabs(lon)); // ABS takes an int. - min = fabs(lon-deg)*60; + deg = floor(fabs(lon)); + min = (fabs(lon)-deg)*60; QString str2; str2.sprintf("%.0f%c%.3f' ", deg,0x00b0, min); if (lon>0)