hub/city_model_structure/transport/traffic_edge.py

142 lines
3.2 KiB
Python
Raw Normal View History

"""
Edge module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
Contributor Milad milad.aghamohamadnia@concordia.ca
2021-08-17 12:52:48 -04:00
Contributor Guille guille.gutierrezmorote@concordia.ca
"""
2021-09-14 13:46:48 -04:00
from typing import List, Union
2021-08-17 12:52:48 -04:00
from city_model_structure.attributes.edge import Edge
from city_model_structure.transport.lane import Lane
2021-08-17 12:52:48 -04:00
class TrafficEdge(Edge):
"""
Edge class
Each edge is unidirectional and starts at the "from" node and ends at the "to" node
"""
2021-08-17 12:52:48 -04:00
def __init__(self, name, nodes, priority, speed, lanes, length, allows=None, disallows=None, sidewalk_width=None,
edge_type='TrafficEdge'):
super().__init__(name, nodes)
self._edge_type = edge_type
self._lanes = lanes
self._priority = priority
self._speed = speed
self._length = length
self._allows = allows
self._disallows = disallows
self._sidewalk_width = sidewalk_width
@property
2021-08-17 12:52:48 -04:00
def edge_type(self):
"""
Get the edge type
:return: str
"""
2021-08-17 12:52:48 -04:00
return self._edge_type
@property
def lanes(self) -> List[Lane]:
"""
Get the lanes on an edge
:return: List[Lane]
"""
return self._lanes
@lanes.setter
def lanes(self, value):
"""
Set the lanes on an edge
:param value: List[Lane]
"""
self._lanes = value
@property
2021-09-14 13:46:48 -04:00
def priority(self) -> Union[None, int]:
"""
Get the priority between different road types.
It starts with one; higher numbers represent more important roads.
2021-09-14 13:46:48 -04:00
:return: None or int
"""
return self._priority
@priority.setter
def priority(self, value):
"""
Set the priority between different road types.
It starts with one; higher numbers represent more important roads.
:param value: int
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._priority = int(value)
@property
2021-09-14 13:46:48 -04:00
def speed(self) -> Union[None, float]:
"""
Get he speed limit in m/s
2021-09-14 13:46:48 -04:00
:return: None or float
"""
return self._speed
@speed.setter
def speed(self, value):
"""
Set the speed limit in m/s
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._speed = float(value)
@property
2021-09-14 13:46:48 -04:00
def length(self) -> Union[None, float]:
"""
Get the lane length in meters
2021-09-14 13:46:48 -04:00
:return: None or float
"""
return self._length
@length.setter
def length(self, value):
"""
Set the lane length in meters
:param value: float
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._length = float(value)
2021-08-17 12:52:48 -04:00
@property
2021-09-14 13:46:48 -04:00
def allows(self) -> Union[None, List[str]]:
2021-08-17 12:52:48 -04:00
"""
Get the list of allowed vehicle classes
2021-09-14 13:46:48 -04:00
:return: None or [str]
2021-08-17 12:52:48 -04:00
"""
return self._allows
@allows.setter
def allows(self, value):
"""
Set the list of allowed vehicle classes
2021-08-17 12:52:48 -04:00
:param value: [str]
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._allows = [str(i) for i in value]
2021-08-17 12:52:48 -04:00
@property
2021-09-14 13:46:48 -04:00
def disallows(self) -> Union[None, List[str]]:
2021-08-17 12:52:48 -04:00
"""
Get the list of not allowed vehicle classes
2021-09-14 13:46:48 -04:00
:return: None or [str]
2021-08-17 12:52:48 -04:00
"""
return self._disallows
@disallows.setter
def disallows(self, value):
"""
Set the list of not allowed vehicle classes
2021-08-17 12:52:48 -04:00
:param value: [str]
"""
2021-09-14 13:46:48 -04:00
if value is not None:
self._disallows = [str(i) for i in value]