aboutsummaryrefslogtreecommitdiff
path: root/gm_fetch.py
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2008-06-24 10:25:26 +0200
committerWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2008-06-24 10:25:26 +0200
commit8949ba5d0ae6f1f1689f0bde7c8f366550a3284d (patch)
treed459e559b7ee8025d0acecf404defabc63ce602c /gm_fetch.py
downloadgooglemaps2007_dl-8949ba5d0ae6f1f1689f0bde7c8f366550a3284d.tar.gz
googlemaps2007_dl-8949ba5d0ae6f1f1689f0bde7c8f366550a3284d.tar.bz2
Initial Commit
Diffstat (limited to 'gm_fetch.py')
-rwxr-xr-xgm_fetch.py99
1 files changed, 99 insertions, 0 deletions
diff --git a/gm_fetch.py b/gm_fetch.py
new file mode 100755
index 0000000..254e649
--- /dev/null
+++ b/gm_fetch.py
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+import googlemaps as gm
+import sys, os
+
+basedir = "gmfetch_DL"
+dryrun = 1
+
+for arg in sys.argv[1:]:
+ exec arg
+
+if lon[0] > lon[1]:
+ lon = (lon[1], lon[0])
+
+if lat[0] > lat[1]:
+ lat = (lat[1], lat[0])
+
+print lon, lat
+
+zooms = range(-5, 18)
+zooms.reverse()
+for z in zooms:
+ for d in ['sat', 'map', 'overlay', 'relief']:
+ try:
+ os.makedirs("%s/%s" % (basedir, d))
+ except:
+ pass
+
+ img_num = (gm.get_image_number(lon[0], lat[0], z), gm.get_image_number(lon[1], lat[1], z))
+
+ for y in range(img_num[1][1], img_num[0][1]+1):
+ for x in range(img_num[0][0], img_num[1][0]+1):
+ sel = gm.image_number_to_sel(x, y, z, ['a', 'b', 'c', 'd'])
+ if not dryrun:
+ img_sat = None
+ img_map = None
+ img_overlay = None
+ img_relief = None
+
+ img_sat_file = "%s/sat/%s" % ( basedir, sel)
+ img_map_file = "%s/map/%s" % ( basedir, sel)
+ img_overlay_file = "%s/overlay/%s" % ( basedir, sel)
+ img_relief_file = "%s/relief/%s" % ( basedir, sel)
+
+ if z >= gm.MIN_SATELLITE_ZOOM:
+ try:
+ pass
+ #os.stat(img_sat_file)
+ except OSError:
+ print "sat %d %d %d" % (x,y,z),
+ img_sat = gm.fetch_satellite_img(x, y, z)
+ if img_sat:
+ f = open("%s/sat/%s" % (basedir, sel), 'w')
+ f.write(img_sat)
+ f.close()
+ else:
+ print " failed",
+ print
+
+ if z >= gm.MIN_MAP_ZOOM:
+ try:
+ os.stat(img_map_file)
+ except OSError:
+ print "map %d %d %d" % (x,y,z),
+ img_map = gm.fetch_map_img(x, y, z)
+ if img_map:
+ f = open("%s/map/%s" % (basedir, sel), 'w')
+ f.write(img_map)
+ f.close()
+ else:
+ print " failed",
+ print
+
+ if z >= gm.MIN_OVERLAY_ZOOM:
+ try:
+ os.stat(img_overlay_file)
+ except OSError:
+ print "overlay %d %d %d" % (x,y,z),
+ img_overlay = gm.fetch_overlay_img(x, y, z)
+ if img_overlay:
+ f = open("%s/overlay/%s" % (basedir, sel), 'w')
+ f.write(img_overlay)
+ f.close()
+ else:
+ print " failed",
+ print
+
+ if z >= gm.MIN_RELIEF_ZOOM:
+ try:
+ os.stat(img_relief_file)
+ except:
+ print "relief %d %d %d" % (x,y,z),
+ img_relief = gm.fetch_relief_img(x, y, z)
+ if img_relief:
+ f = open("%s/relief/%s" % (basedir, sel), 'w')
+ f.write(img_relief)
+ f.close()
+ else:
+ print " failed",
+ print