* Type == 0 in the case of the string "GEOMETRY" or "GEOGRAPHY".
* Return LW_SUCCESS for success.
*/
-int geometry_type_from_string(const char *str, int *type, int *z, int *m)
+int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
{
char *tmpstr;
int tmpstartpos, tmpendpos;
#define SRID_UNKNOWN 0
#define SRID_IS_UNKNOWN(x) ((int)x<=0)
+/**
+* Return a valid SRID from an arbitrary integer
+* Raises a notice if what comes out is different from
+* what went in.
+* Raises an error if SRID value is out of bounds.
+*/
+extern int clamp_srid(int srid);
+
+
/**
* Global functions for memory/logging handlers.
*/
/**
* Determine whether a type number is a collection or not
*/
-extern int lwtype_is_collection(int type);
+extern int lwtype_is_collection(uint8_t type);
/**
* Given an lwtype number, what homogeneous collection can hold it?
*/
-int lwtype_get_collectiontype(int type);
+extern int lwtype_get_collectiontype(uint8_t type);
-/* Return a char string with ASCII versionf of type flags */
-extern const char *lwgeom_typeflags(uint8_t type);
+/**
+* Return a char string with ASCII version of type flags
+*/
+extern const char *lwtype_zmflags(uint8_t type);
+/**
+* Return the type name string associated with a type number
+* (e.g. Point, LineString, Polygon)
+*/
extern const char *lwtype_name(uint8_t type);
extern double next_double_down(float d);
extern double next_double_up(float d);
-extern int geometry_type_from_string(const char *str, int *type, int *z, int *m);
-
#define LW_MAX(a,b) ((a) > (b) ? (a) : (b))
#define LW_MIN(a,b) ((a) <= (b) ? (a) : (b))
#define LW_ABS(a) ((a) < (0) ? -(a) : (a))
* Utility function to get type number from string. For example, a string 'POINTZ'
* would return type of 1 and z of 1 and m of 0. Valid
*/
-extern int geometry_type_from_string(const char *str, int *type, int *z, int *m);
+extern int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m);
/**
* Calculate required memory segment to contain a serialized form of the LWGEOM.
#define SIZE_SET(varsize, size) (((varsize) & 0x00000003)|(((size) & 0x3FFFFFFF) << 2 ))
-/*
- * Return a valid srid from an arbitrary integerj
- * Raises a notice if what comes out is different from
- * what went in.
- * Raises an error if srid value is out of bounds.
- */
-int clamp_srid(int srid);
-
/*
* Internal prototypes
*/
-
/* Machine endianness */
#define XDR 0
#define NDR 1
*/
double lwgeom_distance_spheroid(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2, const SPHEROID *spheroid, double tolerance)
{
- int type1, type2;
+ uint8_t type1, type2;
int check_intersection = LW_FALSE;
GBOX gbox1, gbox2;
/** Return TRUE if the geometry may contain sub-geometries, i.e. it is a MULTI* or COMPOUNDCURVE */
int
-lwtype_is_collection(int type)
+lwtype_is_collection(uint8_t type)
{
switch (type)
* Given an lwtype number, what homogeneous collection can hold it?
*/
int
-lwtype_get_collectiontype(int type)
+lwtype_get_collectiontype(uint8_t type)
{
switch (type)
{
const char *
-lwgeom_typeflags(uint8_t flags)
+lwtype_zmflags(uint8_t flags)
{
static char tflags[4];
int flagno=0;
#include <stdarg.h>
#include <string.h>
-
/* Global variables */
#include "../postgis_config.h"
#include "liblwgeom_internal.h"
"Tin"
};
-
/*
* lwnotice/lwerror handlers
*
}
-const char* lwtype_name(uint8_t type)
+const char*
+lwtype_name(uint8_t type)
{
if ( type > 15 )
{
enough to up-convert the non-MULTI geometry to a MULTI in this case. */
int dummy, i;
- int type = 0, typefound = 0, typemismatch = 0;
+ uint8_t type = 0;
+ int typefound = 0, typemismatch = 0;
state->rowcount = 0;
if ( i == 0 ) /* TYPE */
{
char *s = DatumGetCString(elem_values[i]);
- int type = 0;
+ uint8_t type = 0;
int z = 0;
int m = 0;
sprintf(result, "%*.s%s[%s]\n",
offset, pad, lwtype_name(point->type),
- lwgeom_typeflags(point->flags));
+ lwtype_zmflags(point->flags));
return result;
}
sprintf(result, "%*.s%s[%s] with %d points\n",
offset, pad, lwtype_name(line->type),
- lwgeom_typeflags(line->flags),
+ lwtype_zmflags(line->flags),
line->points->npoints);
return result;
}
sprintf(result, "%*.s%s[%s] with %d elements\n",
offset, pad, lwtype_name(col->type),
- lwgeom_typeflags(col->flags),
+ lwtype_zmflags(col->flags),
col->ngeoms);
for (i=0; i<col->ngeoms; i++)
sprintf(result, "%*.s%s[%s] with %i rings\n",
offset, pad, lwtype_name(poly->type),
- lwgeom_typeflags(poly->flags),
+ lwtype_zmflags(poly->flags),
poly->nrings);
for (i=0; i<poly->nrings; i++)
{
PG_LWGEOM *pglwgeom1, *pglwgeom2, *result;
LWGEOM *lwgeoms[2], *outlwg;
- uint32 type1, type2, outtype;
+ uint32 type1, type2;
+ uint8_t outtype;
int srid;
POSTGIS_DEBUG(2, "LWGEOM_collect called.");
if ((bitmap && (*bitmap & bitmask) != 0) || !bitmap)
{
PG_LWGEOM *geom = (PG_LWGEOM *)(ARR_DATA_PTR(array)+offset);
- uint32 intype = pglwgeom_get_type(geom);
+ uint8_t intype = pglwgeom_get_type(geom);
offset += INTALIGN(VARSIZE(geom));