mapbox / tile-cover

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

horizontal topline edge case #54

Closed morganherlocker closed 9 years ago

morganherlocker commented 9 years ago

It looks like the top line is getting pushed up 1 y, then skipping the next row. Initial debugging appears to reveal the the top line is not registering as a horizontal intersect.

morganherlocker commented 9 years ago

^ turns out they are detected as horizontal, but not as local min/maxima, which is probably what is throwing things off.

morganherlocker commented 9 years ago

horizontal intersections darkened:

It is pushing the intersections correctly, but appears to be incrementing on the wrong row.

morganherlocker commented 9 years ago

Turns out that this is literally a corner case.

When a horizontal intersects at a corner on a topline, you end up with:

  1. the intersect on the top of the left vertical
  2. the intersect on the left side of the horizontal
  3. the intersect on the right side of the horizontal
  4. the intersect on the top of the right vertical

This causes the vertical and horizontal intersections to each be treated as pairs, like local maxima.

I removed the linecover and the results were consistent with this theory:

morganherlocker commented 9 years ago

jackpot:

Cleaning up code and pushing to a branch for CR

morganherlocker commented 9 years ago

PR: https://github.com/mapbox/tile-cover/pull/55

morganherlocker commented 9 years ago

published in https://github.com/mapbox/tile-cover/commit/e7e3a11106b6a076db0aade145cc9b70c4289fcb