paulmach / orb

Types and utilities for working with 2d geometry in Golang
MIT License
886 stars 103 forks source link

Unsure how Tilecover works #148

Closed jjcfrancisco closed 3 months ago

jjcfrancisco commented 3 months ago

If I have a GeoJSON of world countries -> see here and I want to know the maptile.Set needed for zooms 0 to 10. How do I go about it?

I tried the following but it doesn't seem to work:

// This doesn't work as Y seems to always be 0
tiles := maptile.Set{}
for _, z := range []int{0, 1, 2, 3, 4, 5, 6, 7, 8,9,10} {
    t := tilecover.Bound(countries, maptile.Zoom(z))
    tiles.Merge(t)
}

// This doesn't work either
var geoms orb.Collection
for _, feature := range countries.Features {
    geoms = append(geoms, feature.Geometry)
}
tiles := maptile.Set{}
for _, z := range []int{0, 1, 2, 3, 4, 5, 6, 7, 8,9,10} {
    t, _ := tilecover.Collection(geoms, maptile.Zoom(z))
    tiles.Merge(t)
}

Just scratching my head wondering how do I get all the tiles needed to cover from 0 to 10 zooms for the given geojson.

I'd appreciate any tips, advice or examples.