Skip to content

Instantly share code, notes, and snippets.

@alexfish
Created April 5, 2011 19:15
Show Gist options
  • Save alexfish/904309 to your computer and use it in GitHub Desktop.
Save alexfish/904309 to your computer and use it in GitHub Desktop.
returns cloudmade tiles in range
# Format:
# tiles = [
# zoom => [
# [ tx, ty, tz ],
# ],
# [
# [ tx, ty, tz ],
# ],
# zoom => [
# [ tx, ty, tz ],
# ],
# [
# [ tx, ty, tz ],
# ],
# zoom => [
# [ tx, ty, tz ],
# ],
# [
# [ tx, ty, tz ],
# ]
# ]
def returnTiles(latmin,latmax,lonmin,lonmax,zoommin,zoommax)
cm = Client.from_parameters(API KEY)
tiles = []
for zoom in zoommin..zoommax
txmin = cm.tiles.xtile(lonmin,zoom)
txmax = cm.tiles.xtile(lonmax,zoom)
tymin = cm.tiles.ytile(latmax,zoom)
tymax = cm.tiles.ytile(latmin,zoom)
ntx = txmax - txmin + 1
nty = tymax - tymin + 1
tiles[zoom] = []
for tx in txmin..txmax
for ty in tymin..tymax
tiles[zoom].push([tx,ty,zoom])
end
end
end
return tiles
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment