Thread: RE: [HACKERS] Indexing for geographic objects?

RE: [HACKERS] Indexing for geographic objects?

From
Franck Martin
Date:
It seems that your code is exactly what I want.

I have already created geographical objects which contains MBR(Minimum
Bounding Rectangle) in their structure, so it is a question of rewriting
your code to change the access to the cube structure to the MBR structure
inside my geoobject. (cf http://fmaps.sourceforge.net/) Look in the CVS for
latest. I have been slack lately on the project, but I'm not forgetting it.

Quickly I ran through the code, and I think your cube is strictly speaking a
box, which also a MBR.

However I didn't see the case of intersection, which is the main question
when you want to display object that are visible inside a box.

I suppose your code is under GPL, and you have no problem for me to use it,
providing I put your name and credits somewhere.

Cheers.

Franck Martin
Database Development Officer
SOPAC South Pacific Applied Geoscience Commission
Fiji
E-mail: franck@sopac.org
Web site: http://www.sopac.org/

This e-mail is intended for its recipients only. Do not forward this e-mail
without approval. The views expressed in this e-mail may not be necessarily
the views of SOPAC.

-----Original Message-----
From: selkovjr@mcs.anl.gov [mailto:selkovjr@mcs.anl.gov]
Sent: Saturday, 25 November 2000 8:56
To: Franck Martin
Subject: Re: [HACKERS] Indexing for geographic objects?

It is probably possible to hook up an extension directly with the
R-tree methods available in postgres -- if you stare at the code long
enough and figure how to use the correct strategies. I chose an easier
path years ago and I am still satisfied with the results. Check out
the GiST -- a general access method built on top of R-tree to provide
a user-friendly interface to it and to allow indexing of more abstract
types, for which straight R-tree is not directly applicable.

I have a small set of complete data types, of which a couple
illustrate the use of GiST indexing with the geometrical objects, in:

http://wit.mcs.anl.gov/~selkovjr/pg_extensions/

If you are using a pre-7.0 postrgres, grab the file contrib.tgz,
otherwise take contrib-7.0.tgz. The difference is insignificant, but
the pre-7.0 version will not fit the current schema. Unpack the source
into postgresql-*/contrib and follow instructions in the README
files. The types of interest for you will be seg and cube. You will
find pointers to the original sources and docs in the CREDITS section
of the README file. I also have a version of the original example code
in pggist-patched.tgz, but I did not check if it works with current
postgres. It should not be difficult to fix it if it doesn't -- the
recent development in the optimizer area made certain things
unnecessary.

You might want to check out a working example of the segment data type at:

http://wit.mcs.anl.gov/EMP/indexing.html

(search the page for 'KM')

I will be glad to help, but I would also recommend to send more
sophisticated questions to Joe Hellerstein, the leader of the original
postgres team that developed GiST. He was very helpful whenever I
turned to him during the early stages of my data type project.

--Gene

Re: [HACKERS] Indexing for geographic objects?

From
Hannu Krosing
Date:
Franck Martin wrote:
>
> It seems that your code is exactly what I want.
>
> I have already created geographical objects which contains MBR(Minimum
> Bounding Rectangle) in their structure, so it is a question of rewriting
> your code to change the access to the cube structure to the MBR structure
> inside my geoobject. (cf http://fmaps.sourceforge.net/) Look in the CVS for
> latest. I have been slack lately on the project, but I'm not forgetting it.
>
> Quickly I ran through the code, and I think your cube is strictly speaking a
> box, which also a MBR.
>
> However I didn't see the case of intersection, which is the main question
> when you want to display object that are visible inside a box.
>
> I suppose your code is under GPL, and you have no problem for me to use it,
> providing I put your name and credits somewhere.

It would be much better if it were under the standard PostgreSQL license
and
if it is included in the standard distribution.

As Tom said, working Gist would be a great feature.

Now if only someone would write the regression tests ;)

BTW, the regression tests for pl/pgsql seem to be somewhat sparse as
well,
missing at least some types of loops, possibly more.

> Franck Martin
> Database Development Officer
> SOPAC South Pacific Applied Geoscience Commission
> Fiji
> E-mail: franck@sopac.org
> Web site: http://www.sopac.org/
>
> This e-mail is intended for its recipients only. Do not forward this e-mail
> without approval. The views expressed in this e-mail may not be necessarily
> the views of SOPAC.
>
> -----Original Message-----
> From: selkovjr@mcs.anl.gov [mailto:selkovjr@mcs.anl.gov]
> Sent: Saturday, 25 November 2000 8:56
> To: Franck Martin
> Subject: Re: [HACKERS] Indexing for geographic objects?
>
> It is probably possible to hook up an extension directly with the
> R-tree methods available in postgres -- if you stare at the code long
> enough and figure how to use the correct strategies. I chose an easier
> path years ago and I am still satisfied with the results. Check out
> the GiST -- a general access method built on top of R-tree to provide
> a user-friendly interface to it and to allow indexing of more abstract
> types, for which straight R-tree is not directly applicable.
>
> I have a small set of complete data types, of which a couple
> illustrate the use of GiST indexing with the geometrical objects, in:
>
> http://wit.mcs.anl.gov/~selkovjr/pg_extensions/
>
> If you are using a pre-7.0 postrgres, grab the file contrib.tgz,
> otherwise take contrib-7.0.tgz. The difference is insignificant, but
> the pre-7.0 version will not fit the current schema. Unpack the source
> into postgresql-*/contrib and follow instructions in the README
> files. The types of interest for you will be seg and cube. You will
> find pointers to the original sources and docs in the CREDITS section
> of the README file. I also have a version of the original example code
> in pggist-patched.tgz, but I did not check if it works with current
> postgres. It should not be difficult to fix it if it doesn't -- the
> recent development in the optimizer area made certain things
> unnecessary.
>
> You might want to check out a working example of the segment data type at:
>
> http://wit.mcs.anl.gov/EMP/indexing.html
>
> (search the page for 'KM')
>
> I will be glad to help, but I would also recommend to send more
> sophisticated questions to Joe Hellerstein, the leader of the original
> postgres team that developed GiST. He was very helpful whenever I
> turned to him during the early stages of my data type project.
>
> --Gene

Re: [HACKERS] Indexing for geographic objects?

From
selkovjr@mcs.anl.gov
Date:
Franck Martin wrote:
> I have already created geographical objects which contains MBR(Minimum
> Bounding Rectangle) in their structure, so it is a question of rewriting
> your code to change the access to the cube structure to the MBR structure
> inside my geoobject. (cf http://fmaps.sourceforge.net/) Look in the CVS for
> latest. I have been slack lately on the project, but I'm not forgetting it.

I see where you are aiming. I definitely want to be around when it
starts working.

> Quickly I ran through the code, and I think your cube is strictly speaking a
> box, which also a MBR.

Yes, cube is definitely a misnomer -- it suggests things are
equihedral, which they aren't. I am still looking for a short name or
an acronym that would indicate it is a box with an arbitrary number of
dimensions. With your application, you will surely benefit from a
smaller and faster code geared specifically for 3D.

> However I didn't see the case of intersection, which is the main question
> when you want to display object that are visible inside a box.

The procedure is there, it is called cube_inter, but there is no
operator for it.

> I suppose your code is under GPL, and you have no problem for me to use it,
> providing I put your name and credits somewhere.

No problem at all -- I will be honored if you use it. Was I careless
enough not to include a license? It's not exactly a GPL -- it's
completely unrestricted. I should have said that somewhere.

Good luck,

--Gene

RE: [HACKERS] Indexing for geographic objects?

From
"Edmar Wiggers"
Date:
It seems that R-trees become inefficient when the number of dimensions
increase. Has anyone thoght of a transparent way to use Peano codes (hhcode
in Oracle lingo), and use B-tree indexes instead?

Also, I've read that R-trees sometimes suffer a lot when an update overflows
a node in the index.

The only initial problem I see with Peano codes is that the index is made on
real cubes (all dimensions are equal, due to the recursive decomposition of
space). To overcome that, people have talked about using
multiple-entry-indexes. That is, an object is decomposed in a number of
cubes (not too many), which are then indexed.

In this case, there should be a way to make intersection searches be
transparent. Oracle does it using tables and merge-joins. I have thought of
using GiST to do that, but it seemed too advanced for me yet.

So I thought of using the Oracle technique (make tables and use joins).
Problem: I would need a C function to make the cubes describing an spatial
object, but currently C functions cannot return more than one value (have of
thoght of returning an array, but have not tried it). And making inserts
directly from a C function has been described as magic stuff in the
documentation.

Yours sincerely,

Edmar Wiggers
BRASMAP Information Systems
+55 48 9960 2752