def get_args(sys_argv): args = MapArgs(sys_argv) if (args.location is None) and (args.gpx is None) and ((args.lat is None) or (args.lng is None)): args.print_help() os.kill(os.getpid(), signal.SIGTERM) sys.exit(0) if ((args.lat is None) or (args.lng is None)) and (args.gpx is None): locations = ctx_map.get_locations() if (not args.location in locations.keys()): args.location = ctx_map.search_location(args.location) if (args.location[:6] == "error="): print args.location[6:] sys.exit(0) coord = ctx_map.get_locations()[args.location] args.lat = coord[0] args.lng = coord[1] if args.gpx: # GPX path mode args.width = int(args.width) if args.width < 0: args.width = 2 # The default for GPX else: if args.width > 0: args.lng_range = km_to_lon(args.width, args.lat) if args.height > 0: args.lat_range = km_to_lat(args.height) return args
print "location = %s" % args.location if ((args.lat is None) or (args.lng is None)): locations = ctx_map.get_locations() if (not args.location in locations.keys()): args.location = ctx_map.search_location(args.location) if (args.location[:6] == "error="): print args.location[6:] sys.exit(0) coord = ctx_map.get_locations()[args.location] args.lat = coord[0] args.lng = coord[1] if args.width > 0: args.lng_range = km_to_lon(args.width, args.lat) if args.height > 0: args.lat_range = km_to_lat(args.height) if (args.location is None): args.location = "somewhere" print "Download %s (%f, %f), range (%f, %f), zoom level: %d to %d" % \ (args.location, args.lat, args.lng, args.lat_range, args.lng_range, args.max_zl, args.min_zl) downloader = MapDownloader(ctx_map, args.nr_threads) try: download(args.lat, args.lng, args.lat_range, args.lng_range, args.max_zl, args.min_zl, args.layer) finally: