Using libgeos, when I buffer() a polygon and then getExteriorRing() [to make a slightly smaller outline copy of the polygon just inside the original], it seems that which point on the new geometry is the first/last point depends on more factors than I can control directly. When I do this repeatedly using different offsets to get multiple concentric copies of the original shape, the "starting" points on each subsequent shape are not all near each other as I had expected.

In the first specific case where I noticed this, an offset of 30 feet (and any offset between 30' and 60') resulted in a starting point near the right edge of the shape...but every offset that I tried above 60 feet resulted in a staring point at the leftmost point in the shape.

My initial though for how to deal with this goes something like:

  1. find the point on the derived geometry that is closest to the first point in the original geometry
  2. reorder the points in the derived geometry such that the point found in step 1 is the first (and last, these are closed) point
  3. Rinse, repeat for each buffered copy

Step 1 seems like geos::operation::distance::DistanceOp::nearestPoints(). Step 2 eludes me. Maybe that's because I'm trying to do this the hard way and I just don't know the name of the easy way? Is there a way to reorder the points in a GEOS LineString?

I should note that which point is first is important here because I need to treat that point as special for purposes of display and "end of path" detection...and having them all at relatively the same spot on each copy avoids jarring behavior for the user.

  • If you intersect a line from the centroid that goes out through all the buffer polygons and add those intersection points, making new polylines, would that give you a fixed point to start from? – Spacedman Apr 30 '16 at 11:50
  • I've recently seen geos::geom::CoordinateSequence::scroll(). Checking to see if this achieves the goal. – Todd Trimble May 13 '16 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.