]> granicus.if.org Git - postgis/commitdiff
Ensure calls to lwgeom->type use type of uint8_t
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 28 Oct 2011 17:01:02 +0000 (17:01 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 28 Oct 2011 17:01:02 +0000 (17:01 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8027 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/g_util.c
liblwgeom/liblwgeom.h.in
liblwgeom/liblwgeom_internal.h
liblwgeom/lwgeodetic.c
liblwgeom/lwgeom.c
liblwgeom/lwgeom_api.c
liblwgeom/lwutil.c
loader/pgsql2shp-core.c
postgis/gserialized_typmod.c
postgis/lwgeom_debug.c
postgis/lwgeom_functions_basic.c

index 08e8d255c4347dad0a25369a6a493fba986ab372..32c6240a29ed98e503f3300ba013f721739bab82 100644 (file)
@@ -131,7 +131,7 @@ uint8_t gflags(int hasz, int hasm, int geodetic)
 * 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;
index d2e338cdcd1801de20f3fbb5b2ab7f0b9ead8ea7..0e8cf2a60ee7dac1b128b85cbe7d6e8c2b8aacd8 100644 (file)
 #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.
  */
@@ -659,16 +668,22 @@ extern int lwgeom_is_collection(const LWGEOM *lwgeom);
 /** 
 * 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);
 
 
@@ -1053,8 +1068,6 @@ extern float  next_float_up(double d);
 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))
@@ -1578,7 +1591,7 @@ extern int gbox_same(const GBOX *g1, const GBOX *g2);
 * 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.
index 1f5795e7f2cae5a6dc1d988968330483cbf4aac9..27ab73323a90de8743dac919c493fb703049f1a8 100644 (file)
 #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
index b6bdd6a70e248f22343cc086d46678630b667c97..dfd98364350fab82155bf4b383d1733241737e0a 100644 (file)
@@ -1789,7 +1789,7 @@ double lwgeom_area_sphere(const LWGEOM *lwgeom, const SPHEROID *spheroid)
 */
 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;
 
index f3adc37c07859bb92e6dd2096c98e15b277eb054..3c5cd5fe0fdf4892dd534392175bc79a2dd76f3b 100644 (file)
@@ -836,7 +836,7 @@ lwgeom_is_collection(const LWGEOM *geom)
 
 /** 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)
@@ -862,7 +862,7 @@ lwtype_is_collection(int 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)
        {
index 659a3d7864ccb607ea9368d4482e2c8d1a507080..74bf0fb964b3ec312e381452f4df9ac0871da896 100644 (file)
@@ -796,7 +796,7 @@ ptarray_isccw(const POINTARRAY *pa)
 
 
 const char *
-lwgeom_typeflags(uint8_t flags)
+lwtype_zmflags(uint8_t flags)
 {
        static char tflags[4];
        int flagno=0;
index ff55fcd005389050317e107437a28428d7505b5e..7581108e91f3dc67ceff50190e5f94f5c8b7242f 100644 (file)
@@ -3,7 +3,6 @@
 #include <stdarg.h>
 #include <string.h>
 
-
 /* Global variables */
 #include "../postgis_config.h"
 #include "liblwgeom_internal.h"
@@ -41,7 +40,6 @@ static char *lwgeomTypeName[] =
        "Tin"
 };
 
-
 /*
  * lwnotice/lwerror handlers
  *
@@ -208,7 +206,8 @@ void lwgeom_install_default_allocators(void)
 }
 
 
-const char* lwtype_name(uint8_t type)
+const char* 
+lwtype_name(uint8_t type)
 {
        if ( type > 15 )
        {
index 5dbf45a9f608aea8ace517fec37ef82ec588a298..c0edc6298bdaf0802528b5679d6df31a3f8ea7d8 100644 (file)
@@ -947,7 +947,8 @@ getTableInfo(SHPDUMPERSTATE *state)
                   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;
 
index a1513d311bd842e4039c48db2d70f4ef9fc9f81a..e143d3171adcc4b29e28302c3113a8c7a27b7a0a 100644 (file)
@@ -221,7 +221,7 @@ static uint32 gserialized_typmod_in(ArrayType *arr, int is_geography)
                if ( i == 0 ) /* TYPE */
                {
                        char *s = DatumGetCString(elem_values[i]);
-                       int type = 0;
+                       uint8_t type = 0;
                        int z = 0;
                        int m = 0;
 
index 615001e74d296972fe71edd6521ace9dd31b5a59..a07166bfe05d58efa53689e7c449b79921b9f9b6 100644 (file)
@@ -66,7 +66,7 @@ lwpoint_summary(LWPOINT *point, int offset)
 
        sprintf(result, "%*.s%s[%s]\n",
                offset, pad, lwtype_name(point->type),
-               lwgeom_typeflags(point->flags));
+               lwtype_zmflags(point->flags));
        return result;
 }
 
@@ -80,7 +80,7 @@ lwline_summary(LWLINE *line, int offset)
 
        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;
 }
@@ -101,7 +101,7 @@ lwcollection_summary(LWCOLLECTION *col, int offset)
 
        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++)
@@ -136,7 +136,7 @@ lwpoly_summary(LWPOLY *poly, int offset)
 
        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++)
index f4af9ede156fa3daedd34dd6049f4cc6e4d2ad43..7f5024ad89b4de250009d1ee93f7878cc80786a6 100644 (file)
@@ -1049,7 +1049,8 @@ Datum LWGEOM_collect(PG_FUNCTION_ARGS)
 {
        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.");
@@ -1185,7 +1186,7 @@ Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS)
                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));