-->

NMEA message to Android Location

2019-09-08 19:53发布

问题:

I am working with an external GPS, since they are far more accurate. I already have the bluetooth connection worked out, but now I'm stuck in a flood of NMEA formatted messages.

It seems like, since you can get NMEA out of the built in GPS stack, that there must be a way to get a Location given a NMEA message.

How do I go about converting my NMEA messages into useful Location objects?

回答1:

NMEA is quite easy to parse. There are various types of sentences for different things. For location data, the sentence you need to concern yourself with is the "recommended minimum", $GPRMC.

Example from here: http://aprs.gids.nl/nmea/#rmc

$GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68
  • 225446 (Time of fix 22:54:46 UTC)
  • A (Navigation receiver warning A = OK, V = warning)
  • 4916.45,N (Latitude 49 deg. 16.45 min North)
  • 12311.12,W (Longitude 123 deg. 11.12 min West)
  • 000.5 (Speed over ground, Knots)
  • 054.7 (Course Made Good, True)
  • 191194 (Date of fix 19 November 1994)
  • 020.3,E (Magnetic variation 20.3 deg East)
  • *68 (mandatory checksum)

You might be also interested in $GPGSA, which has satellite data long with dilution of position (quality of fix).

If there is no internal class available for parsing NMEA, you can use these examples to easily make one yourself. Unfortunately, I'm not an Android developer, so I don't know what internal classes are available to you.