tippecanoe icon indicating copy to clipboard operation
tippecanoe copied to clipboard

Coordinate rounding is different from Mapnik

Open e-n-f opened this issue 9 years ago • 2 comments

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 avatar Jan 20 '16 23:01 e-n-f

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 avatar Jan 30 '16 00:01 e-n-f

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

e-n-f avatar Jan 10 '23 23:01 e-n-f