3 ms·
In a map project, I had markers stored in PostgreSQL + PostGIS database. As the amount of markers got too heavy for the browser, I tried only querying markers
by MzHN 10y ago
In a map project, I had markers stored in PostgreSQL + PostGIS database.
As the amount of markers got too heavy for the browser, I tried only querying markers within a certain range of a coordinate I was visualizing.
For some reason, no matter what coordinate systems, data type casting and PostGIS functions I tried, I would always get an ellipse-shaped area of markers, where the north-south distance was twice the expected, and the west-east distance was as it should be.
As I realized that the issue was consistent, and always exactly double, I decided on a crazy workaround: I added math to the distance query, to divide the latitude coordinate by 2 and then order the results by distance and LIMIT 1000 closest markers this way.
Voilà, perfect circle on the map!
Even though the resulting coordinates were completely off, it did not matter, because only the distance comparison used the wrong coordinates.