Exemplo n.º 1
0
        public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
        {
            if (newHeading.HeadingAccuracy < 0)
            {
                return;
            }
            if (bestHeading != null && newHeading.HeadingAccuracy >= bestHeading.HeadingAccuracy)
            {
                return;
            }

            bestHeading      = newHeading;
            position.Heading = newHeading.TrueHeading;
            try
            {
                position.Timestamp = new DateTimeOffset(newHeading.Timestamp.ToDateTime());
            }
            catch (Exception ex)
            {
                position.Timestamp = DateTimeOffset.UtcNow;
            }

            haveHeading = true;

            if (haveLocation && position.Accuracy <= desiredAccuracy)
            {
                tcs.TrySetResult(new Position(position));
                StopListening();
            }
        }
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     if (OnHeadingUpdate != null)
     {
         OnHeadingUpdate(newHeading);
     }
 }
Exemplo n.º 3
0
        private void OnUpdatedHeading(CLHeading newHeading)
        {
            var handler = HeadingUpdated;

            if (handler != null)
            {
                handler(this, new HeadingEventArgs(new HeadingData(newHeading.TrueHeading, newHeading.MagneticHeading)));
            }
        }
Exemplo n.º 4
0
            public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
            {
//				if (ctrl != null && ctrl.Engine != null && ctrl.Engine.GameState == EngineGameState.Playing)
//					if (ctrl.Engine.Heading != newHeading.TrueHeading)
//					{
//						ctrl.Engine.RefreshHeading(newHeading.TrueHeading);
//						ctrl.Refresh();
//					}
            }
Exemplo n.º 5
0
        //Called when the foreground is active, updates the heading information.
        public void HandleHeaderChanged(object sender, HeadingUpdatedEventArgs e)
        {
            CLHeading loc = e.GShead;

            if ((loc.TrueHeading >= 330 && loc.TrueHeading <= 360) || (loc.TrueHeading < 30 && loc.TrueHeading >= 0))
            {
                BarButtonItem4.Image = UIImage.FromFile("ARH_Bar_Compass.png");
            }
            else if (loc.TrueHeading >= 30 && loc.TrueHeading < 60)
            {
                BarButtonItem4.Image = UIImage.FromFile("ARH_Bar_Compass_NE.png");
            }
            else if (loc.TrueHeading >= 60 && loc.TrueHeading < 120)
            {
                BarButtonItem4.Image = UIImage.FromFile("ARH_Bar_Compass_E.png");
            }
            else if (loc.TrueHeading >= 120 && loc.TrueHeading < 150)
            {
                BarButtonItem4.Image = UIImage.FromFile("ARH_Bar_Compass_SE.png");
            }
            else if (loc.TrueHeading >= 150 && loc.TrueHeading < 210)
            {
                BarButtonItem4.Image = UIImage.FromFile("ARH_Bar_Compass_S.png");
            }
            else if (loc.TrueHeading >= 210 && loc.TrueHeading < 240)
            {
                BarButtonItem4.Image = UIImage.FromFile("ARH_Bar_Compass_SW.png");
            }
            else if (loc.TrueHeading >= 240 && loc.TrueHeading < 300)
            {
                BarButtonItem4.Image = UIImage.FromFile("ARH_Bar_Compass_W.png");
            }
            else if (loc.TrueHeading >= 300 && loc.TrueHeading < 330)
            {
                BarButtonItem4.Image = UIImage.FromFile("ARH_Bar_Compass_NW.png");
            }
            else
            {
                if (debugPrint)
                {
                    Console.WriteLine("NOT FOUND::" + loc.TrueHeading);
                }
                BarButtonItem4.Image = UIImage.FromFile("ARH_Bar_Blank.png");
            }

            if (debugPrint)
            {
                Console.WriteLine("Foreground Header Updated");
            }
        }
Exemplo n.º 6
0
        public override ValueTask<MvxGeoLocation> GetCurrentLocation()
        {
            if (_locationManager == null)
                throw new MvxException("Location Manager not started");

            var iosLocation = _locationManager.Location;
            if (iosLocation == null)
                return new ValueTask<MvxGeoLocation>((MvxGeoLocation)null);

            CLHeading heading = null;
            if (CLLocationManager.HeadingAvailable)
                heading = _locationManager.Heading;

            return new ValueTask<MvxGeoLocation>(CreateLocation(iosLocation, heading));
        }
        private static MvxGeoLocation CreateLocation(CLLocation location, CLHeading heading)
        {
            var position = new MvxGeoLocation { Timestamp = location.Timestamp.ToDateTimeUtc() };
            var coords = position.Coordinates;

            coords.Altitude = location.Altitude;
            coords.Latitude = location.Coordinate.Latitude;
            coords.Longitude = location.Coordinate.Longitude;
            coords.Speed = location.Speed;
            coords.Accuracy = location.HorizontalAccuracy;
            coords.AltitudeAccuracy = location.VerticalAccuracy;
            if (heading != null)
            {
                coords.Heading = heading.TrueHeading;
                coords.HeadingAccuracy = heading.HeadingAccuracy;
            }

            return position;
        }
Exemplo n.º 8
0
        private static MvxGeoLocation CreateLocation(CLLocation location, CLHeading heading)
        {
            var position = new MvxGeoLocation { Timestamp = location.Timestamp.ToDateTimeUtc() };
            var coords = position.Coordinates;

            coords.Altitude = location.Altitude;
            coords.Latitude = location.Coordinate.Latitude;
            coords.Longitude = location.Coordinate.Longitude;
            coords.Speed = location.Speed;
            coords.Accuracy = location.HorizontalAccuracy;
            coords.AltitudeAccuracy = location.VerticalAccuracy;
            if (heading != null)
            {
                coords.Heading = heading.TrueHeading;
                coords.HeadingAccuracy = heading.HeadingAccuracy;
            }

            return position;
        }
        /// <summary>
        /// Updateds the heading.
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="newHeading">The new heading.</param>
        public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
        {
            if (newHeading.HeadingAccuracy < 0)
            {
                return;
            }
            if (_bestHeading != null && newHeading.HeadingAccuracy >= _bestHeading.HeadingAccuracy)
            {
                return;
            }

            _bestHeading      = newHeading;
            _position.Heading = newHeading.TrueHeading;
            _haveHeading      = true;

            if (_haveLocation && _position.Accuracy <= _desiredAccuracy)
            {
                _tcs.TrySetResult(new Position(_position));
                StopListening();
            }
        }
        public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
        {
            if (newHeading.HeadingAccuracy < 0)
            {
                return;
            }
            if (this.bestHeading != null && newHeading.HeadingAccuracy >= this.bestHeading.HeadingAccuracy)
            {
                return;
            }

            this.bestHeading      = newHeading;
            this.position.Heading = newHeading.TrueHeading;
            this.haveHeading      = true;

            if (this.haveLocation && this.position.Accuracy <= this.desiredAccuracy)
            {
                this.tcs.TrySetResult(new Position(this.position));
                StopListening();
            }
        }
Exemplo n.º 11
0
        public void PrintHeading(object sender, HeadingUpdatedEventArgs e)
        {
            //Used for debugging. Prints the heading.

            CLHeading head = e.GShead;

            if (head.TrueHeading >= 0 && head.TrueHeading < 90)
            {
                if (debugPrint)
                {
                    Console.WriteLine("Course: True North");
                }
                else if (head.TrueHeading >= 90 && head.TrueHeading < 180)
                {
                    if (debugPrint)
                    {
                        Console.WriteLine("Course: True East");
                    }
                    else if (head.TrueHeading >= 180 && head.TrueHeading < 270)
                    {
                        if (debugPrint)
                        {
                            Console.WriteLine("Course: True South");
                        }
                        else if (head.TrueHeading >= 270 && head.TrueHeading < 360)
                        {
                            if (debugPrint)
                            {
                                Console.WriteLine("Course: True West");
                            }
                            else
                            if (debugPrint)
                            {
                                Console.WriteLine("True Course: " + head.TrueHeading);
                            }
                        }
                    }
                }
            }
        }
        public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
        {
            if (newHeading.HeadingAccuracy < 0)
            {
                return;
            }

            if (_BestHeading != null && newHeading.HeadingAccuracy >= _BestHeading.HeadingAccuracy)
            {
                return;
            }

            _BestHeading      = newHeading;
            _Position.Heading = newHeading.TrueHeading;
            _HaveHeading      = true;

            if (!_HaveLocation || !(_Position.Accuracy <= _DesiredAccuracy))
            {
                return;
            }

            _Tcs.TrySetResult(new Position(_Position));
            StopListening();
        }
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     // note that we don't immediately send on the heading information.
     // for user's wanting real-time heading info a different plugin/api will be needed
     _lastSeenHeading = newHeading;
 }
Exemplo n.º 14
0
 public void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     //trueHeadingLabel.Text = $"{newHeading.TrueHeading}º";
     //magneticHeadingLabel.Text = $"{newHeading.MagneticHeading}º";
 }
Exemplo n.º 15
0
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     _lastHeading = newHeading;
     UpdatedLocationAndHeading();
 }
        public void DidUpdateHeading(NMapLocationManager locationManager, CLHeading heading)
        {
            var headingValue = heading.TrueHeading < 0.0 ? heading.MagneticHeading : heading.TrueHeading;

            SetCompassHeadingValue((float)headingValue);
        }
Exemplo n.º 17
0
 /// <summary>
 /// This method is called every time CLLocationManager gets a new
 /// reading from the hardware, _until_ StopUpdatingLocation is called
 /// (which we do call in this method, after the first reading is received)
 /// </summary>
 public override void UpdatedHeading(CLLocationManager locationManager, CLHeading head)
 {
     if (CLLocationManager.HeadingAvailable) {
         unityHeading.TrueHeading = head.TrueHeading;
         unityHeading.HeadingAccuracy = head.HeadingAccuracy;
         unityHeading.MagneticHeading = head.MagneticHeading;
         unityHeading.TimeStamp = head.Timestamp;
         unityHeading.XGeomagneticField = head.X;
         unityHeading.YGeomagneticField = head.Y;
         unityHeading.ZGeomagneticField = head.Z;
     }
 }
        public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
        {
            if (newHeading.HeadingAccuracy < 0)
                return;
            if (this.bestHeading != null && newHeading.HeadingAccuracy >= this.bestHeading.HeadingAccuracy)
                return;

            this.bestHeading = newHeading;
            this.position.Heading = newHeading.TrueHeading;
            this.haveHeading = true;

            if (this.haveLocation && this.position.Accuracy <= this.desiredAccuracy)
            {
                this.tcs.TrySetResult(new Position(this.position));
                StopListening();
            }
        }
Exemplo n.º 19
0
			public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
			{
//				if (ctrl != null && ctrl.Engine != null && ctrl.Engine.GameState == EngineGameState.Playing)
//					if (ctrl.Engine.Heading != newHeading.TrueHeading)
//					{
//						ctrl.Engine.RefreshHeading(newHeading.TrueHeading);
//						ctrl.Refresh();
//					}
			}
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 21
0
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     Console.WriteLine("Magnetic Heading = {0}", newHeading.MagneticHeading);
     Console.WriteLine("True Heading = {0}", newHeading.TrueHeading);
     Console.WriteLine("Heading Accuracy = +/-{0} degress", newHeading.HeadingAccuracy);
 }
Exemplo n.º 22
0
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
 }
Exemplo n.º 23
0
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     ((Compass)manager).OnUpdatedHeading(newHeading);
 }
Exemplo n.º 24
0
 public HeadingUpdatedEventArgs(CLHeading head)
 {
     this.head = head;
 }
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     if (OnHeadingUpdate != null)
         OnHeadingUpdate(newHeading);
 }
Exemplo n.º 26
0
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 27
0
		public override void UpdatedHeading (CLLocationManager manager, CLHeading newHeading)
		{
			Console.Out.WriteLine ("UpdatedHeading");
		}
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     // note that we don't immediately send on the heading information.
     // for user's wanting real-time heading info a different plugin/api will be needed
     _lastSeenHeading = newHeading;
 }
Exemplo n.º 29
0
			public override void UpdatedHeading (CLLocationManager manager, CLHeading newHeading)
			{
				ms.LblMagneticHeading.Text = newHeading.MagneticHeading.ToString () + "º";
				ms.LblTrueHeading.Text = newHeading.TrueHeading.ToString () + "º";
			}
Exemplo n.º 30
0
			public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
			{
			}
 public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
 {
     ms.LblMagneticHeading.Text = newHeading.MagneticHeading.ToString() + "º";
     ms.LblTrueHeading.Text     = newHeading.TrueHeading.ToString() + "º";
 }
        /// <summary>
        /// Updateds the heading.
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="newHeading">The new heading.</param>
        public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading)
        {
            if (newHeading.HeadingAccuracy < 0)
            {
                return;
            }
            if (_bestHeading != null && newHeading.HeadingAccuracy >= _bestHeading.HeadingAccuracy)
            {
                return;
            }

            _bestHeading = newHeading;
            _position.Heading = newHeading.TrueHeading;
            _haveHeading = true;

            if (_haveLocation && _position.Accuracy <= _desiredAccuracy)
            {
                _tcs.TrySetResult(new Position(_position));
                StopListening();
            }
        }
 public override void UpdatedHeading (CLLocationManager manager, CLHeading newHeading)
 {
     Console.WriteLine ("Magnetic Heading = {0}", newHeading.MagneticHeading);
     Console.WriteLine ("True Heading = {0}", newHeading.TrueHeading);
     Console.WriteLine ("Heading Accuracy = +/-{0} degress", newHeading.HeadingAccuracy);
 }