hub/city_model_structure/transport/edge.py
Pilar 2d71136d33 Added first version of traffic classes.
Reorganized classes inside "attributes" into different folders by topic.
2021-08-06 12:28:20 -04:00

169 lines
3.0 KiB
Python

"""
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
"""
from typing import List, TypeVar
Node = TypeVar['Node']
Lane = TypeVar['Lane']
class Edge:
"""
Edge class
Each edge is unidirectional and starts at the "from" node and ends at the "to" node
"""
def __init__(self):
self._id = None
self._from_node = None
self._to_node = None
self._type = None
self._lanes = None
self._number_lanes = None
self._priority = None
self._speed = None
self._length = None
@property
def id(self):
"""
Edge id
:return: str
"""
return self._id
@id.setter
def id(self, value):
"""
Edge id setter
:param value: str
"""
self._id = value
@property
def from_node(self) -> Node:
"""
Starting node
:return: Node
"""
return self._from_node
@from_node.setter
def from_node(self, value):
"""
Starting node setter
:param value: Node
"""
self._from_node = value
@property
def to_node(self) -> Node:
"""
Ending node
:return: Node
"""
return self._to_node
@to_node.setter
def to_node(self, value):
"""
Ending node setter
:param value: Node
"""
self._to_node = value
@property
def type(self):
"""
The name of a type within the SUMO edge type file
:return: str
"""
return self._type
@type.setter
def type(self, value):
"""
Type setter
:param value: str
"""
self._type = value
@property
def lanes(self) -> List[Lane]:
"""
List of lanes on an edge
:return: List[Lane]
"""
return self._lanes
@lanes.setter
def lanes(self, value):
"""
List of lanes on an edge setter
:param value: List[Lane]
"""
self._lanes = value
@property
def number_lanes(self):
"""
Number of default lanes on an edge
:return: int
"""
if self._number_lanes is None:
self._number_lanes = len(self.lanes)
return self._number_lanes
@property
def priority(self):
"""
A number, which determines the priority between different road types.
It starts with one; higher numbers represent more important roads.
:return: int
"""
return self._priority
@priority.setter
def priority(self, value):
"""
Priority setter
:param value: int
"""
self._priority = value
@property
def speed(self):
"""
The speed limit in m/s
:return: float
"""
return self._speed
@speed.setter
def speed(self, value):
"""
The speed limit in m/s setter
:param value: float
"""
self._speed = value
@property
def length(self):
"""
Length in m
:return: float
"""
return self._length
@length.setter
def length(self, value):
"""
Length in m setter
:param value: float
"""
self._length = value