Commit 5e0360e8 authored by Eric Duminil's avatar Eric Duminil
Browse files

Ready for Niedersachsen

parent 732d5f11
......@@ -43,7 +43,7 @@ NIEDERSACHSEN_GEOJSON_URL = (
# TODO: Dry with 02_bayern.py and 10_nordrhein_westfalen.py, and move some functions to utils.py?
# NOTE: Could define a CityGML class: URL, Path, Size, SHA, Date, UTM, Source, Bundesland. And "Up to date?", "Check" method, as well as "Download". "Select", "Compress" too?
def download_and_verify(file_info: dict, tmp_dir: Path, download_dir: Path, max_retries=3) -> bool:
"""Download a file, verify its size, and move to final location."""
"""Download a file, verify its age, and move to final location."""
url = file_info["xml"]
filename = url.split("/")[-1]
last_updated_server = datetime.strptime(file_info["Aktualitaet"], "%Y-%m-%d %H:%M:%S")
......@@ -61,7 +61,7 @@ def download_and_verify(file_info: dict, tmp_dir: Path, download_dir: Path, max_
print(f"✓ {filename} already downloaded and verified")
return True
else:
print(f" Existing file has incorrect hash, will re-download")
print(f" Existing file is too old, will re-download")
final_path.unlink()
tmp_path = tmp_dir / filename
......@@ -117,7 +117,7 @@ def download_all_files(
with open(local_json_path) as json_file:
data = json.load(json_file)
features = data["features"][:20]
features = data["features"]
files = [feature["properties"] for feature in features]
......@@ -160,4 +160,5 @@ if __name__ == "__main__":
NIEDERSACHSEN_GEOJSON_URL,
"niedersachsen_lod2.geojson",
SCRIPT_DIR / "citygml" / "niedersachsen",
retries=2,
)
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