diff --git a/download_files_from_LGL_BW.py b/download_files_from_LGL_BW.py index 87ca4f7343d01b2eab5942a09d2d98d9782d7ecf..6ae52694ce8ce7083f39489075b7df4167c89da2 100644 --- a/download_files_from_LGL_BW.py +++ b/download_files_from_LGL_BW.py @@ -101,14 +101,14 @@ def wkt_polygon_to_grid_coords(location_name: str, wkt: str) -> tuple[int, int, return (x1, x2, y1, y2) -def download_rectangle(output_dir: Path, x1: int, x2: int, y1: int, y2: int) -> None: +def download_whole_region(output_dir: Path, wkt: str, x1: int, x2: int, y1: int, y2: int) -> None: """Downloads every zip of a given region, to output_dir, and extracts CityGML files.""" # FIXME: Too many uninteresting tiles for complex shapes. Check if the tile is interesecting with the polygon! for x in range(x1, x2 + 1, RASTER): for y in range(y1, y2 + 1, RASTER): citygml_zip = f"LoD2_{UTM}_{x}_{y}_{RASTER}_{BUNDESLAND}.zip" citygml_url = f"{CITYGML_SERVER}/{citygml_zip}" - local_zip = output_dir / citygml_zip # .replace('.zip', '.gml') + local_zip = output_dir / citygml_zip if local_zip.exists(): print(f" {local_zip.name} already in {output_dir.name}/") else: @@ -165,7 +165,8 @@ def extract_region(output_dir: Path, location_name: str, wkt: str) -> None: f'@{params_path}' ], text=True, - capture_output=True + capture_output=True, + check=False ) if (result.stderr): print(result.stderr) @@ -195,7 +196,7 @@ def main(regions: dict[str, str]) -> None: output_dir.mkdir(parents=True, exist_ok=True) wkt = get_wkt(wkt_or_zipcode) x1, x2, y1, y2 = wkt_polygon_to_grid_coords(location_name, wkt) - download_rectangle(output_dir, x1, x2, y1, y2) + download_whole_region(output_dir, wkt, x1, x2, y1, y2) if EXTRACT_REGIONS: extract_region(output_dir, location_name, wkt) print()