Пример #1
0
 /// <summary>
 /// Calculates bearing between start and stop.
 /// </summary>
 /// <returns>The <see cref="System.Double"/>.</returns>
 /// <param name="start">Start coordinates.</param>
 /// <param name="stop">Stop coordinates.</param>
 public static double BearingBetween(Coordinates start, Coordinates stop)
 {
     var deltaLon = stop.Longitude - start.Longitude;
     var cosStop = Math.Cos(stop.Latitude);
     return Math.Atan2(
         (Math.Cos(start.Latitude) * Math.Sin(stop.Latitude)) -
         (Math.Sin(start.Latitude) * cosStop * Math.Cos(deltaLon)),
         Math.Sin(deltaLon) * cosStop);
 }
Пример #2
0
        /// <summary>
        /// Calculates distance between two locations.
        /// </summary>
        /// <returns>The <see cref="System.Double"/>The distance in meters</returns>
        /// <param name="a">Location a</param>
        /// <param name="b">Location b</param>
        public static double DistanceBetween(Coordinates a, Coordinates b)
        {
            double distance = Math.Acos(
                (Math.Sin(a.Latitude) * Math.Sin(b.Latitude)) +
                (Math.Cos(a.Latitude) * Math.Cos(b.Latitude)) 
                * Math.Cos(b.Longitude - a.Longitude));

            return EquatorRadius * distance;
        }
Пример #3
0
 void locationMonitor_LocationChanged(object sender, Coordinates e)
 {
     try
     {
         this.db.Create(e);
     }
     catch (Exception ex)
     {
         ex.TryToStore(this.db, this);
     }
 }
Пример #4
0
 void MainActivity_LocationChanged(object sender, Coordinates e)
 {
     this.textLocation.Text = string.Format("New location is {0}", e);
 }
Пример #5
0
 /// <summary>
 /// Calculates this locations bearing to another coordicate.
 /// </summary>
 /// <returns>Bearing degree.</returns>
 /// <param name="other">Other coordinates.</param>
 public double BearingFrom(Coordinates other)
 {
     return BearingBetween(this, other);
 }
Пример #6
0
 /// <summary>
 /// Calculates this locations distance to another coordicate.
 /// </summary>
 /// <returns>The distance to another coordicate</returns>
 /// <param name="other">Other coordinates.</param>
 public double DistanceFrom(Coordinates other)
 {
     return DistanceBetween(this, other);
 }