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
d2e3f935
Commit
d2e3f935
authored
Nov 14, 2025
by
Eric Duminil
Browse files
refactor
parent
ea94b15c
Changes
1
Hide whitespace changes
Inline
Side-by-side
13_sachsen.py
View file @
d2e3f935
# https://www.geodaten.sachsen.de/batch-download-4719.html
# https://geocloud.landesvermessung.sachsen.de/public.php/dav/files/AyJqXpJAZJXomCb/lod2_33278_5590_2_sn_citygml.zip
# https://geodienste.sachsen.de/ags-relay/ArcGISServer/guest/arcgis/rest/services/geosn/rest_geosn_downloadlinks/MapServer/3
import
json
from
datetime
import
datetime
...
...
@@ -15,13 +9,10 @@ SACHSEN = Bundesland(
"Sachsen"
,
source
=
"https://geodienste.sachsen.de/ags-relay/ArcGISServer/guest/arcgis/rest/services/geosn/rest_geosn_downloadlinks/MapServer/3/query"
,
info
=
"https://www.geodaten.sachsen.de/"
,
license
=
"Landesamt für Geobasisinformation Sachsen (GeoSN), DL-DE->BY-2.0"
)
PAGE_SIZE
=
1000
# Max amount for Sachsen Server
all_tiles
=
[]
current_offset
=
0
print
(
f
"Starting paged query to retrieve all tiles (page size:
{
PAGE_SIZE
}
)..."
)
def
get_lod2_key
(
url
:
str
)
->
str
:
...
...
@@ -44,61 +35,56 @@ def get_lod2_key(url: str) -> str:
return
"AyJqXpJAZJXomCb"
keep_downloading
=
True
citygmls
=
[]
KEY
=
get_lod2_key
(
"https://www.geodaten.sachsen.de/batch-download-4719.html"
)
DOWNLOAD_SERVER
=
f
"https://geocloud.landesvermessung.sachsen.de/public.php/dav/files/
{
KEY
}
/"
while
keep_downloading
:
QUERY_PARAMS
=
{
"where"
:
"1=1"
,
"outFields"
:
"Kachel,Download_CityGML,Stand"
,
"f"
:
"json"
,
"returnGeometry"
:
"false"
,
"resultOffset"
:
current_offset
,
"resultRecordCount"
:
PAGE_SIZE
,
}
if
__name__
==
"__main__"
:
print
(
f
"Starting paged query to retrieve all tiles (page size:
{
PAGE_SIZE
}
)..."
)
current_offset
=
0
keep_downloading
=
True
citygmls
=
[]
KEY
=
get_lod2_key
(
"https://www.geodaten.sachsen.de/batch-download-4719.html"
)
DOWNLOAD_SERVER
=
f
"https://geocloud.landesvermessung.sachsen.de/public.php/dav/files/
{
KEY
}
/"
while
keep_downloading
:
query_params
=
{
"where"
:
"1=1"
,
"outFields"
:
"Kachel,Download_CityGML,Stand"
,
"f"
:
"json"
,
"returnGeometry"
:
"false"
,
"resultOffset"
:
current_offset
,
"resultRecordCount"
:
PAGE_SIZE
,
}
try
:
response
=
requests
.
get
(
SACHSEN
.
source
,
params
=
query_params
)
response
.
raise_for_status
()
data
=
response
.
json
()
keep_downloading
=
data
.
get
(
"exceededTransferLimit"
,
False
)
except
requests
.
exceptions
.
RequestException
as
e
:
print
(
f
"❌ Error during request at offset
{
current_offset
}
:
{
e
}
"
)
break
try
:
response
=
requests
.
get
(
SACHSEN
.
source
,
params
=
QUERY_PARAMS
)
response
.
raise_for_status
()
data
=
response
.
json
()
keep_downloading
=
data
.
get
(
"exceededTransferLimit"
,
False
)
except
requests
.
exceptions
.
RequestException
as
e
:
print
(
f
"❌ Error during request at offset
{
current_offset
}
:
{
e
}
"
)
break
if
"features"
in
data
and
data
[
"features"
]:
import
rich
print
()
for
feature
in
data
[
"features"
]:
attributes
=
feature
[
"attributes"
]
import
rich
rich
.
print
(
feature
)
filename
=
attributes
[
"Download_CityGML"
].
split
(
"/"
)[
-
1
]
year
=
int
(
attributes
[
"Stand"
].
split
(
"("
)[
0
])
rich
.
print
(
feature
,
filename
,
year
)
citygmls
.
append
(
CityGMLWithDate
(
url
=
DOWNLOAD_SERVER
+
filename
,
bundesland
=
SACHSEN
,
# NOTE: No information is given about month or day, so assume end of year to be sure files get updated
source_date
=
datetime
(
year
,
12
,
31
),
# coordinate_reference_system ?
if
"features"
in
data
and
data
[
"features"
]:
for
feature
in
data
[
"features"
]:
attributes
=
feature
[
"attributes"
]
filename
=
attributes
[
"Download_CityGML"
].
split
(
"/"
)[
-
1
]
year
=
int
(
attributes
[
"Stand"
].
split
(
"("
)[
0
])
citygmls
.
append
(
CityGMLWithDate
(
url
=
DOWNLOAD_SERVER
+
filename
,
bundesland
=
SACHSEN
,
# NOTE: No information is given about month or day, so assume end of year to be sure files get updated
source_date
=
datetime
(
year
,
12
,
31
),
# coordinate_reference_system ?
)
)
)
break
current_offset
+=
PAGE_SIZE
current_offset
+=
PAGE_SIZE
else
:
if
data
.
get
(
"error"
):
print
(
f
"❌ Error in response:
{
data
[
'error'
][
'message'
]
}
"
)
break
else
:
if
data
.
get
(
"error"
):
print
(
f
"❌ Error in response:
{
data
[
'error'
][
'message'
]
}
"
)
break
download_all_files
(
citygmls
)
download_all_files
(
citygmls
)
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