This project has moved and is read-only. For the latest updates, please go here.

Create polygon from point list

Topics: Algorithms, Italiano, SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0, Web Controls, WinForms Controls
Sep 29, 2015 at 9:04 AM
Hello all,

What is the best way to create a polygon from list of point?
When I click on map I add a point to collection.
when point are at least 3 I join all point to create a polygon
 Dim ClickedPoint As New NetTopologySuite.Geometries.Point(coordinates)

if   ClickedPointArray.Count > 2 then

   Polygonizer = New Polygonizer()

end if        

return Polygonizer.GetPolygons
I think I'm very far from solution.
Could you help me?
Sep 29, 2015 at 2:40 PM
REM Do this elsewhere, you must not reinstantiate the list or you won't get your count greater than one.
Dim clickedPoints As New List<GeoAPI.Geometries.Coordinate>();


if clickedPointArray.Count > 2 then

   REM you need a valid ring (closed)
   clickedPointArray.Add(new GeoAPI.Geometries.Coordinate(clickedPointArray(0))
   dim ring as (GeoAPI.Geometries.ILinearRing) <map>.Factory.CreateLinearRing(clickedPointArray.ToArray())
   dim polygon as (GeoAPI.Geometries.IPolygon) <map>.Factory.CreatePolygon(clickedPointArray.ToArray())
   REM remove closing coordinate
   clickedPointArray.Remove(clickedPointArray.Count - 1)

end if
Oct 1, 2015 at 10:14 AM
with your help it work fine.