topo_map_processor 0.1.21__tar.gz → 0.1.23__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: topo_map_processor
3
- Version: 0.1.21
3
+ Version: 0.1.23
4
4
  Summary: Library for processing topographic maps
5
5
  Project-URL: homepage, https://github.com/ramSeraph/topo_map_processor
6
6
  Project-URL: repository, https://github.com/ramSeraph/topo_map_processor.git
@@ -303,7 +303,8 @@ tile --tiles-dir <dir> --tiffs-dir <dir> --max-zoom <zoom> --name <name> --descr
303
303
  ```
304
304
 
305
305
  - `--tiles-dir`: Directory to store the output tiles. (Required)
306
- - `--tiffs-dir`: Directory containing the input GeoTIFF files. (Required)
306
+ - `--tiffs-dir`: Directory containing the input GeoTIFF files. (Optional if `--tiffs-list-file` is used)
307
+ - `--tiffs-list-file`: File containing a list of tiff files to tile. (Optional if `--tiffs-dir` is used)
307
308
  - `--max-zoom`: Maximum zoom level for tiling. (Required)
308
309
  - `--name`: Name of the mosaic. (Required)
309
310
  - `--description`: Description of the mosaic. (Required)
@@ -226,7 +226,8 @@ tile --tiles-dir <dir> --tiffs-dir <dir> --max-zoom <zoom> --name <name> --descr
226
226
  ```
227
227
 
228
228
  - `--tiles-dir`: Directory to store the output tiles. (Required)
229
- - `--tiffs-dir`: Directory containing the input GeoTIFF files. (Required)
229
+ - `--tiffs-dir`: Directory containing the input GeoTIFF files. (Optional if `--tiffs-list-file` is used)
230
+ - `--tiffs-list-file`: File containing a list of tiff files to tile. (Optional if `--tiffs-dir` is used)
230
231
  - `--max-zoom`: Maximum zoom level for tiling. (Required)
231
232
  - `--name`: Name of the mosaic. (Required)
232
233
  - `--description`: Description of the mosaic. (Required)
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.1.21'
32
- __version_tuple__ = version_tuple = (0, 1, 21)
31
+ __version__ = version = '0.1.23'
32
+ __version_tuple__ = version_tuple = (0, 1, 23)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -50,11 +50,14 @@ def cli():
50
50
  parser = argparse.ArgumentParser(description="End-to-end retiling script.")
51
51
  parser.add_argument("-p", "--pmtiles-release", required=True, help="PMTiles release tag")
52
52
  parser.add_argument("-g", "--gtiffs-release", required=True, help="GeoTIFFs release tag")
53
+ parser.add_argument("-r", "--repo", required=False, help="Github repo to download from and upload to")
53
54
  parser.add_argument("-x", "--pmtiles-prefix", required=True, help="Prefix for PMTiles files")
54
55
  parser.add_argument("--bounds-file-tiled", required=True, help="Name of the bounds file in the pmtiles release (the old bounds file)")
55
56
  parser.add_argument("--no-cache", action='store_true', required=False, help="Don't cache files locally during pmtiles partitioning")
56
57
  args = parser.parse_args()
57
58
 
59
+ repo_arg = ["--repo", args.repo] if args.repo else []
60
+
58
61
  # Define paths and filenames
59
62
  sheets_to_pull_list_outfile = Path("sheets_to_pull_list.txt")
60
63
  tiles_dir = Path("staging/tiles/")
@@ -75,10 +78,10 @@ def cli():
75
78
 
76
79
  # Download bounds files
77
80
  print("Downloading new bounds file from gtiffs release...")
78
- run_command(["gh", "release", "download", args.gtiffs_release, "-p", "bounds.geojson", "--clobber", "-O", str(new_bounds_file)])
81
+ run_command(["gh", "release", "download", args.gtiffs_release, "-p", "bounds.geojson", "--clobber", "-O", str(new_bounds_file)] + repo_arg)
79
82
 
80
83
  print("Downloading old bounds file from pmtiles release...")
81
- run_command(["gh", "release", "download", args.pmtiles_release, "-p", args.bounds_file_tiled, "--clobber", "-O", str(old_bounds_file)])
84
+ run_command(["gh", "release", "download", args.pmtiles_release, "-p", args.bounds_file_tiled, "--clobber", "-O", str(old_bounds_file)] + repo_arg)
82
85
 
83
86
  # Create force redo bounds file
84
87
  print("Creating force redo bounds file...")
@@ -98,7 +101,7 @@ def cli():
98
101
 
99
102
  # Download original PMTiles
100
103
  print("Getting original PMTiles files...")
101
- run_command(["gh", "release", "download", args.pmtiles_release, "-D", str(from_pmtiles_dir), "-p", f"{args.pmtiles_prefix}*"])
104
+ run_command(["gh", "release", "download", args.pmtiles_release, "-D", str(from_pmtiles_dir), "-p", f"{args.pmtiles_prefix}*"] + repo_arg)
102
105
 
103
106
  # Get list of sheets to pull
104
107
  print("Getting list of sheets to pull...")
@@ -115,11 +118,12 @@ def cli():
115
118
  # Download TIFFs
116
119
  print("Downloading TIFFs...")
117
120
  # The download script will report if files are not found, which is expected for dummy sheets.
118
- if download_from_release_main([
121
+ download_args = [
119
122
  "--release", args.gtiffs_release,
120
123
  "--output-dir", str(tiffs_dir),
121
124
  "--file-list", str(sheets_to_pull_list_outfile),
122
- ]) != 0:
125
+ ] + repo_arg
126
+ if download_from_release_main(download_args) != 0:
123
127
  print("Some TIFFs failed to download. This may be expected for dummy sheets from force redo. Continuing...", file=sys.stderr)
124
128
 
125
129
  sheets_to_pull_list_outfile.unlink()
@@ -150,18 +154,18 @@ def cli():
150
154
  print("Deleting old PMTiles files from the release...")
151
155
  old_pmtiles = glob.glob(f"{from_pmtiles_dir}/{args.pmtiles_prefix}*")
152
156
  for pmtile in old_pmtiles:
153
- run_command(["gh", "release", "delete-asset", args.pmtiles_release, Path(pmtile).name, "-y"])
157
+ run_command(["gh", "release", "delete-asset", args.pmtiles_release, Path(pmtile).name, "-y"] + repo_arg)
154
158
 
155
159
  print("Uploading new PMTiles files...")
156
160
  new_pmtiles = glob.glob(f"{to_pmtiles_prefix}*")
157
- run_command(["gh", "release", "upload", args.pmtiles_release, "--clobber"] + new_pmtiles)
161
+ run_command(["gh", "release", "upload", args.pmtiles_release, "--clobber"] + repo_arg + new_pmtiles)
158
162
 
159
163
  # Handle bounds file
160
164
  print("Uploading new bounds file to pmtiles release...")
161
165
  upload_bounds_file = Path(args.bounds_file_tiled)
162
166
  new_bounds_file.rename(upload_bounds_file)
163
167
 
164
- run_command(["gh", "release", "upload", args.pmtiles_release, str(upload_bounds_file), "--clobber"])
168
+ run_command(["gh", "release", "upload", args.pmtiles_release, str(upload_bounds_file), "--clobber"] + repo_arg)
165
169
 
166
170
  upload_bounds_file.unlink()
167
171
 
@@ -75,7 +75,9 @@ def cli():
75
75
 
76
76
  parser = argparse.ArgumentParser(description='Tile the GTiffs and create a TileJSON file')
77
77
  parser.add_argument('--tiles-dir', required=True, help='Directory to store the tiles')
78
- parser.add_argument('--tiffs-dir', required=True, help='Directory with GTiffs to tile')
78
+ tiffs_group = parser.add_mutually_exclusive_group(required=True)
79
+ tiffs_group.add_argument('--tiffs-dir', help='Directory with GTiffs to tile')
80
+ tiffs_group.add_argument('--tiffs-list-file', help='File containing a list of tiff files to tile')
79
81
  parser.add_argument('--max-zoom', type=int, required=True, help='Maximum zoom level for tiling')
80
82
  parser.add_argument('--min-zoom', type=int, default=0, help='Minimum zoom level for tiling')
81
83
  parser.add_argument('--tile-extension', type=str, default='webp', choices=SUPPORTED_FORMATS, help='Tile file extension (default: webp)')
@@ -102,8 +104,15 @@ def cli():
102
104
  tiles_dir = Path(args.tiles_dir)
103
105
  tiles_dir.mkdir(parents=True, exist_ok=True)
104
106
 
105
- file_names = list(glob.glob(f'{args.tiffs_dir}/*.tif'))
106
- file_names = [ str(Path(f).resolve()) for f in file_names ]
107
+ if args.tiffs_dir:
108
+ file_names = list(glob.glob(f'{args.tiffs_dir}/*.tif'))
109
+ file_names = [ str(Path(f).resolve()) for f in file_names ]
110
+ else:
111
+ tiff_list_path = Path(args.tiffs_list_file)
112
+ if not tiff_list_path.exists():
113
+ parser.error(f'Tiffs list file {args.tiffs_list_file} does not exist')
114
+ file_names = [str(Path(line.strip()).resolve()) for line in tiff_list_path.read_text().splitlines() if line.strip()]
115
+
107
116
  print(f'total files: {len(file_names)}')
108
117
 
109
118
  file_list_file = Path('files_to_tile.txt')