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
Comparator to compare two WayPoint objects to see which is closer to its
associated
Way. |
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...1.0) of the span between
the vertices.
|
int |
vertexIndex
The zero-based index into the
Way of the last vertex before the position
along the Way defined by this WayPoint. |
Way |
way
The OpenStreetMap
Way this WayPoint is associated with. |
| 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)
Compare this WayPoint to another, ordering by increasing distance from their associated
Ways. |
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 int vertexIndex
Way of the last vertex before the position
along the Way defined by this WayPoint.public float distFwdFromVertexFract
public float distFromWay
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.Objectpublic 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.Objectpublic int compareTo(WayPoint wayPoint)
Ways.compareTo in interface java.lang.Comparable<WayPoint>wayPoint - WayPoint whose distance should be compared to this WayPointpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.