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 class
NmeaParser.GGA
Global Positioning System Fix Data.(package private) static class
NmeaParser.GLL
Geographic Position - Latitude/Longitude.(package private) static class
NmeaParser.GSA
GNSS DOP and Active Satellites.(package private) static class
NmeaParser.GST
GST - GNSS Pseudorange Noise Statistics(package private) static class
NmeaParser.RMC
Recommended Minimum Specific GNSS Data.(package private) static class
NmeaParser.VTG
Course Over Ground and Ground Speed.
-
Field Summary
Fields Modifier and Type Field Description protected int
checksumErrors
private static java.util.regex.Pattern
DATE_TIME_PATTERN
protected int
malformed
protected int
noChecksum
protected java.lang.String
pDate
protected java.lang.String
pTime
protected WayPoint
pWp
private java.text.SimpleDateFormat
rmcTimeFmt
protected int
success
protected int
unknown
protected java.util.Collection<WayPoint>
waypoints
protected int
zeroCoord
-
Constructor Summary
Constructors Constructor Description NmeaParser()
Constructs a newNmeaParser
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dropOldWaypoints()
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 droppedint
getParserChecksumErrors()
Number of checksum errorsint
getParserMalformed()
Number of malformed errorsint
getParserUnknown()
Number of unknown sentencesint
getParserZeroCoordinates()
Number of empty coordinatesint
getSuccess()
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 boolean
isSentence(java.lang.String address, Sentence formatter)
Determines if the given address denotes the given NMEA sentence formatter of a known talker.private static LatLon
parseLatLon(java.lang.String ns, java.lang.String ew, java.lang.String dlat, java.lang.String dlon)
boolean
parseNMEASentence(java.lang.String s)
Parses split up sentences into WayPoints which are stored in the collection in the NMEAParserState object.private java.time.Instant
readTime(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:
true
if theaddress
denotes 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:
true
if the input made sense,false
otherwise.- Throws:
IllegalDataException
-
parseLatLon
private static LatLon parseLatLon(java.lang.String ns, java.lang.String ew, java.lang.String dlat, java.lang.String dlon)
-
-