|
|||||||||
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. Default datum is WGS84 as generally in NMEA 0183. Notice that datum is only informative and it does not affect calculations or handling of other values.
Constructor Summary | |
---|---|
Position(double lat,
double lon)
Creates a new instance of Position. |
|
Position(double lat,
double lon,
Datum datum)
Creates new instance of Position with latitude, longitude and datum. |
|
Position(double lat,
double lon,
double alt)
Creates a new instance of position with latitude, longitude and altitude. |
|
Position(double lat,
double lon,
double alt,
Datum datum)
Creates new instance of Position with latitude, longitude, altitude and datum. |
Method Summary | |
---|---|
double |
distanceTo(Position pos)
Calculates 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. |
double |
getLatitude()
Get latitude value of Position |
CompassPoint |
getLatitudeHemisphere()
Get the hemisphere of latitude, North or South. |
double |
getLongitude()
Get longitude value of Position |
CompassPoint |
getLongitudeHemisphere()
Get the hemisphere of longitude, East or West. |
boolean |
isLatitudeNorth()
Tells if the latitude is on northern hemisphere. |
boolean |
isLongitudeEast()
Tells if the longitude is on eastern hemisphere. |
void |
setAltitude(double altitude)
Sets the altitude of position above or below mean sea level. |
void |
setLatitude(double latitude)
Set the latitude degrees of Position |
void |
setLongitude(double longitude)
Set the longitude degrees of Position |
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, double lon)
lat
- Latitude degreeslon
- Longitude degreessetAltitude(double)
public Position(double lat, double lon, double alt)
lat
- Latitude degreeslon
- Longitude degreesalt
- Altitude value, in meters.public Position(double lat, double lon, Datum datum)
lat
- Latitude degreeslon
- Longitude degreesdatum
- Datum to setsetAltitude(double)
public Position(double lat, double lon, double alt, Datum datum)
lat
- Latitude degreeslon
- Longitude degreesdatum
- Datum to setMethod Detail |
---|
public double distanceTo(Position pos)
Position
.
The Distance is calculated using the Haversine formula. Implementation is based on example found at codecodex.com.
Earth radius earth
radius used in calculation is 6366.70702
km, based on
the assumption that 1 degrees is exactly 60 NM.
pos
- Position to which the distance is calculated.
pos
in meters.public double getAltitude()
Position
is 0.0.
public Datum getDatum()
Datum.WGS84
, unless datum is specified in
the constructor. Notice also that datum cannot be set afterwards.
public double getLatitude()
public CompassPoint getLatitudeHemisphere()
public double getLongitude()
public CompassPoint getLongitudeHemisphere()
public boolean isLatitudeNorth()
public boolean isLongitudeEast()
public void setAltitude(double altitude)
altitude
- Altitude value to set, in meters.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 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 |