|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.marineapi.nmea.util.Position
public class Position
Represents a geographic position. The default datum is WGS84, unless some other datum is explicitly specified.
Constructor Summary | |
---|---|
Position(double lat,
CompassPoint lath,
double lon,
CompassPoint lonh)
Creates a new instance of Position. |
|
Position(double lat,
CompassPoint lath,
double lon,
CompassPoint lonh,
Datum datum)
Creates new instance of Position. |
Method Summary | |
---|---|
double |
distanceTo(Position pos)
Calculates the distance to specified Position. |
double |
getAltitude()
Gets the position altitude from mean sea level. |
Datum |
getDatum()
Gets the datum, i.e. the coordinate system used to define geographic position. |
CompassPoint |
getLatHemisphere()
Get the hemisphere of latitude (North/South). |
double |
getLatitude()
Get latitude value of Position |
double |
getLongitude()
Get longitude value of Position |
CompassPoint |
getLonHemisphere()
Get the hemisphere of longitude (East/West). |
void |
setAltitude(double altitude)
Sets the altitude of position above mean sea level. |
void |
setLatHemisphere(CompassPoint lathem)
Set the hemisphere of latitude (North/South). |
void |
setLatitude(double latitude)
Set the latitude degrees of Position |
void |
setLongitude(double longitude)
Set the longitude degrees of Position |
void |
setLonHemisphere(CompassPoint lonhem)
Set the hemisphere of longitude (East/West). |
String |
toString()
|
Waypoint |
toWaypoint(String id)
Convenience method for creating a waypoint based in the Position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Position(double lat, CompassPoint lath, double lon, CompassPoint lonh)
setAltitude(double)
method.
lat
- Latitude degreeslath
- Hemisphere of latitudelon
- Longitude degreeslonh
- Hemisphere of longitudepublic Position(double lat, CompassPoint lath, double lon, CompassPoint lonh, Datum datum)
setAltitude(double)
method.
lat
- Latitude degreeslath
- Hemisphere of latitudelon
- Longitude degreeslonh
- Hemisphere of longitudedatum
- DatumMethod Detail |
---|
public double distanceTo(Position pos)
Calculation is done by using the Haversine
formula. The mean earth
radius used in calculation is 6371.009
km.
The implementation is based on example found at codecodex.com.
pos
- Position to which the distance is calculated.
pos
in meters.public double getAltitude()
public Datum getDatum()
Datum.WGS84
, unless datum is specified in
the constructor. Notice also that datum cannot be set afterwards.
public CompassPoint getLatHemisphere()
public double getLatitude()
public double getLongitude()
public CompassPoint getLonHemisphere()
public void setAltitude(double altitude)
altitude
- Altitude value to set, in meters.public void setLatHemisphere(CompassPoint lathem)
lathem
- The hemisphere to set
IllegalArgumentException
- If specified hemisphere is other than
NORTH or SOUTH.public void setLatitude(double latitude)
latitude
- the latitude to set
IllegalArgumentException
- If specified latitude value is out of
range 0..90 degrees.public void setLongitude(double longitude)
longitude
- the longitude to set
IllegalArgumentException
- If specified longitude value is out of
range 0..180 degrees.public void setLonHemisphere(CompassPoint lonhem)
lonhem
- The hemisphere to set
IllegalArgumentException
- If specified hemisphere is other than
EAST or WEST.public String toString()
toString
in class Object
public Waypoint toWaypoint(String id)
id
- Waypoint ID or name
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |