SHPObject * (*shape_creator)(byte *, int);
int big_endian = 0;
int pgis_major_version;
-int zmflag;
/* Prototypes */
int getMaxFieldSize(PGconn *conn, char *schema, char *table, char *fname);
int initialize(void);
int getGeometryOID(PGconn *conn);
int getGeometryType(char *schema, char *table, char *geo_col_name);
-int getGeometryDims(char *schema, char *table, char *geo_col_name);
+int getGeometryMaxDims(char *schema, char *table, char *geo_col_name);
char *shapetypename(int num);
int parse_points(char *str, int num_points, double *x,double *y,double *z);
int num_points(char *str);
void skipdouble(byte **c);
void dump_wkb(byte *wkb);
byte * HexDecode(byte *hex);
+
#define WKBZOFFSET 0x80000000
#define WKBMOFFSET 0x40000000
+#define ZMFLAG(x) (((x)&((WKBZOFFSET)+(WKBMOFFSET)))>>30)
static void exit_nicely(PGconn *conn){
includegid=0;
unescapedattrs=0;
binary = 0;
- zmflag = 0;
#ifdef DEBUG
FILE *debug;
#endif
double *x=NULL, *y=NULL, *zm=NULL;
int nparts=0, *part_index=NULL, totpoints=0, nlines=0;
int li;
+ int zmflag;
+
+ // skip byteOrder
+ skipbyte(&wkb);
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
/*
* Scan all lines in multiline
double *x=NULL, *y=NULL, *z=NULL, *m=NULL;
int nparts=0, *part_index=NULL, totpoints=0, nlines=0;
int li;
+ int zmflag;
+
+ // skip byteOrder
+ skipbyte(&wkb);
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
/*
* Scan all lines in multiline
int nparts=0, *part_index=NULL, totpoints=0, nlines=0;
int li;
SHPObject *obj;
+ int zmflag;
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
/*
* Scan all lines in multiline
double *x=NULL, *y=NULL, *z=NULL, *m=NULL;
uint32 npoints=0, pn;
SHPObject *obj;
+ int zmflag;
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
npoints = popint(&wkb);
double *x=NULL, *y=NULL, *zm=NULL;
uint32 npoints=0, pn;
SHPObject *obj;
+ int zmflag;
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
npoints = popint(&wkb);
double *x=NULL, *y=NULL, *z=NULL;
uint32 npoints=0, pn;
SHPObject *obj;
+ int zmflag;
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
npoints = popint(&wkb);
{
SHPObject *obj;
double x, y, z, m;
+ int zmflag;
+
+ // skip byteOrder
+ skipbyte(&wkb);
- // skip byteOrder and wkbType
- skipbyte(&wkb); skipint(&wkb);
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
x = popdouble(&wkb);
y = popdouble(&wkb);
{
SHPObject *obj;
double x, y, zm;
+ int zmflag;
- // skip byteOrder and wkbType
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
x = popdouble(&wkb);
y = popdouble(&wkb);
{
SHPObject *obj;
double x, y;
+ int zmflag;
+
+ // skip byteOrder
+ skipbyte(&wkb);
- // skip byteOrder and wkbType
- skipbyte(&wkb); skipint(&wkb);
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
x = popdouble(&wkb);
y = popdouble(&wkb);
double *x=NULL, *y=NULL, *z=NULL, *m=NULL;
int npoints;
int pn;
+ int zmflag;
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
npoints = popint(&wkb);
double *x=NULL, *y=NULL, *zm=NULL;
uint32 npoints;
uint32 pn;
+ int zmflag;
+
+ // skip byteOrder
+ skipbyte(&wkb);
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
npoints = popint(&wkb);
double *x=NULL, *y=NULL;
uint32 npoints;
uint32 pn;
+ int zmflag;
+
+ // skip byteOrder
+ skipbyte(&wkb);
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
npoints = popint(&wkb);
SHPObject *obj;
int ri, nrings, totpoints=0, *part_index=NULL;
double *x=NULL, *y=NULL, *z=NULL;
+ int zmflag;
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
/*
* Scan all rings
SHPObject *obj;
int ri, nrings, totpoints=0, *part_index=NULL;
double *x=NULL, *y=NULL, *z=NULL, *m=NULL;
+ int zmflag;
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
/*
* Scan all rings
SHPObject *obj;
int ri, nrings, totpoints=0, *part_index=NULL;
double *x=NULL, *y=NULL, *zm=NULL, *z=NULL;
+ int zmflag;
- // skip byteOrder and type
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
/*
* Scan all rings
int *part_index=NULL;
uint32 pi;
double *x=NULL, *y=NULL;
+ int zmflag;
+
+ // skip byteOrder
+ skipbyte(&wkb);
- // skip byteOrder and type
- //printf("byteOrder is %d\n", popbyte(&wkb));
- //printf("Type is %d", popint(&wkb));
- skipbyte(&wkb); skipint(&wkb);
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
/*
* Scan all polygons in multipolygon
int *part_index=NULL;
int pi;
double *x=NULL, *y=NULL, *z=NULL, *zm=NULL;
+ int zmflag;
+
+ // skip byteOrder
+ skipbyte(&wkb);
- // skip byteOrder and type
- //printf("byteOrder is %d\n", popbyte(&wkb));
- //printf("Type is %d", popint(&wkb));
- skipbyte(&wkb); skipint(&wkb);
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
/*
* Scan all polygons in multipolygon
int *part_index=NULL;
int pi;
double *x=NULL, *y=NULL, *z=NULL, *m=NULL;
+ int zmflag;
- // skip byteOrder and type
- //printf("byteOrder is %d\n", popbyte(&wkb));
- //printf("Type is %d", popint(&wkb));
- skipbyte(&wkb); skipint(&wkb);
+ // skip byteOrder
+ skipbyte(&wkb);
+
+ // extract zmflag from type
+ zmflag = ZMFLAG(popint(&wkb));
/*
* Scan all polygons in multipolygon
* Get Geometry dimensions (2d/3dm/3dz/4d)
**************************************************/
if ( pgis_major_version > 0 )
- if ( -1 == getGeometryDims(schema, table, geo_col_name) )
+ if ( -1 == getGeometryMaxDims(schema, table, geo_col_name) )
return -1;
if ( foundmulti )
* Call only on postgis >= 1.0.0
*/
int
-getGeometryDims(char *schema, char *table, char *geo_col_name)
+getGeometryMaxDims(char *schema, char *table, char *geo_col_name)
{
char query[1024];
PGresult *res;
+ int maxzmflag;
if ( schema )
{
return -1;
}
- zmflag = atoi(PQgetvalue(res, 0, 0));
+ maxzmflag = atoi(PQgetvalue(res, 0, 0));
PQclear(res);
- switch (zmflag)
+ switch (maxzmflag)
{
case 0:
outtype = 's';
/**********************************************************************
* $Log$
+ * Revision 1.65 2004/10/15 08:26:03 strk
+ * Fixed handling of mixed dimensioned geometries in source table.
+ *
* Revision 1.64 2004/10/14 09:59:51 strk
* Added support for user query (replacing schema.table)
*