Commit f64aec69 authored by Eric Duminil's avatar Eric Duminil
Browse files

More types

parent f8a53b6f
......@@ -51,7 +51,7 @@ OUTPUT_DIR = SCRIPT_DIR / 'output'
Bounds = namedtuple("Bounds", "W S E N")
def load_region(wkt_polygon):
def load_region(wkt_polygon: str):
region = wkt.loads(wkt_polygon)
bounds = Bounds(*region.bounds)
return region, bounds
......@@ -61,7 +61,7 @@ def get_basename(bounds):
return f'{bounds.S}__{bounds.N}__{bounds.W}__{bounds.E}_{TREE_DISTANCE}m'.replace('.', '_')
def get_osm_roads(bounds):
def get_osm_roads(bounds: Bounds):
cache_dir = SCRIPT_DIR / 'cache'
cache_dir.mkdir(exist_ok=True)
......@@ -103,7 +103,7 @@ def set_plot(bounds, to_local_coordinates):
return ax
def place_trees(forest, ways, region, to_local, tree_distance, min_distance_2) -> Forest:
def place_trees(forest: Forest, ways: list, region: str, to_local, tree_distance: float, min_distance_2: float) -> Forest:
local_region = transform(to_local.transform, region)
for way in ways:
......@@ -164,7 +164,7 @@ def plot_trees(bounds: Bounds, forest: Forest, tree_distance: float) -> None:
print(" DONE!")
def export_map(bounds, forest, epsg_id) -> None:
def export_map(bounds: Bounds, forest: Forest, epsg_id: str) -> None:
print("Exporting Map...")
to_wgs84 = Transformer.from_crs(f"EPSG:{epsg_id}", "EPSG:4326", always_xy=True)
interactive_map = folium.Map()
......@@ -197,7 +197,7 @@ def export_map(bounds, forest, epsg_id) -> None:
print(" DONE!")
def export_csv(bounds, forest, wkt_polygon, tree_distance, min_distance, epsg_id) -> None:
def export_csv(bounds: Bounds, forest: Forest, wkt_polygon: str, tree_distance: float, min_distance: float, epsg_id: str) -> None:
print("Exporting CSV...")
with open(OUTPUT_DIR / f"{get_basename(bounds)}_trees.csv", "w") as csv:
csv.write(f"# Fake trees for; {wkt_polygon}\n")
......@@ -239,7 +239,7 @@ def export_shapefile(bounds: Bounds, forest: Forest, epsg_id: str) -> None:
print(" DONE!")
def main(wkt_polygon, epsg_id, tree_distance, min_distance, import_tree_shp) -> None:
def main(wkt_polygon: str, epsg_id: str, tree_distance: float, min_distance: float, import_tree_shp) -> None:
region, bounds = load_region(wkt_polygon)
ways = get_osm_roads(bounds)
......
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