Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
Germany Open-Data CityGML
Commits
ae277e50
Commit
ae277e50
authored
Nov 11, 2025
by
Eric Duminil
Browse files
Use metalink
parent
ed302711
Changes
1
Hide whitespace changes
Inline
Side-by-side
11_rheinland_pfalz.py
View file @
ae277e50
...
@@ -3,12 +3,9 @@
...
@@ -3,12 +3,9 @@
# ©GeoBasis-DE / LVermGeoRP <Jahr des Datenbezugs>, dl-de/by-2-0, www.lvermgeo.rlp.de [Daten bearbeitet]
# ©GeoBasis-DE / LVermGeoRP <Jahr des Datenbezugs>, dl-de/by-2-0, www.lvermgeo.rlp.de [Daten bearbeitet]
# {"id":"dl-by-de/2.0","name":"Datenlizenz Deutschland Namensnennung 2.0","url":"https://www.govdata.de/dl-de/by-2-0","quelle":"© GeoBasis-DE / LVermGeoRP<Jahr des Datenbezugs>, dl-de/by-2-0, www.lvermgeo.rlp.de [Daten bearbeitet]"}
# {"id":"dl-by-de/2.0","name":"Datenlizenz Deutschland Namensnennung 2.0","url":"https://www.govdata.de/dl-de/by-2-0","quelle":"© GeoBasis-DE / LVermGeoRP<Jahr des Datenbezugs>, dl-de/by-2-0, www.lvermgeo.rlp.de [Daten bearbeitet]"}
import
random
import
xml.etree.ElementTree
as
ET
from
pathlib
import
Path
# Metalink https://geobasis-rlp.de/data/geb3dlo/current/meta4/geb3dlo_gml_07.meta4
# Metalink https://geobasis-rlp.de/data/geb3dlo/current/meta4/geb3dlo_gml_07.meta4
from
citygml_download
import
TMP_DIR
,
Bundesland
,
CityGMLWithHash
,
download_all_files
,
download_file
from
citygml_download
import
Bundesland
,
download_all_files
from
metalink_download
import
download_metalink
,
parse_metalink
# BUG: There are missing certificates on the server :-/
# BUG: There are missing certificates on the server :-/
# https://serverfault.com/questions/1118578/ubuntu-cannot-verify-sectigo-certificate
# https://serverfault.com/questions/1118578/ubuntu-cannot-verify-sectigo-certificate
...
@@ -18,56 +15,6 @@ RHEINLAND_PFALZ = Bundesland(
...
@@ -18,56 +15,6 @@ RHEINLAND_PFALZ = Bundesland(
info
=
"https://lvermgeo.rlp.de/produktinformationen/geotopografie/3d-geodaten/3d-gebaeudemodell"
,
info
=
"https://lvermgeo.rlp.de/produktinformationen/geotopografie/3d-geodaten/3d-gebaeudemodell"
,
)
)
# TODO: DRY WITH BAYERN!
def
download_metalink
(
metalink_url
:
str
,
tmp_path
:
Path
=
TMP_DIR
)
->
Path
:
"""Download metalink file to temporary directory."""
print
(
f
"Downloading
{
metalink_url
}
"
)
basename
=
metalink_url
.
split
(
"/"
)[
-
1
]
or
"metalink.xml"
metalink_path
=
tmp_path
/
basename
download_file
(
metalink_url
,
metalink_path
)
return
metalink_path
def
parse_metalink
(
metalink_path
:
Path
,
bundesland
:
Bundesland
)
->
list
[
CityGMLWithHash
]:
"""Parse metalink XML file and return CityGMLWithHash objects."""
print
(
f
"Parsing metalink file:
{
metalink_path
}
"
)
tree
=
ET
.
parse
(
metalink_path
)
root
=
tree
.
getroot
()
# Handle namespace
ns
=
{
"ml"
:
"urn:ietf:params:xml:ns:metalink"
}
files
=
[]
for
file_elem
in
root
.
findall
(
"ml:file"
,
ns
):
filename
=
file_elem
.
get
(
"name"
)
if
filename
is
None
:
raise
ValueError
(
f
"Not enough information from
{
file_elem
}
"
)
hash_node
=
file_elem
.
find
(
'ml:hash[@type="sha-256"]'
,
ns
)
if
hash_node
is
None
or
hash_node
.
text
is
None
:
raise
ValueError
(
f
"
{
filename
}
has no sha256"
)
urls
=
[
url
.
text
for
url
in
file_elem
.
findall
(
"ml:url"
,
ns
)
if
url
.
text
]
if
len
(
urls
)
==
0
:
raise
ValueError
(
f
"No URL for
{
file_elem
}
"
)
else
:
# Randomize URL order to distribute load across servers
random
.
shuffle
(
urls
)
url
=
urls
[
0
]
files
.
append
(
CityGMLWithHash
(
url
=
url
,
coordinate_reference_system
=
"EPSG:25832"
,
bundesland
=
bundesland
,
expected_sha256
=
hash_node
.
text
,
)
)
return
files
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
metalink_path
=
download_metalink
(
RHEINLAND_PFALZ
.
source
)
metalink_path
=
download_metalink
(
RHEINLAND_PFALZ
.
source
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment