2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
Crossing module
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
|
|
Code contributors: 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 List, Union
|
2021-08-17 12:49:12 -04:00
|
|
|
from city_model_structure.transport.traffic_node import TrafficNode
|
2021-08-06 12:28:20 -04:00
|
|
|
|
|
|
|
|
2021-08-17 12:49:12 -04:00
|
|
|
class Crossing(TrafficNode):
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
Crossing class
|
|
|
|
"""
|
|
|
|
|
2021-08-17 12:49:12 -04:00
|
|
|
def __init__(self, name, coordinates, priority, width, shape=None, edges=None):
|
2021-08-17 13:30:51 -04:00
|
|
|
super().__init__(name, coordinates, edges=edges, node_type='Crossing')
|
2021-08-17 12:49:12 -04:00
|
|
|
self._priority = priority
|
|
|
|
self._width = width
|
|
|
|
self._shape = shape
|
2021-08-06 12:28:20 -04:00
|
|
|
|
|
|
|
@property
|
2021-09-14 13:46:48 -04:00
|
|
|
def priority(self) -> Union[None, bool]:
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get whether the pedestrians have priority over the vehicles
|
2021-09-14 13:46:48 -04:00
|
|
|
:return: None or bool
|
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 whether the pedestrians have priority over the vehicles
|
2021-08-06 12:28:20 -04:00
|
|
|
:param value: bool
|
|
|
|
"""
|
2021-09-14 13:46:48 -04:00
|
|
|
if value is not None:
|
|
|
|
self._priority = ast.literal_eval(value)
|
2021-08-06 12:28:20 -04:00
|
|
|
|
|
|
|
@property
|
2021-09-14 13:46:48 -04:00
|
|
|
def width(self) -> Union[None, float]:
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get crossing width in meters
|
2021-09-14 13:46:48 -04:00
|
|
|
:return: None or float
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
return self._width
|
|
|
|
|
|
|
|
@width.setter
|
|
|
|
def width(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set crossing width 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._width = float(value)
|
2021-08-06 12:28:20 -04:00
|
|
|
|
|
|
|
@property
|
2021-09-14 13:46:48 -04:00
|
|
|
def shape(self) -> Union[None, List[List[float]]]:
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get the list of positions
|
2021-09-14 13:46:48 -04:00
|
|
|
:return: None or [[x, y, (z)]]
|
2021-08-06 12:28:20 -04:00
|
|
|
"""
|
|
|
|
return self._shape
|
|
|
|
|
|
|
|
@shape.setter
|
|
|
|
def shape(self, value):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Set the list of positions
|
2021-08-06 12:28:20 -04:00
|
|
|
:param value: [[x, y, (z)]]
|
|
|
|
"""
|
2021-09-14 13:46:48 -04:00
|
|
|
if value is not None:
|
|
|
|
self._shape = [[float(i) for i in value]]
|