public class WayPoint extends java.lang.Object implements java.lang.Cloneable, java.lang.Comparable<WayPoint>
Way
as the last vertex passed plus a distance
along the line segment to the next vertex, and can calculate a new position based on an
amount of motion further forwards along the Way.Way.findNearestPositionOnWay(double, double, float, boolean)
Modifier and Type | Field and Description |
---|---|
static java.util.Comparator<WayPoint> |
BEST_TO_WORST |
float |
distFromWay
When fitting an arbitrary point to the nearest point on a Way, this is the distance
for that nearest point in meters.
|
float |
distFwdFromVertexFract
Distance from current vertex to next in a fraction [0.0 ..
|
int |
vertexIndex |
Way |
way |
Constructor and Description |
---|
WayPoint(Way way,
int vertexIndex,
float distFwdFromVertexFract)
Create a positioned WayPoint for the specified Way.
|
WayPoint(Way way,
int vertexIndex,
float distFwdFromVertexFract,
float distFromWay)
Create a positioned WayPoint for the specified Way.
|
Modifier and Type | Method and Description |
---|---|
boolean |
advance(float distInMeters,
boolean doLaps)
Advance the current position along the Way.
|
java.lang.Object |
clone()
Create a duplicate of this WayPoint.
|
int |
compareTo(WayPoint wayPoint) |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.
|
int |
getBearing(boolean doLaps)
Calculate the bearing from the current vertex to the next vertex.
|
double |
getDistanceTo(WayPoint other)
Calculate the distance along the Way between this WayPoint and another specified WayPoint.
|
double |
getLatitude()
Get the latitude of the current WayPoint.
|
double |
getLongitude()
Get the longitude of the current WayPoint.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
public final Way way
public int vertexIndex
public float distFwdFromVertexFract
public float distFromWay
public static java.util.Comparator<WayPoint> BEST_TO_WORST
public WayPoint(Way way, int vertexIndex, float distFwdFromVertexFract)
way
- Way this WayPoint is associated withvertexIndex
- zero-based index into the vertices of the WaydistFwdFromVertexFract
- float fraction (from 0.0 to 1.0) of the proportionalpublic WayPoint(Way way, int vertexIndex, float distFwdFromVertexFract, float distFromWay)
way
- Way this WayPoint is associated withvertexIndex
- zero-based index into the vertices of the WaydistFwdFromVertexFract
- float fraction (from 0.0 to 1.0) of the proportionaldistFromWay
- float distance between calculation point and nearest point on Waypublic double getLatitude()
public double getLongitude()
public double getDistanceTo(WayPoint other) throws java.lang.IllegalArgumentException
other
- WayPoint to compare to this WayPointjava.lang.IllegalArgumentException
- if other WayPoint is not on the same Waypublic int getBearing(boolean doLaps)
doLaps
- boolean true if Way proceeds from last vertex back to first vertexpublic boolean advance(float distInMeters, boolean doLaps)
distInMeters
- distance to move (in meters) along the Way from the current
position, positive moves forwards, negative moves backwardsdoLaps
- boolean true if advance should wrap from the end of course to the beginning
(if forwards, or vice-versa for backwards), false if advance should stop
at the end of the Waypublic java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.toString
in class java.lang.Object
public int compareTo(WayPoint wayPoint)
compareTo
in interface java.lang.Comparable<WayPoint>
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.