Commit 9fb0066d authored by Eric Duminil's avatar Eric Duminil
Browse files

Preparing polygon check

parent 74451055
Showing with 5 additions and 4 deletions
+5 -4
...@@ -101,14 +101,14 @@ def wkt_polygon_to_grid_coords(location_name: str, wkt: str) -> tuple[int, int, ...@@ -101,14 +101,14 @@ def wkt_polygon_to_grid_coords(location_name: str, wkt: str) -> tuple[int, int,
return (x1, x2, y1, y2) 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.""" """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! # 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 x in range(x1, x2 + 1, RASTER):
for y in range(y1, y2 + 1, RASTER): for y in range(y1, y2 + 1, RASTER):
citygml_zip = f"LoD2_{UTM}_{x}_{y}_{RASTER}_{BUNDESLAND}.zip" citygml_zip = f"LoD2_{UTM}_{x}_{y}_{RASTER}_{BUNDESLAND}.zip"
citygml_url = f"{CITYGML_SERVER}/{citygml_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(): if local_zip.exists():
print(f" {local_zip.name} already in {output_dir.name}/") print(f" {local_zip.name} already in {output_dir.name}/")
else: else:
...@@ -165,7 +165,8 @@ def extract_region(output_dir: Path, location_name: str, wkt: str) -> None: ...@@ -165,7 +165,8 @@ def extract_region(output_dir: Path, location_name: str, wkt: str) -> None:
f'@{params_path}' f'@{params_path}'
], ],
text=True, text=True,
capture_output=True capture_output=True,
check=False
) )
if (result.stderr): if (result.stderr):
print(result.stderr) print(result.stderr)
...@@ -195,7 +196,7 @@ def main(regions: dict[str, str]) -> None: ...@@ -195,7 +196,7 @@ def main(regions: dict[str, str]) -> None:
output_dir.mkdir(parents=True, exist_ok=True) output_dir.mkdir(parents=True, exist_ok=True)
wkt = get_wkt(wkt_or_zipcode) wkt = get_wkt(wkt_or_zipcode)
x1, x2, y1, y2 = wkt_polygon_to_grid_coords(location_name, wkt) 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: if EXTRACT_REGIONS:
extract_region(output_dir, location_name, wkt) extract_region(output_dir, location_name, wkt)
print() print()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment