Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codeplug: Negative Geo Coordinates close to zero #40

Open
marcoSchr opened this issue Feb 28, 2024 · 4 comments
Open

Codeplug: Negative Geo Coordinates close to zero #40

marcoSchr opened this issue Feb 28, 2024 · 4 comments

Comments

@marcoSchr
Copy link
Contributor

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
Copy link
Contributor

silseva commented Feb 29, 2024

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
Copy link
Contributor

silseva commented Mar 2, 2024

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.

silseva added a commit that referenced this issue Mar 2, 2024
Updated the format used to store transmitter location:
- removed the +500m offset for altitude, converted the value to a signed type
- fix an error with negative coordinates close to zero, see #40.
@marcoSchr
Copy link
Contributor Author

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

@silseva
Copy link
Contributor

silseva commented Mar 6, 2024

Will do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants