mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-06 04:41:54 +02:00
Merge main.
This commit is contained in:
commit
155b1e21c7
112 changed files with 17854 additions and 5686 deletions
36
map_machine/feature/tree.py
Normal file
36
map_machine/feature/tree.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import numpy as np
|
||||
from colour import Color
|
||||
from svgwrite import Drawing
|
||||
from typing import Dict
|
||||
|
||||
from map_machine.geometry.flinger import Flinger
|
||||
from map_machine.osm.osm_reader import Tagged
|
||||
from map_machine.scheme import Scheme
|
||||
|
||||
|
||||
class Tree(Tagged):
|
||||
"""Tree on the map."""
|
||||
|
||||
def __init__(
|
||||
self, tags: Dict[str, str], coordinates: np.ndarray, point: np.ndarray
|
||||
) -> None:
|
||||
super().__init__(tags)
|
||||
self.coordinates: np.ndarray = coordinates
|
||||
self.point: np.ndarray = point
|
||||
|
||||
def draw(self, svg: Drawing, flinger: Flinger, scheme: Scheme) -> None:
|
||||
"""Draw crown and trunk."""
|
||||
scale: float = flinger.get_scale(self.coordinates)
|
||||
|
||||
radius: float
|
||||
if diameter_crown := self.get_float("diameter_crown") is not None:
|
||||
radius = diameter_crown / 2.0
|
||||
else:
|
||||
radius = 2.0
|
||||
|
||||
color: Color = scheme.get_color("evergreen_color")
|
||||
svg.add(svg.circle(self.point, radius * scale, fill=color, opacity=0.3))
|
||||
|
||||
if (circumference := self.get_float("circumference")) is not None:
|
||||
radius: float = circumference / 2.0 / np.pi
|
||||
svg.add(svg.circle(self.point, radius * scale, fill="#B89A74"))
|
Loading…
Add table
Add a link
Reference in a new issue