[postgis-users] Problem finding intersection of LineString and BOX3D?
Mark Cave-Ayland
mark.cave-ayland at webbased.co.uk
Mon Aug 12 08:27:28 PDT 2002
Hi everyone,
I'm having a problem with PostGIS 0.6.2 and Postgres 7.1.3 and I wonder if
someone could offer some help?
I have a table called 'linetesttab' containing a geometry column named
'geom' which consists of linestrings, and a bounding box defined as a BOX3D
(defined by the user). What I would like to do is determine whether or not
the line passes through the BOX3D but I cannot seem to get it working
correctly! My query is shown below:
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')))
The SELECT statement above only works if one of the points that makes up the
linestring lies within the bounding box. I've looked at the source for the
truly_inside() function and it looks as if it should return the linestring
if any part of it intersects the BOX3D, not just the constituent points.
As a test, the line below has been visually verified to pass through the box
in the above query and yet is not returned by it:
INSERT INTO linetesttab (name, geom) VALUES ('foofoo',
GeometryFromText('LINESTRING(244142.480972302
54546.7797019624,244336.297929395 53728.7211168289,245375.861608349
53794.1658036396,245763.495522536 53074.2742487221,247067.355052072
52485.272067426,248212.637071259 52681.606127858,248688.369602305
52027.1592597512)',-1))
Can anyone see why this is the case????
Many thanks,
Mark.
More information about the postgis-users
mailing list