2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
Connection module
|
|
|
|
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-06 12:28:20 -04:00
|
|
|
Contributor Milad milad.aghamohamadnia@concordia.ca
|
2021-08-17 12:49:12 -04:00
|
|
|
Contributor Guille guille.gutierrezmorote@concordia.ca
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-09-14 13:46:48 -04:00
|
|
|
|
|
|
|
import ast
|
|
|
|
from typing import Union
|
|
|
|
|
2021-08-17 12:49:12 -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
|
|
|
|
|
|
|
|
|
|
|
class Connection:
|
|
|
|
"""
|
|
|
|
Connection class
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self._from_edge = None
|
|
|
|
self._to_edge = None
|
|
|
|
self._from_lane = None
|
|
|
|
self._to_lane = None
|
|
|
|
self._pass = None
|
|
|
|
self._keep_clear = None
|
|
|
|
|
|
|
|
@property
|
|
|
|
def from_edge(self) -> Edge:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get "from" edge
|
2021-08-06 12:28:20 -04:00
|
|
|
:return: Edge
|
|
|
|
"""
|
|
|
|
return self._from_edge
|
|
|
|
|
|
|
|
@from_edge.setter
|
|
|
|
def from_edge(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set "from" edge
|
2021-08-06 12:28:20 -04:00
|
|
|
:param value: Edge
|
|
|
|
"""
|
|
|
|
self._from_edge = value
|
|
|
|
|
|
|
|
@property
|
|
|
|
def to_edge(self) -> Edge:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get "to" edge
|
2021-08-06 12:28:20 -04:00
|
|
|
:return: Edge
|
|
|
|
"""
|
|
|
|
return self._to_edge
|
|
|
|
|
|
|
|
@to_edge.setter
|
|
|
|
def to_edge(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set "to" edge
|
2021-08-06 12:28:20 -04:00
|
|
|
:param value: Edge
|
|
|
|
"""
|
|
|
|
self._to_edge = value
|
|
|
|
|
|
|
|
@property
|
|
|
|
def from_lane(self) -> Lane:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get "from" lane
|
2021-08-06 12:28:20 -04:00
|
|
|
:return: Lane
|
|
|
|
"""
|
|
|
|
return self._to_lane
|
|
|
|
|
|
|
|
@from_lane.setter
|
|
|
|
def from_lane(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set "from" lane
|
2021-08-06 12:28:20 -04:00
|
|
|
:param value: Lane
|
|
|
|
"""
|
|
|
|
self._from_lane = value
|
|
|
|
|
|
|
|
@property
|
|
|
|
def to_lane(self) -> Lane:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get "to" lane
|
2021-08-06 12:28:20 -04:00
|
|
|
:return: Lane
|
|
|
|
"""
|
|
|
|
return self._to_lane
|
|
|
|
|
|
|
|
@to_lane.setter
|
|
|
|
def to_lane(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set "to" lane
|
2021-08-06 12:28:20 -04:00
|
|
|
:param value: Lane
|
|
|
|
"""
|
|
|
|
self._to_lane = value
|
|
|
|
|
|
|
|
@property
|
2021-09-14 13:46:48 -04:00
|
|
|
def pass_not_wait(self) -> Union[None, bool]:
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get if the vehicles which pass this (lane to lane) connection will not wait
|
2021-09-14 13:46:48 -04:00
|
|
|
:return: None or Boolean
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
return self._pass
|
|
|
|
|
|
|
|
@pass_not_wait.setter
|
|
|
|
def pass_not_wait(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set if the vehicles which pass this (lane to lane) connection will not wait
|
|
|
|
:param value: Boolean
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-09-14 13:46:48 -04:00
|
|
|
if value is not None:
|
|
|
|
self._pass = ast.literal_eval(value)
|
2021-08-06 12:28:20 -04:00
|
|
|
|
|
|
|
@property
|
2021-09-14 13:46:48 -04:00
|
|
|
def keep_clear(self) -> Union[None, bool]:
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get if vehicles which pass this (lane to lane) connection should keep the intersection clear
|
2021-09-14 13:46:48 -04:00
|
|
|
:return: None or Boolean
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
return self._keep_clear
|
|
|
|
|
|
|
|
@keep_clear.setter
|
|
|
|
def keep_clear(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set if vehicles which pass this (lane to lane) connection should keep the intersection clear
|
|
|
|
:param value: Boolean
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-09-14 13:46:48 -04:00
|
|
|
if value is not None:
|
|
|
|
self._keep_clear = ast.literal_eval(value)
|