示例#1
0
        public static bool TryParse(String str, out GeoCircle circle)
        {
            circle = null;

            String[] parts = str.Split('R');
            GeoPoint p;
            Double   r;

            if (parts.Length == 2 && GeoPoint.TryParse(parts[0].Trim(), out p) && Double.TryParse(parts[1].Trim(), out r))
            {
                circle = new GeoCircle(p, r);
            }

            return(circle != null);
        }
示例#2
0
        public bool Intersects(GeoCircle circle)
        {
            bool intersects = false;

            foreach (GeoLine line in this)
            {
                GeoPoint p1, p2;
                int      intersections;
                if (circle.Intersects(line, out p1, out p2, out intersections))
                {
                    intersects = true;
                    break;
                }
            }
            return(intersects);
        }
示例#3
0
        public Double GetMiniumumPossibleDistance(GeoCircle postion)
        {
            Double distance = Double.MaxValue;

            if (postion.Intersects(this))
            {
                distance = 0;
            }
            else
            {
                distance = DistanceToEdgeFrom(postion.Center as GeoPoint);
                distance = Math.Max(0, distance - postion.Radius);
            }

            return(distance);
        }
示例#4
0
        public static Double GetMiniumumPossibleDistanceFromAnyPolygon(GeoCircle postion, IEnumerable <GeoPolygon> polygons)
        {
            Double distance = Double.MaxValue;

            foreach (GeoPolygon polygon in polygons)
            {
                if (postion.Intersects(polygon) || polygon.Contains(postion.Center as GeoPoint))
                {
                    distance = 0;
                }
                else
                {
                    Double thisDistance = polygon.DistanceToEdgeFrom(postion.Center as GeoPoint);
                    thisDistance = Math.Max(0, thisDistance - postion.Radius);
                    distance     = Math.Min(distance, thisDistance);
                }

                if (distance == 0)
                {
                    break;
                }
            }
            return(distance);
        }
示例#5
0
 public GeoCircle(GeoCircle other)
     : this(other.Latitude, other.Longitude, other.Radius)
 {
 }
示例#6
0
 public bool Intersects(GeoCircle circle)
 {
     return(circle.Intersects(this));
 }
示例#7
0
 public bool Contains(GeoCircle circle, Double rayLength = DEFAULT_RAY_LENGTH)
 {
     /** see if this polygon entirely contains the given circle */
     return(this.Contains(circle.Center as GeoPoint) == true && circle.Intersects(this) == false);
 }
示例#8
0
 public GeoEllipse(GeoCircle circle)
     : this(circle.Center, circle.Radius, circle.Radius, 0)
 {
 }