flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Feature Request]: Reading altitude from NMEA messages not only from the GPS system

Open MariuszTurek-W3media opened this issue 1 year ago • 1 comments

Is there already an issue requesting this feature?

Please select affected platform(s)

  • [X] Android
  • [ ] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

Use case

In Android we can use useMSLAltitude flag to read altitude from NMEA messages: https://pub.dev/documentation/geolocator_android/latest/geolocator_android/AndroidSettings/useMSLAltitude.html

The problem is that Geolocator only reads the altitude from the GPS system. In my case, my two Android devices receive messages with ID $GNGGA (instead of $GPGGA), example: $GNGGA,113733.000,0000.4351,N,00000.7576,E,1,20,0.60,277.7,M,42.0,M,,*7F and Geolocator does not read altitude from NMEA

Traditionally, the NMEA messages start with $GP, for example the GPS NMEA message GGA starts with the text: $GPGGA. But because various GNSS tracking systems use different systems instead of GPS, some NMEA messages change the second text byte. A GLONASS sometimes uses N instead of P, so a GLONASS GGA message may come out starting with $GNGGA.

https://www.raveon.com/ApplicationNotes/AN246(NMEA_GNSS).pdf https://openrtk.readthedocs.io/en/latest/communication_port/nmea.html

Here is an example of other Talker ID prefixes (but for a GNS message): GA: Galileo GB: BeiDou GP: GPS GL: GLONASS. When more than one constellation is used. GN: Combined GNSS position, for example, GPS and GLONASS. GQ: QZSS

https://receiverhelp.trimble.com/alloy-gnss/en-us/NMEA-0183messages_GNS.html

Proposal

To solve this problem, just modify the code in two places:

https://github.com/Baseflow/flutter-geolocator/blob/eaa173f88f32308c220451f63add8b984021be1d/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/NmeaClient.java#L47

if (message.trim().matches("^\\$..GGA.*$")) {

https://github.com/Baseflow/flutter-geolocator/blob/eaa173f88f32308c220451f63add8b984021be1d/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/NmeaClient.java#L120

if (type.matches("^\\$..GGA$") && tokens.length > 9) {

Specific requirements or considerations

No response

Additional information or context

No response

MariuszTurek-W3media avatar Mar 26 '24 11:03 MariuszTurek-W3media

The proposal looks good to me. I think as part of this change we should also let Android handle MSL with the latest version. The new version of Android has MSL built-in as a property on location data meaning we don't need to start a separate NMEA listener

Wackymax avatar Apr 23 '24 06:04 Wackymax