Commit 76a8c8b2 authored by Eric Duminil's avatar Eric Duminil
Browse files

Allow space in names, with a warning

parent ce7b378e
Showing with 17 additions and 9 deletions
+17 -9
......@@ -164,15 +164,16 @@ def extract_region(output_dir: Path, location_name: str, wkt_str: str, simstadt_
f.write(local_wkt)
with open(params_path, 'w', encoding='utf-8') as f:
f.write("--input\n")
f.write(','.join(f"{gml.as_posix()}" for gml in gml_inputs))
f.write("\n")
f.write("--input\n\"")
f.write(','.join(f'{gml.as_posix()}' for gml in gml_inputs))
f.write("\"\n")
f.write("--output\n")
f.write(f'"{output_file.as_posix()}"\n')
f.write('--local\n')
f.write("--wkt\n")
f.write(f'"{wkt_path.as_posix()}"\n')
result = subprocess.run(['java', '-classpath', f'{region_chooser_libs}',
'eu.simstadt.regionchooser.RegionChooserCLI',
f'@{params_path}'
......@@ -181,9 +182,9 @@ def extract_region(output_dir: Path, location_name: str, wkt_str: str, simstadt_
capture_output=True,
check=False
)
if result.returncode != 0:
if result.stderr:
logger.error("%s", result.stderr)
if result.returncode != 0:
raise ValueError(f"RegionChooser failed with code {result.returncode}")
logger.info(" DONE!")
return output_file
......@@ -251,7 +252,7 @@ def main(location_name: str, wkt_or_zipcode: str, download_only: bool = False,
# Validate location name
if ' ' in location_name:
raise ValueError("Location name should not contain spaces: 'Some City' -> 'SomeCity'")
logger.warning("Location contains spaces, some workflows might fail.")
if output_folder:
output_folder = Path(output_folder)
......
......@@ -9,6 +9,7 @@ import download_LoD2_from_LGL_BW as bw_data
# Just a few buildings in Schwarzwald
KALTENBRONN_WKT = "POLYGON ((8.4266 48.704415, 8.43926 48.704415, 8.43926 48.709031, 8.4266 48.709031, 8.4266 48.704415))"
class TestUtils(unittest.TestCase):
def test_simstadt_is_available(self):
self.assertIsNotNone(bw_data.find_simstadt_folder(),
......@@ -59,8 +60,14 @@ class TestGetOpenData(unittest.TestCase):
self.assertIn("DEBW_B010000BSWW", content)
def test_get_weird_name(self):
bw_data.main("WëírdNämeß", KALTENBRONN_WKT,
output_folder=self.tempFolder / 'Kaltenbronn.proj')
weird_name = "WëírdNämeß"
bw_data.main(weird_name, KALTENBRONN_WKT,
output_folder=self.tempFolder / f'{weird_name}.proj')
def test_get_space_in_name(self):
name_with_space = "Two words"
bw_data.main(name_with_space, KALTENBRONN_WKT,
output_folder=self.tempFolder / f'{name_with_space}.proj')
def test_only_download(self):
gml_path = bw_data.main("JustDownload", KALTENBRONN_WKT, download_only=True,
......
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