类 Position
java.lang.Object
net.sf.marineapi.nmea.util.Position
- 直接已知子类:
Waypoint
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.
- 作者:
- Kimmo Tuukkanen
-
构造器概要
构造器构造器说明Position(double lat, double lon) Creates a new instance of Position.Position(double lat, double lon, double alt) Creates a new instance of position with latitude, longitude and altitude.Creates new instance of Position with latitude, longitude, altitude and datum.Creates new instance of Position with latitude, longitude and datum. -
方法概要
修饰符和类型方法说明doubledistanceTo(Position pos) Calculates distance to specifiedPosition.doubleGets the position altitude from mean sea level.getDatum()Gets the datum, i.e. the coordinate system used to define geographic position.doubleGet latitude value of PositionGet the hemisphere of latitude, North or South.doubleGet longitude value of PositionGet the hemisphere of longitude, East or West.booleanTells if the latitude is on northern hemisphere.booleanTells if the longitude is on eastern hemisphere.voidsetAltitude(double altitude) Sets the altitude of position above or below mean sea level.voidsetLatitude(double latitude) Set the latitude degrees of PositionvoidsetLongitude(double longitude) Set the longitude degrees of PositiontoString()toWaypoint(String id) Convenience method for creating a waypoint based in the Position.
-
构造器详细资料
-
Position
public Position(double lat, double lon) Creates a new instance of Position. Notice that altitude defaults to -0.0 and may be set later.- 参数:
lat- Latitude degreeslon- Longitude degrees- 另请参阅:
-
Position
public Position(double lat, double lon, double alt) Creates a new instance of position with latitude, longitude and altitude.- 参数:
lat- Latitude degreeslon- Longitude degreesalt- Altitude value, in meters.
-
Position
Creates new instance of Position with latitude, longitude and datum. Notice that altitude defaults to -0.0 and may be set later.- 参数:
lat- Latitude degreeslon- Longitude degreesdatum- Datum to set- 另请参阅:
-
Position
Creates new instance of Position with latitude, longitude, altitude and datum.- 参数:
lat- Latitude degreeslon- Longitude degreesalt- Altitude in metersdatum- Datum to set
-
-
方法详细资料
-
distanceTo
Calculates distance to specifiedPosition.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.70702km, based on the assumption that 1 degrees is exactly 60 NM.- 参数:
pos- Position to which the distance is calculated.- 返回:
- Distance to po
posin meters.
-
getAltitude
public double getAltitude()Gets the position altitude from mean sea level. Notice that most sentences with position don't provide this value. When missing, the default value inPositionis 0.0.- 返回:
- Altitude value in meters
-
getDatum
Gets the datum, i.e. the coordinate system used to define geographic position. Default isDatum.WGS84, unless datum is specified in the constructor. Notice also that datum cannot be set afterwards.- 返回:
- Datum enum
-
getLatitude
public double getLatitude()Get latitude value of Position- 返回:
- latitude degrees
-
getLatitudeHemisphere
Get the hemisphere of latitude, North or South.- 返回:
- CompassPoint.NORTH or CompassPoint.SOUTH
-
getLongitude
public double getLongitude()Get longitude value of Position- 返回:
- longitude degrees
-
getLongitudeHemisphere
Get the hemisphere of longitude, East or West.- 返回:
- CompassPoint.EAST or CompassPoint.WEST
-
isLatitudeNorth
public boolean isLatitudeNorth()Tells if the latitude is on northern hemisphere.- 返回:
- true if northern, otherwise false (south).
-
isLongitudeEast
public boolean isLongitudeEast()Tells if the longitude is on eastern hemisphere.- 返回:
- true if eastern, otherwise false (west).
-
setAltitude
public void setAltitude(double altitude) Sets the altitude of position above or below mean sea level. Defaults to zero (-0.0).- 参数:
altitude- Altitude value to set, in meters.
-
setLatitude
public void setLatitude(double latitude) Set the latitude degrees of Position- 参数:
latitude- the latitude to set- 抛出:
IllegalArgumentException- If specified latitude value is out of range 0..90 degrees.
-
setLongitude
public void setLongitude(double longitude) Set the longitude degrees of Position- 参数:
longitude- the longitude to set- 抛出:
IllegalArgumentException- If specified longitude value is out of range 0..180 degrees.
-
toString
-
toWaypoint
Convenience method for creating a waypoint based in the Position.- 参数:
id- Waypoint ID or name- 返回:
- the created Waypoint
-