Esempio n. 1
0
 /// <summary>
 /// Determines whether a point is within the circle.
 /// </summary>
 /// <param name="point">The point being tested.</param>
 /// <returns><c>true</c> if the point is within the circle.</returns>
 public override bool Contains(GeoCoordinate point)
 {
     if (!Bounds.Contains(point))
     {
         return(false);   // Handles clipping cases
     }
     return(GeoHelper.Distance(point, center, planetRadius) <= radius);
 }
Esempio n. 2
0
        /// <summary>
        /// Computes the bounding rectangle for the circle.
        /// </summary>
        private void ComputeBounds()
        {
            // This is a bit tricky.  The approach is to plot points for the edge of
            // the circle on the horizonal and vertical axes, clip these to the edges
            // of the map (since we don't implement coordinate wraparound) and then
            // form the rectangle.
            //
            // Note that this is a bit of hack and may result in inaccuracies for some
            // combinations of planet radii and circle center points.

            double left;
            double top;
            double right;
            double bottom;

            left = GeoHelper.Plot(center, 270, radius, planetRadius).Longitude;
            if (left > center.Longitude)
            {
                left = -180;    // clip
            }
            right = GeoHelper.Plot(center, 90, radius, planetRadius).Longitude;
            if (right < center.Longitude)
            {
                right = 180;    // clip
            }
            top = GeoHelper.Plot(center, 0, radius, planetRadius).Latitude;
            if (top < center.Latitude)
            {
                top = 90;
            }

            bottom = GeoHelper.Plot(center, 180, radius, planetRadius).Latitude;
            if (bottom > center.Latitude)
            {
                bottom = -90;
            }

            base.Bounds = new GeoRectangle(top, right, bottom, left);
        }