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
4d17091f
Commit
4d17091f
authored
Nov 10, 2025
by
Eric Duminil
Browse files
Flat extract
parent
cea14af4
Changes
1
Hide whitespace changes
Inline
Side-by-side
01_baden_wuerttemberg.py
View file @
4d17091f
...
@@ -3,7 +3,7 @@ import zipfile
...
@@ -3,7 +3,7 @@ import zipfile
from
datetime
import
datetime
from
datetime
import
datetime
from
pathlib
import
Path
from
pathlib
import
Path
from
citygml_download
import
TMP_DIR
,
Bundesland
,
CityGMLWithDate
,
download_file
,
download_
all_
file
s
from
citygml_download
import
TMP_DIR
,
Bundesland
,
CityGMLWithDate
,
download_
all_
file
s
,
download_file
# Data are available as WFS
# Data are available as WFS
# NOTE: Use geopandas or specific WFS lib?
# NOTE: Use geopandas or specific WFS lib?
...
@@ -22,14 +22,24 @@ BADEN_WUERTTEMBERG = Bundesland(
...
@@ -22,14 +22,24 @@ BADEN_WUERTTEMBERG = Bundesland(
# NOTE: Slightly different than in 07_hessen.py
# NOTE: Slightly different than in 07_hessen.py
class
ZipFile
(
CityGMLWithDate
):
class
ZipFile
(
CityGMLWithDate
):
@
property
def
download_folder
(
self
)
->
Path
:
tmp_folder
=
TMP_DIR
/
self
.
bundesland
.
name
tmp_folder
.
mkdir
(
exist_ok
=
True
)
return
tmp_folder
def
download
(
self
,
tmp_dir
:
Path
=
TMP_DIR
,
max_retries
:
int
=
3
,
sleep
:
int
=
0
)
->
bool
:
def
download
(
self
,
tmp_dir
:
Path
=
TMP_DIR
,
max_retries
:
int
=
3
,
sleep
:
int
=
0
)
->
bool
:
result
=
super
().
download
(
tmp_dir
,
max_retries
,
sleep
)
result
=
super
().
download
(
tmp_dir
,
max_retries
,
sleep
)
if
result
:
if
result
:
output_folder
=
self
.
download_folder
try
:
try
:
print
(
f
" Extracting
{
self
.
filename
}
"
)
print
(
f
" Extracting
{
self
.
filename
}
"
)
with
zipfile
.
ZipFile
(
self
.
path
,
"r"
)
as
main_zip
:
with
zipfile
.
ZipFile
(
self
.
path
,
"r"
)
as
main_zip
:
main_zip
.
extractall
(
output_folder
)
# Flat extract, without directory
for
zip_info
in
main_zip
.
infolist
():
if
zip_info
.
is_dir
():
continue
zip_info
.
filename
=
Path
(
zip_info
.
filename
).
name
main_zip
.
extract
(
zip_info
,
self
.
bundesland
.
download_folder
)
except
zipfile
.
BadZipfile
:
except
zipfile
.
BadZipfile
:
print
(
f
"🛑
{
self
.
path
}
is corrupt. Deleting"
)
print
(
f
"🛑
{
self
.
path
}
is corrupt. Deleting"
)
self
.
path
.
unlink
()
self
.
path
.
unlink
()
...
...
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