Package org.openstreetmap.josm.io.nmea
Class NmeaReader
- java.lang.Object
-
- org.openstreetmap.josm.io.nmea.NmeaReader
-
- All Implemented Interfaces:
IGpxReader
public class NmeaReader extends Object implements IGpxReader
Reads a NMEA 0183 file. Based on information from http://www.catb.org/gpsd. NMEA files are 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".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
NmeaReader.GGA
Global Positioning System Fix Data.(package private) static class
NmeaReader.GLL
Geographic Position - Latitude/Longitude.(package private) static class
NmeaReader.GSA
GNSS DOP and Active Satellites.private static class
NmeaReader.NMEAParserState
(package private) static class
NmeaReader.RMC
Recommended Minimum Specific GNSS Data.(package private) static class
NmeaReader.VTG
Course Over Ground and Ground Speed.
-
Field Summary
Fields Modifier and Type Field Description (package private) GpxData
data
private static Pattern
DATE_TIME_PATTERN
NmeaReader.NMEAParserState
ps
private SimpleDateFormat
rmcTimeFmt
private InputStream
source
-
Constructor Summary
Constructors Constructor Description NmeaReader(InputStream source)
Constructs a newNmeaReader
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GpxData
getGpxData()
Replies the GPX data.int
getNumberOfCoordinates()
Returns the number of coordinates that have been successfuly read.int
getParserChecksumErrors()
int
getParserMalformed()
int
getParserUnknown()
int
getParserZeroCoordinates()
(package private) static boolean
isSentence(String address, Sentence formatter)
Determines if the given address denotes the given NMEA sentence formatter of a known talker.boolean
parse(boolean tryToFinish)
Parse the GPX data.private static LatLon
parseLatLon(String ns, String ew, String dlat, String dlon)
private boolean
parseNMEASentence(String s, NmeaReader.NMEAParserState ps)
private Instant
readTime(String p)
-
-
-
Field Detail
-
source
private final InputStream source
-
DATE_TIME_PATTERN
private static final Pattern DATE_TIME_PATTERN
-
rmcTimeFmt
private final SimpleDateFormat rmcTimeFmt
-
ps
public NmeaReader.NMEAParserState ps
-
-
Constructor Detail
-
NmeaReader
public NmeaReader(InputStream source) throws IOException
Constructs a newNmeaReader
- Parameters:
source
- NMEA file input stream- Throws:
IOException
- if an I/O error occurs
-
-
Method Detail
-
readTime
private Instant readTime(String p) throws IllegalDataException
- Throws:
IllegalDataException
-
getParserUnknown
public int getParserUnknown()
-
getParserZeroCoordinates
public int getParserZeroCoordinates()
-
getParserChecksumErrors
public int getParserChecksumErrors()
-
getParserMalformed
public int getParserMalformed()
-
getNumberOfCoordinates
public int getNumberOfCoordinates()
Description copied from interface:IGpxReader
Returns the number of coordinates that have been successfuly read.- Specified by:
getNumberOfCoordinates
in interfaceIGpxReader
- Returns:
- the number of coordinates that have been successfuly read
-
parse
public boolean parse(boolean tryToFinish) throws SAXException, IOException
Description copied from interface:IGpxReader
Parse the GPX data.- Specified by:
parse
in interfaceIGpxReader
- Parameters:
tryToFinish
- true, if the reader should return at least part of the GPX data in case of an error.- Returns:
- true if file was properly parsed, false if there was error during parsing but some data were parsed anyway
- Throws:
SAXException
- if any SAX parsing error occursIOException
- if any I/O error occurs
-
isSentence
static boolean isSentence(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
private boolean parseNMEASentence(String s, NmeaReader.NMEAParserState ps) throws IllegalDataException
- Throws:
IllegalDataException
-
getGpxData
public GpxData getGpxData()
Description copied from interface:IGpxReader
Replies the GPX data.- Specified by:
getGpxData
in interfaceIGpxReader
- Returns:
- The GPX data
-
-