Ejemplo n.º 1
0
 public DffGpsPosition(int mercatorX, int mercatorY)
 {
     MercatorX = mercatorX;
     MercatorY = mercatorY;
     DffGpsTools.MercatorToGeodecimal(_mrcX, _mrcY, ref _decLongitude, ref _decLatitude);
 }
Ejemplo n.º 2
0
        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
            {
            }
        }