forked from rttopo/librttopo
Style only commit: use 2-spaces instead of tabs, trim ending newlines
parent
4602723e37
commit
eeb618b66c
|
@ -10,9 +10,10 @@ end_of_line = lf
|
|||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
# C files want tab indentation
|
||||
# C files want space
|
||||
[*.{c,h}]
|
||||
indent_style = tab
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# Makefiles want tab indentation
|
||||
[{Makefile.in,Makefile}]
|
||||
|
|
|
@ -401,7 +401,7 @@ typedef struct RTT_BE_CALLBACKS_T {
|
|||
* as a result of edge splitting, or -1 if the old edge was
|
||||
* modified rather than replaced.
|
||||
*
|
||||
* @return 1 on success, 0 on error
|
||||
* @return 1 on success, 0 on error
|
||||
*
|
||||
* @note on splitting an edge, the new edges both have the
|
||||
* same direction as the original one. If a second new edge was
|
||||
|
@ -538,7 +538,7 @@ typedef struct RTT_BE_CALLBACKS_T {
|
|||
* as a result of face splitting, or -1 if the old face was
|
||||
* modified rather than replaced.
|
||||
*
|
||||
* @return 1 on success, 0 on error (@see lastErroMessage)
|
||||
* @return 1 on success, 0 on error (@see lastErroMessage)
|
||||
*
|
||||
*/
|
||||
int (*updateTopoGeomFaceSplit) (
|
||||
|
|
|
@ -65,13 +65,13 @@
|
|||
/**
|
||||
* RTRTTYPE numbers
|
||||
*/
|
||||
#define RTPOINTTYPE 1
|
||||
#define RTLINETYPE 2
|
||||
#define RTPOLYGONTYPE 3
|
||||
#define RTMULTIPOINTTYPE 4
|
||||
#define RTMULTILINETYPE 5
|
||||
#define RTMULTIPOLYGONTYPE 6
|
||||
#define RTCOLLECTIONTYPE 7
|
||||
#define RTPOINTTYPE 1
|
||||
#define RTLINETYPE 2
|
||||
#define RTPOLYGONTYPE 3
|
||||
#define RTMULTIPOINTTYPE 4
|
||||
#define RTMULTILINETYPE 5
|
||||
#define RTMULTIPOLYGONTYPE 6
|
||||
#define RTCOLLECTIONTYPE 7
|
||||
#define RTCIRCSTRINGTYPE 8
|
||||
#define RTCOMPOUNDTYPE 9
|
||||
#define RTCURVEPOLYTYPE 10
|
||||
|
@ -270,16 +270,16 @@ extern rtinterrupt_callback *rtgeom_register_interrupt_callback(const RTCTX *ctx
|
|||
/******************************************************************/
|
||||
|
||||
typedef struct {
|
||||
double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff, zoff;
|
||||
double afac, bfac, cfac, dfac, efac, ffac, gfac, hfac, ifac, xoff, yoff, zoff;
|
||||
} RTAFFINE;
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double xmin, ymin, zmin;
|
||||
double xmax, ymax, zmax;
|
||||
int32_t srid;
|
||||
double xmin, ymin, zmin;
|
||||
double xmax, ymax, zmax;
|
||||
int32_t srid;
|
||||
}
|
||||
BOX3D;
|
||||
|
||||
|
@ -291,15 +291,15 @@ BOX3D;
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t flags;
|
||||
double xmin;
|
||||
double xmax;
|
||||
double ymin;
|
||||
double ymax;
|
||||
double zmin;
|
||||
double zmax;
|
||||
double mmin;
|
||||
double mmax;
|
||||
uint8_t flags;
|
||||
double xmin;
|
||||
double xmax;
|
||||
double ymin;
|
||||
double ymax;
|
||||
double zmin;
|
||||
double zmax;
|
||||
double mmin;
|
||||
double mmax;
|
||||
} RTGBOX;
|
||||
|
||||
|
||||
|
@ -313,13 +313,13 @@ typedef struct
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
double a; /* semimajor axis */
|
||||
double b; /* semiminor axis b = (a - fa) */
|
||||
double f; /* flattening f = (a-b)/a */
|
||||
double e; /* eccentricity (first) */
|
||||
double e_sq; /* eccentricity squared (first) e_sq = (a*a-b*b)/(a*a) */
|
||||
double radius; /* spherical average radius = (2*a+b)/3 */
|
||||
char name[20]; /* name of ellipse */
|
||||
double a; /* semimajor axis */
|
||||
double b; /* semiminor axis b = (a - fa) */
|
||||
double f; /* flattening f = (a-b)/a */
|
||||
double e; /* eccentricity (first) */
|
||||
double e_sq; /* eccentricity squared (first) e_sq = (a*a-b*b)/(a*a) */
|
||||
double radius; /* spherical average radius = (2*a+b)/3 */
|
||||
char name[20]; /* name of ellipse */
|
||||
}
|
||||
SPHEROID;
|
||||
|
||||
|
@ -328,31 +328,31 @@ SPHEROID;
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
double x, y;
|
||||
double x, y;
|
||||
}
|
||||
RTPOINT2D;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x, y, z;
|
||||
double x, y, z;
|
||||
}
|
||||
RTPOINT3DZ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x, y, z;
|
||||
double x, y, z;
|
||||
}
|
||||
POINT3D;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x, y, m;
|
||||
double x, y, m;
|
||||
}
|
||||
RTPOINT3DM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x, y, z, m;
|
||||
double x, y, z, m;
|
||||
}
|
||||
RTPOINT4D;
|
||||
|
||||
|
@ -365,14 +365,14 @@ RTPOINT4D;
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* Array of POINT 2D, 3D or 4D, possibly missaligned. */
|
||||
uint8_t *serialized_pointlist;
|
||||
/* Array of POINT 2D, 3D or 4D, possibly missaligned. */
|
||||
uint8_t *serialized_pointlist;
|
||||
|
||||
/* Use RTFLAGS_* macros to handle */
|
||||
uint8_t flags;
|
||||
/* Use RTFLAGS_* macros to handle */
|
||||
uint8_t flags;
|
||||
|
||||
int npoints; /* how many points we are currently storing */
|
||||
int maxpoints; /* how many points we have space for in serialized_pointlist */
|
||||
int npoints; /* how many points we are currently storing */
|
||||
int maxpoints; /* how many points we have space for in serialized_pointlist */
|
||||
}
|
||||
RTPOINTARRAY;
|
||||
|
||||
|
@ -381,10 +381,10 @@ RTPOINTARRAY;
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t size; /* For PgSQL use only, use VAR* macros to manipulate. */
|
||||
uint8_t srid[3]; /* 24 bits of SRID */
|
||||
uint8_t flags; /* HasZ, HasM, HasBBox, IsGeodetic, IsReadOnly */
|
||||
uint8_t data[1]; /* See gserialized.txt */
|
||||
uint32_t size; /* For PgSQL use only, use VAR* macros to manipulate. */
|
||||
uint8_t srid[3]; /* 24 bits of SRID */
|
||||
uint8_t flags; /* HasZ, HasM, HasBBox, IsGeodetic, IsReadOnly */
|
||||
uint8_t data[1]; /* See gserialized.txt */
|
||||
} GSERIALIZED;
|
||||
|
||||
|
||||
|
@ -396,198 +396,198 @@ typedef struct
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
void *data;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
void *data;
|
||||
}
|
||||
RTGEOM;
|
||||
|
||||
/* RTPOINTYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /* RTPOINTTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
RTPOINTARRAY *point; /* hide 2d/3d (this will be an array of 1 point) */
|
||||
uint8_t type; /* RTPOINTTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
RTPOINTARRAY *point; /* hide 2d/3d (this will be an array of 1 point) */
|
||||
}
|
||||
RTPOINT; /* "light-weight point" */
|
||||
|
||||
/* RTLINETYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /* RTLINETYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
RTPOINTARRAY *points; /* array of POINT3D */
|
||||
uint8_t type; /* RTLINETYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
RTPOINTARRAY *points; /* array of POINT3D */
|
||||
}
|
||||
RTLINE; /* "light-weight line" */
|
||||
|
||||
/* TRIANGLE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
RTPOINTARRAY *points;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
RTPOINTARRAY *points;
|
||||
}
|
||||
RTTRIANGLE;
|
||||
|
||||
/* RTCIRCSTRINGTYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /* RTCIRCSTRINGTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
RTPOINTARRAY *points; /* array of POINT(3D/3DM) */
|
||||
uint8_t type; /* RTCIRCSTRINGTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
RTPOINTARRAY *points; /* array of POINT(3D/3DM) */
|
||||
}
|
||||
RTCIRCSTRING; /* "light-weight circularstring" */
|
||||
|
||||
/* RTPOLYGONTYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /* RTPOLYGONTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int nrings; /* how many rings we are currently storing */
|
||||
int maxrings; /* how many rings we have space for in **rings */
|
||||
RTPOINTARRAY **rings; /* list of rings (list of points) */
|
||||
uint8_t type; /* RTPOLYGONTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int nrings; /* how many rings we are currently storing */
|
||||
int maxrings; /* how many rings we have space for in **rings */
|
||||
RTPOINTARRAY **rings; /* list of rings (list of points) */
|
||||
}
|
||||
RTPOLY; /* "light-weight polygon" */
|
||||
|
||||
/* RTMULTIPOINTTYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTPOINT **geoms;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTPOINT **geoms;
|
||||
}
|
||||
RTMPOINT;
|
||||
|
||||
/* RTMULTILINETYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTLINE **geoms;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTLINE **geoms;
|
||||
}
|
||||
RTMLINE;
|
||||
|
||||
/* RTMULTIPOLYGONTYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTPOLY **geoms;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTPOLY **geoms;
|
||||
}
|
||||
RTMPOLY;
|
||||
|
||||
/* RTCOLLECTIONTYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTGEOM **geoms;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTGEOM **geoms;
|
||||
}
|
||||
RTCOLLECTION;
|
||||
|
||||
/* RTCOMPOUNDTYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /* RTCOMPOUNDTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTGEOM **geoms;
|
||||
uint8_t type; /* RTCOMPOUNDTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTGEOM **geoms;
|
||||
}
|
||||
RTCOMPOUND; /* "light-weight compound line" */
|
||||
|
||||
/* RTCURVEPOLYTYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /* RTCURVEPOLYTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int nrings; /* how many rings we are currently storing */
|
||||
int maxrings; /* how many rings we have space for in **rings */
|
||||
RTGEOM **rings; /* list of rings (list of points) */
|
||||
uint8_t type; /* RTCURVEPOLYTYPE */
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int nrings; /* how many rings we are currently storing */
|
||||
int maxrings; /* how many rings we have space for in **rings */
|
||||
RTGEOM **rings; /* list of rings (list of points) */
|
||||
}
|
||||
RTCURVEPOLY; /* "light-weight polygon" */
|
||||
|
||||
/* MULTICURVE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTGEOM **geoms;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTGEOM **geoms;
|
||||
}
|
||||
RTMCURVE;
|
||||
|
||||
/* RTMULTISURFACETYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTGEOM **geoms;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTGEOM **geoms;
|
||||
}
|
||||
RTMSURFACE;
|
||||
|
||||
/* RTPOLYHEDRALSURFACETYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTPOLY **geoms;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTPOLY **geoms;
|
||||
}
|
||||
RTPSURFACE;
|
||||
|
||||
/* RTTINTYPE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTTRIANGLE **geoms;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
RTGBOX *bbox;
|
||||
int32_t srid;
|
||||
int ngeoms; /* how many geometries we are currently storing */
|
||||
int maxgeoms; /* how many geometries we have space for in **geoms */
|
||||
RTTRIANGLE **geoms;
|
||||
}
|
||||
RTTIN;
|
||||
|
||||
|
@ -933,7 +933,7 @@ extern RTPOINTARRAY *ptarray_addPoint(const RTCTX *ctx, const RTPOINTARRAY *pa,
|
|||
|
||||
/**
|
||||
* @brief Remove a point from a pointarray.
|
||||
* @param which - is the offset (starting at 0)
|
||||
* @param which - is the offset (starting at 0)
|
||||
* @return #RTPOINTARRAY is newly allocated
|
||||
*/
|
||||
extern RTPOINTARRAY *ptarray_removePoint(const RTCTX *ctx, RTPOINTARRAY *pa, uint32_t where);
|
||||
|
@ -1918,7 +1918,7 @@ extern int gserialized_get_gbox_p(const RTCTX *ctx, const GSERIALIZED *g, RTGBOX
|
|||
#define RT_PARSER_CHECK_ZCLOSURE 8
|
||||
|
||||
#define RT_PARSER_CHECK_NONE 0
|
||||
#define RT_PARSER_CHECK_ALL (RT_PARSER_CHECK_MINPOINTS | RT_PARSER_CHECK_ODD | RT_PARSER_CHECK_CLOSURE)
|
||||
#define RT_PARSER_CHECK_ALL (RT_PARSER_CHECK_MINPOINTS | RT_PARSER_CHECK_ODD | RT_PARSER_CHECK_CLOSURE)
|
||||
|
||||
/**
|
||||
* Parser result structure: returns the result of attempting to convert
|
||||
|
@ -1926,14 +1926,14 @@ extern int gserialized_get_gbox_p(const RTCTX *ctx, const GSERIALIZED *g, RTGBOX
|
|||
*/
|
||||
typedef struct struct_rtgeom_parser_result
|
||||
{
|
||||
const char *wkinput; /* Copy of pointer to input RTWKT/RTWKB */
|
||||
uint8_t *serialized_rtgeom; /* Pointer to serialized RTGEOM */
|
||||
int size; /* Size of serialized RTGEOM in bytes */
|
||||
RTGEOM *geom; /* Pointer to RTGEOM struct */
|
||||
const char *message; /* Error/warning message */
|
||||
int errcode; /* Error/warning number */
|
||||
int errlocation; /* Location of error */
|
||||
int parser_check_flags; /* Bitmask of validity checks run during this parse */
|
||||
const char *wkinput; /* Copy of pointer to input RTWKT/RTWKB */
|
||||
uint8_t *serialized_rtgeom; /* Pointer to serialized RTGEOM */
|
||||
int size; /* Size of serialized RTGEOM in bytes */
|
||||
RTGEOM *geom; /* Pointer to RTGEOM struct */
|
||||
const char *message; /* Error/warning message */
|
||||
int errcode; /* Error/warning number */
|
||||
int errlocation; /* Location of error */
|
||||
int parser_check_flags; /* Bitmask of validity checks run during this parse */
|
||||
}
|
||||
RTGEOM_PARSER_RESULT;
|
||||
|
||||
|
@ -1958,20 +1958,20 @@ RTGEOM_PARSER_RESULT;
|
|||
*/
|
||||
typedef struct struct_rtgeom_unparser_result
|
||||
{
|
||||
uint8_t *serialized_rtgeom; /* Copy of pointer to input serialized RTGEOM */
|
||||
char *wkoutput; /* Pointer to RTWKT or RTWKB output */
|
||||
int size; /* Size of serialized RTGEOM in bytes */
|
||||
const char *message; /* Error/warning message */
|
||||
int errlocation; /* Location of error */
|
||||
uint8_t *serialized_rtgeom; /* Copy of pointer to input serialized RTGEOM */
|
||||
char *wkoutput; /* Pointer to RTWKT or RTWKB output */
|
||||
int size; /* Size of serialized RTGEOM in bytes */
|
||||
const char *message; /* Error/warning message */
|
||||
int errlocation; /* Location of error */
|
||||
}
|
||||
RTGEOM_UNPARSER_RESULT;
|
||||
|
||||
/*
|
||||
* Unparser error messages (these must match the message array in rtgunparse.c)
|
||||
*/
|
||||
#define UNPARSER_ERROR_MOREPOINTS 1
|
||||
#define UNPARSER_ERROR_ODDPOINTS 2
|
||||
#define UNPARSER_ERROR_UNCLOSED 3
|
||||
#define UNPARSER_ERROR_MOREPOINTS 1
|
||||
#define UNPARSER_ERROR_ODDPOINTS 2
|
||||
#define UNPARSER_ERROR_UNCLOSED 3
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
RTGBOX *
|
||||
box2d_clone(const RTCTX *ctx, const RTGBOX *in)
|
||||
{
|
||||
RTGBOX *ret = rtalloc(ctx, sizeof(RTGBOX));
|
||||
memcpy(ret, in, sizeof(RTGBOX));
|
||||
return ret;
|
||||
RTGBOX *ret = rtalloc(ctx, sizeof(RTGBOX));
|
||||
memcpy(ret, in, sizeof(RTGBOX));
|
||||
return ret;
|
||||
}
|
||||
|
|
366
src/bytebuffer.c
366
src/bytebuffer.c
|
@ -31,74 +31,74 @@
|
|||
/**
|
||||
* Allocate a new bytebuffer_t. Use bytebuffer_destroy to free.
|
||||
*/
|
||||
bytebuffer_t*
|
||||
bytebuffer_t*
|
||||
bytebuffer_create(const RTCTX *ctx)
|
||||
{
|
||||
RTDEBUG(2,"Entered bytebuffer_create");
|
||||
return bytebuffer_create_with_size(ctx, BYTEBUFFER_STARTSIZE);
|
||||
RTDEBUG(2,"Entered bytebuffer_create");
|
||||
return bytebuffer_create_with_size(ctx, BYTEBUFFER_STARTSIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a new bytebuffer_t. Use bytebuffer_destroy to free.
|
||||
*/
|
||||
bytebuffer_t*
|
||||
bytebuffer_t*
|
||||
bytebuffer_create_with_size(const RTCTX *ctx, size_t size)
|
||||
{
|
||||
RTDEBUGF(2,"Entered bytebuffer_create_with_size %d", size);
|
||||
bytebuffer_t *s;
|
||||
RTDEBUGF(2,"Entered bytebuffer_create_with_size %d", size);
|
||||
bytebuffer_t *s;
|
||||
|
||||
s = rtalloc(ctx, sizeof(bytebuffer_t));
|
||||
s->buf_start = rtalloc(ctx, size);
|
||||
s->readcursor = s->writecursor = s->buf_start;
|
||||
s->capacity = size;
|
||||
memset(s->buf_start,0,size);
|
||||
RTDEBUGF(4,"We create a buffer on %p of %d bytes", s->buf_start, size);
|
||||
return s;
|
||||
s = rtalloc(ctx, sizeof(bytebuffer_t));
|
||||
s->buf_start = rtalloc(ctx, size);
|
||||
s->readcursor = s->writecursor = s->buf_start;
|
||||
s->capacity = size;
|
||||
memset(s->buf_start,0,size);
|
||||
RTDEBUGF(4,"We create a buffer on %p of %d bytes", s->buf_start, size);
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate just the internal buffer of an existing bytebuffer_t
|
||||
* struct. Useful for allocating short-lived bytebuffers off the stack.
|
||||
*/
|
||||
void
|
||||
void
|
||||
bytebuffer_init_with_size(const RTCTX *ctx, bytebuffer_t *b, size_t size)
|
||||
{
|
||||
b->buf_start = rtalloc(ctx, size);
|
||||
b->readcursor = b->writecursor = b->buf_start;
|
||||
b->capacity = size;
|
||||
memset(b->buf_start, 0, size);
|
||||
b->buf_start = rtalloc(ctx, size);
|
||||
b->readcursor = b->writecursor = b->buf_start;
|
||||
b->capacity = size;
|
||||
memset(b->buf_start, 0, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the bytebuffer_t and all memory managed within it.
|
||||
*/
|
||||
void
|
||||
void
|
||||
bytebuffer_destroy(const RTCTX *ctx, bytebuffer_t *s)
|
||||
{
|
||||
RTDEBUG(2,"Entered bytebuffer_destroy");
|
||||
RTDEBUGF(4,"The buffer has used %d bytes",bytebuffer_getlength(ctx, s));
|
||||
|
||||
if ( s->buf_start )
|
||||
{
|
||||
RTDEBUGF(4,"let's free buf_start %p",s->buf_start);
|
||||
rtfree(ctx, s->buf_start);
|
||||
RTDEBUG(4,"buf_start is freed");
|
||||
}
|
||||
if ( s )
|
||||
{
|
||||
rtfree(ctx, s);
|
||||
RTDEBUG(4,"bytebuffer_t is freed");
|
||||
}
|
||||
return;
|
||||
RTDEBUG(2,"Entered bytebuffer_destroy");
|
||||
RTDEBUGF(4,"The buffer has used %d bytes",bytebuffer_getlength(ctx, s));
|
||||
|
||||
if ( s->buf_start )
|
||||
{
|
||||
RTDEBUGF(4,"let's free buf_start %p",s->buf_start);
|
||||
rtfree(ctx, s->buf_start);
|
||||
RTDEBUG(4,"buf_start is freed");
|
||||
}
|
||||
if ( s )
|
||||
{
|
||||
rtfree(ctx, s);
|
||||
RTDEBUG(4,"bytebuffer_t is freed");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read cursor to the beginning
|
||||
*/
|
||||
void
|
||||
void
|
||||
bytebuffer_reset_reading(const RTCTX *ctx, bytebuffer_t *s)
|
||||
{
|
||||
s->readcursor = s->buf_start;
|
||||
s->readcursor = s->buf_start;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,105 +106,105 @@ bytebuffer_reset_reading(const RTCTX *ctx, bytebuffer_t *s)
|
|||
* without the expense of freeing and re-allocating a new
|
||||
* bytebuffer_t.
|
||||
*/
|
||||
void
|
||||
void
|
||||
bytebuffer_clear(const RTCTX *ctx, bytebuffer_t *s)
|
||||
{
|
||||
s->readcursor = s->writecursor = s->buf_start;
|
||||
s->readcursor = s->writecursor = s->buf_start;
|
||||
}
|
||||
|
||||
/**
|
||||
* If necessary, expand the bytebuffer_t internal buffer to accomodate the
|
||||
* specified additional size.
|
||||
*/
|
||||
static inline void
|
||||
static inline void
|
||||
bytebuffer_makeroom(const RTCTX *ctx, bytebuffer_t *s, size_t size_to_add)
|
||||
{
|
||||
RTDEBUGF(2,"Entered bytebuffer_makeroom with space need of %d", size_to_add);
|
||||
size_t current_write_size = (s->writecursor - s->buf_start);
|
||||
size_t capacity = s->capacity;
|
||||
size_t required_size = current_write_size + size_to_add;
|
||||
RTDEBUGF(2,"Entered bytebuffer_makeroom with space need of %d", size_to_add);
|
||||
size_t current_write_size = (s->writecursor - s->buf_start);
|
||||
size_t capacity = s->capacity;
|
||||
size_t required_size = current_write_size + size_to_add;
|
||||
|
||||
RTDEBUGF(2,"capacity = %d and required size = %d",capacity ,required_size);
|
||||
while (capacity < required_size)
|
||||
capacity *= 2;
|
||||
RTDEBUGF(2,"capacity = %d and required size = %d",capacity ,required_size);
|
||||
while (capacity < required_size)
|
||||
capacity *= 2;
|
||||
|
||||
if ( capacity > s->capacity )
|
||||
{
|
||||
RTDEBUGF(4,"We need to realloc more memory. New capacity is %d", capacity);
|
||||
s->buf_start = rtrealloc(ctx, s->buf_start, capacity);
|
||||
s->capacity = capacity;
|
||||
s->writecursor = s->buf_start + current_write_size;
|
||||
s->readcursor = s->buf_start + (s->readcursor - s->buf_start);
|
||||
}
|
||||
return;
|
||||
if ( capacity > s->capacity )
|
||||
{
|
||||
RTDEBUGF(4,"We need to realloc more memory. New capacity is %d", capacity);
|
||||
s->buf_start = rtrealloc(ctx, s->buf_start, capacity);
|
||||
s->capacity = capacity;
|
||||
s->writecursor = s->buf_start + current_write_size;
|
||||
s->readcursor = s->buf_start + (s->readcursor - s->buf_start);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a uint8_t value to the buffer
|
||||
*/
|
||||
void
|
||||
void
|
||||
bytebuffer_append_byte(const RTCTX *ctx, bytebuffer_t *s, const uint8_t val)
|
||||
{
|
||||
RTDEBUGF(2,"Entered bytebuffer_append_byte with value %d", val);
|
||||
bytebuffer_makeroom(ctx, s, 1);
|
||||
*(s->writecursor)=val;
|
||||
s->writecursor += 1;
|
||||
return;
|
||||
{
|
||||
RTDEBUGF(2,"Entered bytebuffer_append_byte with value %d", val);
|
||||
bytebuffer_makeroom(ctx, s, 1);
|
||||
*(s->writecursor)=val;
|
||||
s->writecursor += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes a uint8_t value to the buffer
|
||||
*/
|
||||
void
|
||||
void
|
||||
bytebuffer_append_bulk(const RTCTX *ctx, bytebuffer_t *s, void * start, size_t size)
|
||||
{
|
||||
RTDEBUGF(2,"bytebuffer_append_bulk with size %d",size);
|
||||
bytebuffer_makeroom(ctx, s, size);
|
||||
memcpy(s->writecursor, start, size);
|
||||
s->writecursor += size;
|
||||
return;
|
||||
{
|
||||
RTDEBUGF(2,"bytebuffer_append_bulk with size %d",size);
|
||||
bytebuffer_makeroom(ctx, s, size);
|
||||
memcpy(s->writecursor, start, size);
|
||||
s->writecursor += size;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a uint8_t value to the buffer
|
||||
*/
|
||||
void
|
||||
void
|
||||
bytebuffer_append_bytebuffer(const RTCTX *ctx, bytebuffer_t *write_to,bytebuffer_t *write_from )
|
||||
{
|
||||
RTDEBUG(2,"bytebuffer_append_bytebuffer");
|
||||
size_t size = bytebuffer_getlength(ctx, write_from);
|
||||
bytebuffer_makeroom(ctx, write_to, size);
|
||||
memcpy(write_to->writecursor, write_from->buf_start, size);
|
||||
write_to->writecursor += size;
|
||||
return;
|
||||
{
|
||||
RTDEBUG(2,"bytebuffer_append_bytebuffer");
|
||||
size_t size = bytebuffer_getlength(ctx, write_from);
|
||||
bytebuffer_makeroom(ctx, write_to, size);
|
||||
memcpy(write_to->writecursor, write_from->buf_start, size);
|
||||
write_to->writecursor += size;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes a signed varInt to the buffer
|
||||
*/
|
||||
void
|
||||
void
|
||||
bytebuffer_append_varint(const RTCTX *ctx, bytebuffer_t *b, const int64_t val)
|
||||
{
|
||||
size_t size;
|
||||
bytebuffer_makeroom(ctx, b, 8);
|
||||
size = varint_s64_encode_buf(ctx, val, b->writecursor);
|
||||
b->writecursor += size;
|
||||
return;
|
||||
{
|
||||
size_t size;
|
||||
bytebuffer_makeroom(ctx, b, 8);
|
||||
size = varint_s64_encode_buf(ctx, val, b->writecursor);
|
||||
b->writecursor += size;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a unsigned varInt to the buffer
|
||||
*/
|
||||
void
|
||||
void
|
||||
bytebuffer_append_uvarint(const RTCTX *ctx, bytebuffer_t *b, const uint64_t val)
|
||||
{
|
||||
size_t size;
|
||||
bytebuffer_makeroom(ctx, b, 8);
|
||||
size = varint_u64_encode_buf(ctx, val, b->writecursor);
|
||||
b->writecursor += size;
|
||||
return;
|
||||
{
|
||||
size_t size;
|
||||
bytebuffer_makeroom(ctx, b, 8);
|
||||
size = varint_u64_encode_buf(ctx, val, b->writecursor);
|
||||
b->writecursor += size;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -214,38 +214,38 @@ bytebuffer_append_uvarint(const RTCTX *ctx, bytebuffer_t *b, const uint64_t val)
|
|||
void
|
||||
bytebuffer_append_int(const RTCTX *ctx, bytebuffer_t *buf, const int val, int swap)
|
||||
{
|
||||
RTDEBUGF(2,"Entered bytebuffer_append_int with value %d, swap = %d", val, swap);
|
||||
|
||||
RTDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
|
||||
char *iptr = (char*)(&val);
|
||||
int i = 0;
|
||||
RTDEBUGF(2,"Entered bytebuffer_append_int with value %d, swap = %d", val, swap);
|
||||
|
||||
if ( sizeof(int) != RTWKB_INT_SIZE )
|
||||
{
|
||||
rterror(ctx, "Machine int size is not %d bytes!", RTWKB_INT_SIZE);
|
||||
}
|
||||
|
||||
bytebuffer_makeroom(ctx, buf, RTWKB_INT_SIZE);
|
||||
/* Machine/request arch mismatch, so flip byte order */
|
||||
if ( swap)
|
||||
{
|
||||
RTDEBUG(4,"Ok, let's do the swaping thing");
|
||||
for ( i = 0; i < RTWKB_INT_SIZE; i++ )
|
||||
{
|
||||
*(buf->writecursor) = iptr[RTWKB_INT_SIZE - 1 - i];
|
||||
buf->writecursor += 1;
|
||||
}
|
||||
}
|
||||
/* If machine arch and requested arch match, don't flip byte order */
|
||||
else
|
||||
{
|
||||
RTDEBUG(4,"Ok, let's do the memcopying thing");
|
||||
memcpy(buf->writecursor, iptr, RTWKB_INT_SIZE);
|
||||
buf->writecursor += RTWKB_INT_SIZE;
|
||||
}
|
||||
|
||||
RTDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
|
||||
return;
|
||||
RTDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
|
||||
char *iptr = (char*)(&val);
|
||||
int i = 0;
|
||||
|
||||
if ( sizeof(int) != RTWKB_INT_SIZE )
|
||||
{
|
||||
rterror(ctx, "Machine int size is not %d bytes!", RTWKB_INT_SIZE);
|
||||
}
|
||||
|
||||
bytebuffer_makeroom(ctx, buf, RTWKB_INT_SIZE);
|
||||
/* Machine/request arch mismatch, so flip byte order */
|
||||
if ( swap)
|
||||
{
|
||||
RTDEBUG(4,"Ok, let's do the swaping thing");
|
||||
for ( i = 0; i < RTWKB_INT_SIZE; i++ )
|
||||
{
|
||||
*(buf->writecursor) = iptr[RTWKB_INT_SIZE - 1 - i];
|
||||
buf->writecursor += 1;
|
||||
}
|
||||
}
|
||||
/* If machine arch and requested arch match, don't flip byte order */
|
||||
else
|
||||
{
|
||||
RTDEBUG(4,"Ok, let's do the memcopying thing");
|
||||
memcpy(buf->writecursor, iptr, RTWKB_INT_SIZE);
|
||||
buf->writecursor += RTWKB_INT_SIZE;
|
||||
}
|
||||
|
||||
RTDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
@ -259,73 +259,73 @@ bytebuffer_append_int(const RTCTX *ctx, bytebuffer_t *buf, const int val, int sw
|
|||
void
|
||||
bytebuffer_append_double(const RTCTX *ctx, bytebuffer_t *buf, const double val, int swap)
|
||||
{
|
||||
RTDEBUGF(2,"Entered bytebuffer_append_double with value %lf swap = %d", val, swap);
|
||||
|
||||
RTDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
|
||||
char *dptr = (char*)(&val);
|
||||
int i = 0;
|
||||
RTDEBUGF(2,"Entered bytebuffer_append_double with value %lf swap = %d", val, swap);
|
||||
|
||||
if ( sizeof(double) != RTWKB_DOUBLE_SIZE )
|
||||
{
|
||||
rterror(ctx, "Machine double size is not %d bytes!", RTWKB_DOUBLE_SIZE);
|
||||
}
|
||||
RTDEBUGF(4,"buf_start = %p and write_cursor=%p", buf->buf_start,buf->writecursor);
|
||||
char *dptr = (char*)(&val);
|
||||
int i = 0;
|
||||
|
||||
bytebuffer_makeroom(ctx, buf, RTWKB_DOUBLE_SIZE);
|
||||
|
||||
/* Machine/request arch mismatch, so flip byte order */
|
||||
if ( swap )
|
||||
{
|
||||
RTDEBUG(4,"Ok, let's do the swapping thing");
|
||||
for ( i = 0; i < RTWKB_DOUBLE_SIZE; i++ )
|
||||
{
|
||||
*(buf->writecursor) = dptr[RTWKB_DOUBLE_SIZE - 1 - i];
|
||||
buf->writecursor += 1;
|
||||
}
|
||||
}
|
||||
/* If machine arch and requested arch match, don't flip byte order */
|
||||
else
|
||||
{
|
||||
RTDEBUG(4,"Ok, let's do the memcopying thing");
|
||||
memcpy(buf->writecursor, dptr, RTWKB_DOUBLE_SIZE);
|
||||
buf->writecursor += RTWKB_DOUBLE_SIZE;
|
||||
}
|
||||
|
||||
RTDEBUG(4,"Return from bytebuffer_append_double");
|
||||
return;
|
||||
if ( sizeof(double) != RTWKB_DOUBLE_SIZE )
|
||||
{
|
||||
rterror(ctx, "Machine double size is not %d bytes!", RTWKB_DOUBLE_SIZE);
|
||||
}
|
||||
|
||||
bytebuffer_makeroom(ctx, buf, RTWKB_DOUBLE_SIZE);
|
||||
|
||||
/* Machine/request arch mismatch, so flip byte order */
|
||||
if ( swap )
|
||||
{
|
||||
RTDEBUG(4,"Ok, let's do the swapping thing");
|
||||
for ( i = 0; i < RTWKB_DOUBLE_SIZE; i++ )
|
||||
{
|
||||
*(buf->writecursor) = dptr[RTWKB_DOUBLE_SIZE - 1 - i];
|
||||
buf->writecursor += 1;
|
||||
}
|
||||
}
|
||||
/* If machine arch and requested arch match, don't flip byte order */
|
||||
else
|
||||
{
|
||||
RTDEBUG(4,"Ok, let's do the memcopying thing");
|
||||
memcpy(buf->writecursor, dptr, RTWKB_DOUBLE_SIZE);
|
||||
buf->writecursor += RTWKB_DOUBLE_SIZE;
|
||||
}
|
||||
|
||||
RTDEBUG(4,"Return from bytebuffer_append_double");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a signed varInt from the buffer
|
||||
*/
|
||||
int64_t
|
||||
int64_t
|
||||
bytebuffer_read_varint(const RTCTX *ctx, bytebuffer_t *b)
|
||||
{
|
||||
size_t size;
|
||||
int64_t val = varint_s64_decode(ctx, b->readcursor, b->buf_start + b->capacity, &size);
|
||||
b->readcursor += size;
|
||||
return val;
|
||||
size_t size;
|
||||
int64_t val = varint_s64_decode(ctx, b->readcursor, b->buf_start + b->capacity, &size);
|
||||
b->readcursor += size;
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a unsigned varInt from the buffer
|
||||
*/
|
||||
uint64_t
|
||||
uint64_t
|
||||
bytebuffer_read_uvarint(const RTCTX *ctx, bytebuffer_t *b)
|
||||
{
|
||||
size_t size;
|
||||
uint64_t val = varint_u64_decode(ctx, b->readcursor, b->buf_start + b->capacity, &size);
|
||||
b->readcursor += size;
|
||||
return val;
|
||||
{
|
||||
size_t size;
|
||||
uint64_t val = varint_u64_decode(ctx, b->readcursor, b->buf_start + b->capacity, &size);
|
||||
b->readcursor += size;
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of the current buffer
|
||||
*/
|
||||
size_t
|
||||
size_t
|
||||
bytebuffer_getlength(const RTCTX *ctx, bytebuffer_t *s)
|
||||
{
|
||||
return (size_t) (s->writecursor - s->buf_start);
|
||||
return (size_t) (s->writecursor - s->buf_start);
|
||||
}
|
||||
|
||||
|
||||
|
@ -336,23 +336,23 @@ bytebuffer_getlength(const RTCTX *ctx, bytebuffer_t *s)
|
|||
bytebuffer_t*
|
||||
bytebuffer_merge(const RTCTX *ctx, bytebuffer_t **buff_array, int nbuffers)
|
||||
{
|
||||
size_t total_size = 0, current_size, acc_size = 0;
|
||||
int i;
|
||||
for ( i = 0; i < nbuffers; i++ )
|
||||
{
|
||||
total_size += bytebuffer_getlength(ctx, buff_array[i]);
|
||||
}
|
||||
|
||||
bytebuffer_t *res = bytebuffer_create_with_size(ctx, total_size);
|
||||
for ( i = 0; i < nbuffers; i++)
|
||||
{
|
||||
current_size = bytebuffer_getlength(ctx, buff_array[i]);
|
||||
memcpy(res->buf_start+acc_size, buff_array[i]->buf_start, current_size);
|
||||
acc_size += current_size;
|
||||
}
|
||||
res->writecursor = res->buf_start + total_size;
|
||||
res->readcursor = res->buf_start;
|
||||
return res;
|
||||
size_t total_size = 0, current_size, acc_size = 0;
|
||||
int i;
|
||||
for ( i = 0; i < nbuffers; i++ )
|
||||
{
|
||||
total_size += bytebuffer_getlength(ctx, buff_array[i]);
|
||||
}
|
||||
|
||||
bytebuffer_t *res = bytebuffer_create_with_size(ctx, total_size);
|
||||
for ( i = 0; i < nbuffers; i++)
|
||||
{
|
||||
current_size = bytebuffer_getlength(ctx, buff_array[i]);
|
||||
memcpy(res->buf_start+acc_size, buff_array[i]->buf_start, current_size);
|
||||
acc_size += current_size;
|
||||
}
|
||||
res->writecursor = res->buf_start + total_size;
|
||||
res->readcursor = res->buf_start;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
size_t capacity;
|
||||
uint8_t *buf_start;
|
||||
uint8_t *writecursor;
|
||||
uint8_t *readcursor;
|
||||
size_t capacity;
|
||||
uint8_t *buf_start;
|
||||
uint8_t *writecursor;
|
||||
uint8_t *readcursor;
|
||||
}
|
||||
bytebuffer_t;
|
||||
|
||||
|
|
892
src/g_box.c
892
src/g_box.c
File diff suppressed because it is too large
Load Diff
1782
src/g_serialized.c
1782
src/g_serialized.c
File diff suppressed because it is too large
Load Diff
258
src/g_util.c
258
src/g_util.c
|
@ -31,10 +31,10 @@
|
|||
/* Structure for the type array */
|
||||
struct geomtype_struct
|
||||
{
|
||||
char *typename;
|
||||
int type;
|
||||
int z;
|
||||
int m;
|
||||
char *typename;
|
||||
int type;
|
||||
int z;
|
||||
int m;
|
||||
};
|
||||
|
||||
/* Type array. Note that the order of this array is important in
|
||||
|
@ -44,85 +44,85 @@ struct geomtype_struct
|
|||
|
||||
struct geomtype_struct geomtype_struct_array[] =
|
||||
{
|
||||
{ "GEOMETRYCOLLECTIONZM", RTCOLLECTIONTYPE, 1, 1 },
|
||||
{ "GEOMETRYCOLLECTIONZ", RTCOLLECTIONTYPE, 1, 0 },
|
||||
{ "GEOMETRYCOLLECTIONM", RTCOLLECTIONTYPE, 0, 1 },
|
||||
{ "GEOMETRYCOLLECTION", RTCOLLECTIONTYPE, 0, 0 },
|
||||
{ "GEOMETRYCOLLECTIONZM", RTCOLLECTIONTYPE, 1, 1 },
|
||||
{ "GEOMETRYCOLLECTIONZ", RTCOLLECTIONTYPE, 1, 0 },
|
||||
{ "GEOMETRYCOLLECTIONM", RTCOLLECTIONTYPE, 0, 1 },
|
||||
{ "GEOMETRYCOLLECTION", RTCOLLECTIONTYPE, 0, 0 },
|
||||
|
||||
{ "GEOMETRYZM", 0, 1, 1 },
|
||||
{ "GEOMETRYZ", 0, 1, 0 },
|
||||
{ "GEOMETRYM", 0, 0, 1 },
|
||||
{ "GEOMETRY", 0, 0, 0 },
|
||||
{ "GEOMETRYZM", 0, 1, 1 },
|
||||
{ "GEOMETRYZ", 0, 1, 0 },
|
||||
{ "GEOMETRYM", 0, 0, 1 },
|
||||
{ "GEOMETRY", 0, 0, 0 },
|
||||
|
||||
{ "POLYHEDRALSURFACEZM", RTPOLYHEDRALSURFACETYPE, 1, 1 },
|
||||
{ "POLYHEDRALSURFACEZ", RTPOLYHEDRALSURFACETYPE, 1, 0 },
|
||||
{ "POLYHEDRALSURFACEM", RTPOLYHEDRALSURFACETYPE, 0, 1 },
|
||||
{ "POLYHEDRALSURFACE", RTPOLYHEDRALSURFACETYPE, 0, 0 },
|
||||
{ "POLYHEDRALSURFACEZM", RTPOLYHEDRALSURFACETYPE, 1, 1 },
|
||||
{ "POLYHEDRALSURFACEZ", RTPOLYHEDRALSURFACETYPE, 1, 0 },
|
||||
{ "POLYHEDRALSURFACEM", RTPOLYHEDRALSURFACETYPE, 0, 1 },
|
||||
{ "POLYHEDRALSURFACE", RTPOLYHEDRALSURFACETYPE, 0, 0 },
|
||||
|
||||
{ "TINZM", RTTINTYPE, 1, 1 },
|
||||
{ "TINZ", RTTINTYPE, 1, 0 },
|
||||
{ "TINM", RTTINTYPE, 0, 1 },
|
||||
{ "TIN", RTTINTYPE, 0, 0 },
|
||||
{ "TINZM", RTTINTYPE, 1, 1 },
|
||||
{ "TINZ", RTTINTYPE, 1, 0 },
|
||||
{ "TINM", RTTINTYPE, 0, 1 },
|
||||
{ "TIN", RTTINTYPE, 0, 0 },
|
||||
|
||||
{ "CIRCULARSTRINGZM", RTCIRCSTRINGTYPE, 1, 1 },
|
||||
{ "CIRCULARSTRINGZ", RTCIRCSTRINGTYPE, 1, 0 },
|
||||
{ "CIRCULARSTRINGM", RTCIRCSTRINGTYPE, 0, 1 },
|
||||
{ "CIRCULARSTRING", RTCIRCSTRINGTYPE, 0, 0 },
|
||||
{ "CIRCULARSTRINGZM", RTCIRCSTRINGTYPE, 1, 1 },
|
||||
{ "CIRCULARSTRINGZ", RTCIRCSTRINGTYPE, 1, 0 },
|
||||
{ "CIRCULARSTRINGM", RTCIRCSTRINGTYPE, 0, 1 },
|
||||
{ "CIRCULARSTRING", RTCIRCSTRINGTYPE, 0, 0 },
|
||||
|
||||
{ "COMPOUNDCURVEZM", RTCOMPOUNDTYPE, 1, 1 },
|
||||
{ "COMPOUNDCURVEZ", RTCOMPOUNDTYPE, 1, 0 },
|
||||
{ "COMPOUNDCURVEM", RTCOMPOUNDTYPE, 0, 1 },
|
||||
{ "COMPOUNDCURVE", RTCOMPOUNDTYPE, 0, 0 },
|
||||
{ "COMPOUNDCURVEZM", RTCOMPOUNDTYPE, 1, 1 },
|
||||
{ "COMPOUNDCURVEZ", RTCOMPOUNDTYPE, 1, 0 },
|
||||
{ "COMPOUNDCURVEM", RTCOMPOUNDTYPE, 0, 1 },
|
||||
{ "COMPOUNDCURVE", RTCOMPOUNDTYPE, 0, 0 },
|
||||
|
||||
{ "CURVEPOLYGONZM", RTCURVEPOLYTYPE, 1, 1 },
|
||||
{ "CURVEPOLYGONZ", RTCURVEPOLYTYPE, 1, 0 },
|
||||
{ "CURVEPOLYGONM", RTCURVEPOLYTYPE, 0, 1 },
|
||||
{ "CURVEPOLYGON", RTCURVEPOLYTYPE, 0, 0 },
|
||||
{ "CURVEPOLYGONZM", RTCURVEPOLYTYPE, 1, 1 },
|
||||
{ "CURVEPOLYGONZ", RTCURVEPOLYTYPE, 1, 0 },
|
||||
{ "CURVEPOLYGONM", RTCURVEPOLYTYPE, 0, 1 },
|
||||
{ "CURVEPOLYGON", RTCURVEPOLYTYPE, 0, 0 },
|
||||
|
||||
{ "MULTICURVEZM", RTMULTICURVETYPE, 1, 1 },
|
||||
{ "MULTICURVEZ", RTMULTICURVETYPE, 1, 0 },
|
||||
{ "MULTICURVEM", RTMULTICURVETYPE, 0, 1 },
|
||||
{ "MULTICURVE", RTMULTICURVETYPE, 0, 0 },
|
||||
{ "MULTICURVEZM", RTMULTICURVETYPE, 1, 1 },
|
||||
{ "MULTICURVEZ", RTMULTICURVETYPE, 1, 0 },
|
||||
{ "MULTICURVEM", RTMULTICURVETYPE, 0, 1 },
|
||||
{ "MULTICURVE", RTMULTICURVETYPE, 0, 0 },
|
||||
|
||||
{ "MULTISURFACEZM", RTMULTISURFACETYPE, 1, 1 },
|
||||
{ "MULTISURFACEZ", RTMULTISURFACETYPE, 1, 0 },
|
||||
{ "MULTISURFACEM", RTMULTISURFACETYPE, 0, 1 },
|
||||
{ "MULTISURFACE", RTMULTISURFACETYPE, 0, 0 },
|
||||
{ "MULTISURFACEZM", RTMULTISURFACETYPE, 1, 1 },
|
||||
{ "MULTISURFACEZ", RTMULTISURFACETYPE, 1, 0 },
|
||||
{ "MULTISURFACEM", RTMULTISURFACETYPE, 0, 1 },
|
||||
{ "MULTISURFACE", RTMULTISURFACETYPE, 0, 0 },
|
||||
|
||||
{ "MULTILINESTRINGZM", RTMULTILINETYPE, 1, 1 },
|
||||
{ "MULTILINESTRINGZ", RTMULTILINETYPE, 1, 0 },
|
||||
{ "MULTILINESTRINGM", RTMULTILINETYPE, 0, 1 },
|
||||
{ "MULTILINESTRING", RTMULTILINETYPE, 0, 0 },
|
||||
{ "MULTILINESTRINGZM", RTMULTILINETYPE, 1, 1 },
|
||||
{ "MULTILINESTRINGZ", RTMULTILINETYPE, 1, 0 },
|
||||
{ "MULTILINESTRINGM", RTMULTILINETYPE, 0, 1 },
|
||||
{ "MULTILINESTRING", RTMULTILINETYPE, 0, 0 },
|
||||
|
||||
{ "MULTIPOLYGONZM", RTMULTIPOLYGONTYPE, 1, 1 },
|
||||
{ "MULTIPOLYGONZ", RTMULTIPOLYGONTYPE, 1, 0 },
|
||||
{ "MULTIPOLYGONM", RTMULTIPOLYGONTYPE, 0, 1 },
|
||||
{ "MULTIPOLYGON", RTMULTIPOLYGONTYPE, 0, 0 },
|
||||
{ "MULTIPOLYGONZM", RTMULTIPOLYGONTYPE, 1, 1 },
|
||||
{ "MULTIPOLYGONZ", RTMULTIPOLYGONTYPE, 1, 0 },
|
||||
{ "MULTIPOLYGONM", RTMULTIPOLYGONTYPE, 0, 1 },
|
||||
{ "MULTIPOLYGON", RTMULTIPOLYGONTYPE, 0, 0 },
|
||||
|
||||
{ "MULTIPOINTZM", RTMULTIPOINTTYPE, 1, 1 },
|
||||
{ "MULTIPOINTZ", RTMULTIPOINTTYPE, 1, 0 },
|
||||
{ "MULTIPOINTM", RTMULTIPOINTTYPE, 0, 1 },
|
||||
{ "MULTIPOINT", RTMULTIPOINTTYPE, 0, 0 },
|
||||
{ "MULTIPOINTZM", RTMULTIPOINTTYPE, 1, 1 },
|
||||
{ "MULTIPOINTZ", RTMULTIPOINTTYPE, 1, 0 },
|
||||
{ "MULTIPOINTM", RTMULTIPOINTTYPE, 0, 1 },
|
||||
{ "MULTIPOINT", RTMULTIPOINTTYPE, 0, 0 },
|
||||
|
||||
{ "LINESTRINGZM", RTLINETYPE, 1, 1 },
|
||||
{ "LINESTRINGZ", RTLINETYPE, 1, 0 },
|
||||
{ "LINESTRINGM", RTLINETYPE, 0, 1 },
|
||||
{ "LINESTRING", RTLINETYPE, 0, 0 },
|
||||
{ "LINESTRINGZM", RTLINETYPE, 1, 1 },
|
||||
{ "LINESTRINGZ", RTLINETYPE, 1, 0 },
|
||||
{ "LINESTRINGM", RTLINETYPE, 0, 1 },
|
||||
{ "LINESTRING", RTLINETYPE, 0, 0 },
|
||||
|
||||
{ "TRIANGLEZM", RTTRIANGLETYPE, 1, 1 },
|
||||
{ "TRIANGLEZ", RTTRIANGLETYPE, 1, 0 },
|
||||
{ "TRIANGLEM", RTTRIANGLETYPE, 0, 1 },
|
||||
{ "TRIANGLE", RTTRIANGLETYPE, 0, 0 },
|
||||
{ "TRIANGLEZM", RTTRIANGLETYPE, 1, 1 },
|
||||
{ "TRIANGLEZ", RTTRIANGLETYPE, 1, 0 },
|
||||
{ "TRIANGLEM", RTTRIANGLETYPE, 0, 1 },
|
||||
{ "TRIANGLE", RTTRIANGLETYPE, 0, 0 },
|
||||
|
||||
{ "POLYGONZM", RTPOLYGONTYPE, 1, 1 },
|
||||
{ "POLYGONZ", RTPOLYGONTYPE, 1, 0 },
|
||||
{ "POLYGONM", RTPOLYGONTYPE, 0, 1 },
|
||||
{ "POLYGON", RTPOLYGONTYPE, 0, 0 },
|
||||
{ "POLYGONZM", RTPOLYGONTYPE, 1, 1 },
|
||||
{ "POLYGONZ", RTPOLYGONTYPE, 1, 0 },
|
||||
{ "POLYGONM", RTPOLYGONTYPE, 0, 1 },
|
||||
{ "POLYGON", RTPOLYGONTYPE, 0, 0 },
|
||||
|
||||
{ "POINTZM", RTPOINTTYPE, 1, 1 },
|
||||
{ "POINTZ", RTPOINTTYPE, 1, 0 },
|
||||
{ "POINTM", RTPOINTTYPE, 0, 1 },
|
||||
{ "POINT", RTPOINTTYPE, 0, 0 }
|
||||
{ "POINTZM", RTPOINTTYPE, 1, 1 },
|
||||
{ "POINTZ", RTPOINTTYPE, 1, 0 },
|
||||
{ "POINTM", RTPOINTTYPE, 0, 1 },
|
||||
{ "POINT", RTPOINTTYPE, 0, 0 }
|
||||
|
||||
};
|
||||
#define GEOMTYPE_STRUCT_ARRAY_LEN (sizeof geomtype_struct_array/sizeof(struct geomtype_struct))
|
||||
|
@ -138,21 +138,21 @@ const char dumb_upper_map[128] = "..............................................
|
|||
|
||||
static char dump_toupper(const RTCTX *ctx, int in)
|
||||
{
|
||||
if ( in < 0 || in > 127 )
|
||||
return '.';
|
||||
return dumb_upper_map[in];
|
||||
if ( in < 0 || in > 127 )
|
||||
return '.';
|
||||
return dumb_upper_map[in];
|
||||
}
|
||||
|
||||
uint8_t gflags(const RTCTX *ctx, int hasz, int hasm, int geodetic)
|
||||
{
|
||||
uint8_t flags = 0;
|
||||
if ( hasz )
|
||||
RTFLAGS_SET_Z(flags, 1);
|
||||
if ( hasm )
|
||||
RTFLAGS_SET_M(flags, 1);
|
||||
if ( geodetic )
|
||||
RTFLAGS_SET_GEODETIC(flags, 1);
|
||||
return flags;
|
||||
uint8_t flags = 0;
|
||||
if ( hasz )
|
||||
RTFLAGS_SET_Z(flags, 1);
|
||||
if ( hasm )
|
||||
RTFLAGS_SET_M(flags, 1);
|
||||
if ( geodetic )
|
||||
RTFLAGS_SET_GEODETIC(flags, 1);
|
||||
return flags;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,68 +163,68 @@ uint8_t gflags(const RTCTX *ctx, int hasz, int hasm, int geodetic)
|
|||
*/
|
||||
int geometry_type_from_string(const RTCTX *ctx, const char *str, uint8_t *type, int *z, int *m)
|
||||
{
|
||||
char *tmpstr;
|
||||
int tmpstartpos, tmpendpos;
|
||||
int i;
|
||||
char *tmpstr;
|
||||
int tmpstartpos, tmpendpos;
|
||||
int i;
|
||||
|
||||
assert(str);
|
||||
assert(type);
|
||||
assert(z);
|
||||
assert(m);
|
||||
assert(str);
|
||||
assert(type);
|
||||
assert(z);
|
||||
assert(m);
|
||||
|
||||
/* Initialize. */
|
||||
*type = 0;
|
||||
*z = 0;
|
||||
*m = 0;
|
||||
/* Initialize. */
|
||||
*type = 0;
|
||||
*z = 0;
|
||||
*m = 0;
|
||||
|
||||
/* Locate any leading/trailing spaces */
|
||||
tmpstartpos = 0;
|
||||
for (i = 0; i < strlen(str); i++)
|
||||
{
|
||||
if (str[i] != ' ')
|
||||
{
|
||||
tmpstartpos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Locate any leading/trailing spaces */
|
||||
tmpstartpos = 0;
|
||||
for (i = 0; i < strlen(str); i++)
|
||||
{
|
||||
if (str[i] != ' ')
|
||||
{
|
||||
tmpstartpos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tmpendpos = strlen(str) - 1;
|
||||
for (i = strlen(str) - 1; i >= 0; i--)
|
||||
{
|
||||
if (str[i] != ' ')
|
||||
{
|
||||
tmpendpos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tmpendpos = strlen(str) - 1;
|
||||
for (i = strlen(str) - 1; i >= 0; i--)
|
||||
{
|
||||
if (str[i] != ' ')
|
||||
{
|
||||
tmpendpos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy and convert to upper case for comparison */
|
||||
tmpstr = rtalloc(ctx, tmpendpos - tmpstartpos + 2);
|
||||
for (i = tmpstartpos; i <= tmpendpos; i++)
|
||||
tmpstr[i - tmpstartpos] = dump_toupper(ctx, str[i]);
|
||||
/* Copy and convert to upper case for comparison */
|
||||
tmpstr = rtalloc(ctx, tmpendpos - tmpstartpos + 2);
|
||||
for (i = tmpstartpos; i <= tmpendpos; i++)
|
||||
tmpstr[i - tmpstartpos] = dump_toupper(ctx, str[i]);
|
||||
|
||||
/* Add NULL to terminate */
|
||||
tmpstr[i - tmpstartpos] = '\0';
|
||||
/* Add NULL to terminate */
|
||||
tmpstr[i - tmpstartpos] = '\0';
|
||||
|
||||
/* Now check for the type */
|
||||
for (i = 0; i < GEOMTYPE_STRUCT_ARRAY_LEN; i++)
|
||||
{
|
||||
if (!strcmp(tmpstr, geomtype_struct_array[i].typename))
|
||||
{
|
||||
*type = geomtype_struct_array[i].type;
|
||||
*z = geomtype_struct_array[i].z;
|
||||
*m = geomtype_struct_array[i].m;
|
||||
/* Now check for the type */
|
||||
for (i = 0; i < GEOMTYPE_STRUCT_ARRAY_LEN; i++)
|
||||
{
|
||||