static public IPolygon Merge(this List<IPolygon> polygons) { Clipper c = new Clipper(); foreach (var polygon in polygons) { c.AddPaths(polygon.ToClipperPolygons(), PolyType.ptSubject, true); } ClipperPolygons result = new ClipperPolygons(); if (c.Execute(ClipType.ctUnion, result, PolyFillType.pftPositive) == true) { return result.ToPolygon(); } return null; }
static public IPolygon Clip(this IPolygon clippee, Envelope clipper) { var clippeePolygons = clippee.ToClipperPolygons(); var clipperPolygons = clipper.ToPolygon().ToClipperPolygons(); var c = new Clipper(); c.AddPaths(clippeePolygons, PolyType.ptSubject, true); c.AddPaths(clipperPolygons, PolyType.ptClip, true); ClipperPolygons result = new ClipperPolygons(); if (c.Execute(ClipType.ctIntersection, result) == true) { return result.ToPolygon(); } return clippee; }