我有幾個重疊的形狀。我希望能夠在包含所有較小形狀的最大形狀上打孔。這些孔將代表較大形狀內的較小形狀。在GeoJson Shapes中打洞 - clipperLib
我使用ClipperLib的C#版本:
const double precisionFactor = 1000000000000000.0;
//precondition: all your polygons have the same orientation
//(ie either clockwise or counter clockwise)
Polygons polys = new Polygons();
multiPolygon.ForEach(x =>
{
Polygon polygon = x.First().Select(y => new IntPoint()
{
X = (long)(y[0] * precisionFactor),
Y = (long)(y[1] * precisionFactor)
}).ToList();
polys.Add(polygon);
});
Polygons solution = new Polygons();
Clipper c = new Clipper();
c.AddPaths(polys, PolyType.ptSubject,true);
c.Execute(ClipType.ctDifference, solution,
PolyFillType.pftNonZero, PolyFillType.pftNonZero);
var coordinates = solution.SelectMany(x => x.Select(y=> (IList<double>)new List<double>()
{
y.X/precisionFactor,
y.Y/precisionFactor
}).ToList()) .ToList();
return coordinates;
但被返回的形狀在上面的圖片中最大的形狀。
GeoJSON的文件: http://s000.tinyupload.com/download.php?file_id=62259172894067221043&t=6225917289406722104327028
你有沒有解決過這個問題? 我想我有同樣的問題 – Dodgson86
http://stackoverflow.com/questions/40148301/clipperlib-issue-cutting-geojson-polygons – Dodgson86