类 PositionParser

java.lang.Object
net.sf.marineapi.nmea.parser.SentenceParser
net.sf.marineapi.nmea.parser.PositionParser
所有已实现的接口:
Sentence

public abstract class PositionParser extends SentenceParser

Abstract base class for sentence parsers that handle geographic position or waypoint data and parse NMEA 0183 lat/lon values.

Notice that PositionSentence interface is not implemented by this parser because the extending parser may not always provide current location.

作者:
Kimmo Tuukkanen
  • 构造器详细资料

    • PositionParser

      protected PositionParser(String nmea, SentenceId type)
      Constructor.
      参数:
      nmea - Sentence string to parse.
      type - Expected Sentence ID
      另请参阅:
      • SentenceParser(String, net.sf.marineapi.nmea.sentence.SentenceId)
    • PositionParser

      protected PositionParser(TalkerId talker, SentenceId type, int size)
      Constructor for empty sentence.
      参数:
      talker - Talker ID to set
      type - Sentence ID to set
      size - Number of empty data fields to set.
      另请参阅:
      • SentenceParser(net.sf.marineapi.nmea.sentence.TalkerId, net.sf.marineapi.nmea.sentence.SentenceId, int)
  • 方法详细资料

    • parseHemisphereLat

      protected CompassPoint parseHemisphereLat(int index)
      Parses the hemisphere of latitude from specified field.
      参数:
      index - Index of field that contains the latitude hemisphere value.
      返回:
      Hemisphere of latitude
    • parseHemisphereLon

      protected CompassPoint parseHemisphereLon(int index)
      Parses the hemisphere of longitude from the specified field.
      参数:
      index - Field index for longitude hemisphere indicator
      返回:
      Hemisphere of longitude
    • parseDegrees

      protected double parseDegrees(int index)
      Parse latitude or longitude degrees and minutes from the specified field. Assumes the dddmm.mmmm formatting where the two digits to the left of dot denote full minutes and any remaining digits to the left denote full degrees (usually padded with leading zeros). Digits to the right of the dot denote the minute decimals.
      参数:
      index - Index of the lat/lon field.
      返回:
      Degrees decimal value
      另请参阅:
    • parsePosition

      protected Position parsePosition(int latIndex, int latHemIndex, int lonIndex, int lonHemIndex)
      Parses a Position from specified fields.
      参数:
      latIndex - Latitude field index
      latHemIndex - Latitude hemisphere field index
      lonIndex - Longitude field index
      lonHemIndex - Longitude hemisphere field index
      返回:
      Position object
      另请参阅:
    • setLatHemisphere

      protected void setLatHemisphere(int field, CompassPoint hem)
      Set the hemisphere of latitude in specified field.
      参数:
      field - Field index
      hem - Direction.NORTH or Direction.SOUTH
      抛出:
      IllegalArgumentException - If specified Direction is other than NORTH or SOUTH.
    • setLatitude

      protected void setLatitude(int index, double lat)
      Sets the latitude value in specified field, formatted in "ddmm.mmm".
      参数:
      index - Field index
      lat - Latitude value in degrees
    • setLongitude

      protected void setLongitude(int index, double lon)
      Sets the longitude value in specified field, formatted in "dddmm.mmm". Does not check if the given value is logically correct to current longitude hemisphere.
      参数:
      index - Field index
      lon - Longitude value in degrees
    • setLonHemisphere

      protected void setLonHemisphere(int field, CompassPoint hem)
      Set the hemisphere of longitude in specified field. Does not check if the given value is logically correct to current longitude value.
      参数:
      field - Field index
      hem - Direction.EAST or Direction.WEST
      抛出:
      IllegalArgumentException - If specified Direction is other than EAST or WEST.
    • setPositionValues

      protected void setPositionValues(Position p, int latIndex, int latHemIndex, int lonIndex, int lonHemIndex)
      Sets the values from specified Position according to given field indices. Sets the absolute values of latitude and longitude, and hemisphere indicators as given by Position. Does not set altitude.
      参数:
      p - Position to set
      latIndex - Index of latitude field
      latHemIndex - Index of latitude hemisphere field
      lonIndex - Index of longitude field
      lonHemIndex - Index of longitude hemisphere field
    • parseDegrees

      public static double parseDegrees(String degreeStr)
      Parse latitude or longitude degrees and minutes from the specified string. Assumes the dddmm.mmmm formatting where the two digits to the left of dot denote full minutes and any remaining digits to the left denote full degrees (usually padded with leading zeros). Digits to the right of the dot denote the minute decimals.
      参数:
      degreeStr - NMEA 0183 degrees/minutes String
      返回:
      Degrees decimal value
    • parseHemisphereLat

      public static CompassPoint parseHemisphereLat(char ch)
      Parses the hemisphere of latitude from specified char.
      参数:
      ch - Hemisphere char indicator.
      返回:
      Corresponding CompassPoint enum value.
      抛出:
      ParseException - If specified char is not 'N' or 'S'.
    • parseHemisphereLon

      public static CompassPoint parseHemisphereLon(char ch)
      Parses the hemisphere of longitude from the specified char.
      参数:
      ch - Hemisphere char indicator.
      返回:
      Corresponding CompassPoint enum value.
      抛出:
      ParseException - If specified char is not 'E' or 'W'.
    • parsePosition

      public static Position parsePosition(String latitudeValue, char latitudeHemisphereIndicator, String longitudeValue, char longitudeHemisphereIndicator)
      Parses a Position from specified fields. The parameters are the raw values from the NMEA Sentence.
      参数:
      latitudeValue - String value from the NMEA Sentence
      latitudeHemisphereIndicator - Character value from the NMEA Sentence
      longitudeValue - String value from the NMEA Sentence
      longitudeHemisphereIndicator - Character value from the NMEA Sentence
      返回:
      Position object