import os import sys import subprocess mkgmap = "E:\\Apps\\mkgmap\\mkgmap.jar" def system( cmdstring ): print cmdstring p = subprocess.Popen( cmdstring, shell=True ) ret = p.wait() return ( ret == 0 ) osm_files = [] osm_files2 = "" for x in range(0, 12): # 32.25 - 34.65 for y in range(0, 6): # 34.60 - 35.80 x_low = 32.25 + x * 0.20 x_high= 32.25 + (x + 1) * 0.20 y_low = 34.60 + y * 0.20 y_high= 34.60 + (y + 1) * 0.20 outfile = "map_%f-%fx%f-%f.osm" % (x_low, x_high, y_low, y_high) print outfile cmd = "wget -O %s http://api.openstreetmap.org/api/0.5/map?bbox=%f,%f,%f,%f" % \ (outfile, x_low, y_low, x_high, y_high) system( cmd ) osm_files.append( outfile ) # work around a bug in mkgmap for f in osm_files: size = os.path.getsize( f ) if size > 50: osm_files2 += f + " " system( "java -jar %s --net --gmapsupp %s" % (mkgmap, osm_files2) )