Skip to content

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

@tibetty

Description

@tibetty

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions