We are developping a GIS system using PG as database.
We could create multiple geographic type in PG: point, line, polygon,... but
we would like to try something else.
We want to use this structure in creating a new PG type (extending PG type
in C)
typedef struct {
int4 size; /* for postgresql and us */
int4 type; /* The type of object NONE, POINT, etc. */
float8 bound[2][3]; /* bounding box -- min(x,y,z) max(x,y,z) */
char data[1]; /* Resizable variable type data */
} geoobj;
The geobj->data would contain the binary representation of various
structures:
typedef struct {
int4 type=1;
float x,y,z
} point
typedef struct {
int4 type=2;
float x1,y1,z1,x2,y2,z2;
} line
and so on...
We could write functions that will convert the various structures into an
ascii stream for display in PG:
select geoobj from table
"POINT [x,y,z]" , "LINE [x1,y1,z1][x2,y2,z2]"
But we would like also the data pushed in pure binary. We could use a
function to ensure we want the binary value of the type
Select XDR(geoobj) from table
<binarystuff>
We will then take the binary stuff stored in a char and we will cast it to
the right structure. Do you think it will work and PG will not jump to the
roof because of binary stream output as a char* ?
BTW it will create a varbinary type that is waiting to be toasted.
Cheers.
Franck Martin
Database Development Officer
SOPAC South Pacific Applied Geoscience Commission
Fiji
E-mail: franck@sopac.org.fj <mailto:franck@sopac.org.fj>
Web site: http://www.sopac.org.fj/ <http://www.sopac.org.fj/>