mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
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>
This commit is contained in:
parent
b652d4e1ab
commit
68eca79dfd
1 changed files with 2 additions and 5 deletions
7
info.c
7
info.c
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue