2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
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-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
|
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-06 12:28:20 -04:00
|
|
|
|
|
|
|
|
2021-08-17 12:52:48 -04:00
|
|
|
class TrafficEdge(Edge):
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
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
|
2021-08-06 12:28:20 -04:00
|
|
|
|
|
|
|
@property
|
2021-08-17 12:52:48 -04:00
|
|
|
def edge_type(self):
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get the edge type
|
2021-08-06 12:28:20 -04:00
|
|
|
:return: str
|
|
|
|
"""
|
2021-08-17 12:52:48 -04:00
|
|
|
return self._edge_type
|
2021-08-06 12:28:20 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def lanes(self) -> List[Lane]:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get the lanes on an edge
|
2021-08-06 12:28:20 -04:00
|
|
|
:return: List[Lane]
|
|
|
|
"""
|
|
|
|
return self._lanes
|
|
|
|
|
|
|
|
@lanes.setter
|
|
|
|
def lanes(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set the lanes on an edge
|
2021-08-06 12:28:20 -04:00
|
|
|
:param value: List[Lane]
|
|
|
|
"""
|
|
|
|
self._lanes = value
|
|
|
|
|
|
|
|
@property
|
2021-09-14 13:46:48 -04:00
|
|
|
def priority(self) -> Union[None, int]:
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get the priority between different road types.
|
2021-08-06 12:28:20 -04:00
|
|
|
It starts with one; higher numbers represent more important roads.
|
2021-09-14 13:46:48 -04:00
|
|
|
:return: None or int
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
return self._priority
|
|
|
|
|
|
|
|
@priority.setter
|
|
|
|
def priority(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set the priority between different road types.
|
|
|
|
It starts with one; higher numbers represent more important roads.
|
2021-08-06 12:28:20 -04:00
|
|
|
:param value: int
|
|
|
|
"""
|
2021-09-14 13:46:48 -04:00
|
|
|
if value is not None:
|
|
|
|
self._priority = int(value)
|
2021-08-06 12:28:20 -04:00
|
|
|
|
|
|
|
@property
|
2021-09-14 13:46:48 -04:00
|
|
|
def speed(self) -> Union[None, float]:
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get he speed limit in m/s
|
2021-09-14 13:46:48 -04:00
|
|
|
:return: None or float
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
return self._speed
|
|
|
|
|
|
|
|
@speed.setter
|
|
|
|
def speed(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set the speed limit in m/s
|
2021-08-06 12:28:20 -04:00
|
|
|
:param value: float
|
|
|
|
"""
|
2021-09-14 13:46:48 -04:00
|
|
|
if value is not None:
|
|
|
|
self._speed = float(value)
|
2021-08-06 12:28:20 -04:00
|
|
|
|
|
|
|
@property
|
2021-09-14 13:46:48 -04:00
|
|
|
def length(self) -> Union[None, float]:
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get the lane length in meters
|
2021-09-14 13:46:48 -04:00
|
|
|
:return: None or float
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
return self._length
|
|
|
|
|
|
|
|
@length.setter
|
|
|
|
def length(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set the lane length in meters
|
2021-08-06 12:28:20 -04:00
|
|
|
: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
|
|
|
"""
|
2021-08-30 14:39:24 -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):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
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
|
|
|
"""
|
2021-08-30 14:39:24 -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):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
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]
|