Commit ab434d94 authored by Eric Duminil's avatar Eric Duminil
Browse files

Brandenburg download

parent 37e7a876
import re
from datetime import datetime
from citygml_download import TMP_DIR, Bundesland, CityGMLWithDate, download_all_files, download_file
BRANDENBURG = Bundesland(
"Brandenburg",
source="https://data.geobasis-bb.de/geobasis/daten/3d_gebaeude/lod2_gml/",
info="https://geoportal.brandenburg.de/detailansichtdienst/render?url=https://geoportal.brandenburg.de/gs-json/xml?fileid=0414a37a-a749-4ee6-9f59-a41226919c58",
license="dl-de/by-2-0",
kontakt="<kundenservice@geobasis-bb.de> Landesvermessung und Geobasisinformation Brandenburg (LGB)",
)
# <tr class="even"><td class="indexcolicon"><img src="/style/icons/file-zip.svg" alt="[ ]" width="16" height="16" /></td><td class="indexcolname"><a href="lod2_33250-5890.zip">lod2_33250-5890.zip</a></td><td class="indexcollastmod">2024-11-07 20:03 </td><td class="indexcolsize"> 56K</td><td class="indexcoldesc">3D-Gebäudemodelle LoD2</td></tr>
# It's supposedly wrong, but funny, to parse HTML with regexen
# ZIP_AND_DATE = re.compile(r"(lod2_\d+-\d+\.zip).*?(20\d+-\d+\d+ \d+:\d+)", re.IGNORECASE)
ZIP_AND_DATE = re.compile(r"(lod2_\d+-\d+\.zip).*?(20\d+-\d+-\d+ \d+:\d+)", re.IGNORECASE)
if __name__ == "__main__":
html_path = TMP_DIR / f"{BRANDENBURG}_lod2.html"
if not html_path.exists():
download_file(BRANDENBURG.source, TMP_DIR / html_path)
citygmls = []
with open(html_path) as html:
for line in html:
if m := ZIP_AND_DATE.search(line):
name, date = m.groups()
print(date)
citygmls.append(
CityGMLWithDate(
url=BRANDENBURG.source + name,
bundesland=BRANDENBURG,
source_date=datetime.strptime(date, "%Y-%m-%d %H:%M"),
)
)
download_all_files(citygmls)
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