[postgis-users] Problems with ST_Within in an island of amultipolygon

Paragon Corporation lr at pcorp.us
Fri Mar 25 10:56:22 PDT 2011


Interesting -- I can confirm too.  When I do a ST_Dwithin check things
behave right.  

select gid, ST_NPoints(the_geom),
ST_Distance(the_geom,ST_GeomFromText('POINT (-115.04252 36.05137)',  -1)) As
dist , 
ST_DWithin(ST_GeomFromText('POINT (-115.04252 36.05137)',  -1),
the_geom,0.0000001) from foo_reload

 gid | st_npoints |        dist         | st_dwithin
-----+------------+---------------------+------------
   1 |        111 |   0.149589748004329 | f
   2 |        342 | 0.00350800000001072 | f
   3 |       2916 |                   0 | t

I'm guessing it's something amiss with the prepared geometry logic that its
somehow using the hash key from the previous geometry.

Paul any thoughts?







 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Larry
Reeder
Sent: Friday, March 25, 2011 12:41 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Problems with ST_Within in an island of
amultipolygon

FYI, I verified I can reproduce this behavior in PostGIS 1.5.2:

#  SELECT postgis_full_version();
                                         postgis_full_version
----------------------------------------------------------------------------
---------------------------
 POSTGIS="1.5.2" GEOS="3.2.0-CAPI-1.6.0" PROJ="Rel. 4.7.1, 23 September
2009" LIBXML="2.7.7" USE_STATS


On Fri, Mar 25, 2011 at 10:11 AM, Larry Reeder <lnreeder at gmail.com> wrote:
> Thanks for the response, Sandro.    I've posted a test case on Dropbox 
> at http://dl.dropbox.com/u/14591732/foo_reload.sql.   This SQL script 
> will create a table called "foo_reload" with three features.   Here's 
> my sample session:
>
> #  \i /tmp/foo_reload.sql
> [load statements removed]
>
> #  select gid, ST_IsValid(the_geom) from foo_reload;
>  gid | st_isvalid
> -----+------------
>   1 | t
>   2 | t
>   3 | t
> (3 rows)
>
> So, all 3 features are valid.   Good.
>
> #  select ST_Within(ST_GeomFromText('POINT (-115.04252 36.05137)', 
> -1), the_geom) from foo_reload where gid = 3;
>  st_within
> -----------
>  t
> (1 row)
>
> Feature #3 contains my test point.   Good.
>
> #  SELECT gid from foo_reload where ST_Within(ST_GeomFromText('POINT
> (-115.04252 36.05137)', -1), the_geom);
>  gid
> -----
> (0 rows)
>
> No features contain my test point.  What????
>
> # delete from foo_reload where gid = 2; DELETE 1
>
> Deleted feature #2 from my layer.  This is the "water" that surrounds 
> my multipolygon "island".
>
> # SELECT gid from foo_reload where ST_Within(ST_GeomFromText('POINT
> (-115.04252 36.05137)', -1), the_geom);
>  gid
> -----
>   3
> (1 row)
>
> Now PostGIS tells me that feature #3 contains the point.  What??
>
>
> Can anyone else reproduce my problem?
>
>
> Thanks..............              Larry
>
>
>
> On Wed, Mar 23, 2011 at 3:23 PM, Sandro Santilli <strk at keybit.net> wrote:
>> On Tue, Mar 22, 2011 at 07:17:26AM -0600, Larry Reeder wrote:
>>> Anybody have any ideas on this one?    Do you think I should post it 
>>> to the developer list?
>>
>> You might post a testcase, the smallest possible.
>>
>> --strk;
>>
>>  ()   Free GIS & Flash consultant/developer
>>  /\   http://strk.keybit.net/services.html
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>
_______________________________________________
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