Search code examples
c++geometrypolygonpolylineboost-geometry

An algorithm for inflating/deflating (offsetting, buffering) polylines


Related Question:
An algorithm for inflating/deflating (offsetting, buffering) polygons

The difference is that I'm searching for a way to inflate a given polyline into a polygon:

polyline with a box around

I've got the following input:

  • List of 2D Points which form the polyline (bright green in the sketch)
  • Width of the line

The output should be a polygon which shows how the line looks expanded by the width.

I originally thought I could use Boost::Geometry::buffer for that, unfortunately it just seems to support boxes for now. A solution using Boost::Geometry or GDAL/OGR would be preffered.

UPDATE:
I chose to use the Clipper Library and its OffsetPolyLines function. As soon as Boost Geometry is released with Polyline-Buffer support I'll switch to Boost (as everything else runs with Boost in my software).


Solution

  • I understand that the OP was preferring a solution in Boost::Geometry or GDAL/OGR but, in case others are following this thread, my Clipper library can also do polyline offsetting. (The soon to be released version 6 that's already in the SourceForge repository simplifies this and it now supports open path (polyline) clipping too.)