-#define TWODIMS 0
-#define THREEDIMS 1
-#define FOURDIMS 2
-
typedef struct
{
float xmin;
} BOX3D;
+
// POINT3D already defined in postgis.h
// ALL LWGEOM structures will use POINT3D as an abstract point.
// This means a 2d geometry will be stored as (x,y) in its serialized
typedef struct
{
char *serialized_pointlist; // probably missaligned. 2d or 3d. points to a double
- char is3d; // true if these are 3d points
+ char ndims; // 2=2d, 3=3d, 4=4d, 5=undef
uint32 npoints;
} POINTARRAY;
+// copies a point from the point array into the parameter point
+// will set point's z=0 (or NaN) if pa is 2d
+// will set point's m=0 (or NaN( if pa is 3d or 2d
+// NOTE: point is a real POINT3D *not* a pointer
+extern POINT4D getPoint4d(POINTARRAY *pa, int n);
+
+// copies a point from the point array into the parameter point
+// will set point's z=0 (or NaN) if pa is 2d
+// will set point's m=0 (or NaN( if pa is 3d or 2d
+// NOTE: this will modify the point4d pointed to by 'point'.
+extern void getPoint4d_p(POINTARRAY *pa, int n, char *point);
+
+
+
// copies a point from the point array into the parameter point
// will set point's z=0 (or NaN) if pa is 2d
// NOTE: point is a real POINT3D *not* a pointer
// constructs a POINTARRAY.
// NOTE: points is *not* copied, so be careful about modification (can be aligned/missaligned)
-// NOTE: is3d is descriptive - it describes what type of data 'points'
+// NOTE: ndims is descriptive - it describes what type of data 'points'
// points to. No data conversion is done.
-extern POINTARRAY *pointArray_construct(char *points, char is3d, uint32 npoints);
+extern POINTARRAY *pointArray_construct(char *points, int ndims, uint32 npoints);
//calculate the bounding box of a set of points
// returns a 3d box
extern bool lwgeom_hasSRID(char type); // true iff S bit is set
-extern bool lwgeom_is3d(char type); // true iff D bit is set
+extern int lwgeom_ndims(char type); // true iff D bit is set
extern int lwgeom_getType(char type); // returns the tttt value
-extern char lwgeom_makeType(char is3d, char hasSRID, int type);
+extern char lwgeom_makeType(int ndims, char hasSRID, int type);
// all the base types (point/line/polygon) will have a
typedef struct
{
- char is3d; // true means points represent 3d points
+ char ndims; // 2=2d, 3=3d, 4=4d, 5=undef
int SRID; // spatial ref sys -1=none
POINTARRAY *points; // array of POINT3D
} LWLINE; //"light-weight line"
// construct a new LWLINE. points will be copied
// use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
-extern LWLINE *lwline_construct(char is3d, int SRID, POINTARRAY *points);
+extern LWLINE *lwline_construct(int ndims, int SRID, POINTARRAY *points);
// given the LWGEOM serialized form (or a pointer into a muli* one)
// construct a proper LWLINE.
typedef struct
{
- char is3d; // true means points represent 3d points
+ char ndims; // 2=2d, 3=3d, 4=4d, 5=undef
int SRID; // spatial ref sys
POINTARRAY *point; // hide 2d/3d (this will be an array of 1 point)
} LWPOINT; // "light-weight point"
// construct a new point. point will NOT be copied
// use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
-extern LWPOINT *lwpoint_construct(char is3d, int SRID, POINTARRAY *point);
+extern LWPOINT *lwpoint_construct(int ndims, int SRID, POINTARRAY *point);
// given the LWPOINT serialized form (or a pointer into a muli* one)
// construct a proper LWPOINT.
typedef struct
{
int32 SRID;
- char is3d;
+ char ndims;
int nrings;
POINTARRAY **rings; // list of rings (list of points)
} LWPOLY; // "light-weight polygon"
// construct a new LWLINE. arrays (points/points per ring) will NOT be copied
// use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
-extern LWPOLY *lwpoly_construct(char is3d, int SRID, int nrings,POINTARRAY **points);
+extern LWPOLY *lwpoly_construct(int ndims, int SRID, int nrings,POINTARRAY **points);
// given the LWPOLY serialized form (or a pointer into a muli* one)
// use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
// all subgeometries must have the same SRID
// if you want to construct an inspected, call this then inspect the result...
-extern char *lwgeom_construct(int SRID,int finalType,char is3d, int nsubgeometries, char **serialized_subs);
+extern char *lwgeom_construct(int SRID,int finalType,int ndims, int nsubgeometries, char **serialized_subs);
// construct the empty geometry (GEOMETRYCOLLECTION(EMPTY))
-extern char *lwgeom_constructempty(int SRID,char is3d);
+extern char *lwgeom_constructempty(int SRID,int ndims);
// helper function (not for general use)
// find the size a geometry (or a sub-geometry)
#include "lwgeom.h"
-extern float nextDown_f(double d);
-extern float nextUp_f(double d);
+extern float nextDown_f(double d);
+extern float nextUp_f(double d);
extern double nextDown_d(float d);
extern double nextUp_d(float d);
// POINTARRAY support functions
+// copies a point from the point array into the parameter point
+// will set point's z=0 (or NaN) if pa is 2d
+// will set point's m=0 (or NaN( if pa is 3d or 2d
+// NOTE: point is a real POINT3D *not* a pointer
+POINT4D getPoint4d(POINTARRAY *pa, int n)
+{
+ POINT4D result;
+ int size;
+
+ if ( (n<0) || (n>=pa->npoints))
+ {
+ return result; //error
+ }
+
+ size = pointArray_ptsize(pa);
+
+ // this does x,y
+ memcpy(&result.x, &pa->serialized_pointlist[size*n],sizeof(double)*2 );
+ if (pa->ndims >2)
+ memcpy(&result.z, &pa->serialized_pointlist[size*n + sizeof(double)*2],sizeof(double) );
+ else
+ result.z = NO_Z_VALUE;
+ if (pa->ndims >3)
+ memcpy(&result.m, &pa->serialized_pointlist[size*n + sizeof(double)*3],sizeof(double) );
+ else
+ result.m = NO_Z_VALUE;
+
+ return result;
+}
+
+// copies a point from the point array into the parameter point
+// will set point's z=0 (or NaN) if pa is 2d
+// will set point's m=0 (or NaN( if pa is 3d or 2d
+// NOTE: this will modify the point4d pointed to by 'point'.
+void getPoint4d_p(POINTARRAY *pa, int n, char *point)
+{
+ int size;
+
+ if ( (n<0) || (n>=pa->npoints))
+ {
+ return ; //error
+ }
+
+ size = pointArray_ptsize(pa);
+
+ // this does x,y
+ memcpy(point, &pa->serialized_pointlist[size*n],sizeof(double)*2 );
+ if (pa->ndims >2)
+ memcpy(point+16, &pa->serialized_pointlist[size*n + sizeof(double)*2],sizeof(double) );
+ else
+ {
+ double bad=NO_Z_VALUE;
+ memcpy(point+16, &bad,sizeof(double) );
+ //point->z = NO_Z_VALUE;
+ }
+
+ if (pa->ndims >3)
+ memcpy(point+24, &pa->serialized_pointlist[size*n + sizeof(double)*2],sizeof(double) );
+ else
+ {
+ double bad=NO_Z_VALUE;
+ memcpy(point+24, &bad,sizeof(double) );
+ //point->z = NO_Z_VALUE;
+ }
+}
+
+
// copies a point from the point array into the parameter point
// will set point's z=0 (or NaN) if pa is 2d
// this does x,y
memcpy(&result.x, &pa->serialized_pointlist[size*n],sizeof(double)*2 );
- if (pa->is3d)
+ if (pa->ndims >2)
memcpy(&result.z, &pa->serialized_pointlist[size*n + sizeof(double)*2],sizeof(double) );
else
result.z = NO_Z_VALUE;
// this does x,y
memcpy(point, &pa->serialized_pointlist[size*n],sizeof(double)*2 );
- if (pa->is3d)
+ if (pa->ndims >2)
memcpy(point+16, &pa->serialized_pointlist[size*n + sizeof(double)*2],sizeof(double) );
else
{
double bad=NO_Z_VALUE;
- memcpy(point+24, &bad,sizeof(double) );
+ memcpy(point+16, &bad,sizeof(double) );
//point->z = NO_Z_VALUE;
}
}
// constructs a POINTARRAY.
// NOTE: points is *not* copied, so be careful about modification (can be aligned/missaligned)
-// NOTE: is3d is descriptive - it describes what type of data 'points'
+// NOTE: ndims is descriptive - it describes what type of data 'points'
// points to. No data conversion is done.
-POINTARRAY *pointArray_construct(char *points, char is3d, uint32 npoints)
+POINTARRAY *pointArray_construct(char *points, int ndims, uint32 npoints)
{
POINTARRAY *pa;
pa = (POINTARRAY*)palloc(sizeof(pa));
- if (is3d>2)
- elog(ERROR,"pointArray_construct:: called with dims = %i", (int) is3d);
+ if (ndims>2)
+ elog(ERROR,"pointArray_construct:: called with dims = %i", (int) ndims);
- pa->is3d = is3d;
+ pa->ndims = ndims;
pa->npoints = npoints;
pa->serialized_pointlist = points;
// 16 for 2d, 24 for 3d, 32 for 4d
int pointArray_ptsize(POINTARRAY *pa)
{
- if (pa->is3d)
+ if (pa->ndims == 3)
return 24;
- else
+ else if (pa->ndims == 2)
return 16;
+ else if (pa->ndims == 4)
+ return 32;
+ elog(ERROR,"pointArray_ptsize:: ndims isnt 2,3, or 4");
+ return 0; // never get here
}
return (type & 0x40);
}
-bool lwgeom_is3d(char type)
+int lwgeom_ndims(char type)
{
- return ( (type & 0x30) >>4);
+ return ( (type & 0x30) >>4) +2;
}
int lwgeom_getType(char type)
return (type & 0x0F);
}
-char lwgeom_makeType(char is3d, char hasSRID, int type)
+char lwgeom_makeType(int ndims, char hasSRID, int type)
{
char result = type;
- if (is3d)
+ if (ndims == 3)
result = result | 0x10;
- if (hasSRID)
+ if (ndims == 4)
result = result | 0x20;
+ if (hasSRID)
+ result = result | 0x40;
return result;
}
// construct a new LWLINE. points will be copied
// use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
-LWLINE *lwline_construct(char is3d, int SRID, POINTARRAY *points)
+LWLINE *lwline_construct(int ndims, int SRID, POINTARRAY *points)
{
LWLINE *result;
result = (LWLINE*) palloc( sizeof(LWLINE));
- result->is3d =is3d;
+ result->ndims =ndims;
result->SRID = SRID;
result->points = points;
npoints = get_uint32(loc);
loc +=4;
- pa = pointArray_construct( loc, lwgeom_is3d(type), npoints);
+ pa = pointArray_construct( loc, lwgeom_ndims(type), npoints);
result->points = pa;
- result->is3d = lwgeom_is3d(type);
+ result->ndims = lwgeom_ndims(type);
return result;
}
if (hasSRID)
size +=4; //4 byte SRID
- if (line->is3d)
+ if (line->ndims == 3)
{
size += 24 * line->points->npoints; //x,y,z
}
- else
+ else if (line->ndims == 2)
{
size += 16 * line->points->npoints; //x,y
}
+ else if (line->ndims == 4)
+ {
+ size += 32 * line->points->npoints; //x,y
+ }
size+=4; // npoints
result = palloc(size);
- result[0] = lwgeom_makeType(line->is3d,hasSRID, LINETYPE);
+ result[0] = lwgeom_makeType(line->ndims,hasSRID, LINETYPE);
loc = result+1;
if (hasSRID)
elog(NOTICE," line serialize - size = %i", size);
- if (line->is3d)
+ if (line->ndims == 3)
{
for (t=0; t< line->points->npoints;t++)
{
loc += 24; // size of a 3d point
}
}
- else
+ else if (line->ndims == 2)
{
for (t=0; t< line->points->npoints;t++)
{
loc += 16; // size of a 2d point
}
}
+ else if (line->ndims == 4)
+ {
+ for (t=0; t< line->points->npoints;t++)
+ {
+ getPoint4d_p(line->points, t, loc);
+ loc += 32; // size of a 2d point
+ }
+ }
//printBYTES((unsigned char *)result, size);
return result;
}
npoints = get_uint32(loc);
result += 4; //npoints
- if (lwgeom_is3d(type) )
+ if (lwgeom_ndims(type) ==3)
{
return result + npoints * 24;
}
- else
+ else if (lwgeom_ndims(type) ==2)
{
return result+ npoints * 16;
}
+ else if (lwgeom_ndims(type) ==4)
+ {
+ return result+ npoints * 32;
+ }
+ elog(NOTICE,"lwline_findlength :: invalid ndims");
+ return 0; //never get here
}
//********************************************************************
// construct a new point. point will not be copied
// use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
-LWPOINT *lwpoint_construct(char is3d, int SRID, POINTARRAY *point)
+LWPOINT *lwpoint_construct(int ndims, int SRID, POINTARRAY *point)
{
LWPOINT *result ;
return NULL; // error
result = palloc(sizeof(LWPOINT));
- result->is3d = is3d;
+ result->ndims = ndims;
result->SRID = SRID;
result->point = point;
// we've read the type (1 byte) and SRID (4 bytes, if present)
- pa = pointArray_construct( loc, lwgeom_is3d(type), 1);
+ pa = pointArray_construct( loc, lwgeom_ndims(type), 1);
result->point = pa;
- result->is3d = lwgeom_is3d(type);
+ result->ndims = lwgeom_ndims(type);
return result;
if (hasSRID)
size +=4; //4 byte SRID
- if (point->is3d)
+ if (point->ndims == 3)
{
size += 24; //x,y,z
}
- else
+ else if (point->ndims == 2)
{
size += 16 ; //x,y,z
}
+ else if (point->ndims == 4)
+ {
+ size += 32 ; //x,y,z,m
+ }
result = palloc(size);
- result[0] = lwgeom_makeType(point->is3d,hasSRID, POINTTYPE);
+ result[0] = lwgeom_makeType(point->ndims,hasSRID, POINTTYPE);
loc = result+1;
if (hasSRID)
//copy in points
- if (point->is3d)
+ if (point->ndims == 3)
{
getPoint3d_p(point->point, 0, loc);
}
- else
+ else if (point->ndims == 2)
{
getPoint2d_p(point->point, 0, loc);
}
+ else if (point->ndims == 4)
+ {
+
+ getPoint4d_p(point->point, 0, loc);
+ }
return result;
}
loc = serialized_point +1;
}
- if (lwgeom_is3d(type))
+ if (lwgeom_ndims(type) == 3)
{
return result + 24;
}
- else
+ else if (lwgeom_ndims(type) == 3)
{
return result + 16;
}
+ else if (lwgeom_ndims(type) == 4)
+ {
+ return result + 32;
+ }
+ elog(NOTICE,"lwpoint_findlength :: invalid ndims");
+ return 0; //never get here
}
// construct a new LWLINE. arrays (points/points per ring) will NOT be copied
// use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
-LWPOLY *lwpoly_construct(char is3d, int SRID, int nrings,POINTARRAY **points)
+LWPOLY *lwpoly_construct(int ndims, int SRID, int nrings,POINTARRAY **points)
{
LWPOLY *result;
result = (LWPOLY*) palloc(sizeof(LWPOLY));
- result->is3d = is3d;
+ result->ndims = ndims;
result->SRID = SRID;
result->nrings = nrings;
result->rings = points;
LWPOLY *result;
uint32 nrings;
- bool is3d;
+ int ndims;
uint32 npoints;
char type;
char *loc;
type = serialized_form[0];
- is3d = lwgeom_is3d(type);
+ ndims = lwgeom_ndims(type);
loc = serialized_form;
if ( lwgeom_getType(type) != POLYGONTYPE)
npoints = get_uint32(loc);
loc +=4;
- result->rings[t] = pointArray_construct(loc, is3d, npoints);
- if (is3d)
+ result->rings[t] = pointArray_construct(loc, ndims, npoints);
+ if (ndims == 3)
loc += 24*npoints;
- else
+ else if (ndims == 2)
loc += 16*npoints;
+ else if (ndims == 4)
+ loc += 32*npoints;
}
- result->is3d = is3d;
+ result->ndims = ndims;
return result;
}
{
total_points += poly->rings[t]->npoints;
}
- if (poly->is3d)
+ if (poly->ndims == 3)
size += 24*total_points;
- else
+ else if (poly->ndims == 2)
size += 16*total_points;
+ else if (poly->ndims == 4)
+ size += 32*total_points;
result = palloc(size);
- result[0] = lwgeom_makeType(poly->is3d,hasSRID, POLYGONTYPE);
+ result[0] = lwgeom_makeType(poly->ndims,hasSRID, POLYGONTYPE);
loc = result+1;
if (hasSRID)
npoints = poly->rings[t]->npoints;
memcpy(loc, &npoints, sizeof(int32)); //npoints this ring
loc+=4;
- if (poly->is3d)
+ if (poly->ndims == 3)
{
for (u=0;u<npoints;u++)
{
loc+= 24;
}
}
- else
+ else if (poly->ndims == 2)
{
for (u=0;u<npoints;u++)
{
loc+= 16;
}
}
+ else if (poly->ndims == 4)
+ {
+ for (u=0;u<npoints;u++)
+ {
+ getPoint4d_p(pa, u, loc);
+ loc+= 32;
+ }
+ }
}
return result;
{
uint32 result = 1; // char type
uint32 nrings;
- bool is3d;
+ int ndims;
int t;
char type;
uint32 npoints;
type = serialized_poly[0];
- is3d = lwgeom_is3d(type);
+ ndims = lwgeom_ndims(type);
if ( lwgeom_getType(type) != POLYGONTYPE)
return -9999;
loc +=4;
result +=4;
- if (is3d)
+ if (ndims == 3)
{
loc += 24*npoints;
result += 24*npoints;
}
- else
+ else if (ndims == 2)
+ {
+ loc += 16*npoints;
+ result += 16*npoints;
+ }
+ else if (ndims == 4)
{
loc += 16*npoints;
result += 16*npoints;
// use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
// all subgeometries must have the same SRID
// if you want to construct an inspected, call this then inspect the result...
-extern char *lwgeom_construct(int SRID,int finalType,char is3d, int nsubgeometries, char **serialized_subs)
+extern char *lwgeom_construct(int SRID,int finalType,int ndims, int nsubgeometries, char **serialized_subs)
{
uint32 *lengths;
int t;
char *loc;
if (nsubgeometries == 0)
- return lwgeom_constructempty(SRID,is3d);
+ return lwgeom_constructempty(SRID,ndims);
lengths = palloc(sizeof(int32) * nsubgeometries);
total_length +=4 ; // nsubgeometries
result = palloc(total_length);
- result[0] = lwgeom_makeType( is3d, SRID != -1, type);
+ result[0] = lwgeom_makeType( ndims, SRID != -1, type);
if (SRID != -1)
{
memcpy(&result[1],&SRID,4);
// construct the empty geometry (GEOMETRYCOLLECTION(EMPTY))
//returns serialized form
-char *lwgeom_constructempty(int SRID,char is3d)
+char *lwgeom_constructempty(int SRID,int ndims)
{
int size = 0;
char *result;
result = palloc(size);
- result[0] = lwgeom_makeType( is3d, SRID != -1, COLLECTIONTYPE);
+ result[0] = lwgeom_makeType( ndims, SRID != -1, COLLECTIONTYPE);
if (SRID != -1)
{
memcpy(&result[1],&SRID,4);
void printLWLINE(LWLINE *line)
{
elog(NOTICE,"LWLINE {");
- elog(NOTICE," is3d = %i", (int)line->is3d);
+ elog(NOTICE," ndims = %i", (int)line->ndims);
elog(NOTICE," SRID = %i", (int)line->SRID);
printPA(line->points);
elog(NOTICE,"}");
int t;
POINT2D pt2;
POINT3D pt3;
+ POINT4D pt4;
elog(NOTICE," POINTARRAY{");
- elog(NOTICE," is3d =%i, ptsize=%i", (int) pa->is3d,pointArray_ptsize(pa));
+ elog(NOTICE," ndims =%i, ptsize=%i", (int) pa->ndims,pointArray_ptsize(pa));
elog(NOTICE," npoints = %i", pa->npoints);
for (t =0; t<pa->npoints;t++)
{
- if (pa->is3d == TWODIMS)
+ if (pa->ndims == 2)
{
pt2 = getPoint2d(pa,t);
elog(NOTICE," %i : %lf,%lf",t,pt2.x,pt2.y);
}
- if (pa->is3d == THREEDIMS)
+ if (pa->ndims == 3)
{
pt3 = getPoint3d(pa,t);
elog(NOTICE," %i : %lf,%lf,%lf",t,pt3.x,pt3.y,pt3.z);
}
+ if (pa->ndims == 4)
+ {
+ pt4 = getPoint4d(pa,t);
+ elog(NOTICE," %i : %lf,%lf,%lf,%lf",t,pt3.x,pt4.y,pt4.z,pt4.m);
+ }
}
elog(NOTICE," }");
{
int t;
elog(NOTICE,"LWPOLY {");
- elog(NOTICE," is3d = %i", (int)poly->is3d);
+ elog(NOTICE," ndims = %i", (int)poly->ndims);
elog(NOTICE," SRID = %i", (int)poly->SRID);
elog(NOTICE," nrings = %i", (int)poly->nrings);
for (t=0;t<poly->nrings;t++)
//point size
ptsize =16;
- if (dims == FOURDIMS)
+ if (dims == 4)
{
ptsize = 32;
}
- if (dims == THREEDIMS)
+ if (dims == 3)
{
ptsize = 24;
}
char *multigeom = NULL;
#ifdef DEBUG
- elog(NOTICE,"lwgeom_to_wkb: entry with simpletype=%i, dims=%i",(int) simple_type,(int) lwgeom_is3d( serialized_form[0]) );
+ elog(NOTICE,"lwgeom_to_wkb: entry with simpletype=%i, dims=%i",(int) simple_type, lwgeom_ndims( serialized_form[0]) );
#endif
bool need_flip = requiresflip( desiredWKBEndian );
#ifdef DEBUG
- elog(NOTICE,"lwpoint_to_wkb: pa dims = %i", (int)pt->point->is3d );
+ elog(NOTICE,"lwpoint_to_wkb: pa dims = %i", (int)pt->point->ndims );
#endif
result[0] = desiredWKBEndian; //endian flag
- wkbtype = constructWKBType(POINTTYPE, pt->point->is3d);
+ wkbtype = constructWKBType(POINTTYPE, pt->point->ndims);
#ifdef DEBUG
- elog(NOTICE,"lwpoint_to_wkb: entry with wkbtype=%i, pa dims = %i",wkbtype, (int)pt->point->is3d );
+ elog(NOTICE,"lwpoint_to_wkb: entry with wkbtype=%i, pa dims = %i",wkbtype, (int)pt->point->ndims );
#endif
memcpy(result+5, pt->point->serialized_pointlist, pointArray_ptsize(pt->point) );
if (need_flip)
- flipPoints(result+5, 1, pt->point->is3d);
+ flipPoints(result+5, 1, pt->point->ndims);
return result;
}
result[0] = desiredWKBEndian; //endian flag
- wkbtype = constructWKBType(LINETYPE, line->points->is3d);
+ wkbtype = constructWKBType(LINETYPE, line->points->ndims);
memcpy(result+1, &wkbtype, 4);
if (need_flip)
flip_endian_int32(result+1);
memcpy(result+9, line->points->serialized_pointlist, ptsize * line->points->npoints);
if (need_flip)
- flipPoints(result+9, line->points->npoints, line->points->is3d);
+ flipPoints(result+9, line->points->npoints, line->points->ndims);
return result;
}
result[0] = desiredWKBEndian; //endian flag
- wkbtype = constructWKBType(POLYGONTYPE, poly->is3d);
+ wkbtype = constructWKBType(POLYGONTYPE, poly->ndims);
memcpy(result+1, &wkbtype, 4); // type
if (need_flip)
flip_endian_int32(result+1);
flip_endian_int32(loc);
memcpy(loc+4, poly->rings[t]->serialized_pointlist, ptsize * npoints);
if (need_flip)
- flipPoints(loc+4, npoints, poly->is3d);
+ flipPoints(loc+4, npoints, poly->ndims);
loc += 4+ ptsize * npoints;
}
return result;
char wkb_dims(uint32 type)
{
if (type & 0x80000000)
- return THREEDIMS;
+ return 3;
if (type & 0x40000000)
- return FOURDIMS;
- return TWODIMS;
+ return 4;
+ return 2;
}
char *loc = pts;
int size =16;
- if (dims == FOURDIMS)
+ if (dims == 4)
{
size = 32;
}
- if (dims == THREEDIMS)
+ if (dims == 3)
{
size = 24;
}
{
flip_endian_double(loc);
flip_endian_double(loc+8);
- if ( (dims == THREEDIMS) || (dims == FOURDIMS) )
+ if ( (dims == 3) || (dims == 4) )
{
flip_endian_double(loc+16);
}
- if (dims == FOURDIMS)
+ if (dims == 4)
{
flip_endian_double(loc+24);
}
uint32 constructWKBType(int simple_type, char dims)
{
- if (dims == TWODIMS)
+ if (dims == 2)
return simple_type;
- if (dims == THREEDIMS)
+ if (dims == 3)
return simple_type | 0x80000000;
return simple_type | 0x40000000;