[postgis-users] the_geom = the_geom strange result

Jean David TECHER david.techer at davidgis.fr
Wed Oct 15 05:33:59 PDT 2008


Taken from postgis documentation

http://www.postgis.org/documentation/manual-1.3/ch06.html

ST_Equals(geometry, geometry)

Returns 1 (TRUE) if the given Geometries are "spatially equal". Use  
this for a 'better' answer than '='. equals('LINESTRING(0 0, 10  
10)','LINESTRING(0 0, 5 5, 10 10)') is true.

Actually  the '=' operator is not overloaded for spatial query.

Have a look in lwpostgis.sql

root at olivia:~# grep OPERATOR /usr/local/pgsql/share/lwpostgis.sql
CREATE OPERATOR < (
CREATE OPERATOR <= (
CREATE OPERATOR = (
CREATE OPERATOR >= (
CREATE OPERATOR > (
CREATE OPERATOR CLASS btree_geometry_ops
         OPERATOR        1       < ,
         OPERATOR        2       <= ,
         OPERATOR        3       = ,
         OPERATOR        4       >= ,
         OPERATOR        5       > ,
CREATE OPERATOR << (
CREATE OPERATOR &< (
CREATE OPERATOR <<| (
CREATE OPERATOR &<| (
CREATE OPERATOR && (
CREATE OPERATOR &> (
CREATE OPERATOR >> (
CREATE OPERATOR |&> (
CREATE OPERATOR |>> (
CREATE OPERATOR ~= (
CREATE OPERATOR @ (
CREATE OPERATOR ~ (

--david;




Quoting Picavet Vincent <Vincent.Picavet at mediapost.fr>:

> Hi,
> Considering two similar geometries, but different, an equality test with
> the '=' operator returns true, whereas st_equals returns false.
> In this case, st_equals behaviour seems right, but I would expect the
> equality test with = to return false as well, since the geometries are
> actually different.
> Does someone have an explanation to this result ? Some kind of float
> precision related issue ?
>
> select st_geometryfromtext(
> 'LINESTRING(94525.0864578169 2403749.07413185,94521.0361656005
> 2403752.12944388,94519.5539334096
> 2403754.3019993,94517.5683187493 2403757.1772215,94512.295369653
> 2403767.3398906)'
> )
> = st_geometryfromtext(
> 'LINESTRING(94512.295369653 2403767.3398906,94520.7920704004
> 2403760.91556806,94524.3349180666
> 2403757.32391662,94525.0864578169 2403749.07413185)'
> );
>
> select st_equals(st_geometryfromtext('LINESTRING(94525.0864578169
> 2403749.07413185,94521.0361656005 2403752.12944388,94519.5539334096
> 2403754.3019993,94517.5683187493 2403757.1772215,94512.295369653
> 2403767.3398906)')
> ,st_geometryfromtext('LINESTRING(94512.295369653
> 2403767.3398906,94520.7920704004 2403760.91556806,94524.3349180666
> 2403757.32391662,94525.0864578169 2403749.07413185)'));
>
> tested with :
> "POSTGIS="1.3.3" GEOS="3.0.0-CAPI-1.4.1" PROJ="Rel. 4.6.0, 21 Dec 2007"
> USE_STATS (procs from 1.3.2 need upgrade)"
> "POSTGIS="1.1.6" GEOS="2.2.3-CAPI-1.1.1" PROJ="Rel. 4.5.0, 22 Oct 2006"
> USE_STATS (procs from 1.3.2 need upgrade)"
>
> Thanks for any explanation,
> Vincent
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>



===================
Jean David TECHER
www.davidgis.fr
06 60 46 85 05
04 99 77 16 87
===================




More information about the postgis-users mailing list