Ejemplo n.º 1
0
 /// <summary>
 /// Converts GpsFix enum value to it's string equivalent
 /// </summary>
 /// <param name="fix">A GpxFix value to convert</param>
 /// <returns>A string equivalent of the fix parameter</returns>
 /// <remarks>ConvertGpsFixToString shoul be used instead ToString() function becouse string representation of the GpsFix values if GPX schema do not equal to their names.</remarks>
 public static string GpsFixToString(GpsFix fix)
 {
     switch (fix) {
         case GpsFix.None: return "none";
         case GpsFix.Fix2D: return "2d";
         case GpsFix.Fix3D: return "3d";
         case GpsFix.Dgps: return "dgps";
         case GpsFix.Pps: return "pps";
         default: return null;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts GpsFix enum value to it's string equivalent
        /// </summary>
        /// <param name="fix">A GpxFix value to convert</param>
        /// <returns>A string equivalent of the fix parameter</returns>
        /// <remarks>ConvertGpsFixToString shoul be used instead ToString() function becouse string representation of the GpsFix values if GPX schema do not equal to their names.</remarks>
        public static string GpsFixToString(GpsFix fix)
        {
            switch (fix)
            {
            case GpsFix.None: return("none");

            case GpsFix.Fix2D: return("2d");

            case GpsFix.Fix3D: return("3d");

            case GpsFix.Dgps: return("dgps");

            case GpsFix.Pps: return("pps");

            default: return(null);
            }
        }
Ejemplo n.º 3
0
        protected override void SetLocation()
        {
            GpsFix gpsFix = NextLocationData;

            _currentLocation.IsLocationServiceEnabled = true;

            if (gpsFix.UserHeading.HasValue)
            {
                _currentLocation.UserHeading = gpsFix.UserHeading.Value;
            }
            else
            {
                // calculate heading ourselves
                _currentLocation.UserHeading = (float)(Math.Atan2(gpsFix.LatLng.y - _currentLocation.LatitudeLongitude.y, gpsFix.LatLng.x - _currentLocation.LatitudeLongitude.x) * 180 / Math.PI);
            }

            if (gpsFix.DeviceOrientation.HasValue)
            {
                _currentLocation.DeviceOrientation = gpsFix.DeviceOrientation.Value;
            }
            else
            {
                // simluate device rotating all the time
                _currentLocation.DeviceOrientation += 15;
                if (_currentLocation.DeviceOrientation > 359)
                {
                    _currentLocation.DeviceOrientation = 0;
                }
            }

            _currentLocation.Provider             = gpsFix.provider;
            _currentLocation.HasGpsFix            = gpsFix.HasGpxFix;
            _currentLocation.LatitudeLongitude    = gpsFix.LatLng;
            _currentLocation.Timestamp            = gpsFix.Timestamp;
            _currentLocation.Accuracy             = gpsFix.Accuracy;
            _currentLocation.SpeedMetersPerSecond = gpsFix.Speed;
            _currentLocation.IsLocationUpdated    = true;
            _currentLocation.IsUserHeadingUpdated = true;
        }
Ejemplo n.º 4
0
        public void ParseGpsFix_ValidGpsFixes_ParsesStringValue(GpsFix expectedValue, string s)
        {
            GpsFix? parsedValue = GpxFixHelper.ParseGpsFix(s);

            Assert.Equal(expectedValue, parsedValue);
        }
Ejemplo n.º 5
0
        public void GpsFixToString_GpsFixes_ConvertsToStringEquivalents(GpsFix fix, string expectedValue)
        {
            string strValue = GpxFixHelper.GpsFixToString(fix);

            Assert.Equal(expectedValue, strValue);
        }
Ejemplo n.º 6
0
        public void GpsFixToString_GpsFixes_ConvertsToStringEquivalents(GpsFix fix, string expectedValue)
        {
            string strValue = GpxFixHelper.GpsFixToString(fix);

            Assert.Equal(expectedValue, strValue);
        }
Ejemplo n.º 7
0
        public void ParseGpsFix_ValidGpsFixes_ParsesStringValue(GpsFix expectedValue, string s)
        {
            GpsFix?parsedValue = GpxFixHelper.ParseGpsFix(s);

            Assert.Equal(expectedValue, parsedValue);
        }