[postgis-users] Strange behaviour of = operator

Steffen Macke sdteffen at gmail.com
Tue Feb 7 04:38:11 PST 2006


> Your best bet is modifying the btree opclass to use equals() instead.
> Note that use of any of the above operators would then fail if you
> don't have GEOS or JTS support compiled in.

I've tried the following:

create or replace function btree_equals(geometry, geometry) returns integer as
$$
  begin
  if equals($1,$2) then
    return 1;
  else
    return 0;
  end if;
end;
$$
language plpgsql;

DROP OPERATOR CLASS btree_geometry_ops USING btree;
CREATE OPERATOR CLASS btree_geometry_ops DEFAULT
   FOR TYPE geometry USING btree AS
   OPERATOR 1  <,
   OPERATOR 2  <=,
   OPERATOR 3  =,
   OPERATOR 4  >=,
   OPERATOR 5  >,
   FUNCTION 1  btree_equals(geometry, geometry);

Now I would like to report the little example that the geometries are unique.
However it doesn't work out. What's wrong?

create table test (id int);
select addgeometrycolumn('test','the_geom',-1,'MULTIPOLYGON',2);
insert into test values (1, GeometryFromText('MULTIPOLYGON(((1 1,1 0,0
0, 1 1)))'));
insert into test values (2, GeometryFromText('MULTIPOLYGON(((1 1, 0
0,0 1,1 1)))'));
select the_geom,count(*) from test group by the_geom;



More information about the postgis-users mailing list