Skip to content

Commit

Permalink
Make progress bar optional
Browse files Browse the repository at this point in the history
  • Loading branch information
pnorman committed Nov 19, 2024
1 parent 4d66245 commit ee10501
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tilekiln/scripts/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ def generate() -> None:
@click.option('--storage-host')
@click.option('--storage-port')
@click.option('--storage-username')
@click.option('--progress/--no-progress', help='Display progress bar')
def tiles(config: int, num_threads: int,
source_dbname: str, source_host: str, source_port: int, source_username: str,
storage_dbname: str, storage_host: str, storage_port: int, storage_username: str) -> None:
storage_dbname: str, storage_host: str, storage_port: int, storage_username: str,
progress: bool) -> None:
'''Generate specific tiles.
A list of z/x/y tiles is read from stdin and those tiles are generated and saved
Expand All @@ -57,7 +59,10 @@ def tiles(config: int, num_threads: int,
"host": storage_host,
"port": storage_port,
"user": storage_username}
tilekiln.generator.generate(c, source_kwargs, storage_kwargs, tqdm(tiles), threads)
if progress:
tilekiln.generator.generate(c, source_kwargs, storage_kwargs, tqdm(tiles), threads)
else:
tilekiln.generator.generate(c, source_kwargs, storage_kwargs, tiles, threads)


@generate.command()
Expand All @@ -74,10 +79,11 @@ def tiles(config: int, num_threads: int,
@click.option('--storage-username')
@click.option('--min-zoom', type=click.INT, required=True)
@click.option('--max-zoom', type=click.INT, required=True)
@click.option('--progress/--no-progress', help='Display progress bar')
def zooms(config: int, num_threads: int,
source_dbname: str, source_host: str, source_port: int, source_username: str,
storage_dbname: str, storage_host: str, storage_port: int, storage_username: str,
min_zoom: int, max_zoom: int) -> None:
min_zoom: int, max_zoom: int, progress: bool) -> None:

c = tilekiln.load_config(config)

Expand All @@ -92,4 +98,7 @@ def zooms(config: int, num_threads: int,
"host": storage_host,
"port": storage_port,
"user": storage_username}
tilekiln.generator.generate(c, source_kwargs, storage_kwargs, tqdm(tiles), threads)
if progress:
tilekiln.generator.generate(c, source_kwargs, storage_kwargs, tqdm(tiles), threads)
else:
tilekiln.generator.generate(c, source_kwargs, storage_kwargs, tiles, threads)
3 changes: 3 additions & 0 deletions tilekiln/tilerange.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ def __iter__(self):

def __len__(self):
return self.maxid - self.minid

def __contains__(self, value):
raise NotImplementedError

0 comments on commit ee10501

Please sign in to comment.