[geos-devel] Find self-intersections

strk strk at keybit.net
Sat Nov 28 13:22:48 EST 2009


What do you really need to do at the end of the day ?
Want a simple ring ? A polygon ?

--strk;

On Fri, Nov 27, 2009 at 05:22:22PM +0100, Frederik Ramm wrote:
> Hi,
> 
>    today I came across the following problem that I tried to solve with 
> GEOS.
> 
> I had 3.000 linestrings which together formed one large ring. However, 
> this ring was not simple; it was 8-shaped. I wanted to find out where 
> the intersection point - or perhaps the intersection line! - was.
> 
> The best I could come up with was:
> 
> for (i=0; i<count; i++)
> {
>    for (j=i+1; j<count; j++)
>    {
>       Geometry *p = linestring[i]->intersection(linestring[j])
>       if (p)
>       {
>          // found something
>       }
>    }
> }
> 
> This is of course rather inefficient! I'd better build a LinearRing from 
> the lot of them and then query for self-intersection. I did find some 
> code that does this when looking at how isSimple() is implemented; 
> however, that code would only find self intersection points, not lines.
> 
> I wonder if there is some generic way to determine a geometry's "self 
> intersection"?
> 
> Bye
> Frederik
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geos-devel

-- 

 Free GIS & Flash consultant/developer      ()  ASCII Ribbon Campaign
 http://foo.keybit.net/~strk/services.html  /\  Keep it simple! 


More information about the geos-devel mailing list