예제 #1
0
        public Distance GetDistanceTo(Position other)
        {
            var d1 = this.Latitude * (Math.PI / 180.0);
            var num1 = this.Longitude * (Math.PI / 180.0);
            var d2 = other.Latitude * (Math.PI / 180.0);
            var num2 = other.Longitude * (Math.PI / 180.0) - num1;
            var d3 = Math.Pow(Math.Sin((d2 - d1) / 2.0), 2.0) +
                     Math.Cos(d1) * Math.Cos(d2) * Math.Pow(Math.Sin(num2 / 2.0), 2.0);

            var meters = 6376500.0 * (2.0 * Math.Atan2(Math.Sqrt(d3), Math.Sqrt(1.0 - d3)));
            return Distance.FromMeters(meters);
        }
예제 #2
0
 protected virtual CLLocationCoordinate2D ToNative(Position position)
 {
     return new CLLocationCoordinate2D(position.Latitude, position.Longitude);
 }
예제 #3
0
 public static bool IsPositionInside(this GeofenceRegion region, Position position)
 {
     var distance = region.Center.GetDistanceTo(position);
     var inside = distance.TotalMeters <= region.Radius.TotalMeters;
     return inside;
 }