Created
April 5, 2011 19:15
-
-
Save alexfish/904309 to your computer and use it in GitHub Desktop.
returns cloudmade tiles in range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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