Ejemplo n.º 1
0
        /* Pick the minimum distance GeoFence using the algorithm given below */
        static double GetNearestGeofenceDistance(Location location, double accuracy, List<Geofence> geofences, ref int minIndex)
        {
            double minDistance = double.MaxValue;
            minIndex = -1;
            for (int i = 0; i < geofences.Count; i++)
            {
                double distance = GetDistance(location, accuracy, geofences[i]);
                if (distance < minDistance)
                {
                    minDistance = distance;
                    minIndex = i;
                }
            }

            return minDistance;
        }
Ejemplo n.º 2
0
        static HashSet<int> GetGeofencesSurrounding(Location location, List<Geofence> geofences)
        {
            HashSet<int> lst = new HashSet<int>();

            for (int i = 0; i < geofences.Count; i++)
            {
                double distance = GetDistanceInKm(location, geofences[i].Location);
                distance -= geofences[i].Radius;
                if (distance < 0)
                {
                    lst.Add(i);
                }
            }

            return lst;
        }
Ejemplo n.º 3
0
 public static Location PerturbDataPointForWifi(Location location)
 {
     double deltaLat = Random.NextDouble() * 0.001;
     double deltaLong = Random.NextDouble() * 0.001;
     Location newLocation = new Location(location.Lat + deltaLat, location.Lng + deltaLong);
     return newLocation;
 }
Ejemplo n.º 4
0
        /* Get distance from current location to centre of geofence */
        static double GetDistance(Location location, double accuracy, Geofence geofence)
        {
            double distance = GetDistanceInKm(location, geofence.Location);
            distance -= accuracy;
            distance -= geofence.Radius;

            return distance;
        }
Ejemplo n.º 5
0
 public static double GetDistanceInKm(Location l1, Location l2)
 {
     return GetDistanceInKm(l1.Lat, l1.Lng, l2.Lat, l2.Lng);
 }