summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-12-05 09:59:52 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-05 10:34:02 -0800
commit5e5e3460acf9d29b03aff71228aff01e31a3bf45 (patch)
tree07629133d0d9ea1948692690929582ae9029e12e /save-xml.c
parent708df33539ef3b6d3cfde435df93fd4475cdde75 (diff)
downloadsubsurface-5e5e3460acf9d29b03aff71228aff01e31a3bf45.tar.gz
Turn latitude and longitude into integer micro-degree values
This actually makes us internally use 'micro-degrees' for latitude and longitude, and we never turn them into floating point either at parse time or save time. That said, the Uemis downloader internally does still use atof() when converting things, which is likely a bug (locale issues and all that), but I'll ask Dirk to check it out. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/save-xml.c b/save-xml.c
index 948f2ed08..5dc47795f 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -4,7 +4,6 @@
#include <stdlib.h>
#include <errno.h>
#include <time.h>
-#include <math.h>
#include "dive.h"
@@ -183,9 +182,9 @@ static void save_salinity(FILE *f, struct dive *dive)
* on a great circle (ie longitude at equator). And micro-degrees
* is also enough to fit in a fixed-point 32-bit integer.
*/
-static int format_degrees(char *buffer, double value)
+static int format_degrees(char *buffer, degrees_t value)
{
- int udeg = round(value * 1000000.0);
+ int udeg = value.udeg;
const char *sign = "";
if (udeg < 0) {
@@ -196,7 +195,7 @@ static int format_degrees(char *buffer, double value)
sign, udeg / 1000000, udeg % 1000000);
}
-static int format_location(char *buffer, double latitude, double longitude)
+static int format_location(char *buffer, degrees_t latitude, degrees_t longitude)
{
int len = sprintf(buffer, "gps='");
@@ -212,8 +211,8 @@ static void show_location(FILE *f, struct dive *dive)
{
char buffer[80];
const char *prefix = " <location>";
- double latitude = dive->latitude;
- double longitude = dive->longitude;
+ degrees_t latitude = dive->latitude;
+ degrees_t longitude = dive->longitude;
/*
* Ok, theoretically I guess you could dive at
@@ -221,7 +220,7 @@ static void show_location(FILE *f, struct dive *dive)
* if you do, just fudge it a bit, and say that
* you dove a few meters away.
*/
- if (latitude || longitude) {
+ if (latitude.udeg || longitude.udeg) {
int len = sprintf(buffer, " <location ");
len += format_location(buffer+len, latitude, longitude);