[postgis-devel] Two geometries intersects but intersection is empty

Martin Davis mbdavis at refractions.net
Thu Jun 3 12:15:00 PDT 2010


Thanks.

I was actually a bit puzzled by this, since in JTS the intersects and 
intersection operations use exactly the same code to test whether the 
point lies inside the polygon.  And in fact, when I run this case in 
JTS, it reports that:

intersects = FALSE
intersection = EMPTY

which is consistent.

It seems odd that PostGIS behaves differently.  It would be interesting 
to try this directly in GEOS.  Although does PostGIS perhaps not use 
GEOS for this particular case? 

Also, the code run in JTS is of fairly recent vintage, so it's possible 
that GEOS isn't reflecting the most up-to-date algorithm.

Martin

Pierre Racine wrote:
> SELECT st_intersects(geomA, geomB), astext(st_intersection(geomA, geomB))
> FROM (SELECT
>       st_geomfromtext('POINT(-75.5516150170498 49.2824791927083)',4326) AS geomA,
>       geomfromewkb(decode('0103000020e610000001000000050000001c9f33ce69e352c0718f0e9a27a44840e77546654fe352c067d2ad7b35a448406cd4767448e352c0fc7fd3a900a44840a1fd63dd62e352c0073d34c8f2a348401c9f33ce69e352c0718f0e9a27a44840', 'hex')) AS geomB
> ) foo
>
>
>   
>> -----Original Message-----
>> From: postgis-devel-bounces at postgis.refractions.net [mailto:postgis-devel-
>> bounces at postgis.refractions.net] On Behalf Of Paul Ramsey
>> Sent: 3 juin 2010 14:26
>> To: PostGIS Development Discussion
>> Subject: Re: [postgis-devel] Two geometries intersects but intersection is empty
>>
>> FYI: select encode(asbinary(geom),'hex') from ...
>>
>> P
>>
>> On Thu, Jun 3, 2010 at 2:24 PM, Martin Davis <mbdavis at refractions.net> wrote:
>>     
>>> Pierre, can you provide the second geometry in WKBHex?  I can't read the
>>> string that you provided.
>>>
>>> Pierre Racine wrote:
>>>       
>>>> Here is the case:
>>>>
>>>> SELECT st_intersects(geomA, geomB), astext(st_intersection(geomA, geomB))
>>>> FROM (SELECT
>>>>      st_geomfromtext('POINT(-75.5516150170498 49.2824791927083)',4326) AS
>>>> geomA,
>>>>      geomfromewkb(E'\\001\\003\\000\\000
>>>>
>>>>         
>> \\346\\020\\000\\000\\001\\000\\000\\000\\005\\000\\000\\000\\034\\2373\\316i\\343R\\300q\\217\\016\\2
>> 32\'\\244H@\\347uFeO\\343R\\300g\\322\\255{5\\244H at l\\324vtH\\343R\\300\\374\\177\\323\\251\\000\\244H
>> @\\241\\375c\\335b\\343R\\300\\007=4\\310\\362\\243H@\\034\\2373\\316i\\343R\\300q\\217\\016\\232\'\\2
>> 44H@')
>>     
>>>> AS geomB
>>>> ) foo
>>>>
>>>> Sorry I can't provide it as wkt as the wkt version return the expected
>>>> result (and the wkb version does not (before I read Paul's last FAQ)).
>>>>
>>>> Pierre
>>>>
>>>>
>>>>         
>>>>> -----Original Message-----
>>>>> From: postgis-devel-bounces at postgis.refractions.net
>>>>> [mailto:postgis-devel-
>>>>> bounces at postgis.refractions.net] On Behalf Of Martin Davis
>>>>> Sent: 3 juin 2010 12:15
>>>>> To: PostGIS Development Discussion
>>>>> Subject: Re: [postgis-devel] Two geometries intersects but intersection
>>>>> is empty
>>>>>
>>>>> Can you post the case?
>>>>>
>>>>> This can happen because the intersects predicate test is more accurate
>>>>> than the intersection computation.  (Technically speaking, it's possible
>>>>> to detect that two segments intersect, but be unable to compute an
>>>>> accurate point that represents the intersection).
>>>>>
>>>>> Pierre Racine wrote:
>>>>>
>>>>>           
>>>>>> Hi,
>>>>>>
>>>>>> Is it possible that st_intersects returns true on two geometries but
>>>>>> their st_intersection returns
>>>>>>
>>>>>>             
>>>>> "GEOMETRYCOLLECTION EMPTY"?
>>>>>
>>>>>           
>>>>>> I have a nice case here...
>>>>>>
>>>>>> Pierre
>>>>>>
>>>>>> _______________________________________________
>>>>>> postgis-devel mailing list
>>>>>> postgis-devel at postgis.refractions.net
>>>>>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>>> --
>>>>> Martin Davis
>>>>> Senior Technical Architect
>>>>> Refractions Research, Inc.
>>>>> (250) 383-3022
>>>>>
>>>>> _______________________________________________
>>>>> postgis-devel mailing list
>>>>> postgis-devel at postgis.refractions.net
>>>>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>>>>
>>>>>           
>>>> _______________________________________________
>>>> postgis-devel mailing list
>>>> postgis-devel at postgis.refractions.net
>>>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>>>
>>>>
>>>>         
>>> --
>>> Martin Davis
>>> Senior Technical Architect
>>> Refractions Research, Inc.
>>> (250) 383-3022
>>>
>>> _______________________________________________
>>> postgis-devel mailing list
>>> postgis-devel at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>>
>>>       
>> _______________________________________________
>> postgis-devel mailing list
>> postgis-devel at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>     
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>
>   

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022




More information about the postgis-devel mailing list