clarisma / geodesk-py

Fast and storage-efficient spatial database engine for OpenStreetMap data
https://docs.geodesk.com/python
GNU Lesser General Public License v3.0
36 stars 0 forks source link

Mercator: scaling factor is off at extreme latitudes #33

Closed clarisma closed 8 months ago

clarisma commented 8 months ago

Use a different calculation: convert y back to lat, then calculate 1 / cos(lat)

Partially responsible for #20.

Also affects Java.

clarisma commented 8 months ago

No, not a bug.

1 / std::cos(latFromY(y) * M_PI / 180.0)

and

std::cosh(y * 2.0 * M_PI / MAP_WIDTH)

are equivalent up to the max mercator latitude (85.0511)