[postgis-users] Overlapping linestrings

Adam McManus adam.mcmanus at gmail.com
Fri Feb 3 12:07:57 PST 2012

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?


Adam McManus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120203/c92e18f4/attachment.html>

More information about the postgis-users mailing list