aim4.map.lane
Class AbstractLane

java.lang.Object
  extended by aim4.map.lane.AbstractLane
All Implemented Interfaces:
Lane
Direct Known Subclasses:
LineSegmentLane

public abstract class AbstractLane
extends Object
implements Lane

This is a base class for all Lanes. Creates an ID system for lanes such that all lanes will have a different integer ID. Also handles traffic generation methods, and other things that are the same no matter the implementation of the Lane.


Constructor Summary
AbstractLane(double speedLimit)
          Create a new Lane.
 
Method Summary
abstract  boolean contains(Point2D pos)
          Whether or not the provided point can be considered "in" this Lane.
abstract  double distanceAlongLane(Point2D pos)
          Get the distance along the Lane from the start of the Lane to the Point in the center of the Lane nearest the given Point.
abstract  Point2D getEndPoint()
          Get the ending point of the Lane.
abstract  double getHeadingAtNormalizedDistance(double normalizedDistance)
          Get the heading of the Lane at a particular normalized distance from the start of the Lane.
 int getId()
          Get the unique ID number of this Lane.
abstract  double getInitialHeading()
          Get the heading of this Lane at its starting point.
 LaneIM getLaneIM()
          Get the LaneIM object that helps to locate the intersection managers on a lane.
abstract  Point2D getLeadPoint(Point2D pos, double leadDist)
          Get a point further down the Lane from the nearest point to the given position.
 Lane getLeftNeighbor()
          Get the left neighbor of this Lane.
abstract  double getLength()
          Get the length of this Lane.
 Lane getNextLane()
          Get the Lane into which this Lane leads, or null if none.
abstract  Point2D getPointAtNormalizedDistance(double normalizedDistance)
          Get a point in the center of the lane at a particular normalized distance from the start of the Lane.
 Lane getPrevLane()
          Get the Lane which leads into this Lane, or null if none.
 Lane getRightNeighbor()
          Get the right neighbor of this Lane.
abstract  Shape getShape()
          Get a Shape describing this Lane, including its width.
abstract  Shape getShape(double startFraction, double endFraction)
          Get a Shape describing an interval of this lane, using normalized distances.
 double getSpeedLimit()
          Get the speed limit of this Lane, in meters per second.
abstract  Point2D getStartPoint()
          Get the starting point of the Lane.
abstract  double getTerminalHeading()
          Get the heading of this Lane at its ending point.
abstract  double getWidth()
          Get the width of this Lane, in meters.
 boolean hasLeftNeighbor()
          Whether the Lane has another Lane immediately to its left travelling in the same direction.
 boolean hasNextLane()
          Whether or not this Lane flows into another Lane.
 boolean hasPrevLane()
          Whether or not another Lane flows into this Lane.
 boolean hasRightNeighbor()
          Whether the Lane has another Lane immediately to its right travelling in the same direction.
abstract  Point2D intersectionPoint(Line2D l)
          The point at which the the given Line intersects the center of this Lane.
abstract  Shape leftBorder()
          Get a Shape representing the left border of this Lane.
abstract  Point2D leftIntersectionPoint(Line2D l)
          The point at which the the given Line intersects the left border of this Lane.
abstract  double nearestDistance(Point2D pos)
          Get the distance from a point to the center of the Lane.
abstract  Point2D nearestPoint(Point2D p)
          Get the point in the center of the Lane nearest to the provided point.
abstract  double normalizedDistanceAlongLane(Point2D pos)
          Get the normalized distance to the point in the center of the lane nearest the provided point.
abstract  double remainingDistanceAlongLane(Point2D pos)
          Get the amount of distance left in this Lane from the point on the Lane nearest to the given point.
abstract  Shape rightBorder()
          Get a Shape representing the right border of this Lane.
abstract  Point2D rightIntersectionPoint(Line2D l)
          The point at which the the given Line intersects the right border of this Lane.
 void setId(int id)
          Set the unique ID number of this Lane.
 void setLeftNeighbor(Lane ln)
          Register another Lane as a left neighbor to this Lane.
 void setNextLane(Lane nextLane)
          Set the Lane into which this Lane leads.
 void setPrevLane(Lane prevLane)
          Set the Lane which leads into this Lane.
 void setRightNeighbor(Lane ln)
          Register another Lane as a right neighbor to this Lane.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface aim4.map.lane.Lane
normalizedDistance
 

Constructor Detail

AbstractLane

public AbstractLane(double speedLimit)
Create a new Lane.

Method Detail

getId

public int getId()
Get the unique ID number of this Lane.

Specified by:
getId in interface Lane
Returns:
the ID number of this lane

setId

public void setId(int id)
Set the unique ID number of this Lane.

Specified by:
setId in interface Lane
Parameters:
id - the ID number of this lane

getSpeedLimit

public double getSpeedLimit()
Get the speed limit of this Lane, in meters per second.

Specified by:
getSpeedLimit in interface Lane
Returns:
the speed limit of this Lane, in meters per second

getLaneIM

public LaneIM getLaneIM()
Get the LaneIM object that helps to locate the intersection managers on a lane.

Specified by:
getLaneIM in interface Lane
Returns:
the LaneIM object

hasNextLane

public boolean hasNextLane()
Whether or not this Lane flows into another Lane.

Specified by:
hasNextLane in interface Lane
Returns:
whether or not this Lane flows into another Lane

getNextLane

public Lane getNextLane()
Get the Lane into which this Lane leads, or null if none.

Specified by:
getNextLane in interface Lane
Returns:
the Lane into which this Lane leads, or null if none

setNextLane

public void setNextLane(Lane nextLane)
Set the Lane into which this Lane leads.

Specified by:
setNextLane in interface Lane
Parameters:
nextLane - the Lane into which this Lane leads

hasPrevLane

public boolean hasPrevLane()
Whether or not another Lane flows into this Lane.

Specified by:
hasPrevLane in interface Lane
Returns:
whether or not another Lane flows into this Lane

getPrevLane

public Lane getPrevLane()
Get the Lane which leads into this Lane, or null if none.

Specified by:
getPrevLane in interface Lane
Returns:
the Lane which leads into this Lane, or null if none

setPrevLane

public void setPrevLane(Lane prevLane)
Set the Lane which leads into this Lane.

Specified by:
setPrevLane in interface Lane
Parameters:
prevLane - the Lane which leads into this Lane

hasLeftNeighbor

public boolean hasLeftNeighbor()
Whether the Lane has another Lane immediately to its left travelling in the same direction. In other words, whether a vehicle can change lanes to the left.

Specified by:
hasLeftNeighbor in interface Lane
Returns:
whether the Lane has a neighbor to its left

getLeftNeighbor

public Lane getLeftNeighbor()
Get the left neighbor of this Lane.

Specified by:
getLeftNeighbor in interface Lane
Returns:
the left neighbor of this Lane, or null if none exists

setLeftNeighbor

public void setLeftNeighbor(Lane ln)
Register another Lane as a left neighbor to this Lane. This is like having two lanes next to each other with a dotted line in between.

Specified by:
setLeftNeighbor in interface Lane
Parameters:
ln - the Lane to set as this Lane's left neighbor

hasRightNeighbor

public boolean hasRightNeighbor()
Whether the Lane has another Lane immediately to its right travelling in the same direction. In other words, whether a vehicle can change lanes to the right.

Specified by:
hasRightNeighbor in interface Lane
Returns:
whether the Lane has a neighbor to its right

getRightNeighbor

public Lane getRightNeighbor()
Get the right neighbor of this Lane.

Specified by:
getRightNeighbor in interface Lane
Returns:
the right neighbor of this Lane, or null if none exists

setRightNeighbor

public void setRightNeighbor(Lane ln)
Register another Lane as a right neighbor to this Lane. This is like having two lanes next to each other with a dotted line in between.

Specified by:
setRightNeighbor in interface Lane
Parameters:
ln - the Lane to set as this Lane's right neighbor

getLength

public abstract double getLength()
Get the length of this Lane.

Specified by:
getLength in interface Lane
Returns:
the length of this Lane, in meters

getStartPoint

public abstract Point2D getStartPoint()
Get the starting point of the Lane.

Specified by:
getStartPoint in interface Lane
Returns:
the starting point of the Lane

getEndPoint

public abstract Point2D getEndPoint()
Get the ending point of the Lane.

Specified by:
getEndPoint in interface Lane
Returns:
the ending point of the Lane

getPointAtNormalizedDistance

public abstract Point2D getPointAtNormalizedDistance(double normalizedDistance)
Get a point in the center of the lane at a particular normalized distance from the start of the Lane.

Specified by:
getPointAtNormalizedDistance in interface Lane
Parameters:
normalizedDistance - the normalized distance (between 0 and 1) from the start of the Lane
Returns:
the point in the center of the Lane at the given normalized distance

nearestPoint

public abstract Point2D nearestPoint(Point2D p)
Get the point in the center of the Lane nearest to the provided point.

Specified by:
nearestPoint in interface Lane
Parameters:
p - the point to which the nearest point in the center of the Lane should be found
Returns:
the point in the center of the Lane nearest to the given point

nearestDistance

public abstract double nearestDistance(Point2D pos)
Get the distance from a point to the center of the Lane.

Specified by:
nearestDistance in interface Lane
Parameters:
pos - the point from which to find the distance to the Lane
Returns:
the distance from the point to the center of the Lane

getLeadPoint

public abstract Point2D getLeadPoint(Point2D pos,
                                     double leadDist)
Get a point further down the Lane from the nearest point to the given position.

Specified by:
getLeadPoint in interface Lane
Parameters:
pos - the position from which to calculate the nearest point in the Lane
leadDist - the lead distance further down the Lane, in meters
Returns:
a point leadDist further down the Lane from the closest point in the Lane to pos

distanceAlongLane

public abstract double distanceAlongLane(Point2D pos)
Get the distance along the Lane from the start of the Lane to the Point in the center of the Lane nearest the given Point.

Specified by:
distanceAlongLane in interface Lane
Parameters:
pos - the point to which to find the distance along the Lane
Returns:
the distance along the Lane from the start of the Lane to the Point in the center of the Lane nearest the given Point

remainingDistanceAlongLane

public abstract double remainingDistanceAlongLane(Point2D pos)
Get the amount of distance left in this Lane from the point on the Lane nearest to the given point. This is used so a vehicle can determine how much of the Lane is left, given its current position.

Specified by:
remainingDistanceAlongLane in interface Lane
Parameters:
pos - the point nearest which to find the distance to the end of the Lane
Returns:
the distance from the nearest point on the Lane to the given point to the end of the Lane.

normalizedDistanceAlongLane

public abstract double normalizedDistanceAlongLane(Point2D pos)
Get the normalized distance to the point in the center of the lane nearest the provided point. That is, given a point, find the nearest point in the center of the lane, then find the proportion of the way from the start point of the lane to the endpoint of the lane that that point is.

Specified by:
normalizedDistanceAlongLane in interface Lane
Parameters:
pos - the point near to which to find the normalized distance
Returns:
the normalized distance to the point in the center of the lane nearest to the given point

getInitialHeading

public abstract double getInitialHeading()
Get the heading of this Lane at its starting point.

Specified by:
getInitialHeading in interface Lane
Returns:
the initial heading of the Lane, in radians

getTerminalHeading

public abstract double getTerminalHeading()
Get the heading of this Lane at its ending point.

Specified by:
getTerminalHeading in interface Lane
Returns:
the terminal heading of the Lane, in radians

getHeadingAtNormalizedDistance

public abstract double getHeadingAtNormalizedDistance(double normalizedDistance)
Get the heading of the Lane at a particular normalized distance from the start of the Lane.

Specified by:
getHeadingAtNormalizedDistance in interface Lane
Parameters:
normalizedDistance - the normalized distance (between 0 and 1) from the start of the Lane
Returns:
the heading of the lane at the given normalized distance

intersectionPoint

public abstract Point2D intersectionPoint(Line2D l)
The point at which the the given Line intersects the center of this Lane.

Specified by:
intersectionPoint in interface Lane
Parameters:
l - the Line with which to find the intersection
Returns:
the point at which the given Line intersects the center of this Lane, or null if it doesn't intersect

getWidth

public abstract double getWidth()
Get the width of this Lane, in meters.

Specified by:
getWidth in interface Lane
Returns:
the width of this Lane, in meters

getShape

public abstract Shape getShape()
Get a Shape describing this Lane, including its width.

Specified by:
getShape in interface Lane
Returns:
a Shape describing this Lane

getShape

public abstract Shape getShape(double startFraction,
                               double endFraction)
Get a Shape describing an interval of this lane, using normalized distances.

Specified by:
getShape in interface Lane
Parameters:
startFraction - the normalized distance from the start of the lane to the start of the segment which the Shape represents
endFraction - the normalized distance from the start of the lane to the end of the segment which the Shape represents
Returns:
a Shape describing the segment

contains

public abstract boolean contains(Point2D pos)
Whether or not the provided point can be considered "in" this Lane. This is equivalent to determining whether the distance from the point to the Lane is less than half of the width of the Lane.

Specified by:
contains in interface Lane
Parameters:
pos - the point to check
Returns:
whether or not the point is in the Lane

leftBorder

public abstract Shape leftBorder()
Get a Shape representing the left border of this Lane.

Specified by:
leftBorder in interface Lane
Returns:
a Shape representing the left border of this Lane

rightBorder

public abstract Shape rightBorder()
Get a Shape representing the right border of this Lane.

Specified by:
rightBorder in interface Lane
Returns:
a Shape representing the right border of this Lane

leftIntersectionPoint

public abstract Point2D leftIntersectionPoint(Line2D l)
The point at which the the given Line intersects the left border of this Lane.

Specified by:
leftIntersectionPoint in interface Lane
Parameters:
l - the Line with which to find the intersection
Returns:
the point at which the given Line intersects the left border of this Lane, or null if it doesn't intersect

rightIntersectionPoint

public abstract Point2D rightIntersectionPoint(Line2D l)
The point at which the the given Line intersects the right border of this Lane.

Specified by:
rightIntersectionPoint in interface Lane
Parameters:
l - the Line with which to find the intersection
Returns:
the point at which the given Line intersects the right border of this Lane, or null if it doesn't intersect


Copyright © 2011. All Rights Reserved.