OpenRTX / openrtx.github.io

12 stars 15 forks source link

Codeplug: Negative Geo Coordinates close to zero #40

Open marcoSchr opened 6 months ago

marcoSchr commented 6 months ago

The geo coordinates as described do not support negative coordinates close to 0, as an integer only has one value for 0. A value like -0.09 N would become 0 for the integer part, which we can not differentiate.

silseva commented 6 months ago

Instead of using the current format for the coordinates, we can store them in Q1.15 or Q1.31 fixed point format, which one is better in terms of resolution. Another possibility is to use a Q8.24 format. Using 32 bit per coordinate we'll use 64 bit for lat. + lon. instead of 48, but is not a problem

silseva commented 6 months ago

Proposal: use a signed 32 bit value for both longitude and latitude and store the values multiplied by 1000. That is: given a coordinate of 123.4567890°, store it as 1234567890 in an int32_t. This allows to store coordinates with a resolution of approximately ±1cm and solves the problem of the sign. Moreover, it just requires a multiplication/division by 1000 when storing and retrieving data expressed in decimal degrees.

marcoSchr commented 6 months ago

This sounds good. You should change the factor to 1.000.000 in you commit, as intended to show 6 decimal places.

silseva commented 6 months ago

Will do!