public Polygon TwoPieces(Polygon polygon1, Polygon polygon2, LineString line1, LineString line2)
 {
     if (polygon1.Intersects(polygon2) || polygon1.Touches(polygon2))
     {
         return polygon1.Union(polygon2) as Polygon;
     }
     else
     {
         var pg = GetConvexHull(line1, line2);
         return pg.Union(polygon1).Union(polygon2) as Polygon;
     }
 }
        /// <summary>
        /// Takes an array of simple polygons and combines them into one multi-part shape.
        /// </summary>
        /// <param name="parts">The array of polygons.</param>
        /// <param name="resultShp">The resulting multi-part shape.</param>
        public static void CombineParts(ref IFeature[] parts, ref IFeature resultShp)
        {
            int numParts = parts.Length;
            Polygon po = new Polygon(parts[0].Coordinates);
            Polygon poly;
            for (int i = 0; i <= numParts - 1; i++)
            {
                poly = new Polygon(parts[i].Coordinates);
                po = poly.Union(po) as Polygon;
            }

            resultShp = new Feature(po);
        }
Beispiel #3
0
 /// <summary>
 /// 1.將多邊形內部的小碎地(小於1平方公尺)移除
 /// </summary>
 /// <param name="polygon"></param>
 public Polygon CleanupPolygon(Polygon polygon)
 {
     if (polygon.Holes.Any(x => x.Envelope.Area() < 1))
     {
         polygon = new Polygon(polygon.ExteriorRing.Coordinates);
         var holes = polygon.Holes.Where(x => x.Envelope.Area() > 1);
         foreach (var hole in holes)
         {
             polygon.Union(new Polygon(hole.Coordinates));
         }
     }
     return polygon;
 }