[postgis-users] Strange behaviour of = operator

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Tue Feb 7 08:23:40 PST 2006


> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-
> bounces at postgis.refractions.net] On Behalf Of strk at refractions.net
> Sent: 07 February 2006 16:08
> To: 'PostGIS Users Discussion'
> Subject: Re: [postgis-users] Strange behaviour of = operator

(cut)

> I think that FUNCTION 1 of btree opclass wants a comparator,
> returning -1, 0, 1 for less then, equal, greater then.
> Please correct me if I'm wrong.
> 
> --strk;


Hi strk,

Yeah looking closer at the docs you are indeed correct. I guess you could
swap the "return 0" and "return 1" around, but while that would work for
equality, you'd need some other metric for less than/greater than. Would it
useful to test for area in these cases? e.g.


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



Kind regards,

Mark.

------------------------
WebBased Ltd
17 Research Way
Plymouth
PL6 8BT

T: +44 (0)1752 797131
F: +44 (0)1752 791023

http://www.webbased.co.uk   
http://www.infomapper.com
http://www.swtc.co.uk  

This email and any attachments are confidential to the intended recipient
and may also be privileged. If you are not the intended recipient please
delete it from your system and notify the sender. You should not copy it or
use it for any purpose nor disclose or distribute its contents to any other
person.





More information about the postgis-users mailing list