Package org.openstreetmap.josm.io.nmea
Class NmeaParser
- java.lang.Object
-
- org.openstreetmap.josm.io.nmea.NmeaParser
-
public class NmeaParser extends java.lang.Object
Parses NMEA 0183 data. Based on information from https://gpsd.gitlab.io/gpsd. NMEA data is in printable ASCII form and may include information such as position, speed, depth, frequency allocation, etc. Typical messages might be 11 to a maximum of 79 characters in length. NMEA standard aims to support one-way serial data transmission from a single "talker" to one or more "listeners". The type of talker is identified by a 2-character mnemonic. NMEA information is encoded through a list of "sentences".- Since:
- 18787
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classNmeaParser.GGAGlobal Positioning System Fix Data.(package private) static classNmeaParser.GLLGeographic Position - Latitude/Longitude.(package private) static classNmeaParser.GSAGNSS DOP and Active Satellites.(package private) static classNmeaParser.GSTGST - GNSS Pseudorange Noise Statistics(package private) static classNmeaParser.RMCRecommended Minimum Specific GNSS Data.(package private) static classNmeaParser.VTGCourse Over Ground and Ground Speed.
-
Field Summary
Fields Modifier and Type Field Description protected intchecksumErrorsprivate static java.util.regex.PatternDATE_TIME_PATTERNprotected intmalformedprotected intnoChecksumprotected java.lang.StringpDateprotected java.lang.StringpTimeprotected WayPointpWpprivate java.text.SimpleDateFormatrmcTimeFmtprotected intsuccessprotected intunknownprotected java.util.Collection<WayPoint>waypointsprotected intzeroCoord
-
Constructor Summary
Constructors Constructor Description NmeaParser()Constructs a newNmeaParser
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddropOldWaypoints()Get rid of older data no longer needed, drops everything except current coordinatejava.util.Collection<WayPoint>getAndDropWaypoints()Return list of collected coordinates and drop old data When parsing a stream the last entry may be still incomplete and usually will not be droppedintgetParserChecksumErrors()Number of checksum errorsintgetParserMalformed()Number of malformed errorsintgetParserUnknown()Number of unknown sentencesintgetParserZeroCoordinates()Number of empty coordinatesintgetSuccess()Number of successful coordinatesjava.util.Collection<WayPoint>getWaypoints()List of collected coordinates When parsing a stream the last entry may be still incomplete(package private) static booleanisSentence(java.lang.String address, Sentence formatter)Determines if the given address denotes the given NMEA sentence formatter of a known talker.private static LatLonparseLatLon(java.lang.String ns, java.lang.String ew, java.lang.String dlat, java.lang.String dlon)booleanparseNMEASentence(java.lang.String s)Parses split up sentences into WayPoints which are stored in the collection in the NMEAParserState object.private java.time.InstantreadTime(java.lang.String p)
-
-
-
Field Detail
-
DATE_TIME_PATTERN
private static final java.util.regex.Pattern DATE_TIME_PATTERN
-
rmcTimeFmt
private final java.text.SimpleDateFormat rmcTimeFmt
-
pTime
protected java.lang.String pTime
-
pDate
protected java.lang.String pDate
-
success
protected int success
-
malformed
protected int malformed
-
checksumErrors
protected int checksumErrors
-
noChecksum
protected int noChecksum
-
unknown
protected int unknown
-
zeroCoord
protected int zeroCoord
-
-
Constructor Detail
-
NmeaParser
public NmeaParser()
Constructs a newNmeaParser
-
-
Method Detail
-
readTime
private java.time.Instant readTime(java.lang.String p) throws IllegalDataException
- Throws:
IllegalDataException
-
getParserUnknown
public int getParserUnknown()
Number of unknown sentences- Returns:
- the number of unknown sentences encountered
-
getParserZeroCoordinates
public int getParserZeroCoordinates()
Number of empty coordinates- Returns:
- the number of coordinates which have been zero
-
getParserChecksumErrors
public int getParserChecksumErrors()
Number of checksum errors- Returns:
- the number of sentences with checksum errors
-
getParserMalformed
public int getParserMalformed()
Number of malformed errors- Returns:
- the number of malformed sentences
-
getSuccess
public int getSuccess()
Number of successful coordinates- Returns:
- the number of successfully read coordinates
-
getWaypoints
public java.util.Collection<WayPoint> getWaypoints()
List of collected coordinates When parsing a stream the last entry may be still incomplete- Returns:
- the collection of points collected
-
getAndDropWaypoints
public java.util.Collection<WayPoint> getAndDropWaypoints()
Return list of collected coordinates and drop old data When parsing a stream the last entry may be still incomplete and usually will not be dropped- Returns:
- the collection of points collected
-
dropOldWaypoints
public void dropOldWaypoints()
Get rid of older data no longer needed, drops everything except current coordinate
-
isSentence
static boolean isSentence(java.lang.String address, Sentence formatter)
Determines if the given address denotes the given NMEA sentence formatter of a known talker.- Parameters:
address- first tag of an NMEA sentenceformatter- sentence formatter mnemonic code- Returns:
trueif theaddressdenotes the given NMEA sentence formatter of a known talker
-
parseNMEASentence
public boolean parseNMEASentence(java.lang.String s) throws IllegalDataException
Parses split up sentences into WayPoints which are stored in the collection in the NMEAParserState object.- Parameters:
s- data to parse- Returns:
trueif the input made sense,falseotherwise.- Throws:
IllegalDataException
-
parseLatLon
private static LatLon parseLatLon(java.lang.String ns, java.lang.String ew, java.lang.String dlat, java.lang.String dlon)
-
-