[geos-devel] how to know if two linestrings "really" cross each other

Sandro Santilli strk at keybit.net
Wed May 30 03:58:52 PDT 2012


On Wed, May 30, 2012 at 12:40:19PM +0200, Jasmin FORMONT wrote:
> Hi everyone
> 
> I can't find a way to tell if two linestrings "really" cross each other.
> 
> For instance if I have this linestring :
> Line1 : LINESTRING(0 0, 1 1, 2 0)
> 
> How can I differentiate the relation of line 1 with one of the following :
> Line2 : LINESTRING(0 2, 1 1, 2 2)    -> no "real" cross, just a contact point
> Line3 : LINESTRING(0 2, 1 1, 1 0)    -> lines "really" cross each other
> 
> I can't find a good combination of crosses, touches, etc... to differentiate these cases.

I can't think of an easy way to do that.

I'd note that for the "split" case there's no way to walk on all segments
of your first geometry w/out stepping over segments of the second.
You can in the "no real cross" case.

You could then look at the planargraph. Not available trough the C API.
Hard trough the C++ one. I guess you could do it with a nice SQL query
with PostGIS 2.0 topology ;)

--strk;


More information about the geos-devel mailing list