Exemplo n.º 1
0
        // Any point with a latitude or longitude beyond the playfield is cold.
        // Any point with a latitude and longitude within a 5% (of the total playfield)
        // area around the current waypoint is considered hot.
        public int GetTemp( GeoCoordinate userLocation, GeoCoordinate lastLocation = null)
        {
            if (this.currentWaypoint == null)
            {
                throw new NullReferenceException("A current waypoint must be explicitly set.");
            }

            // Hot zone
            double hotZoneHalfWidth = playfield.Width * 0.025; // 5% of playfield width (halved)
            double hotZoneHalfHeight = playfield.Height * 0.025; // 5% of playfield height (halved)

            double hotWest = this.currentWaypoint.Latitude - hotZoneHalfWidth;
            double hotEast = this.currentWaypoint.Latitude + hotZoneHalfWidth;
            double hotNorth = this.currentWaypoint.Longitude + hotZoneHalfHeight;
            double hotSouth = this.currentWaypoint.Longitude - hotZoneHalfHeight;
            GeoArea hotZone = new GeoArea(hotWest, hotEast, hotNorth, hotSouth);

            /*
            // User is hot
            if (hotZone.LocationInside(userLocation))
            {
                return 0;
            }
            // User is cold
            else if (playfield.LocationOutside(userLocation))
            {
                return 1;
            }
            */

            // User is neither hot nor cold.
            // Are they colder?
            if (lastLocation != null && Further(userLocation, lastLocation))
            {
                return 2;
            }
            // Are they warmer?
            else if (lastLocation != null && Closer(userLocation, lastLocation))
            {
                return 3;
            }
            // They haven't moved toward or away?
            else if (lastLocation != null)
            {
                return 4;
            }
            // No last location (probably the first check)
            else
            {
                return 5;
            }
        }
Exemplo n.º 2
0
        public HotnessDetector(HashSet<double> allLatitudes, HashSet<double> allLongitudes)
        {
            // Get the entire list of waypoints within a single hunt
            // (or at least every latitude and longitude)
            // and determine the bounds of the playfield.

            // The playfield width is determined from the eastmost latitude
            // of the waypoints and the westmost latitude of the waypoints.
            // The playfield height is determined from the northernmost longitude
            // of the waypoints and the southernmost longitude of the waypoints.

            playfield = new GeoArea(allLongitudes.Min(), allLongitudes.Max(), allLatitudes.Max(), allLatitudes.Min());
        }