calculating intersections on a self-intersecting line

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

calculating intersections on a self-intersecting line

Vishnu
Does boost-geometry have any functions to calculate the intersection points on a self-intersecting linestring? I know I can do this by testing each segment against every other segment, but this may not be the most efficient way. The ultimate goal is to break up a self-intersecting line into a set of rings.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: calculating intersections on a self-intersecting line

joan
Hi,
I'd also need to know in the case of a self-intersection on a polygon on which points the self intersection occurs. And even better on which segment of my polygon !
Joan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: calculating intersections on a self-intersecting line

Barend
Hi Joan,

joan wrote On 6-11-2013 14:22:
> Hi,
> I'd also need to know in the case of a self-intersection on a polygon on
> which points the self intersection occurs. And even better on which segment
> of my polygon !

This can be done by calling the (not yet documented) function self_turns

It returns "turn-info" points, each point has an intersection point,
including the segment-identifier (exactly giving the causing segments of
your polygon).

Best reference is in the unit-test self_intersection_points.cpp where it
is called.

Note that there are some issues left in self-intersection points, for
example a self-tangent point is sometimes reported too (but it should be
excluded). Will be fixed soon.

Regards, Barend



_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: calculating intersections on a self-intersecting line

ankorus
This post has NOT been accepted by the mailing list yet.
Hi Barend,

I have the following issue.
bg states that the polygon is invalid with failure_self_intersections code.
Following your advise I am trying to find those intersections however self_get_turn_points returns empty vector of  turns (see below).

Please, help!

Thx,
ankorus

P.S.           if (validationCode == bg::failure_self_intersections)
                {

                        typedef bg::detail::no_rescale_policy rescale_policy_type;
                        typedef bg::detail::overlay::turn_info
                                <
                                Point2D,
                                typename bg::segment_ratio_type
                                <
                                Point2D, rescale_policy_type
                                >::type
                                > turn_info;

                        std::vector<turn_info> turns;
                        rescale_policy_type rescalePolicy;
                        bg::detail::self_get_turn_points::no_interrupt_policy interruptPolicy;

                        bg::self_turns<
                                bg::detail::overlay::assign_null_policy
                        >(Polygon, rescalePolicy, turns, interruptPolicy);

                        log->info()
                                << "Self turns:";
                        for (const auto& turn : turns)
                        {
                                log->info() << "("
                                        << turn.point.X << ", "
                                        << turn.point.Y << ")";
                        }
                }
Loading...