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())); }
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); }
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); }
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); }
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); }
public GeoPolygon(GeoPolygon other) : this(new GeoPointList(other.GeoPoints)) { }
public virtual bool Intersects(GeoPolygon polygon) { throw new NotImplementedException(); }