I am using Open Street Maps to show a map in my HTML5 application.
It uses a URL like this for the map tiles,
http://b.tile.openstreetmap.org/{Z}/{X}/{Y}.png
If I chose an area, say Auckland, New Zealand, how could I work out all of the values of Z, X, Y that would cover Auckland? I would be looking to write a script to go and grab all those images and cache them in an HTML5 database.
First of all, take a look at the tile usage policy section about bulk download. Secondly, this sort of caching is easily done using TileStache: configure a cache to render or fetch tiles from a certain source, then run
tilestache-seed.py, passing in the bounding box (in WGS84 coordinates) and desired zoom levels, and you should end up with all needed tiles.