Skip to content
Snippets Groups Projects
Commit eb98aa4d authored by David Hoese's avatar David Hoese
Browse files

Add linking/copying to tile generation

parent 5a20999a
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import sys
import warnings
import logging
import subprocess
import shutil
import tile_index
......@@ -43,6 +44,18 @@ def remap_tifs(input_tifs, out_dir, remap_suffix):
yield otif
def link_or_copy(input_tifs, out_dir):
"""Hardlink input tifs to output directory."""
for prod_file in input_tifs:
out_file = os.path.join(out_dir, os.path.basename(prod_file))
try:
os.link(prod_file, out_file)
except OSError:
# on different mounts probably?
shutil.copy2(prod_file, out_file)
yield out_file
def main():
import argparse
parser = argparse.ArgumentParser(description="Take input geotiffs and generate mapserver compatible tiles.")
......@@ -68,9 +81,12 @@ def main():
shp_fn = args.shape_file.format(product=prod)
shp_pathname = os.path.join(out_dir, shp_fn)
# remap if needed
if args.remap:
# remap if needed
prod_files = list(remap_tifs(prod_files, out_dir, args.remap_suffix))
else:
# hardlink if needed
prod_files = list(link_or_copy(prod_files, out_dir))
# create shape file
tile_index.index(prod_files, shp_pathname)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment