[postgis-users] Problem with Contains in Postgis 1.2.1
Michael Fuhr
mike at fuhr.org
Sat May 26 20:56:15 PDT 2007
On Tue, May 15, 2007 at 04:45:34AM -0600, Michael Fuhr wrote:
> 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.
[...]
> 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)
Here's an excerpt of this query's output with PGIS_DEBUG_CALLS and
PGIS_DEBUG defined:
NOTICE: point_in_polygon called.
NOTICE: point_in_ring called.
NOTICE: side result: -200.000000
NOTICE: side result: -100.000000
NOTICE: side result: -0.000000
NOTICE: point on ring boundary between points 2, 3
NOTICE: point_in_polygon: outside exterior ring.
The problem seems to be that the point (10 10) is incorrectly
considered to be on a ring boundary because it's neither left nor
right of the segment (10 20,10 30). Isn't the following exit
condition in point_in_ring() premature?
/* a point on the boundary of a ring is not contained. */
if(fabs(side) < 1e-12)
{
#ifdef PGIS_DEBUG
lwnotice("point on ring boundary between points %d, %d", i, i+1);
#endif
return 0;
}
--
Michael Fuhr
More information about the postgis-users
mailing list