[postgis-users] Overlapping linestrings

Birgit Laggner birgit.laggner at vti.bund.de
Mon Feb 6 02:39:13 PST 2012


Hi Adam,

why do you calculate a buffer for the first linestring? If you only want 
to know if there is any overlapping part of the two linestrings, I would 
expect that ST_Intersects(r1.geo_data,s1.geo_data) would do the job 
best. You could combine it with 
ST_Geometrytype(ST_Intersection(r1.geo_data,s1.geo_data))='ST_LineString' in 
order to to find out if they only cross or really overlap.

Hope that helps,

Birgit.


Am 03.02.2012 21:07, schrieb Adam McManus:
> I'm looking for the fastest way to detect whether a given linestring 
> overlaps another linestring. Here's my current approach.
>
> Given two tables: r1 and s1, both containing a geo_data column of 
> linestring, first narrow the data (taking advantage of gist index) 
> with r1.geo_data && s1.geo_data, then use ST_Contains to see if s1 is 
> overlapping r1, i.e. r1.geo_data && s1.geo_data 
> and ST_Contains(ST_Buffer(r1.geo_data,ST_Length(r1.geo_data)*.002),s1.geo_data)
>
> This approach works, but it's extremely CPU-intensive and slow. Is 
> there a better approach?
>
> Thanks,
>
> --
> Adam McManus
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120206/58d76d6b/attachment.html>


More information about the postgis-users mailing list