Skip to content

Commit

Permalink
Make tiler zoom level configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
MertenF committed Oct 6, 2023
1 parent 38af615 commit 7cd02a7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
16 changes: 16 additions & 0 deletions opendm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,22 @@ def config(argv=None, parser=None):
'suitable for viewers like Leaflet or OpenLayers. '
'Default: %(default)s')

parser.add_argument('--tiles-min-zoom',
type=int,
action=StoreValue,
default=5,
metavar='<positive integer>',
help='Minimum zoom level to generate 2d tiles for. '
'Default: %(default)s')

parser.add_argument('--tiles-max-zoom',
type=int,
action=StoreValue,
default=21,
metavar='<positive integer>',
help='Minimum zoom level to generate 2d tiles for. '
'Default: %(default)s')

parser.add_argument('--3d-tiles',
action=StoreTrue,
nargs=0,
Expand Down
2 changes: 1 addition & 1 deletion opendm/orthophoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def post_orthophoto_steps(args, bounds_file_path, orthophoto_file, orthophoto_ti
generate_kmz(orthophoto_file)

if args.tiles:
generate_orthophoto_tiles(orthophoto_file, orthophoto_tiles_dir, args.max_concurrency)
generate_orthophoto_tiles(orthophoto_file, orthophoto_tiles_dir, args.max_concurrency, args.tiles_min_zoom, args.tiles_max_zoom)

if args.cog:
convert_to_cogeo(orthophoto_file, max_workers=args.max_concurrency, compression=args.orthophoto_compression)
Expand Down
12 changes: 6 additions & 6 deletions opendm/tiles/tiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from opendm import system
from opendm import io

def generate_tiles(geotiff, output_dir, max_concurrency):
def generate_tiles(geotiff, output_dir, max_concurrency, min_zoom, max_zoom):
gdal2tiles = os.path.join(os.path.dirname(__file__), "gdal2tiles.py")
system.run('%s "%s" --processes %s -z 5-21 -n -w none "%s" "%s"' % (sys.executable, gdal2tiles, max_concurrency, geotiff, output_dir))
system.run('%s "%s" --processes %s -z %s-%s -n -w none "%s" "%s"' % (sys.executable, gdal2tiles, max_concurrency, min_zoom, max_zoom, geotiff, output_dir))

def generate_orthophoto_tiles(geotiff, output_dir, max_concurrency):
def generate_orthophoto_tiles(geotiff, output_dir, max_concurrency, min_zoom, max_zoom):
try:
generate_tiles(geotiff, output_dir, max_concurrency)
generate_tiles(geotiff, output_dir, max_concurrency, min_zoom, max_zoom)
except Exception as e:
log.ODM_WARNING("Cannot generate orthophoto tiles: %s" % str(e))

Expand All @@ -37,10 +37,10 @@ def generate_colored_hillshade(geotiff):
log.ODM_WARNING("Cannot generate colored hillshade: %s" % str(e))
return (None, None, None)

def generate_dem_tiles(geotiff, output_dir, max_concurrency):
def generate_dem_tiles(geotiff, output_dir, max_concurrency, min_zoom, max_zoom):
try:
colored_dem, hillshade_dem, colored_hillshade_dem = generate_colored_hillshade(geotiff)
generate_tiles(colored_hillshade_dem, output_dir, max_concurrency)
generate_tiles(colored_hillshade_dem, output_dir, max_concurrency, min_zoom, max_zoom)

# Cleanup
for f in [colored_dem, hillshade_dem, colored_hillshade_dem]:
Expand Down

0 comments on commit 7cd02a7

Please sign in to comment.