5

从点列表创建多边形的最佳方法是什么?

我有一个点数组,如果点至少为 3,我想加入创建一个多边形

Dim ClickedPoint As New NetTopologySuite.Geometries.Point(coordinates)
ClickedPointArray.Add(ClickedPoint)

if   ClickedPointArray.Count > 2 then

   Polygonizer = New Polygonizer()
   Polygonizer.Add(ClickedPointArray)

end if        

return Polygonizer.GetPolygons

我想我离解决方案还很远。你可以帮帮我吗?

4

2 回答 2

4

您可以使用 GeometryFactory 创建一个带有坐标数组的多边形,如下所示:

Dim coordinatesArray as Coordinate[] = YourMethodToGetCoordinates
Dim geomFactory As New GeometryFactory
Dim poly As geomFactory.CreatePolygon(coordinatesArray) //this returns an IPolygon that you can cast to Polygon
于 2018-05-17T12:02:18.673 回答
1

这里是 C#

    Coordinate[] imageOutlineCoordinates = new Coordinate[] 
    {
        new Coordinate(1, 1),
        new Coordinate(2, 1),
        new Coordinate(2, 2),
        new Coordinate(1, 1)
    };
    GeometryFactory geometryFactory = new GeometryFactory();
    Polygon poly = geometryFactory.CreatePolygon(imageOutlineCoordinates);
于 2021-09-09T17:31:31.103 回答