mapbox / tile-cover

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

Invalid tile cover with inner tiles translated right #62

Closed kelvinabrokwa closed 9 years ago

kelvinabrokwa commented 9 years ago

So I have the following valid GeoJSON bounding box for which I want tile cover (not too much to ask...right?)

{
  "type": "Feature",
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          -80.8417701593,
          30.3848788726
        ],
        [
          -85.5870337067,
          30.3848788726
        ],
        [
          -85.5870337067,
          34.9936544389
        ],
        [
          -80.8417701593,
          34.9936544389
        ],
        [
          -80.8417701593,
          30.3848788726
        ]
      ]
    ]
  },
  "properties": {}
}

So...

 > var cover = require('tile-cover')
 > var bbox = { JSON.parse(my_bbox_above) }
 > cover.geojson(bbox.geometry, { min_zoom: 10, max_zoom: 10 })

And the above yields a GeoJSON feature collection like this http://bl.ocks.org/d/f20fc55f9e4b60453808 with the outer tiles at the right location but the inner tiles translated all the way to the right (with longitude in the 400s).

I'm not sure why this is happening.

@yhahn

morganherlocker commented 9 years ago

@kelvinabrokwa can you post some real code for this? I am trying to reproduce with this code, and I am not seeing the same results:

var cover = require('tile-cover')

var poly = {
  type:'Feature',
  properties: {
    'fill-opacity': 0.1,
    'stroke': '#0ff'
  },
  geometry:{
    "type": "Polygon",
    "coordinates": [
      [
        [
          -80.8417701593,
          30.3848788726
        ],
        [
          -85.5870337067,
          30.3848788726
        ],
        [
          -85.5870337067,
          34.9936544389
        ],
        [
          -80.8417701593,
          34.9936544389
        ],
        [
          -80.8417701593,
          30.3848788726
        ]
      ]
    ]
  }
}

var tiles = cover.geojson(poly.geometry, { min_zoom: 10, max_zoom: 10 })

tiles.features.push(poly)

console.log(JSON.stringify(tiles))

returns:

kelvinabrokwa commented 9 years ago

I reinstalled tile-cover after your last patch and it works now. Thanks!