[postgis-users] Lines inside Polys

David Mitchell david.mitchell at telogis.com
Sun Apr 18 16:26:02 PDT 2004


Hi,

I have a whole bunch of lines and each line falls entirely within zero 
or one of a pile of polygons. The line might touch another polygon (for 
instance, if two polygons share an edge and the line goes right to the 
edge of its parent polygon). None of the polygons overlap. What I want 
to find out is which polygon each line falls within. Currently I am 
doing this:

select line_id,poly_id from polygons p,lines l where
l.the_geom && p.the_geom
and within(l.the_geom, p.the_geom);

The problem is that this is quite slow (the polygons are highly detailed 
so the within operation is not great for speed). Is there some way I can 
use the fact that I know each line falls within at most one polygon and 
either falls inside it entirely or not at all (excepting the case where 
its endpoint touches the side of the polygon).

Basically, it takes about 30ms per line at the moment (I have 26 million 
lines so this is a bit of a chore).
-- 
David Mitchell
Software Engineer
Telogis

NOTICE:
This message (including any attachments) contains CONFIDENTIAL
INFORMATION intended for a specific individual and purpose, and
is protected by law.  If you are not the intended recipient,
you should delete this message and are hereby notified that any
disclosure, copying, or distribution of this message, or the
taking of any action based on it, is strictly prohibited.



More information about the postgis-users mailing list