Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
 internal static RepositoryWrapper <GeofenceRegion, GeofenceRegionStore> Wrap(this IRepository repository) => new RepositoryWrapper <GeofenceRegion, GeofenceRegionStore>
 (
     repository,
     args => new GeofenceRegionStore
 {
     Identifier      = args.Identifier,
     CenterLatitude  = args.Center.Latitude,
     CenterLongitude = args.Center.Longitude,
     RadiusMeters    = args.Radius.TotalMeters,
     SingleUse       = args.SingleUse,
     NotifyOnEntry   = args.NotifyOnEntry,
     NotifyOnExit    = args.NotifyOnExit
 },
     store => new GeofenceRegion(
         store.Identifier,
         new Position(store.CenterLatitude, store.CenterLongitude),
         Distance.FromMeters(store.RadiusMeters)
         )
 {
     SingleUse     = store.SingleUse,
     NotifyOnEntry = store.NotifyOnEntry,
     NotifyOnExit  = store.NotifyOnExit
 }
 );