Exemple #1
0
        private static string NmeaSenteceToJson(List <NmeaMessage> messages, int offsetInSeconds, int speedMultipler)
        {
            if (messages.Count != 2)
            {
                return(null);
            }

            GpggaMessage gpgga = messages[0] as GpggaMessage;
            GprmcMessage rmc   = messages[1] as GprmcMessage;

            Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + offsetInSeconds;

            // Longitude and Latitude needs to by formatted in the same way as for the project
            // Speed is in knots 1 knt = 1.852 km/h
            return(string.Format("{{\"quality\": 1, \"timestamp_us\": 0, \"timestamp\": {0}, \"altitude\": {1}, \"precision\": {2}, \"longitude\": {3}, \"latitude\": {4}, \"satellites\": {5}, \"speed\": {6}}}",
                                 unixTimestamp, gpgga.Altitude, gpgga.Hdop, gpgga.Longitude * 100, gpgga.Latitude * 100, gpgga.NumberOfSatellites, rmc.Speed * 1.852 * speedMultipler));
        }
Exemple #2
0
 public GpsDataEventArgs(GprmcMessage gpsLocation)
 {
     Latitude  = gpsLocation.Latitude;
     Longitude = gpsLocation.Longitude;
     Speed     = gpsLocation.Speed;
 }