Example #1
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;
        }
Example #2
0
        public static List<Geofence> GetRandomGeofences(List<DataPoint> dataPoints, int n)
        {
            List<Geofence> geofences = new List<Geofence>();

            int max = dataPoints.Count;

            for (int i = 0; i < n; i++)
            {
                int randomIndex = Random.Next(max);
                Location location = dataPoints[randomIndex].Location;

                Geofence geoFence = new Geofence()
                {
                    Location = new Location(location.Lat, location.Lng),
                    Radius = 0.2
                };

                geofences.Add(geoFence);
            }

            return geofences;
        }