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
ef88640b
Commit
ef88640b
authored
Nov 28, 2025
by
Eric Duminil
Browse files
Refactor
parent
6dd147e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
georss_download.py
View file @
ef88640b
...
@@ -5,6 +5,19 @@ from urllib.parse import urljoin
...
@@ -5,6 +5,19 @@ from urllib.parse import urljoin
from
citygml_download
import
TMP_DIR
,
Bundesland
,
download_file
from
citygml_download
import
TMP_DIR
,
Bundesland
,
download_file
from
zipfile_download
import
ZipFile
from
zipfile_download
import
ZipFile
NAMESPACE
=
{
"atom"
:
"http://www.w3.org/2005/Atom"
}
def
get_updated_date
(
node
:
ET
.
Element
)
->
datetime
|
None
:
updated_node
=
node
.
find
(
"atom:updated"
,
NAMESPACE
)
if
updated_node
is
None
:
return
None
updated_date
=
updated_node
.
text
if
updated_date
is
None
:
return
None
source_date
=
datetime
.
strptime
(
updated_date
,
"%Y-%m-%dT%H:%M:%SZ"
)
return
source_date
def
parse_atom_georss
(
bundesland
:
Bundesland
)
->
list
[
ZipFile
]:
def
parse_atom_georss
(
bundesland
:
Bundesland
)
->
list
[
ZipFile
]:
atom_path
=
TMP_DIR
/
f
"
{
bundesland
}
.atom"
atom_path
=
TMP_DIR
/
f
"
{
bundesland
}
.atom"
...
@@ -14,25 +27,21 @@ def parse_atom_georss(bundesland: Bundesland) -> list[ZipFile]:
...
@@ -14,25 +27,21 @@ def parse_atom_georss(bundesland: Bundesland) -> list[ZipFile]:
root
=
tree
.
getroot
()
root
=
tree
.
getroot
()
zip_files
=
[]
zip_files
=
[]
ns
=
{
"atom"
:
"http://www.w3.org/2005/Atom"
}
global_updated_date
=
get_updated_date
(
root
)
updated_node
=
root
.
find
(
"atom:updated"
,
ns
)
for
link_node
in
root
.
findall
(
"atom:entry/atom:link"
,
NAMESPACE
):
if
updated_node
is
None
:
href
=
link_node
.
attrib
[
"href"
]
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"
]
href
=
urljoin
(
bundesland
.
source
,
href
)
href
=
urljoin
(
bundesland
.
source
,
href
)
# TODO: Check if source_date is specified for each ZipFile
gml_updated_date
=
get_updated_date
(
link_node
)
updated_date
=
gml_updated_date
or
global_updated_date
if
updated_date
is
None
:
raise
ValueError
(
f
"Unknown date for
{
href
}
"
)
if
href
.
endswith
(
".zip"
):
if
href
.
endswith
(
".zip"
):
zip_files
.
append
(
zip_files
.
append
(
ZipFile
(
ZipFile
(
url
=
href
,
url
=
href
,
bundesland
=
bundesland
,
bundesland
=
bundesland
,
source_date
=
source
_date
,
source_date
=
updated
_date
,
)
)
)
)
return
zip_files
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