NMEA data analysis in Android 2.3

I am trying to get data from a gps bluetooth device connected to my Android 2.3 tablet. At the moment, I can link it using the Android bluetooth stack and read from the created serial device. Now I have a lot of NMEA data coming from gps ... I tried to integrate a small piece of java code to parse these lines, but I would like to know if there is something like that already available on the Android platform, All that I You need to know, this is the Latvian / longitude and compass direction. Thanks!

+4
source share
1 answer

Not sure if anything exists, anyway, if you just need a position, you probably just need to parse RMC's suggestions, see http://www.gpsinformation.org/dale/nmea.htm#RMC

A simple Java code example for this:

final String sentence = "$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A"; if (sentence.startsWith("$GPRMC")) { String[] strValues = sentence.split(","); double latitude = Double.parseDouble(strValues[3])*.01; if (strValues[4].charAt(0) == 'S') { latitude = -latitude; } double longitude = Double.parseDouble(strValues[5])*.01; if (strValues[6].charAt(0) == 'W') { longitude = -longitude; } double course = Double.parseDouble(strValues[8]); System.out.println("latitude="+latitude+" ; longitude="+longitude+" ; course = "+course); } 

related question: Analyzing GPS receiver output through regex in Python

+3
source

Source: https://habr.com/ru/post/1447683/


All Articles