Download all tiles in Bounding Box using Cloudmade Ruby API

613 Views Asked by At

Can anybody supply an example of downloading all tiles between say zoom 10-18, inside a bounding box,

I'm trying to do this using the Ruby API but i can't seem to make sense of any of it, i can see how to download a single tile, how to make a boundingbox, but not how to use a bounding box to download all tiles inside it to use offline maps in my iPhone app. Thanks!

2

There are 2 best solutions below

0
On BEST ANSWER

I converted this perl script to Ruby and it works great!

2
On

Look into TileService class. It has methods #get_xy_tile, #latlon2tilenums. That's all you need. Convert (lat1, lon1), (lat2, lon2) to (x1, y1), (x2, y2) with #latlon2tilenums. x(s) and y(s) are integers. Now you have to simple loop from min(x1, x2) to max(x1, x2), do the same for y(s) and that's it.

If you write this function you can send it to authors of API, i.e. me ;), and we commit it to the trunk.