From 57d8730a5a74eddfc7765db46df746e860dab055 Mon Sep 17 00:00:00 2001 From: Eric Duminil <eric.duminil@gmail.com> Date: Sat, 19 Oct 2024 21:11:53 +0200 Subject: [PATCH] Allow many parameters, via input file --- download_files_from_LGL_BW.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/download_files_from_LGL_BW.py b/download_files_from_LGL_BW.py index 3063ffc..d5f20f7 100644 --- a/download_files_from_LGL_BW.py +++ b/download_files_from_LGL_BW.py @@ -129,14 +129,27 @@ def extract_region(output_dir: Path, location_name: str, wkt: str) -> None: if len(gml_inputs) == 0: print("Error: No CityGML found. At least part of the region should be in Baden-Württemberg!") return + + params_path = output_dir / 'params.txt' + wkt_path = output_dir / 'region.wkt' + print(f" Extracting {output_file}.") + with open(wkt_path, 'w') as f: + f.write(wkt) + + with open(params_path, 'w') as f: + f.write("--input\n") + f.write(','.join(f"{gml}" for gml in gml_inputs)) + f.write("\n") + f.write("--output\n") + f.write(f'"{output_file}"\n') + f.write("--wkt\n") + f.write(f'"{wkt_path}"\n') + result = subprocess.run(['java', '-classpath', f'{region_chooser_libs}', 'eu.simstadt.regionchooser.RegionChooserCLI', - '--input', ','.join(str(gml) for gml in gml_inputs), - '--output', str(output_file), - '--wkt', '-', + f'@{params_path}' ], - input=wkt, text=True, capture_output=True, check=True -- GitLab