diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-10 11:14:50 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-10 11:55:45 -0800 |
commit | 68eca79dfdaec7dfd1c534f1d8daf8421ea94579 (patch) | |
tree | 96541b4ca7386f8ab553ddf66ac7ed6484572c51 /info.c | |
parent | b652d4e1abd9e391e48d1b5db2cb87dc00e5aa2f (diff) | |
download | subsurface-68eca79dfdaec7dfd1c534f1d8daf8421ea94579.tar.gz |
Fix rounding of GPS coordinates
The whole "+ 0.5" to round to integers only works for positive values,
and GPS coordinates are signed.
So use the proper "round to int" function (rint()), which does this correctly.
Also, remove the redundant check against the master gps values: we
already checked that if we do have a master dive, the gps values must
match the currently edited dive, so comparing against the master is
entirely redundant.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'info.c')
-rw-r--r-- | info.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -506,12 +506,9 @@ static gboolean gps_changed(struct dive *dive, struct dive *master, const char * if (!parse_gps_text(gps_text, &latitude, &longitude)) return FALSE; - latudeg = 1000000 * latitude + 0.5; - longudeg = 1000000 * longitude + 0.5; + latudeg = rint(1000000 * latitude); + longudeg = rint(1000000 * longitude); - /* if master gps didn't change, don't change dive */ - if (master && master->latitude.udeg == latudeg && master->longitude.udeg == longudeg) - return FALSE; /* if dive gps didn't change, nothing changed */ if (dive->latitude.udeg == latudeg && dive->longitude.udeg == longudeg) return FALSE; |