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

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


Charlie et. al,

I say we just have the union do a binary compare if that is even
possible, but I suspect it is not without a lot of fuss.

It appears that this whole discussion about ST_Equals in the context of
UNION is moot, so sorry for leading everyone astray.  UNION is a kinda
dangerous thing to use as far as POSTGIS Geometries are concerned since
it does an SRID check and then just a bounding box check (although I did
have a sneaking suspicion of that).  Example below


SELECT ST_ASEWKT(the_geom)
FROM (
SELECT ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)', 4269) As the_geom
UNION
SELECT ST_GeomFromText('LINESTRING(0 0, 10 10)',4269) As the_geom
UNION
SELECT ST_GeomFromText('LINESTRING(0 0, 1 2, 10 10 )',4269) As the_geom
) foo;

Yields just one geometry.  
SRID=4269;LINESTRING(0 0,5 5,10 10)


because

SELECT ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)', 4269) =
ST_GeomFromText('LINESTRING(0 0, 1 2, 10 10 )',4269) 

returns true

-----------------------

If you look at LINESTRING(0 0, 1 2, 10 10) you will see in no definition
of equals could we ever consider it to be equal except in the case of =
which strangely maps to a bounding box =.  Perhaps there is just no easy
way to fix that without redefining our = operator which probably has
some major ramifications.

I suspect the use of = operator is baked into the UNION of many
relational databases. 

 and the best we can do is say comparing 2 bounding boxes of different
SRID is false.

I haven't checked what the other databases do so I guess we should
follow the majority if there is such a thing.

Hope that doesn't open up too many can of worms,
Regina
-----------------------------------------
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