diff --git a/map_machine/feature/building.py b/map_machine/feature/building.py index 1fb1030..1fad455 100644 --- a/map_machine/feature/building.py +++ b/map_machine/feature/building.py @@ -10,9 +10,9 @@ from svgwrite.container import Group from svgwrite.path import Path from map_machine.drawing import PathCommands -from map_machine.feature.direction import Segment from map_machine.figure import Figure from map_machine.geometry.flinger import Flinger +from map_machine.geometry.vector import Segment from map_machine.osm.osm_reader import OSMNode from map_machine.scheme import Scheme, LineStyle diff --git a/map_machine/feature/direction.py b/map_machine/feature/direction.py index 534b296..b86d935 100644 --- a/map_machine/feature/direction.py +++ b/map_machine/feature/direction.py @@ -232,23 +232,3 @@ class DirectionSector(Tagged): fill=gradient.get_funciri(), ) svg.add(path_element) - - -class Segment: - """Closed line segment.""" - - def __init__(self, point_1: np.ndarray, point_2: np.ndarray) -> None: - self.point_1: np.ndarray = point_1 - self.point_2: np.ndarray = point_2 - - difference: np.ndarray = point_2 - point_1 - vector: np.ndarray = difference / np.linalg.norm(difference) - self.angle: float = ( - np.arccos(np.dot(vector, np.array((0.0, 1.0)))) / np.pi - ) - - def __lt__(self, other: "Segment") -> bool: - return ( - ((self.point_1 + self.point_2) / 2.0)[1] - < ((other.point_1 + other.point_2) / 2.0)[1] - ) # fmt: skip diff --git a/map_machine/geometry/vector.py b/map_machine/geometry/vector.py index 7398ded..5871743 100644 --- a/map_machine/geometry/vector.py +++ b/map_machine/geometry/vector.py @@ -115,3 +115,23 @@ class Line: def __repr__(self) -> str: return f"{self.a} * x + {self.b} * y + {self.c} == 0" + + +class Segment: + """Closed line segment.""" + + def __init__(self, point_1: np.ndarray, point_2: np.ndarray) -> None: + self.point_1: np.ndarray = point_1 + self.point_2: np.ndarray = point_2 + + difference: np.ndarray = point_2 - point_1 + vector: np.ndarray = difference / np.linalg.norm(difference) + self.angle: float = ( + np.arccos(np.dot(vector, np.array((0.0, 1.0)))) / np.pi + ) + + def __lt__(self, other: "Segment") -> bool: + return ( + ((self.point_1 + self.point_2) / 2.0)[1] + < ((other.point_1 + other.point_2) / 2.0)[1] + ) # fmt: skip