[postgis-devel] Should EMPTY be spatially equal to self ?

Havard Tveite havard.tveite at umb.no
Fri Jan 13 15:44:34 PST 2012


On 13/01/12 17:15, Sandro Santilli wrote:
> On Fri, Jan 13, 2012 at 01:23:19PM +0100, Havard Tveite wrote:
>> On 1/13/2012 12:48 PM, Sandro Santilli wrote:
>>> On Fri, Jan 13, 2012 at 11:01:21AM +0100, Havard Tveite wrote:
>>>> 1) ST_Equals can be used as a spatial join predicate.
>>>> 2) An empty geometry has no location.
>>>>
>>>> Therefore, I think that ST_Equals(empty,empty) should
>>>> not return true and not return false, but NULL.
> ...
>> I was only trying to contribute to the discussion / reasoning
>> in order to find the most correct and/or logical solution.
>
> Ok, so why do you think ST_Equals(empty,empty) should not be true ?
> ST_Equals test two geometries for occupying the exactly same space.

This was also discussed a couple of years ago (October
2009).  I am going to repeat myself.

Paul then made the wiki
http://trac.osgeo.org/postgis/wiki/DevWikiEmptyGeometry

The first paragraph says something about the semantics of
empty geometries.  I agree with that.  I don't agree with
the second paragraph.

Maybe this is a philosophical question, I don't know.

I think that empty geometries make no sense with spatial
predicates.
That is why I suggest that NULL should be returned when
empty geometries are present in spatial predicates.
However, I know too little about the inner workings of
PostGIS to say if this is the right choice.

I have not been convinced that set theory gives any
sensible answers when it comes to the handling of empty
geometries in spatial predicates.

How would you explain the result of ST_Equals(empty,empty)
according to point set topology?  the 9-intersection
model* says that "equals" has the following matrix (T:
non-empty, F: empty, i: interior, b: boundary, e:
exterior):

    i  b  e
i  T  F  F
b  F  T  F
e  F  F  T

I suppose that empty geometries have an empty interior and
an empty boundary.  Then their exterior would be the
universal set.  In that case (and if the empty set is a
member of all sets, also for point set topology), I would
think that the matrix should be all T's, and that is not
the matrix of ST_Equals.

So I don't think it makes sense to return anything else than
NULL for ST_Equals on empty geometries.

In a practical situation, I would not like a spatial join
with ST_Equals as the join predicate to get matches when one
or both of the geometries are empty, since their spatial
relationship cannot be determined (in my opinion).

I guess there are other arguments for returning true or
false for spatial predicates when empty geometries are
involved...  Compatibility with other implementations
being one.  Maybe SQL/MM dictates it?
And we can protect ourselves with ST_IsEmpty.


HÃ¥vard

* 
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.94.2585&rep=rep1&type=pdf



More information about the postgis-devel mailing list