<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: [postgis-users] problem "st_equals".</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Kevin,<BR>
<BR>
We should clarify this in the docs. Yes I was thinking it wasn't really a bug and kind of open to interpretation when you give it something invalid. I was actually thinking it should behave more like the SQL constructs<BR>
<BR>
SELECT NULL IS NULL As istrue, NULL = NULL As isunknown<BR>
<BR>
basically an undefined question should return an undefined answer. Not a false, but I suppose that may add unnecessary overhead and potentially break other things.<BR>
<BR>
Regarding the ST_AsBinary(geom1) = ST_AsBinary(geom2) -- I beg to differ -- although geom1 = geom2 probably does do a bounding box check. I think the ST_AsBinary would force a bit by bit compare I think (actually I have a feeling that is what ST_OrderingEquals really does though haven't looked at the code for that).<BR>
<BR>
Look at this example<BR>
<BR>
SELECT ST_AsBinary(ST_Collect('POINT(1 1)', 'POINT(2 1)')) = ST_AsBinary(ST_Collect('POINT(2 1)', 'POINT(1 1)')) As binaryequal,<BR>
ST_Collect('POINT(1 1)', 'POINT(2 1)') = ST_Collect('POINT(2 1)', 'POINT(1 1)');<BR>
<BR>
<BR>
Thanks,<BR>
Regina<BR>
<BR>
-----Original Message-----<BR>
From: postgis-users-bounces@postgis.refractions.net on behalf of Kevin Neufeld<BR>
Sent: Thu 9/4/2008 11:34 AM<BR>
To: PostGIS Users Discussion<BR>
Subject: Re: [postgis-users] problem "st_equals".<BR>
<BR>
Thanx Regina for looking into this.<BR>
<BR>
I'm not sure I entirely agree that this should be considered a bug. So<BR>
far, the responsibility of ensuring the simplicity and validity of<BR>
geometries have fallen on the user before they invoke any other PostGIS<BR>
functions. If the onus were not on the user, we'd have to precursor<BR>
most PostGIS methods with an internal isvalid check - significantly<BR>
decreasing performance.<BR>
<BR>
Rather, I think we should clarify the input reconditions for every<BR>
method in our new documentation. Ie. ST_Equals, ST_Union, ST_Area, etc.<BR>
should all say that they require valid geometries on input and<BR>
ST_OrderingEquals would state otherwise.<BR>
<BR>
On a side note, your "binaryequal" test is just comparing the bounding<BR>
boxes of the two geometires via the = operator (geometry A = geometry<BR>
B). I'd be curious though, how the ~= operator handles this case. It's<BR>
supposed to return true on vertex-by-vertex equality ... so validity<BR>
shouldn't matter.<BR>
<BR>
Cheers,<BR>
Kevin<BR>
<BR>
<BR>
Paragon Corporation wrote:<BR>
> Rolf,<BR>
><BR>
> I took a look at this. I think the problem is because your polygons are<BR>
> invalid. Since ST_Equals doesn't care about polygon orientation and so<BR>
> forth - it has to validate that geometries are equa by other means. I<BR>
> suspect since your geometries are invalid the false really means -- it had<BR>
> no clue because it couldn't run the equality tests on them. ST_Equals in my<BR>
> opinion should throw an error or give some sort of notice, so I would<BR>
> consider this a bug.<BR>
><BR>
> If I look at the notices section in say PgAdmin when I do an ST_IsValid<BR>
> check, I get this message<BR>
><BR>
> When I do an ST_IsValid check, I get the below<BR>
> NOTICE: Self-intersection at or near point 2.58392e+006 5.68493e+006<BR>
> NOTICE: Self-intersection at or near point 2.58392e+006 5.68493e+006<BR>
> NOTICE: Self-intersection at or near point 2.58392e+006 5.68493e+006<BR>
> NOTICE: Self-intersection at or near point 2.58392e+006 5.68493e+006<BR>
><BR>
> Now however ST_OrderingEquals returns true, because it is more of a check of<BR>
> binary equality (well sort of). Check this query out to see what I mean<BR>
><BR>
> SELECT ST_AsBinary(a.the_geom) = ST_AsBinary(b.the_geom) As binaryequal,<BR>
> ST_Equals(a.the_geom, b.the_geom) As spatially_equal,<BR>
> ST_OrderingEquals(a.the_geom, b.the_geom) As<BR>
> orderequal,ST_IsValid(a.the_geom) As a_isvalid, ST_IsValid(b.the_geom) as<BR>
> b_isvalid<BR>
> from equal_test a, equal_test b where a.name <> b.name and not<BR>
> st_equals(a.the_geom,b.the_geom)<BR>
><BR>
> -- On my install this returns<BR>
> binaryequal | spatially_equal | orderequal | a_isvalid | b_isvalid<BR>
> ------------+-----------------+------------+-----------+-----------<BR>
> t | f | t | f | f<BR>
> t | f | t | f | f<BR>
><BR>
><BR>
> Hope that helps,<BR>
> Regina<BR>
><BR>
> -----Original Message-----<BR>
> From: postgis-users-bounces@postgis.refractions.net<BR>
> [<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>] On Behalf Of Stüwe<BR>
> Rolf<BR>
> Sent: Thursday, September 04, 2008 3:31 AM<BR>
> To: PostGIS Users Discussion<BR>
> Subject: AW: [postgis-users] problem "st_equals".<BR>
><BR>
> Hi Kevin,<BR>
><BR>
> i send an example and hope yuo can reconstuct it.<BR>
><BR>
> create table equal_test (name char(6)); SELECT<BR>
> AddGeometryColumn('','equal_test','the_geom','31466','MULTIPOLYGON',2);<BR>
> <BR>
> COPY equal_test (name, the_geom) FROM stdin;<BR>
> geom01<BR>
> 0106000020EA7A0000010000000103000000010000002B000000F18C9EFFB9B64341E314A022<BR>
> B1AF55<BR>
> 41AF0335FAB9B64341700D0F26B1AF5541C9C9D4F4B9B643418AAC8129B1AF5541B8B07CEFB9<BR>
> B64341F072F72C<BR>
> B1AF5541E2BF2CEAB9B64341D75B7030B1AF5541A3FEE4E4B9B643417162EC33B1AF55414974<BR>
> A5DFB9B64341EB<BR>
> 816B37B1AF55411A286EDAB9B643416DB5ED3AB1AF55414D213FD5B9B643411BF8723EB1AF55<BR>
> 41106718D0B9B6<BR>
> 43411645FB41B1AF55418500FACAB9B643417A978645B1AF5541C3F4E3C5B9B643415EEA1449<BR>
> B1AF5541D34AD6<BR>
> C0B9B64341D738A64CB1AF5541B609D1BBB9B64341F27D3A50B1AF55415F38D4B6B9B64341BD<BR>
> B4D153B1AF5541<BR>
> B5DDDFB1B9B643413ED86B57B1AF55419500F4ACB9B6434178E3085BB1AF5541CFA710A8B9B6<BR>
> 43416BD1A85EB1<BR>
> AF554127DA35A3B9B64341119D4B62B1AF5541579E639EB9B643416341F165B1AF55419A9999<BR>
> 99B9B643419A99<BR>
> 9969B1AF554166666686BAB6434152B81EB5B0AF554159EFACC7BAB64341CED465B6B0AF5541<BR>
> C245E5BCBAB643<BR>
> 41E1CD6EBBB0AF5541F73B31B2BAB64341973F82C0B0AF55419A6391A7BAB643415E41A0C5B0<BR>
> AF55415DE6059D<BR>
> BAB6434120BFC8CAB0AF5541A2ED8E92BAB643419FA4FBCFB0AF55417BA22C88BAB6434174DD<BR>
> 38D5B0AF5541A8<BR>
> 2DDF7DBAB643410F5580DAB0AF554197B7A673BAB64341B8F6D1DFB0AF554166688369BAB643<BR>
> 4191AD2DE5B0AF<BR>
> 5541DC67755FBAB64341916493EAB0AF554170DD7C55BAB643418A0603F0B0AF554143F0994B<BR>
> BAB64341277E7C<BR>
> F5B0AF554122C7CC41BAB64341ECB5FFFAB0AF554183881538BAB6434136988C00B1AF554188<BR>
> 5A742EBAB64341<BR>
> 3D0F2306B1AF5541FB62E924BAB643411405C30BB1AF55414FC7741BBAB64341A7636C11B1AF<BR>
> 5541A1AC1612BA<BR>
> B64341BE141F17B1AF5541B437CF08BAB64341FD01DB1CB1AF5541F18C9EFFB9B64341E314A0<BR>
> 22B1AF5541<BR>
> geom02<BR>
> 0106000020EA7A0000010000000103000000010000002B000000F18C9EFFB9B64341E314A022<BR>
> B1AF55<BR>
> 41AF0335FAB9B64341700D0F26B1AF5541C9C9D4F4B9B643418AAC8129B1AF5541B8B07CEFB9<BR>
> B64341F072F72C<BR>
> B1AF5541E2BF2CEAB9B64341D75B7030B1AF5541A3FEE4E4B9B643417162EC33B1AF55414974<BR>
> A5DFB9B64341EB<BR>
> 816B37B1AF55411A286EDAB9B643416DB5ED3AB1AF55414D213FD5B9B643411BF8723EB1AF55<BR>
> 41106718D0B9B6<BR>
> 43411645FB41B1AF55418500FACAB9B643417A978645B1AF5541C3F4E3C5B9B643415EEA1449<BR>
> B1AF5541D34AD6<BR>
> C0B9B64341D738A64CB1AF5541B609D1BBB9B64341F27D3A50B1AF55415F38D4B6B9B64341BD<BR>
> B4D153B1AF5541<BR>
> B5DDDFB1B9B643413ED86B57B1AF55419500F4ACB9B6434178E3085BB1AF5541CFA710A8B9B6<BR>
> 43416BD1A85EB1<BR>
> AF554127DA35A3B9B64341119D4B62B1AF5541579E639EB9B643416341F165B1AF55419A9999<BR>
> 99B9B643419A99<BR>
> 9969B1AF554166666686BAB6434152B81EB5B0AF554159EFACC7BAB64341CED465B6B0AF5541<BR>
> C245E5BCBAB643<BR>
> 41E1CD6EBBB0AF5541F73B31B2BAB64341973F82C0B0AF55419A6391A7BAB643415E41A0C5B0<BR>
> AF55415DE6059D<BR>
> BAB6434120BFC8CAB0AF5541A2ED8E92BAB643419FA4FBCFB0AF55417BA22C88BAB6434174DD<BR>
> 38D5B0AF5541A8<BR>
> 2DDF7DBAB643410F5580DAB0AF554197B7A673BAB64341B8F6D1DFB0AF554166688369BAB643<BR>
> 4191AD2DE5B0AF<BR>
> 5541DC67755FBAB64341916493EAB0AF554170DD7C55BAB643418A0603F0B0AF554143F0994B<BR>
> BAB64341277E7C<BR>
> F5B0AF554122C7CC41BAB64341ECB5FFFAB0AF554183881538BAB6434136988C00B1AF554188<BR>
> 5A742EBAB64341<BR>
> 3D0F2306B1AF5541FB62E924BAB643411405C30BB1AF55414FC7741BBAB64341A7636C11B1AF<BR>
> 5541A1AC1612BA<BR>
> B64341BE141F17B1AF5541B437CF08BAB64341FD01DB1CB1AF5541F18C9EFFB9B64341E314A0<BR>
> 22B1AF5541<BR>
> \.<BR>
> <BR>
> select a.name,b.name from equal_test a, equal_test b where a.name <> b.name<BR>
> and not st_equ als(a.the_geom,b.the_geom);<BR>
> <BR>
> output (though the geometries are the same):<BR>
> <BR>
> name | name<BR>
> --------+--------<BR>
> geom01 | geom02<BR>
> geom02 | geom01<BR>
> (2 rows)<BR>
><BR>
><BR>
><BR>
><BR>
><BR>
> Bye Rolf<BR>
><BR>
> -----Ursprüngliche Nachricht-----<BR>
> Von: postgis-users-bounces@postgis.refractions.net<BR>
> [<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>] Im Auftrag von Kevin<BR>
> Neufeld<BR>
> Gesendet: Dienstag, 2. September 2008 18:01<BR>
> An: PostGIS Users Discussion<BR>
> Betreff: Re: [postgis-users] problem "st_equals".<BR>
><BR>
> My understanding is that ST_Equals shouldn't care if the geometries are not<BR>
> simple. If the two geometries are spatially equivalent, this function<BR>
> should return true.<BR>
><BR>
> If the geometry is not too large, can you post it here?<BR>
><BR>
> Cheers,<BR>
> Kevin<BR>
><BR>
> Stüwe Rolf wrote:<BR>
>> Hallo all,<BR>
>> <BR>
>> we have a problem concerning the function "st_equals" under PostgreSQL<BR>
>> 8.2.3 , PostGIS1.2.1.<BR>
>> <BR>
>> We duplicated a geometry having a Self-intersection. The two<BR>
>> geometries are not st_equals(the original geometry, the duplicated<BR>
> geometry). Why?????<BR>
>> Many thanks for help us!<BR>
>><BR>
>><BR>
>> ----------------------------------------------------------------------<BR>
>> --<BR>
>><BR>
>> _______________________________________________<BR>
>> postgis-users mailing list<BR>
>> postgis-users@postgis.refractions.net<BR>
>> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
><BR>
><BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
_______________________________________________<BR>
postgis-users mailing list<BR>
postgis-users@postgis.refractions.net<BR>
<A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
<BR>
<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>
<HTML><BODY><P><hr size=1></P>
<P><STRONG>
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.
</STRONG></P></BODY></HTML>
<P><hr size=1></P>
<P><STRONG><font size="2" color="339900"> Help make the earth a greener place. If at all possible resist printing this email and join us in saving paper. </p> <p> </font></STRONG></P>