difference between overlap and intersect using geometric types of postgresql

Started by dhoubrechtsabout 23 years ago2 messagesgeneral
Jump to latest
#1dhoubrechts
dhoubrechts@cybernet.be

Can somebody help me. I can't understand the difference between overlap
of polygon and intersect of path.
Here are the results of comparison :
geo=# \d geom
Table "public.geom"
Column | Type | Modifiers
--------+-----------------------+-----------
parc | character varying(10) |
poly | polygon |

geo=# select * from geom;
parc | poly
------+---------------------------------------
A135 | ((0,2),(1,6),(2,7),(5,5),(5,2),(3,1))
A52 | ((4,1),(3,3),(7,4),(8,1))
A221 | ((5,6),(4,8),(7,9),(8,7))
A222 | ((5,7),(4,8),(7,9),(8,7))
(4 rows)

geo=# SELECT a.parc, b.parc, a.poly as polya, b.poly as polyb , (a.poly
@ b.poly) as cont, a.poly && b.poly as over, (a.poly &> b.poly)as
dr,(a.poly &< b.poly)as gh, (a.poly::path ?# b.poly::path) as inters
from geom a, geom b ;
parc | parc | polya |
polyb | cont | over | dr | gh | inters
------+------+---------------------------------------+---------------------------------------+------+------+----+----+--------
A135 | A135 | ((0,2),(1,6),(2,7),(5,5),(5,2),(3,1)) |
((0,2),(1,6),(2,7),(5,5),(5,2),(3,1)) | t | t | t | t | t
A135 | A52 | ((0,2),(1,6),(2,7),(5,5),(5,2),(3,1)) |
((4,1),(3,3),(7,4),(8,1)) | f | t | t | t | t
A135 | A221 | ((0,2),(1,6),(2,7),(5,5),(5,2),(3,1)) |
((5,6),(4,8),(7,9),(8,7)) | f | t | t | t | f
A135 | A222 | ((0,2),(1,6),(2,7),(5,5),(5,2),(3,1)) |
((5,7),(4,8),(7,9),(8,7)) | f | t | t | t | f
A52 | A135 | ((4,1),(3,3),(7,4),(8,1)) |
((0,2),(1,6),(2,7),(5,5),(5,2),(3,1)) | f | t | t | t | t
A52 | A52 | ((4,1),(3,3),(7,4),(8,1)) |
((4,1),(3,3),(7,4),(8,1)) | t | t | t | t | t
A52 | A221 | ((4,1),(3,3),(7,4),(8,1)) |
((5,6),(4,8),(7,9),(8,7)) | f | f | t | t | f
A52 | A222 | ((4,1),(3,3),(7,4),(8,1)) |
((5,7),(4,8),(7,9),(8,7)) | f | f | t | t | f
A221 | A135 | ((5,6),(4,8),(7,9),(8,7)) |
((0,2),(1,6),(2,7),(5,5),(5,2),(3,1)) | f | t | t | t | f
A221 | A52 | ((5,6),(4,8),(7,9),(8,7)) |
((4,1),(3,3),(7,4),(8,1)) | f | f | t | t | f
A221 | A221 | ((5,6),(4,8),(7,9),(8,7)) |
((5,6),(4,8),(7,9),(8,7)) | t | t | t | t | t
A221 | A222 | ((5,6),(4,8),(7,9),(8,7)) |
((5,7),(4,8),(7,9),(8,7)) | f | t | t | t | t
A222 | A135 | ((5,7),(4,8),(7,9),(8,7)) |
((0,2),(1,6),(2,7),(5,5),(5,2),(3,1)) | f | t | t | t | f
A222 | A52 | ((5,7),(4,8),(7,9),(8,7)) |
((4,1),(3,3),(7,4),(8,1)) | f | f | t | t | f
A222 | A221 | ((5,7),(4,8),(7,9),(8,7)) |
((5,6),(4,8),(7,9),(8,7)) | t | t | t | t | t
A222 | A222 | ((5,7),(4,8),(7,9),(8,7)) |
((5,7),(4,8),(7,9),(8,7)) | t | t | t | t | t
(16 rows)

You can see that A135 and A221 for example don't intersect and don't
overlap but the results of postgresql say they overlap :/

Please help me !

Didier

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: dhoubrechts (#1)
Re: difference between overlap and intersect using geometric types of postgresql

dhoubrechts <dhoubrechts@cybernet.be> writes:

Can somebody help me. I can't understand the difference between overlap
of polygon and intersect of path.

A little looking in the code finds:

/*-----------------------------------------------------------------
* Determine if polygon A overlaps polygon B by determining if
* their bounding boxes overlap.
*
* XXX ought to do a more correct check?
*-----------------------------------------------------------------*/
Datum
poly_overlap(PG_FUNCTION_ARGS)

Feel free to submit a better implementation ...

regards, tom lane