* Add flag check for kmz

* Add generate_kmz

* remove osparam from systemrun

* Remove extra aaarg

* Add orthophoto-kmz argument to parser
pull/1273/head
Stephen Mather 2021-04-15 23:21:55 -04:00 zatwierdzone przez GitHub
rodzic dbcc656b13
commit 38434e9184
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 24 dodań i 0 usunięć

Wyświetl plik

@ -542,6 +542,14 @@ def config(argv=None, parser=None):
default=False,
help='Set this parameter if you want to generate a PNG rendering of the orthophoto. '
'Default: %(default)s')
parser.add_argument('--orthophoto-kmz',
action=StoreTrue,
nargs=0,
default=False,
help='Set this parameter if you want to generate a Google Earth (KMZ) rendering of the orthophoto. '
'Default: %(default)s')
parser.add_argument('--orthophoto-compression',
metavar='<string>',

Wyświetl plik

@ -54,7 +54,20 @@ def generate_png(orthophoto_file, output_file=None, outsize=None):
system.run('gdal_translate -of png "%s" "%s" %s %s '
'--config GDAL_CACHEMAX %s%% ' % (orthophoto_file, output_file, osparam, bandparam, get_max_memory()))
def generate_kmz(orthophoto_file, output_file=None, outsize=None):
if output_file is None:
base, ext = os.path.splitext(orthophoto_file)
output_file = base + '.kmz'
# See if we need to select top three bands
bandparam = ""
gtif = gdal.Open(orthophoto_file)
if gtif.RasterCount > 4:
bandparam = "-b 1 -b 2 -b 3 -a_nodata 0"
system.run('gdal_translate -of KMLSUPEROVERLAY -co FORMAT=JPEG "%s" "%s" %s '
'--config GDAL_CACHEMAX %s%% ' % (orthophoto_file, output_file, bandparam, get_max_memory()))
def post_orthophoto_steps(args, bounds_file_path, orthophoto_file, orthophoto_tiles_dir):
if args.crop > 0:
Cropper.crop(bounds_file_path, orthophoto_file, get_orthophoto_vars(args), keep_original=not args.optimize_disk_space, warp_options=['-dstalpha'])
@ -64,6 +77,9 @@ def post_orthophoto_steps(args, bounds_file_path, orthophoto_file, orthophoto_ti
if args.orthophoto_png:
generate_png(orthophoto_file)
if args.orthophoto_kmz:
generate_kmz(orthophoto_file)
if args.tiles:
generate_orthophoto_tiles(orthophoto_file, orthophoto_tiles_dir, args.max_concurrency)