/// <summary>
        /// Sentence constructor
        /// </summary>
        public GPRMCGpsSentence(string SentenceInstance)
            : base(SentenceInstance)
        {
            // Base
            SentenceName = "$GPRMC";
            Description = "Recommended Minimum Specific GPS/TRANSIT Data";

            // Instance
            _fixed = isFixed(Words[2]);
            _latitude = new LatitudeLongitude(Words[3], Words[4]);
            _longitude = new LatitudeLongitude(Words[5], Words[6]);
            _speedOverGround = new GpsSpeed(Words[7]);
            if(Words[8] == String.Empty)
            {
                _courseOverGround = -1;
            }
            else
            {
                _courseOverGround = double.Parse(Words[8], new CultureInfo("en-US"));
            }
            _magneticVariation = Words[10];

            if (Words[1].Length != 0)
            {
                try
                {
                    if (Words[1].Length == 6)
                    {
                        // Only HHMMSS
                        _uTCDateTime = new DateTime(
                            int.Parse(Words[9].Substring(4, 2)),
                            int.Parse(Words[9].Substring(2, 2)),
                            int.Parse(Words[9].Substring(0, 2)),
                            int.Parse(Words[1].Substring(0, 2)),
                            int.Parse(Words[1].Substring(2, 2)),
                            int.Parse(Words[1].Substring(4, 2)));
                    }
                    else
                    {
                        // HHMMSS.MS
                        _uTCDateTime = new DateTime(
                            int.Parse(Words[9].Substring(4, 2)),
                            int.Parse(Words[9].Substring(2, 2)),
                            int.Parse(Words[9].Substring(0, 2)),
                            int.Parse(Words[1].Substring(0, 2)),
                            int.Parse(Words[1].Substring(2, 2)),
                            int.Parse(Words[1].Substring(4, 2)),
                            int.Parse(Words[1].Substring(7)));
                    }
                }
                catch(ArgumentNullException){}
            }
        }
Example #2
0
        /// <summary>
        /// Sentence constructor
        /// </summary>
        public GPRMCGpsSentence(string SentenceInstance) : base(SentenceInstance)
        {
            // Base
            SentenceName = "$GPRMC";
            Description  = "Recommended Minimum Specific GPS/TRANSIT Data";

            // Instance
            _fixed           = isFixed(Words[2]);
            _latitude        = new LatitudeLongitude(Words[3], Words[4]);
            _longitude       = new LatitudeLongitude(Words[5], Words[6]);
            _speedOverGround = new GpsSpeed(Words[7]);
            if (Words[8] == String.Empty)
            {
                _courseOverGround = -1;
            }
            else
            {
                _courseOverGround = double.Parse(Words[8], new CultureInfo("en-US"));
            }
            _magneticVariation = Words[10];

            if (Words[1].Length != 0)
            {
                try
                {
                    if (Words[1].Length == 6)
                    {
                        // Only HHMMSS
                        _uTCDateTime = new DateTime(
                            int.Parse(Words[9].Substring(4, 2)),
                            int.Parse(Words[9].Substring(2, 2)),
                            int.Parse(Words[9].Substring(0, 2)),
                            int.Parse(Words[1].Substring(0, 2)),
                            int.Parse(Words[1].Substring(2, 2)),
                            int.Parse(Words[1].Substring(4, 2)));
                    }
                    else
                    {
                        // HHMMSS.MS
                        _uTCDateTime = new DateTime(
                            int.Parse(Words[9].Substring(4, 2)),
                            int.Parse(Words[9].Substring(2, 2)),
                            int.Parse(Words[9].Substring(0, 2)),
                            int.Parse(Words[1].Substring(0, 2)),
                            int.Parse(Words[1].Substring(2, 2)),
                            int.Parse(Words[1].Substring(4, 2)),
                            int.Parse(Words[1].Substring(7)));
                    }
                }
                catch (ArgumentNullException) {}
            }
        }