Beispiel #1
0
        public static GeoCircle CreateFromRegionPolygon(GeoPolygon polygon)
        {
            GeoPoint      centroid  = polygon.Centroid;
            List <Double> distances = new List <Double>();

            foreach (GeoPoint point in polygon.Points)
            {
                distances.Add(EarthGeo.GetDistance(centroid, point));
            }

            return(new GeoCircle(centroid, distances.Average()));
        }
Beispiel #2
0
        public GeoPolygon ToGeoPolygon(int sides = 16)
        {
            GeoPointList points    = new GeoPointList();
            Double       angleSize = (360 / (Double)sides);

            for (Double degrees = 0; degrees < 360; degrees += angleSize)
            {
                points.Add(EarthGeo.GetPoint(_center, Radius, degrees));
            }

            GeoPolygon polygon = new GeoPolygon(points);

            return(polygon);
        }
Beispiel #3
0
        public override bool Intersects(GeoPolygon polygon)
        {
            bool result = false;

            foreach (GeoLine line in polygon.Lines)
            {
                if (this.Contains(line.P1 as GeoPoint) ||
                    this.Contains(line.P2 as GeoPoint) ||
                    this.Intersects(line))
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
Beispiel #4
0
        public bool Equals(GeoPolygon other)
        {
            bool result = false;

            if (Lines.Count == other.Lines.Count)
            {
                result = true;
                for (int x = 0; x < Lines.Count; x++)
                {
                    if (Lines[x].Equals(other.Lines[x]) == false)
                    {
                        result = false;
                        break;
                    }
                }
            }
            return(result);
        }
Beispiel #5
0
        public bool Intersects(GeoPolygon polygon, out GeoPoint closestIntersection)
        {
            closestIntersection = null;
            Double closestDistance = Double.MaxValue;

            foreach (GeoLine line in polygon.Lines)
            {
                GeoPoint intersection;
                if (this.Intersects(line, out intersection))
                {
                    Double distance = ClosestDistanceFrom(intersection);
                    if (distance < closestDistance)
                    {
                        closestDistance     = distance;
                        closestIntersection = intersection;
                    }
                }
            }
            return(closestIntersection != null);
        }
Beispiel #6
0
 public GeoPolygon(GeoPolygon other)
     : this(new GeoPointList(other.GeoPoints))
 {
 }
Beispiel #7
0
 public virtual bool Intersects(GeoPolygon polygon)
 {
     throw new NotImplementedException();
 }