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
66d66e7d
Commit
66d66e7d
authored
Nov 28, 2025
by
Eric Duminil
Browse files
DRYing parse_atom_georss
parent
a9ff018a
Changes
3
Hide whitespace changes
Inline
Side-by-side
03_berlin.py
View file @
66d66e7d
import
xml.etree.ElementTree
as
ET
from
citygml_download
import
Bundesland
,
download_all_files
from
datetime
import
datetime
from
georss_download
import
parse_atom_georss
from
citygml_download
import
TMP_DIR
,
Bundesland
,
download_all_files
,
download_file
from
zipfile_download
import
ZipFile
BERLIN
=
Bundesland
(
BERLIN
=
Bundesland
(
"Berlin"
,
"Berlin"
,
...
@@ -12,33 +9,14 @@ BERLIN = Bundesland(
...
@@ -12,33 +9,14 @@ BERLIN = Bundesland(
)
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
atom_path
=
TMP_DIR
/
f
"
{
BERLIN
}
.atom"
zip_files
=
parse_atom_georss
(
BERLIN
)
download_file
(
BERLIN
.
source
,
TMP_DIR
/
atom_path
)
import
rich
tree
=
ET
.
parse
(
atom_path
)
root
=
tree
.
getroot
()
zip_files
=
[]
ns
=
{
"atom"
:
"http://www.w3.org/2005/Atom"
}
updated_node
=
root
.
find
(
"atom:updated"
,
ns
)
rich
.
print
(
zip_files
)
if
updated_node
is
None
:
exit
()
raise
ValueError
(
"No date has been found"
)
updated_date
=
updated_node
.
text
if
updated_date
is
None
:
raise
ValueError
(
"No date has been found"
)
source_date
=
datetime
.
strptime
(
updated_date
,
"%Y-%m-%dT%H:%M:%SZ"
)
for
file_elem
in
root
.
findall
(
"atom:entry/atom:link"
,
ns
):
href
=
file_elem
.
attrib
[
"href"
]
if
href
.
endswith
(
".zip"
):
zip_files
.
append
(
ZipFile
(
url
=
href
,
bundesland
=
BERLIN
,
source_date
=
source_date
,
)
)
download_all_files
(
zip_files
)
download_all_files
(
zip_files
)
# NOTE: Extracted files are called xml. Rename them to gml:
# NOTE: Extracted files are called xml. Rename them to gml:
for
xml_path
in
BERLIN
.
download_folder
.
glob
(
'
*.xml
'
):
for
xml_path
in
BERLIN
.
download_folder
.
glob
(
"
*.xml
"
):
gml_path
=
xml_path
.
with_suffix
(
'
.gml
'
)
gml_path
=
xml_path
.
with_suffix
(
"
.gml
"
)
xml_path
.
rename
(
gml_path
)
xml_path
.
rename
(
gml_path
)
14_sachsen_anhalt.py
View file @
66d66e7d
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
# NOTE: Multiple sources are available. Large ZIP might be hard to update
# NOTE: Multiple sources are available. Large ZIP might be hard to update
# ATOM : https://geodatenportal.sachsen-anhalt.de/arcgisinspire/rest/directories/web/INSPIRE_ALKIS/ALKIS_LOD2_BU/datasetlod2.xml
# ATOM : https://geodatenportal.sachsen-anhalt.de/arcgisinspire/rest/directories/web/INSPIRE_ALKIS/ALKIS_LOD2_BU/datasetlod2.xml
from
citygml_download
import
TMP_DIR
,
Bundesland
,
download_all_files
,
download_file
from
citygml_download
import
Bundesland
,
download_all_files
from
zipfile
_download
import
ZipFile
from
georss
_download
import
parse_atom_georss
SACHSEN_ANHALT
=
Bundesland
(
SACHSEN_ANHALT
=
Bundesland
(
"Sachsen-Anhalt"
,
"Sachsen-Anhalt"
,
...
@@ -12,3 +12,10 @@ SACHSEN_ANHALT = Bundesland(
...
@@ -12,3 +12,10 @@ SACHSEN_ANHALT = Bundesland(
license
=
"dl-de/by-2-0"
,
license
=
"dl-de/by-2-0"
,
kontakt
=
"Landesamt für Vermessung und Geoinformation Sachsen-Anhalt <service.lvermgeo@sachsen-anhalt.de>"
,
kontakt
=
"Landesamt für Vermessung und Geoinformation Sachsen-Anhalt <service.lvermgeo@sachsen-anhalt.de>"
,
)
)
if
__name__
==
"__main__"
:
zip_files
=
parse_atom_georss
(
SACHSEN_ANHALT
)
import
rich
rich
.
print
(
zip_files
)
# download_all_files(zip_files)
georss_download.py
0 → 100644
View file @
66d66e7d
import
xml.etree.ElementTree
as
ET
from
datetime
import
datetime
from
citygml_download
import
TMP_DIR
,
Bundesland
,
download_file
from
zipfile_download
import
ZipFile
def
parse_atom_georss
(
bundesland
:
Bundesland
)
->
list
[
ZipFile
]:
atom_path
=
TMP_DIR
/
f
"
{
bundesland
}
.atom"
download_file
(
bundesland
.
source
,
atom_path
)
tree
=
ET
.
parse
(
atom_path
)
root
=
tree
.
getroot
()
zip_files
=
[]
ns
=
{
"atom"
:
"http://www.w3.org/2005/Atom"
}
updated_node
=
root
.
find
(
"atom:updated"
,
ns
)
if
updated_node
is
None
:
raise
ValueError
(
"No date has been found"
)
updated_date
=
updated_node
.
text
if
updated_date
is
None
:
raise
ValueError
(
"No date has been found"
)
source_date
=
datetime
.
strptime
(
updated_date
,
"%Y-%m-%dT%H:%M:%SZ"
)
for
file_elem
in
root
.
findall
(
"atom:entry/atom:link"
,
ns
):
href
=
file_elem
.
attrib
[
"href"
]
if
href
.
endswith
(
".zip"
):
zip_files
.
append
(
ZipFile
(
url
=
href
,
bundesland
=
bundesland
,
source_date
=
source_date
,
)
)
return
zip_files
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