Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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 setpublic 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 setIllegalArgumentException
- If specified latitude value is out of
range 0..90 degrees.public void setLongitude(double longitude)
longitude
- the longitude to setIllegalArgumentException
- If specified longitude value is out of
range 0..180 degrees.Copyright (C) 2010-2017 Java Marine API authors. All Rights Reserved.