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
0a5d84d9
Commit
0a5d84d9
authored
1 month ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Allow to specify output folder.
parent
6c2f4d01
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
download_LoD2_from_LGL_BW.py
+12
-9
download_LoD2_from_LGL_BW.py
with
12 additions
and
9 deletions
+12
-9
download_LoD2_from_LGL_BW.py
+
12
-
9
View file @
0a5d84d9
...
...
@@ -221,7 +221,7 @@ def parse_arguments():
epilog
=
"""
Examples:
python download_LoD2_from_LGL_BW.py StuttgartCenter "POLYGON((9.175287 48.780916, 9.185501 48.777522, 9.181467 48.773704, 9.174429 48.768472, 9.168807 48.773902, 9.175287 48.780916))"
python download_LoD2_from_LGL_BW.py Freiburg "79098,79102"
python download_LoD2_from_LGL_BW.py Freiburg "79098,79102"
--output-folder="/path/to/FreiburgFolder"
python download_LoD2_from_LGL_BW.py Möhringen "70567" --download-only
"""
)
...
...
@@ -239,21 +239,24 @@ Examples:
help
=
'Path to SimStadt installation folder. By default, tries to find it on the Desktop.'
)
parser
.
add_argument
(
'--output-folder'
,
type
=
Path
,
default
=
None
,
help
=
'Folder in which the tiles should be downloaded and extracted. By default, use the folder of the current script.'
)
help
=
'Folder in which the tiles should be downloaded and extracted. By default, use the folder of the current script
/ name.proj
.'
)
return
parser
.
parse_args
()
def
main
(
location_name
:
str
,
wkt_or_zipcode
:
str
,
download_only
:
bool
=
False
,
simstadt_folder
:
Path
|
None
=
None
):
def
main
(
location_name
:
str
,
wkt_or_zipcode
:
str
,
download_only
:
bool
=
False
,
simstadt_folder
:
Path
|
None
=
None
,
output_folder
:
Path
|
None
=
None
):
"""Main function to process arguments and run the download/extraction"""
# Validate location name
if
' '
in
location_name
:
raise
ValueError
(
"Location name should not contain spaces: 'Some City' -> 'SomeCity'"
)
# Create output directory
output_dir
=
SCRIPT_DIR
/
(
location_name
+
'.proj'
)
output_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
if
not
output_folder
:
# Create output directory
output_folder
=
SCRIPT_DIR
/
(
location_name
+
'.proj'
)
output_folder
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
# Get WKT string
wkt_str
=
get_wkt
(
wkt_or_zipcode
)
...
...
@@ -262,7 +265,7 @@ def main(location_name: str, wkt_or_zipcode: str, download_only: bool = False, s
x1
,
x2
,
y1
,
y2
=
wkt_polygon_to_grid_coords
(
location_name
,
wkt_str
)
# Download region
download_whole_region
(
output_
di
r
,
wkt_str
,
x1
,
x2
,
y1
,
y2
)
download_whole_region
(
output_
folde
r
,
wkt_str
,
x1
,
x2
,
y1
,
y2
)
# Extract region if not download-only
if
not
download_only
:
...
...
@@ -272,7 +275,7 @@ def main(location_name: str, wkt_or_zipcode: str, download_only: bool = False, s
"No SimStadt installation found! Please provide --simstadt-folder or use --download-only."
)
return
extract_region
(
output_
di
r
,
location_name
,
wkt_str
,
simstadt_folder
)
extract_region
(
output_
folde
r
,
location_name
,
wkt_str
,
simstadt_folder
)
else
:
logger
.
info
(
"Download-only mode: Skipping region extraction."
)
...
...
@@ -281,4 +284,4 @@ def main(location_name: str, wkt_or_zipcode: str, download_only: bool = False, s
if
__name__
==
'__main__'
:
args
=
parse_arguments
()
main
(
args
.
name
,
args
.
region
,
args
.
download_only
,
args
.
simstadt_folder
)
main
(
args
.
name
,
args
.
region
,
args
.
download_only
,
args
.
simstadt_folder
,
args
.
output_folder
)
This diff is collapsed.
Click to expand it.
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