public static double CalculateDestination(this Overture.ServiceModel.Customers.Stores.Store store, Coordinate searchPoint)
 {
     return(store.HasLocation()
         ? Math.Round(GeoCodeCalculator.CalcDistance(store.GetLatitude(), store.GetLongitude(),
                                                     searchPoint.Lat, searchPoint.Lng, EarthRadiusMeasurement.Kilometers), 2)
         : double.MaxValue);
 }
예제 #2
0
 public StoreGeoCoordinate(Overture.ServiceModel.Customers.Stores.Store store)
 {
     if (store == null)
     {
         throw new ArgumentNullException(nameof(store));
     }
     _store = store;
 }
        public static bool InBounds(this Overture.ServiceModel.Customers.Stores.Store store, Bounds bound)
        {
            var address = store.FulfillmentLocation?.Addresses.FirstOrDefault();

            return(address != null
                ? address.Latitude.HasValue && address.Longitude.HasValue &&
                   bound.Contains(address.Latitude.Value, address.Longitude.Value)
                : false);
        }
        public static bool HasLocation(this Overture.ServiceModel.Customers.Stores.Store store)
        {
            var address = store.FulfillmentLocation?.Addresses.FirstOrDefault();

            if (address != null)
            {
                return(address.Latitude.HasValue && address.Longitude.HasValue);
            }
            return(false);
        }
예제 #5
0
        public static double CalculateDestination(this Overture.ServiceModel.Customers.Stores.Store store, Coordinate searchPoint, LengthMeasureUnitEnum lengthMeasureUnit)
        {
            double radius = lengthMeasureUnit == LengthMeasureUnitEnum.km
                ? EarthRadiusMeasurement.Kilometers
                : EarthRadiusMeasurement.Miles;

            return(store.HasLocation()
                ? Math.Round(GeoCodeCalculator.CalcDistance(store.GetLatitude(), store.GetLongitude(),
                                                            searchPoint.Lat, searchPoint.Lng, radius), 2)
                : double.MaxValue);
        }
        public static double GetLongitude(this Overture.ServiceModel.Customers.Stores.Store store)
        {
            var address = store.FulfillmentLocation?.Addresses.FirstOrDefault()
                          ?? throw new ArgumentException(GetMessageOfNullEmpty(nameof(store.FulfillmentLocation.Addresses)), nameof(store));

            if (!address.Longitude.HasValue)
            {
                throw new InvalidOperationException(nameof(address.Longitude));
            }

            return(address.Longitude.Value);
        }
예제 #7
0
        public static double GetLongitude(this Overture.ServiceModel.Customers.Stores.Store store)
        {
            var address = store.FulfillmentLocation?.Addresses.FirstOrDefault();

            if (address == null)
            {
                throw new NullReferenceException("Address");
            }
            if (!address.Longitude.HasValue)
            {
                throw new ArgumentException("Longitude");
            }
            return(address.Longitude.Value);
        }