类 PositionParser
java.lang.Object
net.sf.marineapi.nmea.parser.SentenceParser
net.sf.marineapi.nmea.parser.PositionParser
- 所有已实现的接口:
Sentence
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
-
字段概要
从接口继承的字段 net.sf.marineapi.nmea.sentence.Sentence
ALTERNATIVE_BEGIN_CHAR, BEGIN_CHAR, CHECKSUM_DELIMITER, FIELD_DELIMITER, MAX_LENGTH, TERMINATOR -
构造器概要
构造器限定符构造器说明protectedPositionParser(String nmea, SentenceId type) Constructor.protectedPositionParser(TalkerId talker, SentenceId type, int size) Constructor for empty sentence. -
方法概要
修饰符和类型方法说明protected doubleparseDegrees(int index) Parse latitude or longitude degrees and minutes from the specified field.static doubleparseDegrees(String degreeStr) Parse latitude or longitude degrees and minutes from the specified string.static CompassPointparseHemisphereLat(char ch) Parses the hemisphere of latitude from specified char.protected CompassPointparseHemisphereLat(int index) Parses the hemisphere of latitude from specified field.static CompassPointparseHemisphereLon(char ch) Parses the hemisphere of longitude from the specified char.protected CompassPointparseHemisphereLon(int index) Parses the hemisphere of longitude from the specified field.protected PositionparsePosition(int latIndex, int latHemIndex, int lonIndex, int lonHemIndex) Parses aPositionfrom specified fields.static PositionparsePosition(String latitudeValue, char latitudeHemisphereIndicator, String longitudeValue, char longitudeHemisphereIndicator) Parses aPositionfrom specified fields.protected voidsetLatHemisphere(int field, CompassPoint hem) Set the hemisphere of latitude in specified field.protected voidsetLatitude(int index, double lat) Sets the latitude value in specified field, formatted in "ddmm.mmm".protected voidsetLongitude(int index, double lon) Sets the longitude value in specified field, formatted in "dddmm.mmm".protected voidsetLonHemisphere(int field, CompassPoint hem) Set the hemisphere of longitude in specified field.protected voidsetPositionValues(Position p, int latIndex, int latHemIndex, int lonIndex, int lonHemIndex) Sets the values from specifiedPositionaccording to given field indices.从类继承的方法 net.sf.marineapi.nmea.parser.SentenceParser
equals, getBeginChar, getCharValue, getDoubleValue, getFieldCount, getIntValue, getSentenceId, getStringValue, getStringValues, getTalkerId, hashCode, hasValue, isAISSentence, isProprietary, isValid, reset, setBeginChar, setCharValue, setDegreesValue, setDoubleValue, setDoubleValue, setFieldCount, setIntValue, setIntValue, setStringValue, setStringValues, setTalkerId, toSentence, toSentence, toString
-
构造器详细资料
-
PositionParser
Constructor.- 参数:
nmea- Sentence string to parse.type- Expected Sentence ID- 另请参阅:
-
SentenceParser(String, net.sf.marineapi.nmea.sentence.SentenceId)
-
PositionParser
Constructor for empty sentence.- 参数:
talker- Talker ID to settype- Sentence ID to setsize- Number of empty data fields to set.- 另请参阅:
-
SentenceParser(net.sf.marineapi.nmea.sentence.TalkerId, net.sf.marineapi.nmea.sentence.SentenceId, int)
-
-
方法详细资料
-
parseHemisphereLat
Parses the hemisphere of latitude from specified field.- 参数:
index- Index of field that contains the latitude hemisphere value.- 返回:
- Hemisphere of latitude
-
parseHemisphereLon
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 thedddmm.mmmmformatting 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
Parses aPositionfrom specified fields.- 参数:
latIndex- Latitude field indexlatHemIndex- Latitude hemisphere field indexlonIndex- Longitude field indexlonHemIndex- Longitude hemisphere field index- 返回:
- Position object
- 另请参阅:
-
setLatHemisphere
Set the hemisphere of latitude in specified field.- 参数:
field- Field indexhem- 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 indexlat- 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 indexlon- Longitude value in degrees
-
setLonHemisphere
Set the hemisphere of longitude in specified field. Does not check if the given value is logically correct to current longitude value.- 参数:
field- Field indexhem- 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 specifiedPositionaccording to given field indices. Sets the absolute values of latitude and longitude, and hemisphere indicators as given byPosition. Does not set altitude.- 参数:
p- Position to setlatIndex- Index of latitude fieldlatHemIndex- Index of latitude hemisphere fieldlonIndex- Index of longitude fieldlonHemIndex- Index of longitude hemisphere field
-
parseDegrees
Parse latitude or longitude degrees and minutes from the specified string. Assumes thedddmm.mmmmformatting 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
Parses the hemisphere of latitude from specified char.- 参数:
ch- Hemisphere char indicator.- 返回:
- Corresponding
CompassPointenum value. - 抛出:
ParseException- If specified char is not 'N' or 'S'.
-
parseHemisphereLon
Parses the hemisphere of longitude from the specified char.- 参数:
ch- Hemisphere char indicator.- 返回:
- Corresponding
CompassPointenum value. - 抛出:
ParseException- If specified char is not 'E' or 'W'.
-
parsePosition
public static Position parsePosition(String latitudeValue, char latitudeHemisphereIndicator, String longitudeValue, char longitudeHemisphereIndicator) Parses aPositionfrom specified fields. The parameters are the raw values from the NMEA Sentence.- 参数:
latitudeValue- String value from the NMEA SentencelatitudeHemisphereIndicator- Character value from the NMEA SentencelongitudeValue- String value from the NMEA SentencelongitudeHemisphereIndicator- Character value from the NMEA Sentence- 返回:
- Position object
-