Пример #1
0
 /// <summary>
 /// Initializes the NMEA Estimated Position Error and parses an NMEA sentence
 /// </summary>
 /// <param name="NMEAsentence"></param>
 public GPRME(string NMEAsentence)
 {
     try
     {
         //Split into an array of strings.
         string[] split = NMEAsentence.Split(new Char[] { ',' });
         GPSHandler.dblTryParse(split[1], out _estHorisontalError);
         GPSHandler.dblTryParse(split[3], out _estVerticalError);
         GPSHandler.dblTryParse(split[5], out _estSphericalError);
     }
     catch { }
 }
Пример #2
0
        /// <summary>
        ///  GPS DOP and active satellites and parses an NMEA sentence
        /// </summary>
        /// <param name="NMEAsentence"></param>
        public GPGSA(string NMEAsentence)
        {
            _pRNInSolution = new List <string>();
            try
            {
                if (NMEAsentence.IndexOf('*') > 0)
                {
                    NMEAsentence = NMEAsentence.Substring(0, NMEAsentence.IndexOf('*'));
                }
                //Split into an array of strings.
                string[] split = NMEAsentence.Split(new Char[] { ',' });
                if (split[1].Length > 0)
                {
                    _mode = split[1][0];
                }
                else
                {
                    _mode = ' ';
                }
                if (split[2].Length > 0)
                {
                    switch (split[2])
                    {
                    case "2": _fixMode = GSAFixModeEnum._2D; break;

                    case "3": _fixMode = GSAFixModeEnum._3D; break;

                    default: _fixMode = GSAFixModeEnum.FixNotAvailable; break;
                    }
                }
                _pRNInSolution.Clear();
                for (int i = 0; i <= 11; i++)
                {
                    if (split[i + 3] != "")
                    {
                        _pRNInSolution.Add(split[i + 3]);
                    }
                }
                GPSHandler.dblTryParse(split[15], out _pdop);
                GPSHandler.dblTryParse(split[16], out _hdop);
                GPSHandler.dblTryParse(split[17], out _vdop);
            }
            catch { }
        }
Пример #3
0
        /// <summary>
        /// Initializes the NMEA Global Positioning System Fix Data and parses an NMEA sentence
        /// </summary>
        /// <param name="NMEAsentence"></param>
        public GPGGA(string NMEAsentence)
        {
            try
            {
                if (NMEAsentence.IndexOf('*') > 0)
                {
                    NMEAsentence = NMEAsentence.Substring(0, NMEAsentence.IndexOf('*'));
                }
                //Split into an array of strings.
                string[] split = NMEAsentence.Split(new Char[] { ',' });
                if (split[1].Length >= 6)
                {
                    TimeSpan t = new TimeSpan(GPSHandler.intTryParse(split[1].Substring(0, 2)),
                                              GPSHandler.intTryParse(split[1].Substring(2, 2)), GPSHandler.intTryParse(split[1].Substring(4, 2)));
                    DateTime nowutc = DateTime.UtcNow;
                    nowutc     = nowutc.Add(-nowutc.TimeOfDay);
                    _timeOfFix = nowutc.Add(t);
                }

                _position = new Coordinate(GPSHandler.GPSToDecimalDegrees(split[4], split[5]),
                                           GPSHandler.GPSToDecimalDegrees(split[2], split[3]));
                if (split[6] == "1")
                {
                    _fixQuality = FixQualityEnum.GPS;
                }
                else if (split[6] == "2")
                {
                    _fixQuality = FixQualityEnum.DGPS;
                }
                else
                {
                    _fixQuality = FixQualityEnum.Invalid;
                }
                _noOfSats = Convert.ToByte(split[7]);
                GPSHandler.dblTryParse(split[8], out _dilution);
                GPSHandler.dblTryParse(split[9], out _altitude);
                _altitudeUnits = split[10][0];
                GPSHandler.dblTryParse(split[11], out _heightOfGeoid);
                GPSHandler.intTryParse(split[13], out _dGPSUpdate);
                _dGPSStationID = split[14];
            }
            catch { }
        }
Пример #4
0
            public static NTRIPCaster ParseFromString(string line)
            {
                string[]    strData = line.Trim().Split(';');
                NTRIPCaster data    = new NTRIPCaster();

                data.Host = new System.Net.IPEndPoint(System.Net.Dns.GetHostEntry(strData[1]).AddressList[0], int.Parse(strData[2]));
                //data.Host = new System.Net.IPEndPoint(System.Net.IPAddress.Parse(strData[1]),int.Parse(strData[2]));
                data.Identifier = strData[3];
                data.Operator   = strData[4];
                data.NMEA       = (strData[5] == "1");
                data.Country    = strData[6];
                GPSHandler.dblTryParse(strData[7], out data.Latitude);
                GPSHandler.dblTryParse(strData[8], out data.Longitude);
                if (strData.Length > 9)
                {
                    data.FallbackHost = strData[9];
                }
                return(data);
            }
Пример #5
0
        /// <summary>
        /// Initializes the NMEA Recommended minimum specific GPS/Transit data and parses an NMEA sentence
        /// </summary>
        /// <param name="NMEAsentence"></param>
        public GPRMC(string NMEAsentence)
        {
            try
            {
                //Split into an array of strings.
                string[] split = NMEAsentence.Split(new Char[] { ',' });

                //Extract date/time
                try
                {
                    string[] DateTimeFormats = { "ddMMyyHHmmss", "ddMMyy", "ddMMyyHHmmss.FFFFFF" };
                    if (split[9].Length >= 6)                       //Require at least the date to be present
                    {
                        string time = split[9] + split[1];          // +" 0";
                        _timeOfFix = DateTime.ParseExact(time, DateTimeFormats, GPSHandler.NumberFormatEnUs, System.Globalization.DateTimeStyles.AssumeUniversal);
                    }
                    else
                    {
                        _timeOfFix = new DateTime();
                    }
                }
                catch { _timeOfFix = new DateTime(); }

                if (split[2] == "A")
                {
                    _status = StatusEnum.OK;
                }
                else
                {
                    _status = StatusEnum.Warning;
                }

                _position = new Coordinate(GPSHandler.GPSToDecimalDegrees(split[5], split[6]),
                                           GPSHandler.GPSToDecimalDegrees(split[3], split[4]));

                GPSHandler.dblTryParse(split[7], out _speed);
                GPSHandler.dblTryParse(split[8], out _course);
                GPSHandler.dblTryParse(split[10], out _magneticVariation);
            }
            catch { }
        }