def bin_to_ims(base_dir, subdirs, tif_file_list): for s in subdirs: #Generate jpgs and geoTIFs from .bin try: bin_to_geotiff.main(s, s, tif_file_list, GPS_BOUNDS) except Exception as ex: fail("\tFailed to process folder %s: %s" % (s, str(ex)))
def main(): args = options() in_dir = path.join(args.in_dir, args.date) out_dir = path.join(args.out_dir, args.date) if not path.isdir(in_dir) or not path.isdir(args.out_dir): return subdirs = listdir(in_dir) TILE_FOLDER_NAME = 'tiles_' + args.date # Create a file to write the paths for all of the TIFFs. This will be used create the VRT. tif_file_list = path.join(out_dir, 'tif_list.txt') # If there is a pre-existing tiles folder with this name, delete it (failing to do so can result in some weirdness when you load tiles later) if path.exists(out_dir): rmtree(out_dir) makedirs(out_dir) if path.exists(tif_file_list): try: remove( tif_file_list) # start from a fresh list of TIFFs for the day except OSError: pass # Convert binary files that are within GPS bounds to JPGs and GeoTIFFs print "Starting binary to image conversion..." for subdir in subdirs: in_path = path.join(in_dir, subdir) out_path = path.join(out_dir, subdir) try: bin_to_geotiff.main(in_path, out_path, tif_file_list, GPS_BOUNDS) except Exception as ex: fail("\tFailed to process folder %s: %s" % (in_path, str(ex))) print "Completed binary to image conversion..." print "Found " + str( file_len(tif_file_list)) + " folders within GPS bounds." # Create VRT from every GeoTIFF print "Starting VRT creation..." createVrt(out_dir, tif_file_list) print "Completed VRT creation..." # Generate tiles from VRT print "Starting map tile creation..." createMapTiles(out_dir, TILE_FOLDER_NAME) print "Completed map tile creation..." # Generate google map html template print "Starting google map html creation..." generate_googlemaps(out_dir, path.join(out_dir, TILE_FOLDER_NAME)) print "Completed google map html creation..."
def create_tif_list(in_dir, out_dir): if not os.path.isdir(in_dir): return subdirs = os.listdir(in_dir) # Create a file to write the paths for all of the TIFFs. This will be used create the VRT. tif_file_list = os.path.join(out_dir, 'tif_list.txt') # If there is a pre-existing tiles folder with this name, delete it (failing to do so can result in some weirdness when you load tiles later) if os.path.exists(out_dir): shutil.rmtree(out_dir) os.makedirs(out_dir) if os.path.exists(tif_file_list): try: os.remove( tif_file_list) # start from a fresh list of TIFFs for the day except OSError: pass # Convert binary files that are within GPS bounds to JPGs and GeoTIFFs print "Starting binary to image conversion..." for subdir in subdirs: in_path = os.path.join(in_dir, subdir) out_path = os.path.join(out_dir, subdir) try: bin_to_geotiff.main(in_path, out_path, tif_file_list, GPS_BOUNDS) except Exception as ex: fail("\tFailed to process folder %s: %s" % (in_path, str(ex))) print "Completed binary to image conversion..." print "Found " + str( file_len(tif_file_list)) + " folders within GPS bounds." # Create VRT from every GeoTIFF print "Starting VRT creation..." geotiff_to_tiles.createVrt(out_dir, tif_file_list) print "Completed VRT creation..." return