davidmoten / davidmoten/rtree

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

Open
#97 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.1k
Forks
218
Avg merge
2m
Merged PRs (30d)
1

Description

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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.