Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
Get Baden-Württemberg CityGML Opendata
Commits
101dc71b
Commit
101dc71b
authored
Mar 24, 2025
by
Eric Duminil
Browse files
Very basic download tests
parent
0a5d84d9
Changes
2
Show whitespace changes
Inline
Side-by-side
download_LoD2_from_LGL_BW.py
View file @
101dc71b
...
@@ -85,7 +85,7 @@ def coordinates_to_grid(longitude: float, latitude: float) -> tuple[int, int]:
...
@@ -85,7 +85,7 @@ def coordinates_to_grid(longitude: float, latitude: float) -> tuple[int, int]:
return
(
x
+
1
,
y
)
return
(
x
+
1
,
y
)
def
wkt_polygon_to_
grid_coords
(
location_name
:
str
,
wkt_str
:
str
)
->
tuple
[
int
,
int
,
int
,
int
]:
def
wkt_polygon_to_
bounding_box
(
location_name
:
str
,
wkt_str
:
str
)
->
tuple
[
int
,
int
,
int
,
int
]:
"""Returns (x, y) of lower-left and bottom-right tiles, containing a given region."""
"""Returns (x, y) of lower-left and bottom-right tiles, containing a given region."""
if
'POLYGON'
not
in
wkt_str
:
if
'POLYGON'
not
in
wkt_str
:
raise
ValueError
(
f
"wkt for
{
location_name
}
should be a WKT POLYGON or MULTIPOLYGON"
)
raise
ValueError
(
f
"wkt for
{
location_name
}
should be a WKT POLYGON or MULTIPOLYGON"
)
...
@@ -262,7 +262,7 @@ def main(location_name: str, wkt_or_zipcode: str, download_only: bool = False,
...
@@ -262,7 +262,7 @@ def main(location_name: str, wkt_or_zipcode: str, download_only: bool = False,
wkt_str
=
get_wkt
(
wkt_or_zipcode
)
wkt_str
=
get_wkt
(
wkt_or_zipcode
)
# Get grid coordinates
# Get grid coordinates
x1
,
x2
,
y1
,
y2
=
wkt_polygon_to_
grid_coords
(
location_name
,
wkt_str
)
x1
,
x2
,
y1
,
y2
=
wkt_polygon_to_
bounding_box
(
location_name
,
wkt_str
)
# Download region
# Download region
download_whole_region
(
output_folder
,
wkt_str
,
x1
,
x2
,
y1
,
y2
)
download_whole_region
(
output_folder
,
wkt_str
,
x1
,
x2
,
y1
,
y2
)
...
...
test_download_lod2.py
0 → 100644
View file @
101dc71b
import
unittest
import
tempfile
import
shutil
from
pathlib
import
Path
import
download_LoD2_from_LGL_BW
as
bw_data
class
TestUtils
(
unittest
.
TestCase
):
def
test_simstadt_is_available
(
self
):
self
.
assertIsNotNone
(
bw_data
.
find_simstadt_folder
(),
"SimStadt folder should be on the Desktop in order for tests to run"
)
def
test_coordinates_to_grid
(
self
):
self
.
assertEqual
(
bw_data
.
coordinates_to_grid
(
9.180
,
48.778
),
(
513
,
5402
))
# Stuttgart - Schloßplatz
self
.
assertEqual
(
bw_data
.
coordinates_to_grid
(
7.853
,
47.990
),
(
413
,
5314
))
# Freiburg - Dreisam
def
test_get_bounding_box
(
self
):
freiburg_to_stuttgart
=
"POLYGON ((7.853 47.990, 9.180 48.778, 7.853 47.990))"
self
.
assertEqual
(
bw_data
.
wkt_polygon_to_bounding_box
(
"Just a line"
,
freiburg_to_stuttgart
),
(
413
,
513
,
5314
,
5402
))
class
TestGetOpenData
(
unittest
.
TestCase
):
@
classmethod
def
setUpClass
(
cls
):
cls
.
tempFolder
=
Path
(
tempfile
.
mkdtemp
())
def
test_get_schlossplatz
(
self
):
# Stuttgart - Schloßplatz
stuttgart_wkt
=
"POLYGON ((9.179206 48.779454, 9.179292 48.777644, 9.178498 48.776753, 9.18118 48.775933, 9.181952 48.77705, 9.182768 48.77862, 9.179206 48.779454))"
bw_data
.
main
(
"Schlossplatz"
,
stuttgart_wkt
)
def
test_get_schwarzwald
(
self
):
# Reichental
reichental_wkt
=
"POLYGON ((8.424282 48.745889, 8.381882 48.737286, 8.382397 48.721773, 8.439903 48.726869, 8.424282 48.745889))"
bw_data
.
main
(
"Reichental"
,
reichental_wkt
)
@
classmethod
def
tearDownClass
(
cls
):
shutil
.
rmtree
(
cls
.
tempFolder
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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