Class LaneFactory
- java.lang.Object
-
- org.opentrafficsim.road.network.factory.LaneFactory
-
public final class LaneFactory extends Object
Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.$LastChangedDate: 2015-09-16 19:20:07 +0200 (Wed, 16 Sep 2015) $, @version $Revision: 1405 $, by $Author: averbraeck $, initial version 30 okt. 2014
- Author:
- Peter Knoppers
-
-
Constructor Summary
Constructors Constructor Description LaneFactory(OTSRoadNetwork network, OTSRoadNode from, OTSRoadNode to, LinkType type, OTSSimulatorInterface simulator, LaneKeepingPolicy policy)
LaneFactory(OTSRoadNetwork network, OTSRoadNode from, OTSRoadNode to, LinkType type, OTSSimulatorInterface simulator, LaneKeepingPolicy policy, OTSLine3D line)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LaneFactory
addLanes(Stripe.Permeable... permeable)
Adds a lane pair for each permeable, where the permeable determines the right-hand side line when building from left to right and vice versa.LaneFactory
addShoulder(Length width, LateralDirectionality lat)
Adds 1 or 2 shoulders to the current set of lanes.List<Lane>
getLanes()
Returns the created lanes in build order.LaneFactory
leftToRight(double leftLanes, Length laneWidth, LaneType laneType, Speed speedLimit)
Prepare the factory to add lanes from left to right.static OTSLine3D
makeBezier(OTSNode n1, OTSNode n2, OTSNode n3, OTSNode n4)
static Lane
makeLane(OTSRoadNetwork network, String name, OTSRoadNode from, OTSRoadNode to, OTSPoint3D[] intermediatePoints, LaneType laneType, Speed speedLimit, OTSSimulatorInterface simulator)
Create a simple Lane.static CrossSectionLink
makeLink(OTSRoadNetwork network, String name, OTSRoadNode from, OTSRoadNode to, OTSPoint3D[] intermediatePoints, OTSSimulatorInterface simulator)
Create a Link along intermediate coordinates from one Node to another.static Lane[]
makeMultiLane(OTSRoadNetwork network, String name, OTSRoadNode from, OTSRoadNode to, OTSPoint3D[] intermediatePoints, int laneCount, int laneOffsetAtStart, int laneOffsetAtEnd, LaneType laneType, Speed speedLimit, OTSSimulatorInterface simulator)
Create a simple road with the specified number of Lanes.
This method returns an array of Lane.static Lane[]
makeMultiLane(OTSRoadNetwork network, String name, OTSRoadNode from, OTSRoadNode to, OTSPoint3D[] intermediatePoints, int laneCount, LaneType laneType, Speed speedLimit, OTSSimulatorInterface simulator)
Create a simple road with the specified number of Lanes.
This method returns an array of Lane.static Lane[]
makeMultiLaneBezier(OTSRoadNetwork network, String name, OTSRoadNode n1, OTSRoadNode n2, OTSRoadNode n3, OTSRoadNode n4, int laneCount, int laneOffsetAtStart, int laneOffsetAtEnd, LaneType laneType, Speed speedLimit, OTSSimulatorInterface simulator)
Create a simple road with the specified number of Lanes, based on a Bezier curve.
This method returns an array of Lane.LaneFactory
rightToLeft(double rightLanes, Length laneWidth, LaneType laneType, Speed speedLimit)
Prepare the factory to add lanes from right to left.LaneFactory
setOffsetEnd(Length endOffset)
Set end offset.LaneFactory
setOffsetStart(Length startOffset)
Set start offset.
-
-
-
Constructor Detail
-
LaneFactory
public LaneFactory(OTSRoadNetwork network, OTSRoadNode from, OTSRoadNode to, LinkType type, OTSSimulatorInterface simulator, LaneKeepingPolicy policy) throws OTSGeometryException, NetworkException
- Parameters:
network
- OTSRoadNetwork; networkfrom
- OTSRoadNode; from nodeto
- OTSRoadNode; to nodetype
- LinkType; link typesimulator
- OTSSimulatorInterface; simulatorpolicy
- LaneKeepingPolicy; lane keeping policy- Throws:
OTSGeometryException
- if no valid line can be createdNetworkException
- if the link exists, or a node does not exist, in the network
-
LaneFactory
public LaneFactory(OTSRoadNetwork network, OTSRoadNode from, OTSRoadNode to, LinkType type, OTSSimulatorInterface simulator, LaneKeepingPolicy policy, OTSLine3D line) throws NetworkException
- Parameters:
network
- OTSRoadNetwork; networkfrom
- OTSRoadNode; from nodeto
- OTSRoadNode; to nodetype
- LinkType; link typesimulator
- OTSSimulatorInterface; simulatorpolicy
- LaneKeepingPolicy; lane keeping policyline
- OTSLine3D; line- Throws:
NetworkException
- if the link exists, or a node does not exist, in the network
-
-
Method Detail
-
leftToRight
public LaneFactory leftToRight(double leftLanes, Length laneWidth, LaneType laneType, Speed speedLimit)
Prepare the factory to add lanes from left to right.- Parameters:
leftLanes
- double; number of lanes left from the link design linelaneWidth
- Length; lane widthlaneType
- LaneType; lane typespeedLimit
- Speed; speed limit- Returns:
- LaneFactory this lane factory for method chaining
-
rightToLeft
public LaneFactory rightToLeft(double rightLanes, Length laneWidth, LaneType laneType, Speed speedLimit)
Prepare the factory to add lanes from right to left.- Parameters:
rightLanes
- double; number of lanes right from the link design linelaneWidth
- Length; lane widthlaneType
- LaneType; lane typespeedLimit
- Speed; speed limit- Returns:
- LaneFactory this lane factory for method chaining
-
setOffsetStart
public LaneFactory setOffsetStart(Length startOffset)
Set start offset.- Parameters:
startOffset
- Length; offset- Returns:
- LaneFactory this lane factory for method chaining
-
setOffsetEnd
public LaneFactory setOffsetEnd(Length endOffset)
Set end offset.- Parameters:
endOffset
- Length; offset- Returns:
- LaneFactory this lane factory for method chaining
-
addLanes
public LaneFactory addLanes(Stripe.Permeable... permeable)
Adds a lane pair for each permeable, where the permeable determines the right-hand side line when building from left to right and vice versa. The left-most line is created inleftToRight()
, meaning that each permeable describes permeablility between a lane and it's right-hand neighbor, when building left to right (and vice versa). For no allowed lane changes usenull
. This method internally addsnull
to create the final continuous stripe.- Parameters:
permeable
- Permeable...; permeable per lane pair, for N lanes N-1 should be provided- Returns:
- this LaneFactory this lane factory for method chaining
-
addShoulder
public LaneFactory addShoulder(Length width, LateralDirectionality lat)
Adds 1 or 2 shoulders to the current set of lanes.- Parameters:
width
- Length; width of the shoulderlat
- LateralDirectionality; side of shoulder, usenull
orNONE
for both- Returns:
- LaneFactory this lane factory for method chaining
- Throws:
IllegalStateException
- if no lanes are defined
-
getLanes
public List<Lane> getLanes()
Returns the created lanes in build order.- Returns:
- List<Lane> created lanes in build order
-
makeLink
public static CrossSectionLink makeLink(OTSRoadNetwork network, String name, OTSRoadNode from, OTSRoadNode to, OTSPoint3D[] intermediatePoints, OTSSimulatorInterface simulator) throws OTSGeometryException, NetworkException
Create a Link along intermediate coordinates from one Node to another.- Parameters:
network
- RoadNetwork; the networkname
- String; name of the new Linkfrom
- OTSRoadNode; start Node of the new Linkto
- OTSRoadNode; end Node of the new LinkintermediatePoints
- OTSPoint3D[]; array of intermediate coordinates (may be null); the intermediate points may contain the coordinates of the from node and to nodesimulator
- OTSSimulatorInterface; the simulator for this network- Returns:
- Link; the newly constructed Link
- Throws:
OTSGeometryException
- when the design line is degenerate (only one point or duplicate point)NetworkException
- if link already exists in the network, if name of the link is not unique, or if the start node or the end node of the link are not registered in the network.
-
makeLane
public static Lane makeLane(OTSRoadNetwork network, String name, OTSRoadNode from, OTSRoadNode to, OTSPoint3D[] intermediatePoints, LaneType laneType, Speed speedLimit, OTSSimulatorInterface simulator) throws NetworkException, OTSGeometryException
Create a simple Lane.- Parameters:
network
- RoadNetwork; the networkname
- String; name of the Lane (and also of the Link that owns it)from
- OTSRoadNode; starting node of the new Laneto
- OTSRoadNode; ending node of the new LaneintermediatePoints
- OTSPoint3D[]; intermediate coordinates or null to create a straight road; the intermediate points may contain the coordinates of the from node and to nodelaneType
- LaneType; type of the new LanespeedLimit
- Speed; the speed limit on the new Lanesimulator
- OTSSimulatorInterface; the simulator- Returns:
- Lane; the new Lane
- Throws:
NetworkException
- on network inconsistencyOTSGeometryException
- when creation of center line or contour fails
-
makeMultiLane
public static Lane[] makeMultiLane(OTSRoadNetwork network, String name, OTSRoadNode from, OTSRoadNode to, OTSPoint3D[] intermediatePoints, int laneCount, int laneOffsetAtStart, int laneOffsetAtEnd, LaneType laneType, Speed speedLimit, OTSSimulatorInterface simulator) throws NetworkException, OTSGeometryException
Create a simple road with the specified number of Lanes.
This method returns an array of Lane. These lanes are embedded in a Link that can be accessed through the getParentLink method of the Lane.- Parameters:
network
- RoadNetwork; the networkname
- String; name of the Linkfrom
- OTSNode; starting node of the new Laneto
- OTSNode; ending node of the new LaneintermediatePoints
- OTSPoint3D[]; intermediate coordinates or null to create a straight road; the intermediate points may contain the coordinates of the from node and to nodelaneCount
- int; number of lanes in the roadlaneOffsetAtStart
- int; extra offset from design line in lane widths at start of linklaneOffsetAtEnd
- int; extra offset from design line in lane widths at end of linklaneType
- LaneType; type of the new LanesspeedLimit
- Speed; the speed limit on all lanessimulator
- OTSSimulatorInterface; the simulator- Returns:
- Lane<String, String>[]; array containing the new Lanes
- Throws:
NetworkException
- on topological problemsOTSGeometryException
- when creation of center line or contour fails
-
makeMultiLane
public static Lane[] makeMultiLane(OTSRoadNetwork network, String name, OTSRoadNode from, OTSRoadNode to, OTSPoint3D[] intermediatePoints, int laneCount, LaneType laneType, Speed speedLimit, OTSSimulatorInterface simulator) throws NamingException, NetworkException, OTSGeometryException
Create a simple road with the specified number of Lanes.
This method returns an array of Lane. These lanes are embedded in a Link that can be accessed through the getParentLink method of the Lane.- Parameters:
network
- RoadNetwork; the networkname
- String; name of the Linkfrom
- OTSRoadNode; starting node of the new Laneto
- OTSRoadNode; ending node of the new LaneintermediatePoints
- OTSPoint3D[]; intermediate coordinates or null to create a straight road; the intermediate points may contain the coordinates of the from node and to nodelaneCount
- int; number of lanes in the roadlaneType
- LaneType; type of the new LanesspeedLimit
- Speed; Speed the speed limit (applies to all generated lanes)simulator
- OTSSimulatorInterface; the simulator- Returns:
- Lane<String, String>[]; array containing the new Lanes
- Throws:
NamingException
- when names cannot be registered for animationNetworkException
- on topological problemsOTSGeometryException
- when creation of center line or contour fails
-
makeMultiLaneBezier
public static Lane[] makeMultiLaneBezier(OTSRoadNetwork network, String name, OTSRoadNode n1, OTSRoadNode n2, OTSRoadNode n3, OTSRoadNode n4, int laneCount, int laneOffsetAtStart, int laneOffsetAtEnd, LaneType laneType, Speed speedLimit, OTSSimulatorInterface simulator) throws NamingException, NetworkException, OTSGeometryException
Create a simple road with the specified number of Lanes, based on a Bezier curve.
This method returns an array of Lane. These lanes are embedded in a Link that can be accessed through the getParentLink method of the Lane.- Parameters:
network
- RoadNetwork; the networkname
- String; name of the Linkn1
- OTSRoadNode; control node for the start directionn2
- OTSRoadNode; starting node of the new Lanen3
- OTSRoadNode; ending node of the new Lanen4
- OTSRoadNode; control node for the end directionlaneCount
- int; number of lanes in the roadlaneOffsetAtStart
- int; extra offset from design line in lane widths at start of linklaneOffsetAtEnd
- int; extra offset from design line in lane widths at end of linklaneType
- LaneType; type of the new LanesspeedLimit
- Speed; the speed limit on all lanessimulator
- OTSSimulatorInterface; the simulator- Returns:
- Lane<String, String>[]; array containing the new Lanes
- Throws:
NamingException
- when names cannot be registered for animationNetworkException
- on topological problemsOTSGeometryException
- when creation of center line or contour fails
-
makeBezier
public static OTSLine3D makeBezier(OTSNode n1, OTSNode n2, OTSNode n3, OTSNode n4) throws OTSGeometryException
- Parameters:
n1
- OTSNode; node 1n2
- OTSNode; node 2n3
- OTSNode; node 3n4
- OTSNode; node 4- Returns:
- line between n2 and n3 with start-direction n1-->n2 and end-direction n3-->n4
- Throws:
OTSGeometryException
- on failure of Bezier curve creation
-
-