-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath_points.py
More file actions
78 lines (64 loc) · 2.54 KB
/
Copy pathpath_points.py
File metadata and controls
78 lines (64 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from qgis.core import QgsPointXY
from .vehicle import Vehicle
from .coord import CartesianCoord
class PathPoints:
"""
Class to store the path points during simulation
"""
def __init__(self,
vehicle: Vehicle,
vehicle_name: str,
vehicle_type: str,
vehicle_part_type: str,
vehicle_part: str):
"""
Init a new path point
@param vehicle: Reference to the vehicle
@param vehicle_name: Vehicle name (from vehicle class)
@param vehicle_type: Type main or trailer
@param vehicle_part_type: Part type wheels or body
@param vehicle_part: Point name of the vehicle i.e. fwl, fl, br
"""
self._points: list[CartesianCoord] = [] # List of the points
self._vehicle: Vehicle = vehicle
self._vehicle_name: str = vehicle_name # Vehicle name (from vehicle class)
self._vehicle_type: str = vehicle_type # Type main or trailer
self._vehicle_part_type: str = vehicle_part_type # Part type wheels or body
self._vehicle_part: str = vehicle_part # Point name of the vehicle i.e. fwl, fl, br
def __str__(self):
return "{}. Points: {}".format(self.vehicle_name, len(self._points))
def add_point(self, point: CartesianCoord):
"""
Append a new point to the point list
@param point: Point to add as CartesianCoord
"""
self._points.append(point)
def get_list_as_cartesian(self) -> list[CartesianCoord]:
""" Returns the points as CartesionCoords in a one dimensional list """
return self._points
def get_list_as_qgs_points(self) -> list[QgsPointXY]:
""" Returns the point list as QgsPointXY """
point_list = []
for p in self._points:
point_list.append(QgsPointXY(p.x, p.y))
return point_list
@property
def vehicle(self) -> Vehicle:
""" Returns a reference tho the vehicle """
return self._vehicle
@property
def vehicle_name(self) -> str:
""" Returns vehicle name (from vehicle class) """
return self._vehicle_name
@property
def vehicle_type(self) -> str:
""" Returns type main or trailer """
return self._vehicle_type
@property
def vehicle_part_type(self) -> str:
""" Returns part type wheels or body """
return self._vehicle_part_type
@property
def vehicle_part(self) -> str:
""" Returns point name of the vehicle i.e. fwl, fl, br """
return self._vehicle_part