mapbox / tippecanoe

Build vector tilesets from large collections of GeoJSON features.
BSD 2-Clause "Simplified" License
2.72k stars 432 forks source link

Coordinate rounding is different from Mapnik #153

Open e-n-f opened 8 years ago

e-n-f commented 8 years ago

WGS84 coordinates are usually not exact multiples of tile coordinates. When they are not, Tippecanoe rounds toward the top left, by doing the projection math as precisely as possible and then masking off low-order bits. It looks like Mapnik rounds toward the equator and prime meridian instead.

The symptom is that (at z0) in Tippecanoe [ -1, -1 ] will appear as [ -1.054688, -0.966751 ], but [ 1, 1 ] will appear as [ 0.966797, 1.054628 ]. In Mapnik, they are [ -0.966797, -0.966751 ] and [ 0.966797, 0.966751 ].

e-n-f commented 8 years ago

The other thing along these lines that could be a problem is that to_tile_scale() converts from world coordinates to tile coordinates by shifting, which may do strange things with negative numbers. On most CPUs this will be an arithmetic shift and will round downward, as opposed to division which will round toward zero, but if it is interpreted as a logical shift without sign-extension it will be completely wrong.

e-n-f commented 1 year ago

This will be fixed in https://github.com/felt/tippecanoe/pull/60