Class 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
    • 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 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,
                                       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 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​(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 in leftToRight(), 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 use null. This method internally adds null 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 shoulder
        lat - LateralDirectionality; side of shoulder, use null or NONE 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 network
        name - String; name of the new Link
        from - OTSRoadNode; start Node of the new Link
        to - OTSRoadNode; end Node of the new Link
        intermediatePoints - OTSPoint3D[]; array of intermediate coordinates (may be null); the intermediate points may contain the coordinates of the from node and to node
        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​(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 network
        name - String; name of the Lane (and also of the Link that owns it)
        from - OTSRoadNode; starting node of the new Lane
        to - OTSRoadNode; ending node of the new Lane
        intermediatePoints - OTSPoint3D[]; 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
        Returns:
        Lane; the new Lane
        Throws:
        NetworkException - on network inconsistency
        OTSGeometryException - 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 network
        name - String; name of the Link
        from - OTSNode; starting node of the new Lane
        to - OTSNode; ending node of the new Lane
        intermediatePoints - OTSPoint3D[]; 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
        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​(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 network
        name - String; name of the Link
        from - OTSRoadNode; starting node of the new Lane
        to - OTSRoadNode; ending node of the new Lane
        intermediatePoints - OTSPoint3D[]; 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
        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​(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 network
        name - String; name of the Link
        n1 - OTSRoadNode; control node for the start direction
        n2 - OTSRoadNode; starting node of the new Lane
        n3 - OTSRoadNode; ending node of the new Lane
        n4 - OTSRoadNode; 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
        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