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

More info from tabs

parent 361b1885
......@@ -137,7 +137,8 @@ def place_trees(forest, ways, region, to_local, tree_distance, min_distance_2) -
if local_region.contains(geometry.Point(x, y)):
forest.add_tree_if_possible(min_distance_2, x, y,
color='#DFFF00',
description='Fake Tree',
type='Fake Tree',
description='Tilia tomentosa'
radius=3
)
......@@ -145,6 +146,7 @@ def place_trees(forest, ways, region, to_local, tree_distance, min_distance_2) -
def plot_trees(bounds, forest, tree_distance) -> None:
print("Exporting diagram...")
tree_xs, tree_ys, colors = forest.xs_ys_cs
plt.scatter(tree_xs, tree_ys, s=2, c=colors)
......@@ -195,10 +197,10 @@ def export_csv(bounds, forest, wkt_polygon, tree_distance, min_distance, epsg_id
csv.write(f"# Tree distance along roads; {tree_distance}; [m]\n")
csv.write(f"# Minimum allowed distance between trees; {min_distance}; [m]\n")
csv.write(f"# EPSG; {epsg_id}\n")
csv.write("# X; Y\n")
csv.write("# [m]; [m]\n")
csv.write("# X; Y; Type; Description; Radius\n")
csv.write("# [m]; [m]; [?]; [?]; [m]\n")
for tree in forest:
csv.write(f"{tree.x};{tree.y}\n")
csv.write(f"{tree.x};{tree.y};{tree.type};{tree.description};{tree.radius}\n")
print(" DONE!")
......
......@@ -4,7 +4,14 @@ from tree import Tree, Forest
def get_existing_forest(shp_input):
print(f"Importing {shp_input}")
df = gpd.read_file(shp_input)
trees = [Tree(p.x, p.y) for p in df.geometry]
trees = []
for tree_row in df.itertuples():
point = tree_row.geometry
trees.append(Tree(point.x, point.y,
description=tree_row.Bezeichnun,
radius=tree_row.Kroneradi,
type=tree_row.Baumart
))
return Forest(trees)
if __name__ == "__main__":
......
......@@ -10,8 +10,8 @@ class Tree:
z: float = 0
height: float = None
radius: float = None
description: str = None
type: str = None
description: str = '?'
color: str = 'green'
def __len__(self):
......@@ -21,7 +21,7 @@ class Tree:
return [self.x, self.y][i]
def __str__(self):
return f"{self.description}, {self.radius or '?'} m (X={self.x:.1f}, Y={self.y:.1f})"
return f"{self.type} ({self.description}), {self.radius or '?'} m (X={self.x:.1f}, Y={self.y:.1f})"
class Forest(UserList):
......
Markdown is supported
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