Quick pointer required re indexing geometry

Started by Paul Matthewsover 16 years ago3 messages
#1Paul Matthews
plm@netspace.net.au

Witting a box@>point function easy. Having a spot of trouble trying to
figure out where and how to graft this into the GiST stuff. Could
someone please point me in the general direction?

Thanks.

#2Dimitri Fontaine
dfontaine@hi-media.com
In reply to: Paul Matthews (#1)
Re: Quick pointer required re indexing geometry

Hi,

Paul Matthews <plm@netspace.net.au> writes:

Witting a box@>point function easy. Having a spot of trouble trying to
figure out where and how to graft this into the GiST stuff. Could
someone please point me in the general direction?

You want index support for it, I suppose?

Without index support (but needed anyway), you implement your code in a
C module then make it visible from SQL. I'm not sure you're asking help
for the C part so don't expand, please ask more if needed:

CREATE OR REPLACE FUNCTION box_contains_point(box, point)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;

CREATE OPERATOR @> (
LEFTARG = box,
RIGHTARG = point,
PROCEDURE = box_contains_point,
COMMUTATOR = '<@',
RESTRICT = contsel,
JOIN = contjoinsel
);
COMMENT ON OPERATOR @>(box, point) IS 'box contains point?';

Now for adding support for index lookups, you have to see documentation
about OPERATOR CLASS and OPERATOR FAMILY. I guess you need to make a
family out of point and box if none already exists, add the @> operator
there and point to your function.

I'm unclear if you need to add it to an OPERATOR CLASS too and which, so
I won't risk into writing the commands. Cross datatype indexing support,
as far as I've understood, is tied together with operator families.

Hope this helps, regards,
--
dim

#3Paul Matthews
plm@netspace.net.au
In reply to: Dimitri Fontaine (#2)
Re: Quick pointer required re indexing geometry

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Dimitri Fontaine wrote:<br>
<blockquote cite="mid:87vdkuh2vk.fsf@hi-media-techno.com" type="cite">
<pre wrap="">Paul Matthews <a class="moz-txt-link-rfc2396E" href="mailto:plm@netspace.net.au">&lt;plm@netspace.net.au&gt;</a> writes:
</pre>
<blockquote type="cite">
<pre wrap="">Witting a box@&gt;point function easy. Having a spot of trouble trying to
figure out where and how to graft this into the GiST stuff. Could
someone please point me in the general direction?
</pre>
</blockquote>
<pre wrap=""><!---->
You want index support for it, I suppose?
</pre>
</blockquote>
Yes<br>
<blockquote cite="mid:87vdkuh2vk.fsf@hi-media-techno.com" type="cite">
<pre wrap="">Without index support (but needed anyway), you implement your code in a
C module then make it visible from SQL. ...cut...
COMMENT ON OPERATOR @&gt;(box, point) IS 'box contains point?';
</pre>
</blockquote>
All done but the comment part :-) <br>
<blockquote cite="mid:87vdkuh2vk.fsf@hi-media-techno.com" type="cite">
<pre wrap="">
Now for adding support for index lookups, you have to see documentation
about OPERATOR CLASS and OPERATOR FAMILY.
Hope this helps, regards,
</pre>
</blockquote>
Thanks overlooked CLASS and FAMILY in my hurry. Hopefully that is where
the problem is.<br>
<br>
What I am hoping to do is provide a "real" patch to make box@&gt;point
available for all. But we can get to that later. A lot of code in
pgsql, but not much in the way of comments.<br>
</body>
</html>