[postgis-devel] overlaps left
Mark Cave-Ayland
mark.cave-ayland at siriusit.co.uk
Thu Jan 22 01:56:00 PST 2009
Kevin Neufeld wrote:
> The docs said that &> returned true if the bounding boxes overlap OR is
> to the left of ...
>
> That doesn't seem to be the case:
> SELECT tbl1.column1, tbl2.column1,
> tbl1.column2 && tbl2.column2 AS overlaps,
> tbl1.column2 &< tbl2.column2 AS overlapsleft
> FROM
> ( VALUES
> (1, 'LINESTRING( 1 2, 4 6 )'::geometry)) AS tbl1,
> ( VALUES
> (2, 'LINESTRING( 0 0, 3 3 )'::geometry)) AS tbl2;
>
> column1 | column1 | overlaps | overlapsleft
> ---------+---------+----------+--------------
> 1 | 2 | t | f
> (1 row)
Yeah... I found this when I was debugging some of the R-Tree routines
before. The R-Tree semantics for "overlap" are defined differently than
you or I would expect.
Here are a set of examples to try and help explain this: if you imagine
A sliding from the right to the left across B in the X dimension then it
should make sense.
A: -------
B: ------
A &< B == False
A: ------
B: -------
A &< B == False
A: ------
B: ------
A &< B == True
A: ------
B: ------
A &< B == True
If you think of overlap as being "directly on top of" then this may help
too. But feel free to come up with a better definition of course.
HTH,
Mark.
--
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063
More information about the postgis-devel
mailing list