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

Brent Wood pcreso at pcreso.com
Mon Sep 29 00:09:36 PDT 2008


> > ST_Equals(different srids) should return an error. 
> Its not that its unknown
> > its that we are too lazy to calculate it.  Its quite
> known if we had the energy.

I don't think that is the case.... we don't know & I'm not sure we can ever know given the issue below.

So to add to the debate....

Note the following two SQL's... the first returns t, the second f.

The third suggests that with rounding errors generated during reprojections, supposedly identical geometries with different SRID's will never be equal.  


select equals(geometryfromtext('POINT(1 1)',4326),
  geometryfromtext('POINT(1 1)',4326));

select equals(geometryfromtext('POINT(1 1)',4326),
  transform(transform(geometryfromtext('POINT(1 1)',4326),27200), 4326));

select astext(geometryfromtext('POINT(175 -45)',4326)),
  astext(transform(transform(geometryfromtext('POINT(175  
 -45)',4326),27200), 4326));

     astext     |                  astext
----------------+-------------------------------------------
 POINT(175 -45) | POINT(175.000000000118 -45.0000000001992)


So the result of _ANY_ st_equals() query between gemetries with different SRID's is always unknown, given any reprojection to compare them will introduce such discrepancies. I guess if the authors believe that different SRID comparisons actually comprise erroneous input under these circumstances, that makes sense.   


I'm now pondering the implications of a reprojection generating these changes, though I don't see what we can do about it, short of allowing ST_equals to provide a means of specifying the coordinate precision which is used to determine equality.

Does anyone know how/what other GIS/OGC SFS compliant databases do in this regard?


Cheers,

Brent Wood




More information about the postgis-users mailing list