Please do not top-post.

Zhang Qun wrote:
Hi, Adam thanks for the reply and detailed code and explanation. Yes, it worked.
I implemented as per your instructions but encountered a small problem. That is sometimes I realized the intersections points between the linestrings and the polygon are not in a "consistent" order, e.g. as shown in the below image, lingstring 1 has P1->P2; However, instead of P3->P4, linestring 2 is P4->P3. I actually expect linestring 2 is also along P3->P4 direction. Is this how it is supposed to be? Any workaround to solve this problem? Thanks.

Presentation1.png

I don't know what happens in this case exactly because I don't know the data but I would rather assume that Boost.Geometry doesn't care about the order of linestring points (both directions represent the same geometry). The simplest solution would be to check the direction of the output and if needed reverse the linestrings manually or with bg::reverse().

Adam