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

Propose to store the geographic rectangles in Integer rather than in Float #97

Open
tibetty opened this issue Sep 14, 2019 · 0 comments

Comments

@tibetty
Copy link

tibetty commented Sep 14, 2019

As we know a single precision float (Float type in Java) has only 7 decimal digits precision (include the integral part), so for longitude the absolution value of which is greater than 100, it has only 4 decimal digits for fractional part. I've calculated and analyzed the possible distance deviation caused by different precision, and 0.0001 longitude difference will lead to about 11m deviation on the equator.

To improve the accuracy meanwhile save the memory/storage usage, a widely applied measure in geospatial industry is to multiply longitude/latitude with a certain multiplier from 1e5 up to 1e7 (1e8 will cause an overflow) and round it to a 32 bit integer (Integer in Java), and the corresponding derivation will be 1.1m to 1.1cm, more accurate than Float.

Besides, under nowadays computer architecture, an int calculation will be faster than a fp, so this change might lead to a slight performance improvement as well.

Any suggestions?

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

1 participant