Commit 2f4477c0 authored by Eric Duminil's avatar Eric Duminil
Browse files

Format, and common cache

parent 72ab4f60
......@@ -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'
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment