1

I'm new to Open Street Map and PostGIS, and am trying to figure out how to find all of the ways that intersect a linestring (i.e. all of the streets that intersect a route). Is there a way to do this that doesn't involve calling ST_Intersects on every row of the table?

Marc Regan
  • 13
  • 2

1 Answers1

2

What you are looking for is only checking for intersecting within a bounding box. See: Selecting by bounding box with PostGIS

mrg
  • 1,565
  • 3
  • 17
  • 27
  • 1
    Just to be clear: you're not saying that ST_Intersects and intersection with the BB are the same thing; you're simply suggesting making a preliminary selection based on intersection with the BB and following that up with the ST_Intersects tests, right? – whuber Jan 01 '12 at 14:46
  • Yes, sorry it was newyear night and i drank a lot of champagne. I could have been a little bit more elaborate. – mrg Jan 01 '12 at 15:26
  • ST_Intersects makes a bbox (if possible index-based) first selection before doing the "real" computation. – Nicklas Avén Jan 02 '12 at 20:59
  • Thanks, I ended up getting all of the lines that intersect the linestring's bounding box and then used ST_DWithin to find the intersections. – Marc Regan Jan 12 '12 at 17:34
  • I find it a bit weird to use ST_DWithin for your needs. Do you check on distance = 0? – mrg Jan 12 '12 at 19:53