Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CircularGreenSimCity
CircularGreenSimCity
Commits
2f4477c0
Commit
2f4477c0
authored
Nov 20, 2024
by
Eric Duminil
Browse files
Format, and common cache
parent
72ab4f60
Changes
1
Hide whitespace changes
Inline
Side-by-side
python_scripts/add_trees_to_open_street_map/add_trees.py
View file @
2f4477c0
...
...
@@ -58,10 +58,10 @@ MIN_DISTANCE = 10 # [m]
# Tree properties, which will be used for every added tree:
TREE_SPECIES
=
'Acer platanoides'
# Should be known by Tree-DB
TREE_CROWN_DIAMETER
=
8
# [m]
TREE_HEIGHT
=
12
# [m]
TREE_TRUNK_DIAMETER
=
90
# [cm]
TREE_SPECIES
=
'Acer platanoides'
# Should be known by Tree-DB
TREE_CROWN_DIAMETER
=
8
# [m]
TREE_HEIGHT
=
12
# [m]
TREE_TRUNK_DIAMETER
=
90
# [cm]
########################
# STREETS #
...
...
@@ -101,15 +101,19 @@ def load_region(wkt_polygon: str):
return
region
,
bounds
def
get_basename
(
bounds
:
Bounds
):
return
f
'
{
bounds
.
S
}
__
{
bounds
.
N
}
__
{
bounds
.
W
}
__
{
bounds
.
E
}
_
{
TREE_DISTANCE
}
m'
.
replace
(
'.'
,
'_'
)
def
get_basename
(
bounds
:
Bounds
,
with_tree_distance
=
True
)
->
str
:
bounds_description
=
f
'
{
bounds
.
S
}
__
{
bounds
.
N
}
__
{
bounds
.
W
}
__
{
bounds
.
E
}
'
.
replace
(
'.'
,
'_'
)
if
with_tree_distance
:
return
f
'
{
bounds_description
}
_
{
TREE_DISTANCE
}
m'
else
:
return
bounds_description
def
get_osm_roads
(
bounds
:
Bounds
):
cache_dir
=
SCRIPT_DIR
/
'cache'
cache_dir
.
mkdir
(
exist_ok
=
True
)
cache_file
=
(
cache_dir
/
get_basename
(
bounds
)).
with_suffix
(
'.pickle'
)
cache_file
=
(
cache_dir
/
get_basename
(
bounds
,
False
)).
with_suffix
(
'.pickle'
)
if
cache_file
.
exists
():
print
(
"Cache has been found. Parsing..."
)
...
...
@@ -220,9 +224,9 @@ def place_trees(forest: Forest, ways: list, region: str, to_local, tree_distance
color
=
'#DFFF00'
,
type
=
'Fake Tree'
,
description
=
TREE_SPECIES
,
diameter
=
TREE_CROWN_DIAMETER
,
# [m]
height
=
TREE_HEIGHT
,
# [m]
trunk_diameter
=
TREE_TRUNK_DIAMETER
,
# [cm]
diameter
=
TREE_CROWN_DIAMETER
,
# [m]
height
=
TREE_HEIGHT
,
# [m]
trunk_diameter
=
TREE_TRUNK_DIAMETER
,
# [cm]
source
=
'add_trees.py'
)
...
...
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