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

Chris Hodgson chodgson at refractions.net
Mon Jan 16 10:44:41 PST 2012


Just going to throw my bits into this discussion.
>> I belive the spatial relationship of two empty geometries
>> is well defined as :
>>
>>        i  b  e
>>     i  F  F  F
>>     b  F  F  F
>>     e  F  F  2
> I think you should justify this.  Is it not so that the
> empty set is a member of all sets?  If the interior and
> boundary of the empty set is the empty set, How come you
> get so many F's in your matix?
I believe that matrix is correct. The empty set is not a member of all 
sets; if it were, the intersection between any two sets could never be 
empty. The empty set IS a subset of all sets; but that is not at issue 
here. Personally I don't think it is necessary to define the matrix at all.

The reason why I believe it is necessary to have the empty geometry is 
for "geometric formulas". Consider the following, where A, B, and C are 
arbitrary geometries:

A minus (B intersect C)

If (B intersect C) is empty, and we return NULL, then A minus NULL will 
return NULL, leaving us with no answer. If we allow for (B intersect C) 
to return an EMPTY geometry, then we can proceed with A minus EMPTY and 
return A, which is almost certainly the answer we were looking for. You 
can replace the minus and intersect with whatever operations you like, 
certainly there are other even more interesting cases which suggest that 
EMPTY has a use.

Given that this is a valid reason for having EMPTY geometries, and 
treating them with different semantics than NULLs, we consider what 
semantics we should use for EMPTY == EMPTY, and it seems to me, that if 
you were ever doing an equals test where it was possible to have empty 
geometries on either side, having two empty geometries be equal is the 
only useful meaning. If you really want to attach another meaning is 
possible to do by specifically filtering for EMPTY cases - though the 
same is true either way so this doesn't lend much weight to my argument; 
if anything it should lift some weight from the overall decision.

Overall it seems to me than EMPTY has more similar mechanics to zero 
than to null, and clearly 0 == 0.

Cheers,
Chris



More information about the postgis-devel mailing list