[postgis-users] Precision problem
Paragon Corporation
lr at pcorp.us
Sat Jul 18 12:17:38 PDT 2009
Maxine,
No this is not really a precision problem. The ST_AsText finds it within
because yes it truncates thus making the point full within the polygon.
The fact that ST_Dwithin when given 0 returns true and ST_Within returns
false, is because you misunderstand the subtleties of ST_Within. Most
people do so don't feel bad.
For a geometry to be considered ST_Within, the geometry can not sit wholly
on the boundary of the other. Its an often misunderstood thing. You really
want to use ST_Covers or ST_CoveredBy.
http://postgis.refractions.net/documentation/manual-1.4.0SVN/ST_CoveredBy.ht
ml
Leo
-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Maxime
van Noppen
Sent: Saturday, July 18, 2009 12:50 PM
To: PostGIS Users Discussion
Subject: [postgis-users] Precision problem
Hello,
I face what I think is a precision problem. I have a point and a polygon and
I test whether the point is within the polygon or not. When both geometries
are in WKB, ST_Within returns false whereas when they are in WKT it returns
true.
WKB :
--------------------------------------------------------------------------
# SELECT ST_Within('010100000013898E0BA7E833C1FF843EA52C212C41', '
0103000000010000000400000000000000A09134C10000000088212A4100000000A0E832C100
00000000812A41000000005E0634C1CDCCCCCC79512C4100000000A09134C10000000088212A
41');
st_within
-----------
f
(1 row)
--------------------------------------------------------------------------
WKT :
--------------------------------------------------------------------------
# SELECT ST_Within('POINT(-1304743.04514367 921750.322742611)',
'POLYGON((-1348000 856260,-1239200 868480,-1312350 927932.9,-1348000
856260))'); st_within
-----------
t
(1 row)
--------------------------------------------------------------------------
The point is on the border of the polygon and I found that using DWithin
with 0 as tolerance makes both test work :
WKB :
--------------------------------------------------------------------------
# SELECT ST_DWithin('010100000013898E0BA7E833C1FF843EA52C212C41',
'0103000000010000000400000000000000A09134C10000000088212A4100000000A0E832C10
000000000812A41000000005E0634C1CDCCCCCC79512C4100000000A09134C10000000088212
A41',
0);
st_dwithin
------------
t
(1 row)
--------------------------------------------------------------------------
For now I'll use this solution but I find it quite hacky. Is this a normal
precision-related behaviour ?
Thanks,
--
yabo
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list