1

I am looking for a way to buffer a polyline in C#, with the purpose of creating a polygon.

However, what I am after is not a graphical solution but a numerical one. Several topics, such as Create a Polygon around a Polyline like a Buffer, suggest ways to do this but the solutions presented seem to be graphical without an indication on whether the solution can be converted into a numerical one.

Can anyone recommend an efficient way to do this operation numerically? Is there a way to get the result for GetWidenedPathGeometry() as a set of polygon coordinates?

Community
  • 1
  • 1
gktscrk
  • 173
  • 2
  • 12
  • I believe GDAL has many stuff for handling spatial objects like polygons, polylines, multi-geometries... See here: http://www.gdal.org/. This is a library many OpenSource-GIS like QuantumGIS also use. – MakePeaceGreatAgain Nov 25 '14 at 15:17
  • *Graphical solutions* can still use serialization to store/restore data. `GetWidenedPathGeometry` produces `PathGeometry` which, I think, can be stored as `StreamGeometry` and produces quite compact figure definition ([path markup](http://msdn.microsoft.com/en-us/library/ms752293.aspx)). – Sinatr Nov 25 '14 at 15:44
  • @Sinatr, do you have a working example of how to restore data from a GetWidenedPathGeometry result in that case? – gktscrk Nov 25 '14 at 16:34
  • Really, is it hard to google? To serialize use `pathGeometry.ToString()`. To deserialize `StreamGeometry.Parse()`. See [here](http://stackoverflow.com/a/4438415/1997232). – Sinatr Nov 26 '14 at 08:19
  • 1
    The accepted solution in the given link IS numerical and works very well. –  Nov 26 '14 at 09:03
  • @Sinatr, would you like to add your answer as a full answer so I can accept it? ToString seems to provide the functionality I was looking for. The only odd thing I have noticed thus far is that the delimiter in the ToString output seems to change rather widely (L,M,',',' ') -- can you direct me towards anything which would highlight the significance of the different options? – gktscrk Nov 27 '14 at 14:25
  • Feel free to post answer yourself if you think it will be useful for community :) See [path markup](http://msdn.microsoft.com/en-us/library/ms752293.aspx) for meaning of `L`, `M`, etc. – Sinatr Nov 27 '14 at 14:33

0 Answers0