Exemple #1
0
        // Input example: $GPRMC,102156.000,A,2232.4690,N,11403.6847,E,0.00,,180909,,*15
        public static GPRMC Parse(string input)
        {
            Match match = new Regex("(\\d{2}\\d{2}\\d{2}.\\d+)," + // dd mm yy
                                    "(A|V)," +                     // gps fix
                                    "(\\d+.\\d+),(N|S)," +         // latitude
                                    "(\\d+.\\d+),(E|W)," +         // longitude
                                    "(.*?)," +                     // speed
                                    "(.*?)," +                     // heading
                                    "(\\d{2}\\d{2}\\d{2})")        // hh mm ss . ss
                          .Match(input);

            if (match.Success)
            {
                GPRMC gprmc = new GPRMC
                {
                    DateTime = NewDateTimeUtil.Convert(DateFormat.HHMMSS_SS_DDMMYY, match.Groups[1].Value,
                                                       match.Groups[9].Value),
                    PositionStatus = match.Groups[2].Value == "A",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(match.Groups[3].Value, match.Groups[4].Value),
                    Longitude      = GpsUtil.ConvertDmmLongToDecimal(match.Groups[5].Value, match.Groups[6].Value),
                    Speed          = SpeedUtil.KnotsToKph(match.Groups[7].Get <decimal>()),
                    Heading        = match.Groups[8].Get <decimal?>()
                };

                return(gprmc);
            }

            return(null);
        }
Exemple #2
0
        public GPRMC(string input)
        {
            input = input.Replace("$GPRMC,", String.Empty);
            string[] split = input.Split(",");

            DateTime       = GetDateTime(split[0], split[8]);
            Latitude       = GpsUtil.ConvertDegreeAngleToDouble(@"(\d{2})(\d{2}).(\d{4})", split[2], split[3]);
            Longitude      = GpsUtil.ConvertDegreeAngleToDouble(@"(\d{3})(\d{2}).(\d{4})", split[4], split[5]);
            PositionStatus = split[1] == "A";
            Speed          = split.Get <double>(6) * 1.852;
            Heading        = split.Get <float?>(7);
        }
Exemple #3
0
        // Input example: $GPRMC,102156.000,A,2232.4690,N,11403.6847,E,0.00,,180909,,*15
        public GPRMC(string input)
        {
            input = input.Replace("$GPRMC,", String.Empty);
            string[] split = input.Split(",");

            PositionStatus = split[1] == "A";
            DateTime       = GetDateTime(split[0], split[8]);
            Latitude       = GpsUtil.ConvertDmmLatToDecimal(split[2], split[3]);
            Longitude      = GpsUtil.ConvertDmmLongToDecimal(split[4], split[5]);
            Speed          = SpeedUtil.KnotsToKph(split.Get <decimal>(6));
            Heading        = split.Get <decimal?>(7);
        }