Fix rounding of GPS coordinates

Linus Torvalds torvalds at linux-foundation.org
Sun Feb 10 11:39:44 PST 2013


On Sun, Feb 10, 2013 at 11:14 AM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
> 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.

Btw, this bug actually seems to cause more failures than just rounding errors.

What seems to happen is:

 - before editing the dive, we copy the dive information to the
"edit_dive" which will now be the master information

 - gps_map_callback() will do "gps_changed()" on the dive, which will
*change* the dive location due to the gps_text resulting in a rounding
error

 - now the dive gps will not match the master dive any more, so it
will refuse to change it again

 - when we press "ok" to actually finalize the data, the lack of
master matching again results in us not actually changing the location
at all.

Even with the rounding fix, this seems to happen (for the same reason)
if you just pick a location twice using the map widget before you
press "Ok".

So the whole map widget editing seems a bit bogus. I think that
"gps_changed()" call in gps_map_callback() is wrong, exactly because
it changes the dive settings before the OK button has been pressed.

Dirk, please double-check me.

                     Linus


More information about the subsurface mailing list