Fw: Re: [postgis-users] Re: Comparing Geometries with Different SRIDs

Brent Wood pcreso at pcreso.com
Sun Sep 28 12:11:57 PDT 2008


My 02c.... 

A slightly different perspective...

There are three possible results of ST_equals(), true, false & unknown (null).

Logically, ST_equals should return the same value for
geometries of different SRID's as it does for a null
geometry, or a -1 SRID, which in this context I believe is
equivalent to an unknown geometry. (ie, we don't actually know where the geometries lie relative to each other, just as we don't for a null) 
 
ST_equals(null,null);
returns null
 
ST_equals(geometryfromtext('POINT(0 0)',null);
returns null

I suggest that ST_equals() on mixed SRID geometries, should
return a null, just like a null geometry does.
 
I think this is the most consistent approach when the
result is actually unknown, and therefore a result of either true or
false is inappropriate. 

WHile this apparently makes a trinary logic out of a binary boolean function, my contention (really shouldn't use "point" here :-) is that st_equals() is already a trinary function in similar cases. 
 
The user can convert such nulls to true/false by ensuring both SRID's are the same, in which case either T or F will be returned. 


Cheers,
 
   Brent Wood
 
 
--- On Mon, 9/29/08, Charlie Savage
> <cfis at savagexi.com> wrote:
> 
> > From: Charlie Savage <cfis at savagexi.com>
> > Subject: Re: [postgis-users] Re: Comparing Geometries
> with Different SRIDs
> > To: "PostGIS Users Discussion"
> <postgis-users at postgis.refractions.net>
> > Date: Monday, September 29, 2008, 7:10 AM
> > Reid Priedhorsky wrote:
> > > Charlie Savage wrote:
> > >>> The 2 point could be spatially equal
> given
> > different SRIDS and 
> > >>> coordinates if they were projected to a
> common
> > SRID. So should
> > >>> geometry operators silently Call
> st_transform
> > to make the righthand
> > >>> match the lefthand before comparing? This
> > would be quite the
> > >>> expensive operation.
> > >>
> > >> No. You can't automatically transform
> between
> > different SRID values 
> > >> Think of the case of one geometry with an
> SRID
> > value of 4326 and one
> > >>  with an SRID value of -1 (no coordinate
> system).
> > > 
> > > Exactly.
> > > 
> > >> So different SRID values, then the geometries
> are
> > not equal.
> > > 
> > > No -- as Stanley said, the geometries could be in
> fact
> > equal, but 
> > > expressed in different SRS. So if ST_Equals()
> returned
> > False, it would 
> > > be wrong.
> > 
> > Maybe.  But returning "Operation permitted"
> is
> > even worse because it 
> > means you can't do natural things like this
> (without
> > extra annoying SRID 
> > checking code) in plpgsql:
> > 
> > IF (geom1 == geom2) ... END IF;
> > 
> > Or the example with the union earlier posted
> > 
> > 
> > >> It is up to the user to transform geometries
> to
> > the same SRID before
> > >> calling ST_EQUALS.
> > > 
> > > Exactly. ;)
> > 
> > So, I still vote that st_equals will not blow up when
> > comparing two 
> > geometries with different SRID values, it just will
> return
> > false.
> > 
> > Charlie
> > _______________________________________________
> > 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