Fix rounding of GPS coordinates

Dirk Hohndel dirk at hohndel.org
Sun Feb 10 12:08:24 PST 2013


Linus Torvalds <torvalds at linux-foundation.org> writes:

> 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

Yeah, that's not good.

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

yep

>  - 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.

Which is odd since I tested that part and it used to work. But clearly I
must have changed the flow since then

> 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.

Your analysis seems correct

/D


More information about the subsurface mailing list