[postgis-users] Problem with Contains in Postgis 1.2.1

Michael Fuhr mike at fuhr.org
Tue May 15 03:45:34 PDT 2007


Regarding the Contains() problem discussed in:

http://postgis.refractions.net/pipermail/postgis-users/2007-April/015317.html

I get true (as expected) for the test case in 1.2.2SVN.  However,
the second of the following examples appears to be wrong.  The only
difference between the polygons in each example is in the third and
fourth points.  Relate() returns the same relationship in all three
examples but Contains() incorrectly reports false in Example 2,
where X in the third and fourth points of the polygon matches X in
the point.

Example 1:

select Relate(GeomFromText('POLYGON((0 0,0 20,9 20,9 30,30 30,30 0,0 0))'),
              GeomFromText('POINT(10 10)'));
  relate   
-----------
 0F2FF1FF2
(1 row)

select Contains(GeomFromText('POLYGON((0 0,0 20,9 20,9 30,30 30,30 0,0 0))'),
                GeomFromText('POINT(10 10)'));
 contains 
----------
 t
(1 row)


Example 2:

select Relate(GeomFromText('POLYGON((0 0,0 20,10 20,10 30,30 30,30 0,0 0))'),
              GeomFromText('POINT(10 10)'));
  relate   
-----------
 0F2FF1FF2
(1 row)

select Contains(GeomFromText('POLYGON((0 0,0 20,10 20,10 30,30 30,30 0,0 0))'),
                GeomFromText('POINT(10 10)'));
 contains 
----------
 f
(1 row)


Example 3:

select Relate(GeomFromText('POLYGON((0 0,0 20,11 20,11 30,30 30,30 0,0 0))'),
              GeomFromText('POINT(10 10)'));
  relate   
-----------
 0F2FF1FF2
(1 row)

select Contains(GeomFromText('POLYGON((0 0,0 20,11 20,11 30,30 30,30 0,0 0))'),
                GeomFromText('POINT(10 10)'));
 contains 
----------
 t
(1 row)

-- 
Michael Fuhr



More information about the postgis-users mailing list