mapbox / tile-cover

Generate the minimum number of tiles to cover a geojson geometry
MIT License
189 stars 40 forks source link

Occasional bad tiles on random polygons #66

Open mourner opened 8 years ago

mourner commented 8 years ago

@morganherlocker when feeding tile-cover with require('geojson-random').polygon(10), it occasionally includes a bad tile that looks like this: z: -24, x: -435.99999994039536, y: -1.9999999403953552.

Looks like some backwards loop doesn't stop at 0 somewhere. It may be caused by polygons that exceed normally expected coords (-180..180, -85..85), but not sure.

This is the what caused livetile builds to fail sporadically. cc @rclark

morganherlocker commented 8 years ago

Interesting. I guess it's time to start doing fuzz testing.

mourner commented 8 years ago

Minimal test case that breaks:

cover.tiles({
    "type": "Polygon",
    "coordinates": [[[152,85], [154,89], [161,82], [147,82], [150,87], [152,85]]]
}, {min_zoom: 4, max_zoom: 4});

Looks like it bugs out on out-of-range latitudes.

mourner commented 8 years ago

Will likely be fixed by https://github.com/mapbox/tilebelt/pull/27 after some improvements.