I have a polygon in a PostGIS database and I need a list of the Web Mercator tile X/Y pairs that cover the polygon at a particular zoom level. Let's say the polygon is the boundary of the France and the zoom level is 15. For an example of what I mean by X/Y pairs, the slippy map on this site presents the concept visually.
What I've tried so far is using ST_SquareGrid()
to create a level-15 grid/graticule for the entire world, and then intersecting it with the boundary of France. The grid took forever to generate and I didn't realize it would be ~1 billion polygons. So far, any operation against that grid has been very expensive and slow, even after indexing. I'm wondering if there's a more straightforward way of doing this that I'm missing.