Class LaneFactory

java.lang.Object
org.opentrafficsim.road.network.factory.LaneFactory

public final class LaneFactory extends Object

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 Details

  • 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 line
      laneWidth - Length; lane width
      laneType - LaneType; lane type
      speedLimit - 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 line
      laneWidth - Length; lane width
      laneType - LaneType; lane type
      speedLimit - Speed; speed limit
      Returns:
      LaneFactory this lane factory for method chaining
    • setOffsetStart

      public LaneFactory setOffsetStart(org.djunits.value.vdouble.scalar.Length startOffset)
      Set start offset.
      Parameters:
      startOffset - Length; offset
      Returns:
      LaneFactory this lane factory for method chaining
    • setOffsetEnd

      public LaneFactory setOffsetEnd(org.djunits.value.vdouble.scalar.Length endOffset)
      Set end offset.
      Parameters:
      endOffset - Length; offset
      Returns:
      LaneFactory this lane factory for method chaining
    • addLanes

      public LaneFactory 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. The left-most stripe is created in leftToRight(), 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 adds SOLID 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

      public LaneFactory addLanes(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. The left-most stripe is created in leftToRight(), 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 adds SOLID 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 shoulder
      lat - LateralDirectionality; side of shoulder, use null or NONE for both
      laneType - LaneType; lane type.
      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(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 network
      name - String; name of the new Link
      from - Node; start Node of the new Link
      to - Node; end Node of the new Link
      intermediatePoints - 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 network
      name - String; name of the Lane (and also of the Link that owns it)
      from - Node; starting node of the new Lane
      to - Node; ending node of the new Lane
      intermediatePoints - Point2d[]; intermediate coordinates or null to create a straight road; the intermediate points may contain the coordinates of the from node and to node
      laneType - LaneType; type of the new Lane
      speedLimit - Speed; the speed limit on the new Lane
      simulator - OtsSimulatorInterface; the simulator
      gtuType - GtuType; parent GTU type of relevant GTUs
      Returns:
      Lane; the new Lane
      Throws:
      NetworkException - on network inconsistency
      OtsGeometryException - 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 network
      name - String; name of the Link
      from - Node; starting node of the new Lane
      to - Node; ending node of the new Lane
      intermediatePoints - Point2d[]; intermediate coordinates or null to create a straight road; the intermediate points may contain the coordinates of the from node and to node
      laneCount - int; number of lanes in the road
      laneOffsetAtStart - int; extra offset from design line in lane widths at start of link
      laneOffsetAtEnd - int; extra offset from design line in lane widths at end of link
      laneType - LaneType; type of the new Lanes
      speedLimit - Speed; the speed limit on all lanes
      simulator - OtsSimulatorInterface; the simulator
      gtuType - GtuType; parent GTU type of relevant GTUs
      Returns:
      Lane<String, String>[]; array containing the new Lanes
      Throws:
      NetworkException - on topological problems
      OtsGeometryException - 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 network
      name - String; name of the Link
      from - Node; starting node of the new Lane
      to - Node; ending node of the new Lane
      intermediatePoints - Point2d[]; intermediate coordinates or null to create a straight road; the intermediate points may contain the coordinates of the from node and to node
      laneCount - int; number of lanes in the road
      laneType - LaneType; type of the new Lanes
      speedLimit - Speed; Speed the speed limit (applies to all generated lanes)
      simulator - OtsSimulatorInterface; the simulator
      gtuType - GtuType; parent GTU type of relevant GTUs
      Returns:
      Lane<String, String>[]; array containing the new Lanes
      Throws:
      NamingException - when names cannot be registered for animation
      NetworkException - on topological problems
      OtsGeometryException - 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 network
      name - String; name of the Link
      n1 - Node; control node for the start direction
      n2 - Node; starting node of the new Lane
      n3 - Node; ending node of the new Lane
      n4 - Node; control node for the end direction
      laneCount - int; number of lanes in the road
      laneOffsetAtStart - int; extra offset from design line in lane widths at start of link
      laneOffsetAtEnd - int; extra offset from design line in lane widths at end of link
      laneType - LaneType; type of the new Lanes
      speedLimit - Speed; the speed limit on all lanes
      simulator - OtsSimulatorInterface; the simulator
      gtuType - GtuType; parent GTU type of relevant GTUs
      Returns:
      Lane<String, String>[]; array containing the new Lanes
      Throws:
      NamingException - when names cannot be registered for animation
      NetworkException - on topological problems
      OtsGeometryException - when creation of center line or contour fails
    • makeBezier

      public static OtsLine2d makeBezier(Node n1, Node n2, Node n3, Node n4) throws OtsGeometryException
      Parameters:
      n1 - Node; node 1
      n2 - Node; node 2
      n3 - Node; node 3
      n4 - 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