[postgis-users] Problem finding intersection of LineString and BOX3D?

Mark Cave-Ayland mark.cave-ayland at webbased.co.uk
Tue Aug 13 05:44:11 PDT 2002


> Mark Cave-Ayland wrote:
> > SELECT name FROM linetesttab WHERE geom && setSRID('BOX3D(247531.5250251
> > 52556.353020652,247567.13124875 52591.959244305)'::BOX3D,
> > find_srid('','linetesttab','geom') ) AND truly_inside(geom,
> > setSRID('BOX3D(247531.5250251 52556.353020652,247567.13124875
> > 52591.959244305)'::BOX3D, find_srid('', 'linetesttab', 'geom')))
>
> Mark,
> You could be correct - the truly_inside() function hasn't been well
> tested.  Its based on the cohen-sutherland line-clip-to-box algorithm,
> and I
> might have missed one of the cases.
>
> I'd recommend using the distance() function which is slower, but tested
> much better (plus its more general).
>
> SELECT name FROM linetesttab WHERE geom && setSRID('BOX3D(247531.5250251
>  52556.353020652,247567.13124875 52591.959244305)'::BOX3D,
>  find_srid('','linetesttab','geom') ) AND distance(geom,
>  setSRID('BOX3D(247531.5250251 52556.353020652,247567.13124875
>  52591.959244305)'::BOX3D, find_srid('', 'linetesttab', 'geom'))) =0
>
> dave

Hi Dave,

Thanks for your reply. I tried your new select statement but it doesn't work
for lines at all :( It would be useful to get the cohen-sutherland algorithm
working as it seems really fast - what's the easiest way to step through the
routine while it tests a linestring?

Cheers,

Mark.







More information about the postgis-users mailing list