Class LaneFactory
java.lang.Object
org.opentrafficsim.road.network.factory.LaneFactory
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Peter Knoppers
-
Constructor Summary
ConstructorDescriptionLaneFactory
(RoadNetwork network, Node from, Node to, LinkType type, OtsSimulatorInterface simulator, LaneKeepingPolicy policy, GtuType gtuType) LaneFactory
(RoadNetwork network, Node from, Node to, LinkType type, OtsSimulatorInterface simulator, LaneKeepingPolicy policy, GtuType gtuType, ContinuousLine line) -
Method Summary
Modifier and TypeMethodDescriptionaddLanes
(List<? super Stripe> stripeList, Stripe.Type... types) Adds a lane pair for each stripe type, where the type determines the right-hand side stripe when building from left to right and vice versa.addLanes
(Stripe.Type... types) Adds a lane pair for each stripe type, where the type determines the right-hand side stripe when building from left to right and vice versa.addShoulder
(org.djunits.value.vdouble.scalar.Length width, LateralDirectionality lat, LaneType laneType) Adds 1 or 2 shoulders to the current set of lanes.getLanes()
Returns the created lanes in build order.leftToRight
(double leftLanes, org.djunits.value.vdouble.scalar.Length laneWidth, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit) Prepare the factory to add lanes from left to right.static OtsLine2d
makeBezier
(Node n1, Node n2, Node n3, Node n4) static Lane
makeLane
(RoadNetwork network, String name, Node from, Node to, org.djutils.draw.point.Point2d[] intermediatePoints, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit, OtsSimulatorInterface simulator, GtuType gtuType) Create a simple Lane.static CrossSectionLink
makeLink
(RoadNetwork network, String name, Node from, Node to, org.djutils.draw.point.Point2d[] intermediatePoints, OtsSimulatorInterface simulator) Create a Link along intermediate coordinates from one Node to another.static Lane[]
makeMultiLane
(RoadNetwork network, String name, Node from, Node to, org.djutils.draw.point.Point2d[] intermediatePoints, int laneCount, int laneOffsetAtStart, int laneOffsetAtEnd, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit, OtsSimulatorInterface simulator, GtuType gtuType) Create a simple road with the specified number of Lanes.
This method returns an array of Lane.static Lane[]
makeMultiLane
(RoadNetwork network, String name, Node from, Node to, org.djutils.draw.point.Point2d[] intermediatePoints, int laneCount, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit, OtsSimulatorInterface simulator, GtuType gtuType) Create a simple road with the specified number of Lanes.
This method returns an array of Lane.static Lane[]
makeMultiLaneBezier
(RoadNetwork network, String name, Node n1, Node n2, Node n3, Node n4, int laneCount, int laneOffsetAtStart, int laneOffsetAtEnd, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit, OtsSimulatorInterface simulator, GtuType gtuType) Create a simple road with the specified number of Lanes, based on a Bezier curve.
This method returns an array of Lane.rightToLeft
(double rightLanes, org.djunits.value.vdouble.scalar.Length laneWidth, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit) Prepare the factory to add lanes from right to left.setOffsetEnd
(org.djunits.value.vdouble.scalar.Length endOffset) Set end offset.setOffsetStart
(org.djunits.value.vdouble.scalar.Length startOffset) Set start offset.
-
Constructor Details
-
LaneFactory
public LaneFactory(RoadNetwork network, Node from, Node to, LinkType type, OtsSimulatorInterface simulator, LaneKeepingPolicy policy, GtuType gtuType) throws OtsGeometryException, NetworkException - Parameters:
network
- RoadNetwork; networkfrom
- Node; from nodeto
- Node; to nodetype
- LinkType; link typesimulator
- OtsSimulatorInterface; simulatorpolicy
- LaneKeepingPolicy; lane keeping policygtuType
- GtuType; parent GTU type of relevant GTUs.- 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(RoadNetwork network, Node from, Node to, LinkType type, OtsSimulatorInterface simulator, LaneKeepingPolicy policy, GtuType gtuType, ContinuousLine line) throws NetworkException - Parameters:
network
- RoadNetwork; networkfrom
- Node; from nodeto
- Node; to nodetype
- LinkType; link typesimulator
- OtsSimulatorInterface; simulatorpolicy
- LaneKeepingPolicy; lane keeping policygtuType
- GtuType; parent GTU type of relevant GTUs.line
- ContinuousLine; line- Throws:
NetworkException
- if the link exists, or a node does not exist, in the network
-
-
Method Details
-
leftToRight
public LaneFactory leftToRight(double leftLanes, org.djunits.value.vdouble.scalar.Length laneWidth, LaneType laneType, org.djunits.value.vdouble.scalar.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, org.djunits.value.vdouble.scalar.Length laneWidth, LaneType laneType, org.djunits.value.vdouble.scalar.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
Set start offset.- Parameters:
startOffset
- Length; offset- Returns:
- LaneFactory this lane factory for method chaining
-
setOffsetEnd
Set end offset.- Parameters:
endOffset
- Length; offset- Returns:
- LaneFactory this lane factory for method chaining
-
addLanes
Adds a lane pair for each stripe type, where the type determines the right-hand side stripe when building from left to right and vice versa. The left-most stripe is created inleftToRight()
, meaning that each type describes permeablility between a lane and it's right-hand neighbor, when building left to right (and vice versa). This method internally addsSOLID
to create the final continuous stripe.- Parameters:
types
- Type...; type per lane pair, for N lanes N-1 should be provided- Returns:
- this LaneFactory this lane factory for method chaining
-
addLanes
Adds a lane pair for each stripe type, where the type determines the right-hand side stripe when building from left to right and vice versa. The left-most stripe is created inleftToRight()
, meaning that each type describes permeablility between a lane and it's right-hand neighbor, when building left to right (and vice versa). This method internally addsSOLID
to create the final continuous stripe. All generated stripes, including the one generated in leftToRight() or rightToLeft(), is returned in the provided list for custom permeability.- Parameters:
stripeList
- List<? super Stripe>; list in to which the generated stripes are placed.types
- Type...; type per lane pair, for N lanes N-1 should be provided- Returns:
- this LaneFactory this lane factory for method chaining
-
addShoulder
public LaneFactory addShoulder(org.djunits.value.vdouble.scalar.Length width, LateralDirectionality lat, LaneType laneType) 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 bothlaneType
- LaneType; lane type.- Returns:
- LaneFactory this lane factory for method chaining
- Throws:
IllegalStateException
- if no lanes are defined
-
getLanes
Returns the created lanes in build order.- Returns:
- List<Lane> created lanes in build order
-
makeLink
public static CrossSectionLink makeLink(RoadNetwork network, String name, Node from, Node to, org.djutils.draw.point.Point2d[] 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
- Node; start Node of the new Linkto
- Node; end Node of the new LinkintermediatePoints
- Point2d[]; array of intermediate coordinates (may be null in which case the node points are used)simulator
- 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(RoadNetwork network, String name, Node from, Node to, org.djutils.draw.point.Point2d[] intermediatePoints, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit, OtsSimulatorInterface simulator, GtuType gtuType) 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
- Node; starting node of the new Laneto
- Node; ending node of the new LaneintermediatePoints
- Point2d[]; 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 simulatorgtuType
- GtuType; parent GTU type of relevant GTUs- Returns:
- Lane; the new Lane
- Throws:
NetworkException
- on network inconsistencyOtsGeometryException
- when creation of center line or contour fails
-
makeMultiLane
public static Lane[] makeMultiLane(RoadNetwork network, String name, Node from, Node to, org.djutils.draw.point.Point2d[] intermediatePoints, int laneCount, int laneOffsetAtStart, int laneOffsetAtEnd, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit, OtsSimulatorInterface simulator, GtuType gtuType) 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
- Node; starting node of the new Laneto
- Node; ending node of the new LaneintermediatePoints
- Point2d[]; 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 simulatorgtuType
- GtuType; parent GTU type of relevant GTUs- 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(RoadNetwork network, String name, Node from, Node to, org.djutils.draw.point.Point2d[] intermediatePoints, int laneCount, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit, OtsSimulatorInterface simulator, GtuType gtuType) 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
- Node; starting node of the new Laneto
- Node; ending node of the new LaneintermediatePoints
- Point2d[]; 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 simulatorgtuType
- GtuType; parent GTU type of relevant GTUs- 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(RoadNetwork network, String name, Node n1, Node n2, Node n3, Node n4, int laneCount, int laneOffsetAtStart, int laneOffsetAtEnd, LaneType laneType, org.djunits.value.vdouble.scalar.Speed speedLimit, OtsSimulatorInterface simulator, GtuType gtuType) 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
- Node; control node for the start directionn2
- Node; starting node of the new Lanen3
- Node; ending node of the new Lanen4
- Node; 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 simulatorgtuType
- GtuType; parent GTU type of relevant GTUs- 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
- Parameters:
n1
- Node; node 1n2
- Node; node 2n3
- Node; node 3n4
- Node; 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
-