summaryrefslogtreecommitdiffstats
path: root/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-05-20 12:25:46 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-20 10:34:10 -0700
commit187f7dab9fb6fba4ee798beda707e82b1aeb32f0 (patch)
tree9437285e952a079f11d5a3bd0707433da093096c /qthelper.cpp
parent0e78915c7e28166872039ba31448fe7615fb4661 (diff)
downloadsubsurface-187f7dab9fb6fba4ee798beda707e82b1aeb32f0.tar.gz
Add option to display GPS coordinates as decimals
This adds a field to the units preferences to have GPS coordinates show as decimals (as for example Google maps does it). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qthelper.cpp')
-rw-r--r--qthelper.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/qthelper.cpp b/qthelper.cpp
index 030ed94c9..bbe908e6f 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -84,19 +84,23 @@ extern "C" const char *printGPSCoords(int lat, int lon)
if (!lat && !lon)
return strdup("");
- lath = lat >= 0 ? translate("gettextFromC", "N") : translate("gettextFromC", "S");
- lonh = lon >= 0 ? translate("gettextFromC", "E") : translate("gettextFromC", "W");
- lat = abs(lat);
- lon = abs(lon);
- latdeg = lat / 1000000U;
- londeg = lon / 1000000U;
- latmin = (lat % 1000000U) * 60U;
- lonmin = (lon % 1000000U) * 60U;
- latsec = (latmin % 1000000) * 60;
- lonsec = (lonmin % 1000000) * 60;
- result.sprintf("%u%s%02d\'%06.3f\"%s %u%s%02d\'%06.3f\"%s",
- latdeg, UTF8_DEGREE, latmin / 1000000, latsec / 1000000, lath.toUtf8().data(),
- londeg, UTF8_DEGREE, lonmin / 1000000, lonsec / 1000000, lonh.toUtf8().data());
+ if (prefs.coordinates_traditional) {
+ lath = lat >= 0 ? translate("gettextFromC", "N") : translate("gettextFromC", "S");
+ lonh = lon >= 0 ? translate("gettextFromC", "E") : translate("gettextFromC", "W");
+ lat = abs(lat);
+ lon = abs(lon);
+ latdeg = lat / 1000000U;
+ londeg = lon / 1000000U;
+ latmin = (lat % 1000000U) * 60U;
+ lonmin = (lon % 1000000U) * 60U;
+ latsec = (latmin % 1000000) * 60;
+ lonsec = (lonmin % 1000000) * 60;
+ result.sprintf("%u%s%02d\'%06.3f\"%s %u%s%02d\'%06.3f\"%s",
+ latdeg, UTF8_DEGREE, latmin / 1000000, latsec / 1000000, lath.toUtf8().data(),
+ londeg, UTF8_DEGREE, lonmin / 1000000, lonsec / 1000000, lonh.toUtf8().data());
+ } else {
+ result.sprintf("%f %f", (double) lat / 1000000.0, (double) lon / 1000000.0);
+ }
return strdup(result.toUtf8().data());
}