Hi Adrià,

Adrià Navarro López wrote On 9-7-2014 17:45:

I'm currently using the intersection function to get the intersecting points of two linestrings. The relevant code is the following:

BOOST_GEOMETRY_REGISTER_POINT_2D(Vec2f, double, cs::cartesian, x, y);
std::vector<Vec2f> output, lineStringA, lineStringB;
boost::geometry::intersection(lineStringA, lineStringB, output);

What I would also like to know is in which segment on the linestring the intersection happens (the index of the vector). Is there any way to obtain that information? Or should I try to replace bg::intersection for smaller, segment by segment calculations?

There can be zero or more intersections. Yes you can use segment by segment calculations but (depending on your inputs) that might hurt performance.

We don't have yet a user-function for this, but there is an internal function which you can use: get_turns.

That will give you this information, and much more. Each intersection (internally we call it turn because used for polygon/intersections/unions) contains two operations, both with segment identifiers, which is the information you asked for.

There is no doc page but one (rather old) exampe, and a unit test, which might help you.


Regards, Barend