Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mayer
CircularGreenSimCity
Commits
06421a92
Commit
06421a92
authored
11 months ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
OSM: some widths are given with units
parent
770caa5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python_scripts/add_trees_to_open_street_map/add_trees.py
+5
-3
python_scripts/add_trees_to_open_street_map/add_trees.py
with
5 additions
and
3 deletions
+5
-3
python_scripts/add_trees_to_open_street_map/add_trees.py
+
5
-
3
View file @
06421a92
...
...
@@ -109,17 +109,19 @@ def set_plot(bounds: Bounds, to_local_coordinates):
return
ax
def
get_default_widths
(
ways
:
list
)
->
dict
[
str
,
float
]
:
def
get_default_widths
(
ways
:
list
)
->
dict
[
str
,
float
]:
"""Check existing OSM highways, and extract the most common width for each type"""
width_counters
=
{}
for
way
in
ways
:
width
=
float
(
way
.
tags
.
get
(
"width"
,
0
))
# NOTE: Some widths are written with units, so try to remove [m] first.
# TODO: use regex instead
width
=
float
(
way
.
tags
.
get
(
"width"
,
'0'
).
replace
(
'm'
,
''
))
way_type
=
way
.
tags
.
get
(
"highway"
)
if
width
:
if
way_type
not
in
width_counters
:
width_counters
[
way_type
]
=
Counter
()
width_counters
[
way_type
][
width
]
+=
1
return
{
w
:
c
.
most_common
(
1
)[
0
][
0
]
for
w
,
c
in
width_counters
.
items
()}
return
{
w
:
c
.
most_common
(
1
)[
0
][
0
]
for
w
,
c
in
width_counters
.
items
()}
def
place_trees
(
forest
:
Forest
,
ways
:
list
,
region
:
str
,
to_local
,
tree_distance
:
float
,
min_distance_2
:
float
)
->
Forest
:
...
...
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