hub/city_model_structure/transport/crossing.py

75 lines
1.8 KiB
Python
Raw Normal View History

"""
Crossing module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2021 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
Contributor Milad milad.aghamohamadnia@concordia.ca
Contributor Guille guille.gutierrezmorote@concordia.ca
"""
2021-09-14 13:46:48 -04:00
import ast
from typing import List, Union
from city_model_structure.transport.traffic_node import TrafficNode
class Crossing(TrafficNode):
"""
Crossing class
"""
def __init__(self, name, coordinates, priority, width, shape=None, edges=None):
2021-08-17 13:30:51 -04:00
super().__init__(name, coordinates, edges=edges, node_type='Crossing')
self._priority = priority
self._width = width
self._shape = shape
@property
2021-09-14 13:46:48 -04:00
def priority(self) -> Union[None, bool]:
"""
Get whether the pedestrians have priority over the vehicles
2021-09-14 13:46:48 -04:00
:return: None or bool
"""
return self._priority
@priority.setter
def priority(self, value):
"""
Set whether the pedestrians have priority over the vehicles
:param value: bool
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._priority = ast.literal_eval(value)
@property
2021-09-14 13:46:48 -04:00
def width(self) -> Union[None, float]:
"""
Get crossing width in meters
2021-09-14 13:46:48 -04:00
:return: None or float
"""
return self._width
@width.setter
def width(self, value):
"""
Set crossing width in meters
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._width = float(value)
@property
2021-09-14 13:46:48 -04:00
def shape(self) -> Union[None, List[List[float]]]:
"""
Get the list of positions
2021-09-14 13:46:48 -04:00
:return: None or [[x, y, (z)]]
"""
return self._shape
@shape.setter
def shape(self, value):
"""
Set the list of positions
:param value: [[x, y, (z)]]
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._shape = [[float(i) for i in value]]