39 lines
1.3 KiB
Dart
39 lines
1.3 KiB
Dart
import 'package:nmea/nmea.dart';
|
|
|
|
class Gnrmc extends TalkerSentence {
|
|
static const String id = "GNRMC";
|
|
Gnrmc({required super.raw});
|
|
|
|
@override
|
|
bool get valid => super.valid && fields.length == 14;
|
|
|
|
String get messageId => fields[0];
|
|
String get utcOfPositionFix => fields[1];
|
|
String get Status => fields[2];
|
|
double get latitude => _getCoordinateFromGpsLatitude(fields[3]);
|
|
String get latitudeDirection => fields[4];
|
|
double get longitude => _getCoordinateFromGpsLongitude(fields[5]);
|
|
String get longitudeDirection => fields[6];
|
|
double get speedOverGroundKnots => double.parse(fields[7]);
|
|
double get courseOverGround => double.parse(fields[8]);
|
|
String get date => fields[9];
|
|
double get magneticVariation => double.parse(fields[10]);
|
|
String get magneticVariationDirection => fields[11];
|
|
String get positioningSystemModeIndicator => fields[12];
|
|
|
|
double _getCoordinateFromGpsLongitude(String coordinate) {
|
|
double result =
|
|
double.parse("${coordinate[0]}${coordinate[1]}${coordinate[2]}") +
|
|
double.parse(coordinate.substring(3)) / 60;
|
|
|
|
return result;
|
|
}
|
|
|
|
double _getCoordinateFromGpsLatitude(String coordinate) {
|
|
double result = double.parse("${coordinate[0]}${coordinate[1]}") +
|
|
double.parse(coordinate.substring(2)) / 60;
|
|
|
|
return result;
|
|
}
|
|
}
|