// 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);
+extern POINT4D getPoint4d(const 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);
+extern void getPoint4d_p(const 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
-extern POINT3D getPoint3d(POINTARRAY *pa, int n);
+extern POINT3D getPoint3d(const 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
// NOTE: this will modify the point3d pointed to by 'point'.
-extern void getPoint3d_p(POINTARRAY *pa, int n, char *point);
+extern void getPoint3d_p(const POINTARRAY *pa, int n, char *point);
// copies a point from the point array into the parameter point
// z value (if present is not returned)
// NOTE: point is a real POINT3D *not* a pointer
-extern POINT2D getPoint2d(POINTARRAY *pa, int n);
+extern POINT2D getPoint2d(const POINTARRAY *pa, int n);
// copies a point from the point array into the parameter point
// z value (if present is not returned)
// NOTE: this will modify the point2d pointed to by 'point'.
-extern void getPoint2d_p(POINTARRAY *pa, int n, char *point);
+extern void getPoint2d_p(const POINTARRAY *pa, int n, char *point);
// get a pointer to nth point of a POINTARRAY
// You'll need to cast it to appropriate dimensioned point.
// Note that if you cast to a higher dimensional point you'll
// possibly corrupt the POINTARRAY.
-extern char *getPoint(POINTARRAY *pa, int n);
+extern char *getPoint(const POINTARRAY *pa, int n);
//--- here is a macro equivalent, for speed...
//#define getPoint(x,n) &( (x)->serialized_pointlist[((x)->ndims*8)*(n)] )
// returns a 3d box
// if pa is 2d, then box3d's zmin/zmax will be either 0 or NaN
// dont call on an empty pa
-extern BOX3D *pointArray_bbox(POINTARRAY *pa);
+extern BOX3D *pointArray_bbox(const POINTARRAY *pa);
//size of point represeneted in the POINTARRAY
// 16 for 2d, 24 for 3d, 32 for 4d
-extern int pointArray_ptsize(POINTARRAY *pa);
+extern int pointArray_ptsize(const POINTARRAY *pa);
/*
* This function computes the size in bytes
* of the serialized geometries.
*/
-extern int lwgeom_size(char *serialized_form);
-extern int lwgeom_size_subgeom(char *serialized_form, int geom_number);
+extern int lwgeom_size(const char *serialized_form);
+extern int lwgeom_size_subgeom(const char *serialized_form, int geom_number);
//--------------------------------------------------------
extern BOX3D *lwpoint_findbbox(LWPOINT *point);
// convenience functions to hide the POINTARRAY
-extern POINT2D lwpoint_getPoint2d(LWPOINT *point);
-extern POINT3D lwpoint_getPoint3d(LWPOINT *point);
+extern POINT2D lwpoint_getPoint2d(const LWPOINT *point);
+extern POINT3D lwpoint_getPoint3d(const LWPOINT *point);
//--------------------------------------------------------
typedef struct
{
int SRID;
- char *serialized_form; // orginal structure
+ const char *serialized_form; // orginal structure
unsigned char type; // 8-bit type for the LWGEOM
- int ngeometries; // number of sub-geometries
- char **sub_geoms; // list of pointers (into serialized_form) of the sub-geoms
+ int ngeometries; // number of sub-geometries
+ char * * const sub_geoms; // list of pointers (into serialized_form) of the sub-geoms
} LWGEOM_INSPECTED;
+extern int lwgeom_size_inspected(const LWGEOM_INSPECTED *inspected, int geom_number);
+
/*
* This structure is intended to be used for geometry collection construction
*/
// This function just computes the length of each sub-object and pre-caches this info.
// For a geometry collection of multi* geometries, you can inspect the sub-components
// as well.
-extern LWGEOM_INSPECTED *lwgeom_inspect(char *serialized_form);
+extern LWGEOM_INSPECTED *lwgeom_inspect(const char *serialized_form);
// 1st geometry has geom_number = 0
// ie. lwgeom_getpoint( lwgeom_getsubgeometry( serialized, 0), 1)
// --> POINT(1 1)
// you can inspect the sub-geometry as well if you wish.
-extern char *lwgeom_getsubgeometry(char *serialized_form, int geom_number);
+extern char *lwgeom_getsubgeometry(const char *serialized_form, int geom_number);
extern char *lwgeom_getsubgeometry_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
//***********************************************************
// utility
-extern uint32 get_uint32(char *loc);
-extern int32 get_int32(char *loc);
+extern uint32 get_uint32(const char *loc);
+extern int32 get_int32(const char *loc);
extern void printPA(POINTARRAY *pa);
extern void printLWPOINT(LWPOINT *point);
extern void printLWLINE(LWLINE *line);
#ifdef DEBUG_EXPLODED
void checkexplodedsize(char *srl, LWGEOM_EXPLODED *exploded, int alloced, char wantbbox);
#endif
-static uint32 lwgeom_size_line(char *serialized_line);
-static uint32 lwgeom_size_point(char *serialized_point);
-static uint32 lwgeom_size_poly(char *serialized_line);
-static int lwgeom_size_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
+static uint32 lwgeom_size_line(const char *serialized_line);
+static uint32 lwgeom_size_point(const char *serialized_point);
+static uint32 lwgeom_size_poly(const char *serialized_line);
//*********************************************************************
// BOX routines
// 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
+getPoint4d(const POINTARRAY *pa, int n)
{
POINT4D result;
int size;
// 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)
+void
+getPoint4d_p(const POINTARRAY *pa, int n, char *point)
{
int size;
// 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
-POINT3D getPoint3d(POINTARRAY *pa, int n)
+POINT3D
+getPoint3d(const POINTARRAY *pa, int n)
{
POINT3D result;
int size;
// NOTE: this will modify the point3d pointed to by 'point'.
// we use a char* instead of a POINT3D because we want to use this function
// for serialization/de-serialization
-void getPoint3d_p(POINTARRAY *pa, int n, char *point)
+void
+getPoint3d_p(const POINTARRAY *pa, int n, char *point)
{
int size;
POINT3D *op, *ip;
// z value (if present is not returned)
// NOTE: point is a real POINT2D *not* a pointer
POINT2D
-getPoint2d(POINTARRAY *pa, int n)
+getPoint2d(const POINTARRAY *pa, int n)
{
POINT2D result;
int size;
// NOTE: this will modify the point2d pointed to by 'point'.
// we use a char* instead of a POINT2D because we want to use this function
// for serialization/de-serialization
-void getPoint2d_p(POINTARRAY *pa, int n, char *point)
+void
+getPoint2d_p(const POINTARRAY *pa, int n, char *point)
{
int size;
// Note that if you cast to a higher dimensional point you'll
// possibly corrupt the POINTARRAY.
char *
-getPoint(POINTARRAY *pa, int n)
+getPoint(const POINTARRAY *pa, int n)
{
int size;
// calculate the bounding box of a set of points
// returns a palloced BOX3D, or NULL on empty array.
// zmin/zmax values are set to NO_Z_VALUE if not available.
-BOX3D *pointArray_bbox(POINTARRAY *pa)
+BOX3D *pointArray_bbox(const POINTARRAY *pa)
{
int t;
BOX3D *result;
//size of point represeneted in the POINTARRAY
// 16 for 2d, 24 for 3d, 32 for 4d
-int pointArray_ptsize(POINTARRAY *pa)
+int
+pointArray_ptsize(const POINTARRAY *pa)
{
if ( pa->ndims < 2 || pa->ndims > 4 )
{
// basic sub-geometry types
// handle missaligned unsigned int32 data
-uint32 get_uint32(char *loc)
+uint32
+get_uint32(const char *loc)
{
uint32 result;
}
// handle missaligned signed int32 data
-int32 get_int32(char *loc)
+int32
+get_int32(const char *loc)
{
int32 result;
// find length of this serialized line
uint32
-lwgeom_size_line(char *serialized_line)
+lwgeom_size_line(const char *serialized_line)
{
int type = (unsigned char) serialized_line[0];
uint32 result =1; //type
- char *loc;
+ const char *loc;
uint32 npoints;
if ( lwgeom_getType(type) != LINETYPE)
// convenience functions to hide the POINTARRAY
// TODO: obsolete this
POINT2D
-lwpoint_getPoint2d(LWPOINT *point)
+lwpoint_getPoint2d(const LWPOINT *point)
{
POINT2D result;
// convenience functions to hide the POINTARRAY
POINT3D
-lwpoint_getPoint3d(LWPOINT *point)
+lwpoint_getPoint3d(const LWPOINT *point)
{
POINT3D result;
//find length of this serialized point
uint32
-lwgeom_size_point(char *serialized_point)
+lwgeom_size_point(const char *serialized_point)
{
uint result = 1;
unsigned char type;
- char *loc;
+ const char *loc;
type = (unsigned char) serialized_point[0];
//find length of this serialized polygon
uint32
-lwgeom_size_poly(char *serialized_poly)
+lwgeom_size_poly(const char *serialized_poly)
{
uint32 result = 1; // char type
uint32 nrings;
int t;
unsigned char type;
uint32 npoints;
- char *loc;
+ const char *loc;
if (serialized_poly == NULL)
return -9999;
// This function just computes the length of each sub-object and pre-caches this info.
// For a geometry collection of multi* geometries, you can inspect the sub-components
// as well.
-LWGEOM_INSPECTED *lwgeom_inspect(char *serialized_form)
+LWGEOM_INSPECTED *
+lwgeom_inspect(const char *serialized_form)
{
LWGEOM_INSPECTED *result = palloc(sizeof(LWGEOM_INSPECTED));
unsigned char type;
char **sub_geoms;
- char *loc;
+ const char *loc;
int t;
if (serialized_form == NULL)
return NULL;
- result->serialized_form = serialized_form;
+ result->serialized_form = serialized_form;
result->type = (unsigned char) serialized_form[0];
result->SRID = -1; // assume
// ie. lwgeom_getpoint( lwgeom_getsubgeometry( serialized, 0), 1)
// --> POINT(1 1)
// you can inspect the sub-geometry as well if you wish.
-char *lwgeom_getsubgeometry(char *serialized_form, int geom_number)
+char *
+lwgeom_getsubgeometry(const char *serialized_form, int geom_number)
{
//major cheat!!
char * result;
// --> size of the point
// take a geometry, and find its length
-int lwgeom_size(char *serialized_form)
+int
+lwgeom_size(const char *serialized_form)
{
unsigned char type = lwgeom_getType((unsigned char) serialized_form[0]);
int t;
- char *loc;
+ const char *loc;
uint32 ngeoms;
int sub_size;
int result = 1; //"type"
return result;
}
-int lwgeom_size_subgeom(char *serialized_form, int geom_number)
+int
+lwgeom_size_subgeom(const char *serialized_form, int geom_number)
{
if (geom_number == -1)
{
int
-lwgeom_size_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
+lwgeom_size_inspected(const LWGEOM_INSPECTED *inspected, int geom_number)
{
return lwgeom_size(inspected->sub_geoms[geom_number]);
}
//get bounding box of LWGEOM (automatically calls the sub-geometries bbox generators)
//dont forget to pfree() result
-BOX3D *lw_geom_getBB(char *serialized_form)
+BOX3D *
+lw_geom_getBB(char *serialized_form)
{
LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized_form);
elog(NOTICE,"}");
}
-void printMULTI(char *serialized)
+void
+printMULTI(char *serialized)
{
LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized);
LWLINE *line;