Exemple #1
0
 public static void Load()
 {
     try
     {
         if (DataManager.Has(nameof(PlacesManager)))
         {
             Current = DataManager.Get <PlacesManager>(nameof(PlacesManager));
         }
     }
     catch
     {
         //do nothing
     }
     finally
     {
         if (Current == null)
         {
             Current = new PlacesManager()
             {
                 Places = new List <GeolocationPlace>()
             }
         }
         ;
     }
 }
Exemple #2
0
        public static double GetDistanceBetween(IGeolocationTarget[] users, string userId, string device, string placeName)
        {
            var user = users.FirstOrDefault(x => x.Id.Equals(userId));

            if (user == null)
            {
                return(EquatorLength);
            }
            var place = PlacesManager.GetAllAvailablePlaces().FirstOrDefault(x => x.Name.Equals(placeName));

            if (place == null || place == GeolocationPlace.Empty || place == GeolocationPlace.Other)
            {
                return(EquatorLength);
            }
            var info = GetUserCurrentGeolocation(users, userId, device);

            if (info.Geolocation == Lazurite.Shared.Geolocation.Empty)
            {
                return(EquatorLength);
            }
            return(GeoCalculator.GetDistance(
                       info.Geolocation.Latitude, info.Geolocation.Longtitude,
                       place.Location.Latitude, place.Location.Longtitude, 1, DistanceUnit.Meters));
        }