|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmain.Position
public class Position
The Position class represents coordinates given in
latitude/longitude pairs.
| Field Summary | |
|---|---|
private java.lang.Double |
latitude
|
private java.lang.Double |
longitude
|
private double |
RADIUS_EARTH
|
| Constructor Summary | |
|---|---|
Position()
Constructs a new Position with the value of null
to indicate that the values are not known. |
|
Position(java.lang.Double latitude,
java.lang.Double longitude)
Constructs a new Position with the position indicated by
the arguments. |
|
Position(Position p)
Constructs a new Position that represents the same
position as the argument; in other words, the newly created position is a
copy of the argument position. |
|
| Method Summary | |
|---|---|
double |
coordinateDistanceTo(Position position)
Finds the square of the distance between two positions, treating them as points on a flat plane. |
double |
distanceTo(Position position)
Finds the distance in meters between two positions on earth. |
boolean |
equals(Position other)
is other object equal to this one? |
java.lang.Double |
getLatitude()
Returns the latitude. |
java.lang.Double |
getLongitude()
Returns the longitude. |
boolean |
isDefined()
Returns true if both latitude and longitude are not null and false otherwise. |
void |
setLatitude(java.lang.Double latitude)
Sets the latitude. |
void |
setLongitude(java.lang.Double longitude)
Sets the longitude. |
java.lang.String |
toString()
Returns a string representation of this Position. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private java.lang.Double latitude
private java.lang.Double longitude
private final double RADIUS_EARTH
| Constructor Detail |
|---|
public Position(java.lang.Double latitude,
java.lang.Double longitude)
Position with the position indicated by
the arguments. The arguments can be null if the values are
not known.
latitude - a Doublelongitude - a Doublepublic Position()
Position with the value of null
to indicate that the values are not known.
public Position(Position p)
Position that represents the same
position as the argument; in other words, the newly created position is a
copy of the argument position.
p - a Position| Method Detail |
|---|
public java.lang.Double getLatitude()
public java.lang.Double getLongitude()
public void setLatitude(java.lang.Double latitude)
latitude - a Doublepublic void setLongitude(java.lang.Double longitude)
longitude - a Doublepublic double distanceTo(Position position)
position - a Position
public double coordinateDistanceTo(Position position)
position - a Position
public boolean isDefined()
public java.lang.String toString()
Position. This is
for debugging purposes only.
toString in class java.lang.ObjectPositionpublic boolean equals(Position other)
other -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||