private void CalculateMercatorValues()
        {
            if ((_decLongitude == 0 & _decLatitude == 0) & (DmsLatitude != 0 & DmsLongitude != 0))
            {
                CalcualteDecValues();
            }
            var newMercX = 0;
            var newMercY = 0;

            DffGpsTools.GeodecimalToMercator(_decLongitude, _decLatitude, ref newMercX, ref newMercY);
            _mrcX = newMercX;
            _mrcY = newMercY;
        }
 public DffGpsPosition(int mercatorX, int mercatorY)
 {
     MercatorX = mercatorX;
     MercatorY = mercatorY;
     DffGpsTools.MercatorToGeodecimal(_mrcX, _mrcY, ref _decLongitude, ref _decLatitude);
 }
        private void CalcualteDecValues()
        {
            IFormatProvider format        = new CultureInfo("en-US", true);
            var             decLatString  = "";
            var             decLongString = "";

            var latNeg        = false;
            var longNeg       = false;
            var dmsLatString  = _dmsLatitude.ToString(format);
            var dmsLongString = _dmsLongitude.ToString(format);

            if (dmsLatString.IndexOf(".") == -1)
            {
                dmsLatString = dmsLatString + ".00000";
            }
            if (dmsLongString.IndexOf(".") == -1)
            {
                dmsLongString = dmsLongString + ".00000";
            }

            if (dmsLatString.StartsWith("-"))
            {
                latNeg       = true;
                dmsLatString = dmsLatString.Substring(1);
            }
            if (dmsLongString.StartsWith("-"))
            {
                longNeg       = true;
                dmsLongString = dmsLongString.Substring(1);
            }

            while (dmsLatString.Substring(dmsLatString.IndexOf(".") + 1).Length < 5)
            {
                dmsLatString = dmsLatString + "0";
            }
            while (dmsLongString.Substring(dmsLongString.IndexOf(".") + 1).Length < 5)
            {
                dmsLongString = dmsLongString + "0";
            }
            while (dmsLatString.Length < 8)
            {
                dmsLatString = "0" + dmsLatString;
            }
            while (dmsLongString.Length < 8)
            {
                dmsLongString = "0" + dmsLongString;
            }
            if (latNeg)
            {
                dmsLatString = "-" + dmsLatString;
            }
            if (longNeg)
            {
                dmsLongString = "-" + dmsLongString;
            }

            DffGpsTools.Geodms2Geodec(dmsLatString.Replace(".", ""), dmsLongString.Replace(".", ""), ref decLatString,
                                      ref decLongString);
            _decLongitude = double.Parse(decLongString) / 100000;
            _decLatitude  = double.Parse(decLatString) / 100000;
        }
        public DffGpsPosition(string dffPositionFormatString)
        {
            if (string.IsNullOrEmpty(dffPositionFormatString))
            {
                return;
            }

            //Wenn es sich um mehrere Fences handelt nur den ersten nehmen.
            if (dffPositionFormatString.Contains(";"))
            {
                dffPositionFormatString = dffPositionFormatString.Split(";".ToCharArray())[0];
            }
            else if (dffPositionFormatString.Contains(","))
            {
                dffPositionFormatString = dffPositionFormatString.Split(",".ToCharArray())[0];
            }

            if (string.IsNullOrEmpty(dffPositionFormatString))
            {
                return;
            }

            //Wenn es sich um einen Fence handelt, den Radius entfernen
            if (dffPositionFormatString.Contains("@"))
            {
                var temp         = dffPositionFormatString.Substring(dffPositionFormatString.IndexOf("@", StringComparison.Ordinal) + 1);
                var radiusString = dffPositionFormatString.Substring(0, dffPositionFormatString.IndexOf("@", StringComparison.Ordinal));
                dffPositionFormatString = temp;
                try
                {
                    FenceRadiusMeter = int.Parse(radiusString);
                }
                catch
                {
                }
            }

            DffGpsTools.DffPositionStringToMercator(dffPositionFormatString, ref _mrcX, ref _mrcY);
            DffGpsTools.MercatorToGeodecimal(_mrcX, _mrcY, ref _decLongitude, ref _decLatitude);

            if (!dffPositionFormatString.Contains("||"))
            {
                return;
            }
            try
            {
                var speedDirInfo = dffPositionFormatString.Substring(dffPositionFormatString.IndexOf("||", StringComparison.Ordinal) + 2);
                var infos        = speedDirInfo.Split("|".ToCharArray());
                if (infos.Length > 0 && !string.IsNullOrEmpty(infos[0]))
                {
                    Speed = double.Parse(infos[0]);
                }
                if (infos.Length > 1 && !string.IsNullOrEmpty(infos[1]))
                {
                    Heading = int.Parse(infos[1]);
                }
            }
            catch
            {
            }
        }