类 Position

java.lang.Object
net.sf.marineapi.nmea.util.Position
直接已知子类:
Waypoint

public class Position extends Object
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.
    Position(double lat, double lon, double alt, Datum datum)
    Creates new instance of Position with latitude, longitude, altitude and datum.
    Position(double lat, double lon, Datum datum)
    Creates new instance of Position with latitude, longitude and datum.
  • 方法概要

    修饰符和类型
    方法
    说明
    double
    Calculates distance to specified Position.
    double
    Gets the position altitude from mean sea level.
    Gets the datum, i.e. the coordinate system used to define geographic position.
    double
    Get latitude value of Position
    Get the hemisphere of latitude, North or South.
    double
    Get longitude value of Position
    Get the hemisphere of longitude, East or West.
    boolean
    Tells if the latitude is on northern hemisphere.
    boolean
    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
     
    Convenience method for creating a waypoint based in the Position.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 构造器详细资料

    • 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 degrees
      lon - Longitude degrees
      另请参阅:
    • Position

      public Position(double lat, double lon, double alt)
      Creates a new instance of position with latitude, longitude and altitude.
      参数:
      lat - Latitude degrees
      lon - Longitude degrees
      alt - Altitude value, in meters.
    • Position

      public Position(double lat, double lon, Datum datum)
      Creates new instance of Position with latitude, longitude and datum. Notice that altitude defaults to -0.0 and may be set later.
      参数:
      lat - Latitude degrees
      lon - Longitude degrees
      datum - Datum to set
      另请参阅:
    • Position

      public Position(double lat, double lon, double alt, Datum datum)
      Creates new instance of Position with latitude, longitude, altitude and datum.
      参数:
      lat - Latitude degrees
      lon - Longitude degrees
      alt - Altitude in meters
      datum - Datum to set
  • 方法详细资料

    • distanceTo

      public double distanceTo(Position pos)
      Calculates distance to specified 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.
      返回:
      Distance to popos in 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 in Position is 0.0.
      返回:
      Altitude value in meters
    • getDatum

      public Datum getDatum()
      Gets the datum, i.e. the coordinate system used to define geographic position. Default is Datum.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

      public CompassPoint 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

      public CompassPoint 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

      public String toString()
      覆盖:
      toString 在类中 Object
    • toWaypoint

      public Waypoint toWaypoint(String id)
      Convenience method for creating a waypoint based in the Position.
      参数:
      id - Waypoint ID or name
      返回:
      the created Waypoint