Traffic classes proposal
This commit is contained in:
parent
f1d23a056b
commit
487ae2fa26
44
city_model_structure/attributes/edge.py
Normal file
44
city_model_structure/attributes/edge.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
"""
|
||||
Node module
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
Contributor Milad milad.aghamohamadnia@concordia.ca
|
||||
"""
|
||||
import uuid
|
||||
|
||||
from city_model_structure.attributes.node import Node
|
||||
from typing import List
|
||||
|
||||
|
||||
class Edge:
|
||||
"""
|
||||
Generic edge class to be used as base for the network edges
|
||||
"""
|
||||
def __init__(self, name, nodes=[]):
|
||||
self._name = name
|
||||
self._id = None
|
||||
self._nodes = nodes
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
Edge name
|
||||
"""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
Edge id, an universally unique identifier randomly generated
|
||||
:return: str
|
||||
"""
|
||||
if self._id is None:
|
||||
self._id = uuid.uuid4()
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def nodes(self) -> List[Node]:
|
||||
"""
|
||||
Delimiting nodes for the edge
|
||||
"""
|
||||
return self._nodes
|
48
city_model_structure/attributes/node.py
Normal file
48
city_model_structure/attributes/node.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
"""
|
||||
Node module
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
Contributor Milad milad.aghamohamadnia@concordia.ca
|
||||
"""
|
||||
|
||||
import uuid
|
||||
|
||||
from city_model_structure.attributes.edge import Edge
|
||||
from typing import List
|
||||
|
||||
|
||||
class Node:
|
||||
"""
|
||||
Generic node class to be used as base for the network nodes
|
||||
"""
|
||||
def __init__(self, name, edges=None):
|
||||
if edges is None:
|
||||
edges = []
|
||||
self._name = name
|
||||
self._id = None
|
||||
self._edges = edges
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
Node name
|
||||
"""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
Node id, an universally unique identifier randomly generated
|
||||
:return: str
|
||||
"""
|
||||
if self._id is None:
|
||||
self._id = uuid.uuid4()
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def edges(self) -> List[Edge]:
|
||||
"""
|
||||
Edges delimited by the node
|
||||
"""
|
||||
return self._edges
|
||||
|
48
city_model_structure/network.py
Normal file
48
city_model_structure/network.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
"""
|
||||
Network module
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||
Contributor Milad milad.aghamohamadnia@concordia.ca
|
||||
"""
|
||||
import uuid
|
||||
|
||||
from city_model_structure.city_object import CityObject
|
||||
from city_model_structure.attributes.edge import Edge
|
||||
from city_model_structure.attributes.node import Node
|
||||
from typing import List
|
||||
|
||||
|
||||
class Network(CityObject):
|
||||
"""
|
||||
Generic network class to be used as base for the network models
|
||||
"""
|
||||
def __init__(self, name, edges=None, nodes=None):
|
||||
super().__init__(name, 0, [], None)
|
||||
if nodes is None:
|
||||
nodes = []
|
||||
if edges is None:
|
||||
edges = []
|
||||
self._id = None
|
||||
self._edges = edges
|
||||
self._nodes = nodes
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
Network id, an universally unique identifier randomly generated
|
||||
:return: str
|
||||
"""
|
||||
if self._id is None:
|
||||
self._id = uuid.uuid4()
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def edges(self) -> List[Edge]:
|
||||
"""
|
||||
Network edges
|
||||
"""
|
||||
return self._edges
|
||||
|
||||
@property
|
||||
def nodes(self) -> List[Node]:
|
||||
return self._nodes
|
|
@ -1,160 +0,0 @@
|
|||
"""
|
||||
Traffic network 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
|
||||
from city_model_structure.city_object import CityObject
|
||||
from city_model_structure.transport.road_type import RoadType
|
||||
from city_model_structure.transport.node import Node
|
||||
from city_model_structure.transport.join import Join
|
||||
from city_model_structure.transport.join_exclude import JoinExclude
|
||||
from city_model_structure.transport.edge import Edge
|
||||
from city_model_structure.transport.roundabout import Roundabout
|
||||
from city_model_structure.transport.connection import Connection
|
||||
from city_model_structure.transport.prohibition import Prohibition
|
||||
from city_model_structure.transport.crossing import Crossing
|
||||
from city_model_structure.transport.walking_area import WalkingArea
|
||||
from city_model_structure.transport.traffic_light_logic import TrafficLightLogic
|
||||
|
||||
|
||||
class TrafficNetwork(CityObject):
|
||||
"""
|
||||
TrafficNetwork(CityObject) class
|
||||
"""
|
||||
def __init__(self, name, lod, surfaces, city_lower_corner):
|
||||
super().__init__(name, lod, surfaces, city_lower_corner)
|
||||
self._types = None
|
||||
self._nodes = None
|
||||
self._joins = None
|
||||
self._join_excludes = None
|
||||
self._edges = None
|
||||
self._roundabouts = None
|
||||
self._connections = None
|
||||
self._prohibitions = None
|
||||
self._crossings = None
|
||||
self._walking_areas = None
|
||||
self._traffic_light_logics = None
|
||||
|
||||
@property
|
||||
def types(self) -> List[RoadType]:
|
||||
return self._types
|
||||
|
||||
@types.setter
|
||||
def types(self, value):
|
||||
"""
|
||||
:param value: [RoadType]
|
||||
"""
|
||||
self._types = value
|
||||
|
||||
@property
|
||||
def nodes(self) -> List[Node]:
|
||||
return self._nodes
|
||||
|
||||
@nodes.setter
|
||||
def nodes(self, value):
|
||||
"""
|
||||
:param value: [Node]
|
||||
"""
|
||||
self._nodes = value
|
||||
|
||||
@property
|
||||
def joins(self) -> List[Join]:
|
||||
return self._joins
|
||||
|
||||
@joins.setter
|
||||
def joins(self, value):
|
||||
"""
|
||||
:param value: [Join]
|
||||
"""
|
||||
self._joins = value
|
||||
|
||||
@property
|
||||
def join_excludes(self) -> List[JoinExclude]:
|
||||
return self._join_excludes
|
||||
|
||||
@join_excludes.setter
|
||||
def join_excludes(self, value):
|
||||
"""
|
||||
:param value: [JoinExclude]
|
||||
"""
|
||||
self._join_excludes = value
|
||||
|
||||
@property
|
||||
def edges(self) -> List[Edge]:
|
||||
return self._edges
|
||||
|
||||
@edges.setter
|
||||
def edges(self, value):
|
||||
"""
|
||||
:param value: [Edge]
|
||||
"""
|
||||
self._edges = value
|
||||
|
||||
@property
|
||||
def roundabouts(self) -> List[Roundabout]:
|
||||
return self._roundabouts
|
||||
|
||||
@roundabouts.setter
|
||||
def roundabouts(self, value):
|
||||
"""
|
||||
:param value: [Roundabout]
|
||||
"""
|
||||
self._roundabouts = value
|
||||
|
||||
@property
|
||||
def connections(self) -> List[Connection]:
|
||||
return self._connections
|
||||
|
||||
@connections.setter
|
||||
def connections(self, value):
|
||||
"""
|
||||
:param value: [Connection]
|
||||
"""
|
||||
self._connections = value
|
||||
|
||||
@property
|
||||
def prohibitions(self) -> List[Prohibition]:
|
||||
return self._prohibitions
|
||||
|
||||
@prohibitions.setter
|
||||
def prohibitions(self, value):
|
||||
"""
|
||||
:param value: [Prohibition]
|
||||
"""
|
||||
self._prohibitions = value
|
||||
|
||||
@property
|
||||
def crossings(self) -> List[Crossing]:
|
||||
return self._crossings
|
||||
|
||||
@crossings.setter
|
||||
def crossings(self, value):
|
||||
"""
|
||||
:param value: [Crossing]
|
||||
"""
|
||||
self._crossings = value
|
||||
|
||||
@property
|
||||
def walking_areas(self) -> List[WalkingArea]:
|
||||
return self._walking_areas
|
||||
|
||||
@walking_areas.setter
|
||||
def walking_areas(self, value):
|
||||
"""
|
||||
:param value: [WalkingArea]
|
||||
"""
|
||||
self._walking_areas = value
|
||||
|
||||
@property
|
||||
def traffic_light_logics(self) -> List[TrafficLightLogic]:
|
||||
return self._traffic_light_logics
|
||||
|
||||
@traffic_light_logics.setter
|
||||
def traffic_light_logics(self, value):
|
||||
"""
|
||||
:param value: [TrafficLightLogic]
|
||||
"""
|
||||
self._traffic_light_logics = value
|
|
@ -9,6 +9,8 @@ from typing import List, TypeVar
|
|||
|
||||
Node = TypeVar['Node']
|
||||
|
||||
# todo: check if this class makes sense????
|
||||
|
||||
|
||||
class JoinExclude:
|
||||
"""
|
|
@ -3,21 +3,34 @@ Join 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
|
||||
Contributor Guille guille.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
|
||||
from typing import List, TypeVar
|
||||
from typing import List
|
||||
|
||||
Node = TypeVar['Node']
|
||||
from city_model_structure.attributes.node import Node
|
||||
from city_model_structure.transport.traffic_node import TrafficNode
|
||||
|
||||
|
||||
class Join:
|
||||
class Join(TrafficNode):
|
||||
"""
|
||||
Join class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._nodes = None
|
||||
self._nodes_ids = None
|
||||
def __init__(self, name, coordinates, nodes=None):
|
||||
self._nodes = nodes
|
||||
edges = None
|
||||
prohibitions = None
|
||||
connections = None
|
||||
if self._nodes is not None:
|
||||
edges = []
|
||||
prohibitions = []
|
||||
connections = []
|
||||
for node in self._nodes:
|
||||
edges = edges + node.edges
|
||||
prohibitions = prohibitions + node.prohibitions
|
||||
connections = connections + node.connections
|
||||
super().__init__(name, coordinates, edges, prohibitions, connections)
|
||||
|
||||
@property
|
||||
def nodes(self) -> List[Node]:
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
"""
|
||||
Node 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
|
||||
"""
|
||||
|
||||
|
||||
class Node:
|
||||
"""
|
||||
Node class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._id = None
|
||||
self._x = None
|
||||
self._y = None
|
||||
self._z = None
|
||||
self._type = None
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
Node id
|
||||
:return: str
|
||||
"""
|
||||
return self._id
|
||||
|
||||
@id.setter
|
||||
def id(self, value):
|
||||
"""
|
||||
Node id setter
|
||||
:param value: str
|
||||
"""
|
||||
self._id = value
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
"""
|
||||
The x-position of the node on the plane in m
|
||||
:return: float
|
||||
"""
|
||||
return self._x
|
||||
|
||||
@x.setter
|
||||
def x(self, value):
|
||||
"""
|
||||
The x-position of the node on the plane in m setter
|
||||
:param value: float
|
||||
"""
|
||||
self._x = value
|
||||
|
||||
@property
|
||||
def y(self):
|
||||
"""
|
||||
The y-position of the node on the plane in m
|
||||
:return: float
|
||||
"""
|
||||
return self._y
|
||||
|
||||
@y.setter
|
||||
def y(self, value):
|
||||
"""
|
||||
The y-position of the node on the plane in m setter
|
||||
:param value: float
|
||||
"""
|
||||
self._y = value
|
||||
|
||||
@property
|
||||
def z(self):
|
||||
"""
|
||||
The z-position of the node on the plane in m
|
||||
:return: float
|
||||
"""
|
||||
return self._z
|
||||
|
||||
@z.setter
|
||||
def z(self, value):
|
||||
"""
|
||||
The z-position of the node on the plane in m setter
|
||||
:param value: float
|
||||
"""
|
||||
self._z = value
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
"""
|
||||
Type
|
||||
enum ( "priority", "traffic_light", "right_before_left", "unregulated", "priority_stop", "traffic_light_unregulated", "allway_stop", "rail_signal", "zipper", "traffic_light_right_on_red", "rail_crossing")
|
||||
:return: enum
|
||||
"""
|
||||
return self._type
|
|
@ -1,48 +0,0 @@
|
|||
"""
|
||||
Prohibition 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
|
||||
"""
|
||||
|
||||
|
||||
class Prohibition:
|
||||
"""
|
||||
Prohibition class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._prohibitor = None
|
||||
self._prohibited = None
|
||||
|
||||
@property
|
||||
def prohibitor(self):
|
||||
"""
|
||||
prohibitor
|
||||
:return: str
|
||||
"""
|
||||
return self._prohibitor
|
||||
|
||||
@prohibitor.setter
|
||||
def prohibitor(self, value):
|
||||
"""
|
||||
prohibitor setter
|
||||
:param value: str
|
||||
"""
|
||||
self._prohibitor = value
|
||||
|
||||
@property
|
||||
def prohibited(self):
|
||||
"""
|
||||
prohibited
|
||||
:return: str
|
||||
"""
|
||||
return self._prohibited
|
||||
|
||||
@prohibited.setter
|
||||
def prohibited(self, value):
|
||||
"""
|
||||
prohibited setter
|
||||
:param value: str
|
||||
"""
|
||||
self._prohibited = value
|
|
@ -3,94 +3,40 @@ 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
|
||||
Contributor Guille guille.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
|
||||
from typing import List, TypeVar
|
||||
|
||||
Node = TypeVar['Node']
|
||||
Lane = TypeVar['Lane']
|
||||
from typing import List
|
||||
from city_model_structure.attributes.edge import Edge
|
||||
from city_model_structure.transport.lane import Lane
|
||||
|
||||
|
||||
class Edge:
|
||||
class TrafficEdge(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
|
||||
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
|
||||
|
||||
@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):
|
||||
def edge_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
|
||||
return self._edge_type
|
||||
|
||||
@property
|
||||
def lanes(self) -> List[Lane]:
|
||||
|
@ -114,9 +60,7 @@ class Edge:
|
|||
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
|
||||
return len(self.lanes)
|
||||
|
||||
@property
|
||||
def priority(self):
|
||||
|
@ -166,3 +110,35 @@ class Edge:
|
|||
:param value: float
|
||||
"""
|
||||
self._length = value
|
||||
|
||||
@property
|
||||
def allows(self) -> List[str]:
|
||||
"""
|
||||
List of allowed vehicle classes
|
||||
:return: [str]
|
||||
"""
|
||||
return self._allows
|
||||
|
||||
@allows.setter
|
||||
def allows(self, value):
|
||||
"""
|
||||
List of allowed vehicle classes setter
|
||||
:param value: [str]
|
||||
"""
|
||||
self._allows = value
|
||||
|
||||
@property
|
||||
def disallows(self) -> List[str]:
|
||||
"""
|
||||
List of not allowed vehicle classes
|
||||
:return: [str]
|
||||
"""
|
||||
return self._disallows
|
||||
|
||||
@disallows.setter
|
||||
def disallows(self, value):
|
||||
"""
|
||||
List of not allowed vehicle classes setter
|
||||
:param value: [str]
|
||||
"""
|
||||
self._disallows = value
|
64
city_model_structure/transport/traffic_light.py
Normal file
64
city_model_structure/transport/traffic_light.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
"""
|
||||
Traffic light 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
|
||||
Contributor Guille guille.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
|
||||
from typing import List
|
||||
from city_model_structure.transport.phase import Phase
|
||||
from city_model_structure.transport.traffic_node import TrafficNode
|
||||
|
||||
|
||||
class TrafficLight(TrafficNode):
|
||||
"""
|
||||
Traffic light class
|
||||
"""
|
||||
def __init__(self, name, coordinates, offset, phases=None, edges=None, right_on_red=False):
|
||||
super().__init__(name, coordinates, edges)
|
||||
if phases is None:
|
||||
phases = []
|
||||
self._right_on_red = right_on_red
|
||||
self._offset = offset
|
||||
self._phases = phases
|
||||
|
||||
@property
|
||||
def right_on_red(self):
|
||||
return self._right_on_red
|
||||
|
||||
@right_on_red.setter
|
||||
def right_on_red(self, value):
|
||||
self._right_on_red = value
|
||||
|
||||
@property
|
||||
def offset(self):
|
||||
"""
|
||||
The initial time offset of the program
|
||||
:return: int
|
||||
"""
|
||||
return self._offset
|
||||
|
||||
@offset.setter
|
||||
def offset(self, value):
|
||||
"""
|
||||
The initial time offset of the program setter
|
||||
:param value: int
|
||||
"""
|
||||
self._offset = value
|
||||
|
||||
@property
|
||||
def phases(self) -> List[Phase]:
|
||||
"""
|
||||
Phases of the traffic light logic
|
||||
:return: [Phase]
|
||||
"""
|
||||
return self._phases
|
||||
|
||||
@phases.setter
|
||||
def phases(self, value):
|
||||
"""
|
||||
Phases setter
|
||||
:param value: [Phase]
|
||||
"""
|
||||
self._phases = value
|
|
@ -1,105 +0,0 @@
|
|||
"""
|
||||
Traffic light Logic module
|
||||
These network elements are used to connect multiple side walks and pedestrian crossings
|
||||
(typically one in each corner of an intersection).
|
||||
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
|
||||
|
||||
Phase = TypeVar['Phase']
|
||||
|
||||
|
||||
class TrafficLightLogic:
|
||||
"""
|
||||
TrafficLightLogic class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._id = None
|
||||
self._type = None
|
||||
self._program_id = None
|
||||
self._offset = None
|
||||
self._phases = None
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
Traffic light's id
|
||||
:return: str
|
||||
"""
|
||||
return self._id
|
||||
|
||||
@id.setter
|
||||
def id(self, value):
|
||||
"""
|
||||
Traffic light's id setter
|
||||
:param value: str
|
||||
"""
|
||||
self._id = value
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
"""
|
||||
enum (static, actuated, delay_based)
|
||||
:return:
|
||||
"""
|
||||
return self._type
|
||||
|
||||
@type.setter
|
||||
def type(self, value):
|
||||
"""
|
||||
Type setter
|
||||
:param value:
|
||||
"""
|
||||
self._type = value
|
||||
|
||||
@property
|
||||
def program_id(self):
|
||||
"""
|
||||
Traffic light program's id
|
||||
:return: str
|
||||
"""
|
||||
return self._program_id
|
||||
|
||||
@program_id.setter
|
||||
def program_id(self, value):
|
||||
"""
|
||||
Traffic light program's id setter
|
||||
:param value: str
|
||||
"""
|
||||
self._program_id = value
|
||||
|
||||
@property
|
||||
def offset(self):
|
||||
"""
|
||||
The initial time offset of the program
|
||||
:return: int
|
||||
"""
|
||||
return self._offset
|
||||
|
||||
@offset.setter
|
||||
def offset(self, value):
|
||||
"""
|
||||
The initial time offset of the program setter
|
||||
:param value: int
|
||||
"""
|
||||
self._offset = value
|
||||
|
||||
@property
|
||||
def phases(self) -> List[Phase]:
|
||||
"""
|
||||
Phases of the traffic light logic
|
||||
:return: [Phase]
|
||||
"""
|
||||
return self._phases
|
||||
|
||||
@phases.setter
|
||||
def phases(self, value):
|
||||
"""
|
||||
Phases setter
|
||||
:param value: [Phase]
|
||||
"""
|
||||
self._phases = value
|
30
city_model_structure/transport/traffic_network.py
Normal file
30
city_model_structure/transport/traffic_network.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
"""
|
||||
Traffic network 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
|
||||
Contributor Guille guille.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
|
||||
from typing import List
|
||||
from city_model_structure.attributes.node import Node
|
||||
from city_model_structure.network import Network
|
||||
|
||||
|
||||
class TrafficNetwork(Network):
|
||||
"""
|
||||
TrafficNetwork(CityObject) class
|
||||
"""
|
||||
def __init__(self, name, edges=None, nodes=None):
|
||||
super().__init__(name, edges, nodes)
|
||||
|
||||
@property
|
||||
def nodes(self) -> List[Node]:
|
||||
return self._nodes
|
||||
|
||||
@nodes.setter
|
||||
def nodes(self, value):
|
||||
"""
|
||||
:param value: [Node]
|
||||
"""
|
||||
self._nodes = value
|
83
city_model_structure/transport/traffic_node.py
Normal file
83
city_model_structure/transport/traffic_node.py
Normal file
|
@ -0,0 +1,83 @@
|
|||
"""
|
||||
Node 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
|
||||
Contributor Guille guille.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
from typing import List
|
||||
from city_model_structure.attributes.edge import Edge
|
||||
from city_model_structure.attributes.node import Node
|
||||
from city_model_structure.attributes.point import Point
|
||||
|
||||
|
||||
from city_model_structure.transport.connection import Connection
|
||||
|
||||
|
||||
class TrafficNode(Node):
|
||||
"""
|
||||
Node class
|
||||
"""
|
||||
|
||||
def __init__(self, name, coordinates, edges=None, prohibitions=None, connections=None):
|
||||
super().__init__(name, edges)
|
||||
if connections is None:
|
||||
connections = []
|
||||
if prohibitions is None:
|
||||
prohibitions = []
|
||||
self._coordinates = coordinates
|
||||
self._prohibitions = prohibitions
|
||||
self._connections = connections
|
||||
|
||||
@property
|
||||
def coordinates(self) -> Point:
|
||||
"""
|
||||
The x,y,z - Node coordinates
|
||||
:return: Point
|
||||
"""
|
||||
return self._coordinates
|
||||
|
||||
@coordinates.setter
|
||||
def coordinates(self, value):
|
||||
"""
|
||||
The x,y,z - Node coordinates setter
|
||||
:param value: Point
|
||||
"""
|
||||
self._coordinates = value
|
||||
|
||||
@property
|
||||
def prohibitions(self) -> List[(Edge, Edge)]:
|
||||
"""
|
||||
return a list of forbidden edges tuples meaning you can not move from the first edge to the second
|
||||
"""
|
||||
return self._prohibitions
|
||||
|
||||
@prohibitions.setter
|
||||
def prohibitions(self, value):
|
||||
"""
|
||||
Set the prohibitions tuples for this node
|
||||
"""
|
||||
self._prohibitions = value
|
||||
|
||||
@property
|
||||
def connections(self) -> List[Connection]:
|
||||
"""
|
||||
Return a list of connections for the node
|
||||
"""
|
||||
return self._connections
|
||||
|
||||
@connections.setter
|
||||
def connections(self, value):
|
||||
"""
|
||||
Set the connections for this node
|
||||
"""
|
||||
self._connections = value
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Type
|
||||
enum ( "priority", "traffic_light", "right_before_left", "unregulated", "priority_stop", "traffic_light_unregulated", "allway_stop", "rail_signal", "zipper", "traffic_light_right_on_red", "rail_crossing")
|
||||
:return: enum
|
||||
"""
|
|
@ -1,70 +0,0 @@
|
|||
"""
|
||||
Walking area 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
|
||||
|
||||
Edge = TypeVar['Edge']
|
||||
Node = TypeVar['Node']
|
||||
|
||||
|
||||
class WalkingArea:
|
||||
"""
|
||||
WalkingArea class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._node = None
|
||||
self._edges = None
|
||||
self._shape = None
|
||||
|
||||
@property
|
||||
def node(self) -> Node:
|
||||
"""
|
||||
The node at which this walking area is located
|
||||
:return: Node
|
||||
"""
|
||||
return self._node
|
||||
|
||||
@node.setter
|
||||
def node(self, value):
|
||||
"""
|
||||
The node at which this walking area is located setter
|
||||
:param value: Node
|
||||
"""
|
||||
self._node = value
|
||||
|
||||
@property
|
||||
def edges(self) -> List[Edge]:
|
||||
"""
|
||||
The (road) edges which uniquely define the walking area
|
||||
:return: [Edge]
|
||||
"""
|
||||
return self._edges
|
||||
|
||||
@edges.setter
|
||||
def edges(self, value):
|
||||
"""
|
||||
The (road) edges which uniquely define the walking area setter
|
||||
:param value: [Edge]
|
||||
"""
|
||||
self._edges = value
|
||||
|
||||
@property
|
||||
def shape(self) -> List[List[float]]:
|
||||
"""
|
||||
List of positions (positions in m)
|
||||
:return: [[x, y, (z)]]
|
||||
"""
|
||||
return self._shape
|
||||
|
||||
@shape.setter
|
||||
def shape(self, value):
|
||||
"""
|
||||
List of positions setter
|
||||
:param value: [[x, y, (z)]]
|
||||
"""
|
||||
self._shape = value
|
37
city_model_structure/transport/walkway_node.py
Normal file
37
city_model_structure/transport/walkway_node.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
"""
|
||||
Walking area 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
|
||||
Contributor Guille guille.gutierrezmorote@concordia.ca
|
||||
"""
|
||||
|
||||
from typing import List
|
||||
from city_model_structure.transport.traffic_node import TrafficNode
|
||||
|
||||
|
||||
class WalkwayNode(TrafficNode):
|
||||
"""
|
||||
WalkingArea class
|
||||
"""
|
||||
|
||||
def __init__(self, name, coordinates, edges=None, shape=None):
|
||||
super().__init__(name, coordinates, edges)
|
||||
self._edges = edges
|
||||
self._shape = shape
|
||||
|
||||
@property
|
||||
def shape(self) -> List[List[float]]:
|
||||
"""
|
||||
List of positions (positions in m)
|
||||
:return: [[x, y, (z)]]
|
||||
"""
|
||||
return self._shape
|
||||
|
||||
@shape.setter
|
||||
def shape(self, value):
|
||||
"""
|
||||
List of positions setter
|
||||
:param value: [[x, y, (z)]]
|
||||
"""
|
||||
self._shape = value
|
|
@ -36,7 +36,7 @@ class Idf:
|
|||
|
||||
def __init__(self, city, output_path, idf_file_path, idd_file_path, epw_file_path, export_type="Surfaces"):
|
||||
self._city = city
|
||||
self._output_path = str(output_path.resolve())
|
||||
self._output_path = str((output_path / f'{city.name}.idf').resolve())
|
||||
self._export_type = export_type
|
||||
self._idd_file_path = str(idd_file_path)
|
||||
self._idf_file_path = str(idf_file_path)
|
||||
|
@ -222,9 +222,11 @@ class Idf:
|
|||
self._add_construction(thermal_boundary)
|
||||
|
||||
if self._export_type == "Surfaces":
|
||||
print(len(building.surfaces))
|
||||
self._add_surfaces(building)
|
||||
else:
|
||||
self._add_block(building)
|
||||
self._idf.match()
|
||||
self._idf.saveas(str(self._output_path))
|
||||
|
||||
def _add_block(self, building):
|
||||
|
@ -254,4 +256,4 @@ class Idf:
|
|||
Construction_Name=boundary.construction_name)
|
||||
coordinates = self._matrix_to_list(boundary.surface.solid_polygon.coordinates)
|
||||
surface.setcoords(coordinates)
|
||||
self._idf.intersect_match()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user