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

Obe, Regina robe.dnd at cityofboston.gov
Mon Sep 29 04:16:27 PDT 2008


Brent,

I was going to bring that up about the floating point error introduced
with transformation.  There are many cases (and to me the more common
cases where this doesn't happen).

1) you bring in a geometry via OGR and it produces a fairly identical
spatial ref with different SRID

2) A point in NAD 83 long lat vs. one in WGS 84 long lat
SELECT ST_Equals(ST_GeomFromText('POINT(1 1)', 4326),
ST_Transform(ST_GeomFromText('POINT(1 1)', 4269),4326))

So to me the fact that I accidentally brought in some of my data as 4326
and some as 4269 and ST_Equals/ST_OrderingEquals returns null or false
is hmm - a bit disturbing.  I would rather it just throw an error just
like all the other relation functions do so I can correct my problem.

The only case in fact this silent failure I can think of is useful is in
UNION.  That's my point.  Lets not forget ST_Equals doesn't even work
with invalid geometries so if you are trying to union invalid geometries
and PostGIS is actually using that function (haven't checked) - tough
luck. To me relationally unioning invalid geometries is just as valid as
relationally unioning geometries with different SRIDs.

It is like when you give a kid a calculator - the kid happily plays with
it for a while and one day discovers that when he types

999999 ^ 999999

he gets 
-- Invalid input for function

What do you tell the child? I'm sorry 999999 ^ 999999 is unknown or
your calculator just can't calculate that high?  To me those are 2
different things and one is the wrong answer and one is the right
answer.


Interestingly - looking at DB 2 help they have an ST_Equals (which does
what ours does + I presume supports comparing different SRIDS) and an
Equal() - which does a binary compare (I suspect they use the Equal() in
there Union though would be nice to know)
http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/co
m.ibm.spatial.doc/spat162.htm

Thanks,
Regina


-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Brent Wood
Sent: Monday, September 29, 2008 3:10 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Re: Comparing Geometries with Different
SRIDs


> > 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

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.




More information about the postgis-users mailing list