2021-08-17 12:52:48 -04:00
|
|
|
"""
|
2021-10-18 16:07:18 -04:00
|
|
|
TrafficNode module
|
2021-08-17 12:52:48 -04:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2021-10-22 13:13:12 -04:00
|
|
|
Copyright © 2021 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2021-08-17 12:52:48 -04:00
|
|
|
Contributor Milad milad.aghamohamadnia@concordia.ca
|
|
|
|
Contributor Guille guille.gutierrezmorote@concordia.ca
|
|
|
|
"""
|
2021-10-22 13:13:12 -04:00
|
|
|
|
2021-10-25 13:28:43 -04:00
|
|
|
from typing import List, TypeVar
|
2021-08-17 13:30:51 -04:00
|
|
|
|
2021-08-17 12:52:48 -04:00
|
|
|
from city_model_structure.attributes.edge import Edge
|
|
|
|
from city_model_structure.attributes.node import Node
|
|
|
|
from city_model_structure.attributes.point import Point
|
2021-10-25 13:28:43 -04:00
|
|
|
|
|
|
|
Connection = TypeVar('Connection')
|
|
|
|
TrafficEdge = TypeVar('TrafficEdge')
|
2021-08-17 12:52:48 -04:00
|
|
|
|
|
|
|
|
|
|
|
class TrafficNode(Node):
|
|
|
|
"""
|
2021-10-18 16:07:18 -04:00
|
|
|
TrafficNode class
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
|
2021-08-17 13:30:51 -04:00
|
|
|
def __init__(self, name, coordinates, node_type='TrafficNode', edges=None, prohibitions=None, connections=None):
|
2021-08-17 12:52:48 -04:00
|
|
|
super().__init__(name, edges)
|
|
|
|
if connections is None:
|
|
|
|
connections = []
|
|
|
|
if prohibitions is None:
|
|
|
|
prohibitions = []
|
|
|
|
self._coordinates = coordinates
|
|
|
|
self._prohibitions = prohibitions
|
|
|
|
self._connections = connections
|
2021-08-17 13:30:51 -04:00
|
|
|
self._node_type = node_type
|
|
|
|
|
|
|
|
@property
|
|
|
|
def node_type(self):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get node type
|
2021-08-17 13:30:51 -04:00
|
|
|
:return: str
|
|
|
|
"""
|
|
|
|
return self._node_type
|
2021-08-17 12:52:48 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def coordinates(self) -> Point:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get node coordinates
|
2021-08-17 12:52:48 -04:00
|
|
|
:return: Point
|
|
|
|
"""
|
|
|
|
return self._coordinates
|
|
|
|
|
|
|
|
@coordinates.setter
|
|
|
|
def coordinates(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set node coordinates
|
2021-08-17 12:52:48 -04:00
|
|
|
:param value: Point
|
|
|
|
"""
|
|
|
|
self._coordinates = value
|
|
|
|
|
2021-10-22 13:13:12 -04:00
|
|
|
@property
|
|
|
|
def edges(self) -> List[TrafficEdge]:
|
|
|
|
"""
|
|
|
|
get edges delimited by the node
|
|
|
|
:return: [TrafficEdge]
|
|
|
|
"""
|
|
|
|
return self._edges
|
|
|
|
|
2021-08-17 12:52:48 -04:00
|
|
|
@property
|
2021-09-22 07:25:53 -04:00
|
|
|
def prohibitions(self) -> [(Edge, Edge)]:
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get node prohibitions
|
|
|
|
:return: [(Edge, Edge)]
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
return self._prohibitions
|
|
|
|
|
|
|
|
@prohibitions.setter
|
|
|
|
def prohibitions(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set node prohibitions
|
|
|
|
:param value: [(Edge, Edge)]
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
self._prohibitions = value
|
|
|
|
|
|
|
|
@property
|
|
|
|
def connections(self) -> List[Connection]:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get node connections
|
|
|
|
:return: [Connection]
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
return self._connections
|
|
|
|
|
|
|
|
@connections.setter
|
|
|
|
def connections(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set node connections
|
|
|
|
:param value: [Connection]
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
self._connections = value
|