static void do_test_lwgeom_effectivearea(POINTARRAY *pa,double *the_areas,int avoid_collaps)
{
- int i;
+ uint32_t i;
EFFECTIVE_AREAS *ea;
ea=initiate_effectivearea(pa);
{
POINT3D A1, A2, B1, B2;
GEOGRAPHIC_POINT g;
- int rv;
+ uint32_t rv;
/* Covers case, end-to-end intersection */
line2pts("LINESTRING(50 -10.999999999999998224, -10.0 50.0)", &A1, &A2);
static void test_geos_noop(void)
{
- int i;
+ size_t i;
char *ewkt[] =
{
GSERIALIZED *g;
char *in_ewkt;
char *out_ewkt;
- int i = 0;
+ size_t i = 0;
char *ewkt[] =
{
*/
static void test_lwgeom_clone(void)
{
- int i;
+ size_t i;
char *ewkt[] =
{
uint32_t expected_collapsed_ids2[] = { 8, 0, 0, 0, 7, 0, 8, 7, 8, 7 };
collapsed_ids = UF_get_collapsed_cluster_ids(uf, is_in_cluster);
- int i;
+ uint32_t i;
for (i = 0; i < uf->N; i++)
{
if (is_in_cluster[i])
static POINTARRAY * ptarray_set_effective_area(POINTARRAY *inpts,int avoid_collaps,int set_area, double trshld)
{
LWDEBUG(2, "Entered ptarray_set_effective_area");
- int p;
+ uint32_t p;
POINT4D pt;
EFFECTIVE_AREAS *ea;
POINTARRAY *opts;
static LWPOLY* lwpoly_set_effective_area(const LWPOLY *ipoly,int set_area, double trshld)
{
LWDEBUG(2, "Entered lwpoly_set_effective_area");
- int i;
+ uint32_t i;
int set_m;
int avoid_collapse=4;
if(set_area)
static LWCOLLECTION* lwcollection_set_effective_area(const LWCOLLECTION *igeom,int set_area, double trshld)
{
LWDEBUG(2, "Entered lwcollection_set_effective_area");
- int i;
+ uint32_t i;
int set_m;
if(set_area)
set_m=1;
int ptarray_calculate_gbox_cartesian(const POINTARRAY *pa, GBOX *gbox )
{
- int i;
+ uint32_t i;
POINT4D p;
int has_z, has_m;
uint8_t flags = gflags(FLAGS_GET_Z(curve->flags), FLAGS_GET_M(curve->flags), 0);
GBOX tmp;
POINT4D p1, p2, p3;
- int i;
+ uint32_t i;
if ( ! curve ) return LW_FAILURE;
if ( curve->points->npoints < 3 ) return LW_FAILURE;
static int lwcollection_calculate_gbox_cartesian(LWCOLLECTION *coll, GBOX *gbox)
{
GBOX subbox;
- int i;
+ uint32_t i;
int result = LW_FAILURE;
int first = LW_TRUE;
assert(coll);
static size_t gserialized_from_lwpoly_size(const LWPOLY *poly)
{
size_t size = 4; /* Type number. */
- int i = 0;
+ uint32_t i = 0;
assert(poly);
static size_t gserialized_from_lwcollection_size(const LWCOLLECTION *col)
{
size_t size = 4; /* Type number. */
- int i = 0;
+ uint32_t i = 0;
assert(col);
static size_t gserialized_from_lwpoly(const LWPOLY *poly, uint8_t *buf)
{
- int i;
+ uint32_t i;
uint8_t *loc;
int ptsize;
int type = POLYGONTYPE;
{
size_t subsize = 0;
uint8_t *loc;
- int i;
+ uint32_t i;
int type;
assert(coll);
LWPOLY *poly;
uint8_t *ordinate_ptr;
uint32_t nrings = 0;
- int i = 0;
+ uint32_t i = 0;
assert(data_ptr);
uint8_t *start_ptr = data_ptr;
LWCOLLECTION *collection;
uint32_t ngeoms = 0;
- int i = 0;
+ uint32_t i = 0;
assert(data_ptr);
int geometry_type_from_string(const char *str, uint8_t *type, int *z, int *m)
{
char *tmpstr;
- int tmpstartpos, tmpendpos;
- int i;
+ size_t tmpstartpos, tmpendpos;
+ size_t i;
assert(str);
assert(type);
}
tmpendpos = strlen(str) - 1;
- for (i = strlen(str) - 1; i >= 0; i--)
+ for (i = strlen(str) - 1; i != 0; i--)
{
if (str[i] != ' ')
{
/* Use FLAGS_* 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 */
+ uint32_t npoints; /* how many points we are currently storing */
+ uint32_t maxpoints; /* how many points we have space for in serialized_pointlist */
}
POINTARRAY;
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int nrings; /* how many rings we are currently storing */
- int maxrings; /* how many rings we have space for in **rings */
+ uint32_t nrings; /* how many rings we are currently storing */
+ uint32_t maxrings; /* how many rings we have space for in **rings */
POINTARRAY **rings; /* list of rings (list of points) */
}
LWPOLY; /* "light-weight polygon" */
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int ngeoms; /* how many geometries we are currently storing */
- int maxgeoms; /* how many geometries we have space for in **geoms */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
LWPOINT **geoms;
}
LWMPOINT;
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int ngeoms; /* how many geometries we are currently storing */
- int maxgeoms; /* how many geometries we have space for in **geoms */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
LWLINE **geoms;
}
LWMLINE;
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int ngeoms; /* how many geometries we are currently storing */
- int maxgeoms; /* how many geometries we have space for in **geoms */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
LWPOLY **geoms;
}
LWMPOLY;
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int ngeoms; /* how many geometries we are currently storing */
- int maxgeoms; /* how many geometries we have space for in **geoms */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
LWGEOM **geoms;
}
LWCOLLECTION;
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int ngeoms; /* how many geometries we are currently storing */
- int maxgeoms; /* how many geometries we have space for in **geoms */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
LWGEOM **geoms;
}
LWCOMPOUND; /* "light-weight compound line" */
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int nrings; /* how many rings we are currently storing */
- int maxrings; /* how many rings we have space for in **rings */
+ uint32_t nrings; /* how many rings we are currently storing */
+ uint32_t maxrings; /* how many rings we have space for in **rings */
LWGEOM **rings; /* list of rings (list of points) */
}
LWCURVEPOLY; /* "light-weight polygon" */
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int ngeoms; /* how many geometries we are currently storing */
- int maxgeoms; /* how many geometries we have space for in **geoms */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
LWGEOM **geoms;
}
LWMCURVE;
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int ngeoms; /* how many geometries we are currently storing */
- int maxgeoms; /* how many geometries we have space for in **geoms */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
LWGEOM **geoms;
}
LWMSURFACE;
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int ngeoms; /* how many geometries we are currently storing */
- int maxgeoms; /* how many geometries we have space for in **geoms */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
LWPOLY **geoms;
}
LWPSURFACE;
uint8_t flags;
GBOX *bbox;
int32_t srid;
- int ngeoms; /* how many geometries we are currently storing */
- int maxgeoms; /* how many geometries we have space for in **geoms */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
LWTRIANGLE **geoms;
}
LWTIN;
/**
* Given an lwtype number, what homogeneous collection can hold it?
*/
-extern int lwtype_get_collectiontype(uint8_t type);
+extern uint32_t lwtype_get_collectiontype(uint8_t type);
/**
* Return the type name string associated with a type number
* 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(const POINTARRAY *pa, int n);
+extern POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n);
/*
* copies a point from the point array into the parameter point
* 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 int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point);
+extern int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *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 POINT3DZ getPoint3dz(const POINTARRAY *pa, int n);
-extern POINT3DM getPoint3dm(const POINTARRAY *pa, int n);
+extern POINT3DZ getPoint3dz(const POINTARRAY *pa, uint32_t n);
+extern POINT3DM getPoint3dm(const POINTARRAY *pa, uint32_t 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 int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point);
-extern int getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *point);
+extern int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point);
+extern int getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *point);
/*
* z value (if present is not returned)
* NOTE: point is a real POINT3D *not* a pointer
*/
-extern POINT2D getPoint2d(const POINTARRAY *pa, int n);
+extern POINT2D getPoint2d(const POINTARRAY *pa, uint32_t 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 int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point);
+extern int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point);
/**
* Returns a POINT2D pointer into the POINTARRAY serialized_ptlist,
* and declared const because you aren't allowed to muck with the
* values, only read them.
*/
-extern const POINT2D* getPoint2d_cp(const POINTARRAY *pa, int n);
+extern const POINT2D* getPoint2d_cp(const POINTARRAY *pa, uint32_t n);
/**
* Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist,
* and declared const because you aren't allowed to muck with the
* values, only read them.
*/
-extern const POINT3DZ* getPoint3dz_cp(const POINTARRAY *pa, int n);
+extern const POINT3DZ* getPoint3dz_cp(const POINTARRAY *pa, uint32_t n);
/**
* Returns a POINT4D pointer into the POINTARRAY serialized_ptlist,
* and declared const because you aren't allowed to muck with the
* values, only read them.
*/
-extern const POINT4D* getPoint4d_cp(const POINTARRAY *pa, int n);
+extern const POINT4D* getPoint4d_cp(const POINTARRAY *pa, uint32_t n);
/*
* set point N to the given value
*
* N must be a valid point index
*/
-extern void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d);
+extern void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d);
/*
* get a pointer to nth point of a POINTARRAY
* WARNING: Don't cast this to a POINT !
* it would not be reliable due to memory alignment constraints
*/
-extern uint8_t *getPoint_internal(const POINTARRAY *pa, int n);
+extern uint8_t *getPoint_internal(const POINTARRAY *pa, uint32_t n);
/*
* size of point represeneted in the POINTARRAY
* 16 for 2d, 24 for 3d, 32 for 4d
*/
-extern int ptarray_point_size(const POINTARRAY *pa);
+extern size_t ptarray_point_size(const POINTARRAY *pa);
/**
* Insert a point into an existing #POINTARRAY. Zero
* is the index of the start of the array.
*/
-extern int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where);
+extern int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where);
/**
* Remove a point from an existing #POINTARRAY. Zero
* is the index of the start of the array.
*/
-extern int ptarray_remove_point(POINTARRAY *pa, int where);
+extern int ptarray_remove_point(POINTARRAY *pa, uint32_t where);
/**
* @brief Add a point in a pointarray.
/**
* Add a LWPOINT to an LWLINE
*/
-extern int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where);
+extern int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, uint32_t where);
/**
* Interpolate one or more points along a line
extern double lwgeom_perimeter_2d(const LWGEOM *geom);
extern int lwgeom_dimension(const LWGEOM *geom);
-extern LWPOINT* lwline_get_lwpoint(const LWLINE *line, int where);
-extern LWPOINT* lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, int where);
+extern LWPOINT* lwline_get_lwpoint(const LWLINE *line, uint32_t where);
+extern LWPOINT* lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, uint32_t where);
extern LWPOINT* lwcompound_get_startpoint(const LWCOMPOUND *lwcmp);
extern LWPOINT* lwcompound_get_endpoint(const LWCOMPOUND *lwcmp);
-extern LWPOINT* lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, int where);
+extern LWPOINT* lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, uint32_t where);
extern double ptarray_length_2d(const POINTARRAY *pts);
extern int pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring);
/**
* Count the total number of vertices in any #LWGEOM.
*/
-extern int lwgeom_count_vertices(const LWGEOM *geom);
+extern uint32_t lwgeom_count_vertices(const LWGEOM *geom);
/**
* Count the total number of rings in any #LWGEOM. Multipolygons
* and other collections get counted, not the same as OGC st_numrings.
*/
-extern int lwgeom_count_rings(const LWGEOM *geom);
+extern uint32_t lwgeom_count_rings(const LWGEOM *geom);
/**
* Return true or false depending on whether a geometry has
/*
* Point density functions
*/
-extern LWMPOINT *lwpoly_to_points(const LWPOLY *poly, int npoints);
-extern LWMPOINT *lwmpoly_to_points(const LWMPOLY *mpoly, int npoints);
-extern LWMPOINT *lwgeom_to_points(const LWGEOM *lwgeom, int npoints);
+extern LWMPOINT *lwpoly_to_points(const LWPOLY *poly, uint32_t npoints);
+extern LWMPOINT *lwmpoly_to_points(const LWMPOLY *mpoly, uint32_t npoints);
+extern LWMPOINT *lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints);
/*
* Geometric median
* New function to read doubles directly from the double* coordinate array
* of an aligned lwgeom #POINTARRAY (built by de-serializing a #GSERIALIZED).
*/
-extern int getPoint2d_p_ro(const POINTARRAY *pa, int n, POINT2D **point);
+extern int getPoint2d_p_ro(const POINTARRAY *pa, uint32_t n, POINT2D **point);
/**
* Calculate geodetic (x/y/z) box and add values to gbox. Return #LW_SUCCESS on success.
typedef struct struct_lwgeom_parser_result
{
const char *wkinput; /* Copy of pointer to input WKT/WKB */
- uint8_t *serialized_lwgeom; /* Pointer to serialized LWGEOM */
- int size; /* Size of serialized LWGEOM in bytes */
+ uint8_t *serialized_lwgeom; /* Pointer to serialized LWGEOM */
+ size_t size; /* Size of serialized LWGEOM in bytes */
LWGEOM *geom; /* Pointer to LWGEOM struct */
const char *message; /* Error/warning message */
int errcode; /* Error/warning number */
{
uint8_t *serialized_lwgeom; /* Copy of pointer to input serialized LWGEOM */
char *wkoutput; /* Pointer to WKT or WKB output */
- int size; /* Size of serialized LWGEOM in bytes */
+ size_t size; /* Size of serialized LWGEOM in bytes */
const char *message; /* Error/warning message */
int errlocation; /* Location of error */
}
LWGEOM *lwgeom_linemerge(const LWGEOM *geom1);
LWGEOM *lwgeom_unaryunion(const LWGEOM *geom1);
LWGEOM *lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1);
-LWCOLLECTION *lwgeom_subdivide(const LWGEOM *geom, int maxvertices);
+LWCOLLECTION *lwgeom_subdivide(const LWGEOM *geom, uint32_t maxvertices);
/**
* Snap vertices and segments of a geometry to another using a given tolerance.
* @param ngeoms the number of elements in the array
* @param k the number of clusters to calculate
*/
-int * lwgeom_cluster_2d_kmeans(const LWGEOM **geoms, int ngeoms, int k);
+int * lwgeom_cluster_2d_kmeans(const LWGEOM **geoms, uint32_t ngeoms, uint32_t k);
#endif /* !defined _LIBLWGEOM_H */
/*
* Number of vertices?
*/
-int lwline_count_vertices(LWLINE *line);
-int lwpoly_count_vertices(LWPOLY *poly);
-int lwcollection_count_vertices(LWCOLLECTION *col);
+uint32_t lwline_count_vertices(LWLINE *line);
+uint32_t lwpoly_count_vertices(LWPOLY *poly);
+uint32_t lwcollection_count_vertices(LWCOLLECTION *col);
/*
* DP simplification
/**
* @param minpts minimun number of points to retain, if possible.
*/
-void ptarray_simplify_in_place(POINTARRAY *pa, double epsilon, unsigned int minpts);
+void ptarray_simplify_in_place(POINTARRAY *pa, double epsilon, uint32_t minpts);
/*
* The possible ways a pair of segments can interact. Returned by lw_segment_intersects
* Support for in place modification of point arrays, fast
* function to move coordinate values around
*/
-void ptarray_copy_point(POINTARRAY *pa, int from, int to);
+void ptarray_copy_point(POINTARRAY *pa, uint32_t from, uint32_t to);
/*
* Reverse
*/
POINTARRAY *ptarray_remove_repeated_points(const POINTARRAY *in, double tolerance);
LWGEOM* lwline_remove_repeated_points(const LWLINE *in, double tolerance);
-void ptarray_remove_repeated_points_in_place(POINTARRAY *pa, double tolerance, int min_points);
+void ptarray_remove_repeated_points_in_place(POINTARRAY *pa, double tolerance, uint32_t min_points);
/*
* Closure test
int lwline_split_by_point_to(const LWLINE* ln, const LWPOINT* pt, LWMLINE* to);
/** Ensure the collection can hold at least up to ngeoms geometries */
-void lwcollection_reserve(LWCOLLECTION *col, int ngeoms);
+void lwcollection_reserve(LWCOLLECTION *col, uint32_t ngeoms);
/** Check if subtype is allowed in collectiontype */
int lwcollection_allows_subtype(int collectiontype, int subtype);
pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring)
{
int cn = 0; /* the crossing number counter */
- int i;
+ uint32_t i;
const POINT2D *v1, *v2;
const POINT2D *first, *last;
*/
int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2)
{
- int i = 0, j = 0;
+ uint32_t i = 0, j = 0;
const POINT2D *p1, *p2, *q1, *q2;
POINTARRAY *pa1 = NULL, *pa2 = NULL;
int cross_left = 0;
* Returns freshly allocated #LWPOINT that corresponds to the index where.
* Returns NULL if the geometry is empty or the index invalid.
*/
-LWPOINT* lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, int where) {
+LWPOINT* lwcircstring_get_lwpoint(const LWCIRCSTRING *circ, uint32_t where) {
POINT4D pt;
LWPOINT *lwpoint;
POINTARRAY *pa;
- if ( lwcircstring_is_empty(circ) || where < 0 || where >= circ->points->npoints )
+ if ( lwcircstring_is_empty(circ) || where >= circ->points->npoints )
return NULL;
pa = ptarray_construct_empty(FLAGS_GET_Z(circ->flags), FLAGS_GET_M(circ->flags), 1);
/**
* Ensure the collection can hold up at least ngeoms
*/
-void lwcollection_reserve(LWCOLLECTION *col, int ngeoms)
+void lwcollection_reserve(LWCOLLECTION *col, uint32_t ngeoms)
{
if ( ngeoms <= col->maxgeoms ) return;
LWCOLLECTION *
lwcollection_segmentize2d(const LWCOLLECTION *col, double dist)
{
- uint32_t i;
+ uint32_t i,j;
LWGEOM **newgeoms;
if ( ! col->ngeoms ) return lwcollection_clone(col);
{
newgeoms[i] = lwgeom_segmentize2d(col->geoms[i], dist);
if ( ! newgeoms[i] ) {
- while (i--) lwgeom_free(newgeoms[i]);
+ for (j=0; j < i; i++)
+ lwgeom_free(newgeoms[j]);
lwfree(newgeoms);
return NULL;
}
int lwcollection_ngeoms(const LWCOLLECTION *col)
{
- int i;
+ uint32_t i;
int ngeoms = 0;
if ( ! col )
void lwcollection_free(LWCOLLECTION *col)
{
- int i;
+ uint32_t i;
if ( ! col ) return;
if ( col->bbox )
*/
LWCOLLECTION* lwcollection_extract(LWCOLLECTION *col, int type)
{
- int i = 0;
+ uint32_t i = 0;
LWGEOM **geomlist;
LWCOLLECTION *outcol;
int geomlistsize = 16;
/* Recurse into sub-collections */
if ( lwtype_is_collection( subtype ) )
{
- int j = 0;
+ uint32_t j = 0;
LWCOLLECTION *tmpcol = lwcollection_extract((LWCOLLECTION*)col->geoms[i], type);
for ( j = 0; j < tmpcol->ngeoms; j++ )
{
}
else
{
- int i;
+ uint32_t i;
LWGEOM **geoms = NULL;
geoms = lwalloc(sizeof(LWGEOM*) * col->ngeoms);
for( i = 0; i < col->ngeoms; i++ )
int lwcollection_is_empty(const LWCOLLECTION *col)
{
- int i;
+ uint32_t i;
if ( (col->ngeoms == 0) || (!col->geoms) )
return LW_TRUE;
for( i = 0; i < col->ngeoms; i++ )
}
-int lwcollection_count_vertices(LWCOLLECTION *col)
+uint32_t lwcollection_count_vertices(LWCOLLECTION *col)
{
- int i = 0;
- int v = 0; /* vertices */
+ uint32_t i = 0;
+ uint32_t v = 0; /* vertices */
assert(col);
for ( i = 0; i < col->ngeoms; i++ )
{
double lwcompound_length_2d(const LWCOMPOUND *comp)
{
- int i;
+ uint32_t i;
double length = 0.0;
if ( lwgeom_is_empty((LWGEOM*)comp) )
return 0.0;
int
lwcompound_contains_point(const LWCOMPOUND *comp, const POINT2D *pt)
{
- int i;
+ uint32_t i;
LWLINE *lwline;
LWCIRCSTRING *lwcirc;
int wn = 0;
}
LWPOINT*
-lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, int where)
+lwcompound_get_lwpoint(const LWCOMPOUND *lwcmp, uint32_t where)
{
- int i;
- int count = 0;
- int npoints = 0;
+ uint32_t i;
+ uint32_t count = 0;
+ uint32_t npoints = 0;
if ( lwgeom_is_empty((LWGEOM*)lwcmp) )
return NULL;
npoints = lwgeom_count_vertices((LWGEOM*)lwcmp);
- if ( where < 0 || where >= npoints )
+ if ( where >= npoints )
{
lwerror("%s: index %d is not in range of number of vertices (%d) in input", __func__, where, npoints);
return NULL;
for ( i = 0; i < lwcmp->ngeoms; i++ )
{
LWGEOM* part = lwcmp->geoms[i];
- int npoints_part = lwgeom_count_vertices(part);
+ uint32_t npoints_part = lwgeom_count_vertices(part);
if ( where >= count && where < count + npoints_part )
{
return lwline_get_lwpoint((LWLINE*)part, where - count);
lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
{
LWCURVEPOLY *ret;
- int i;
+ uint32_t i;
ret = lwalloc(sizeof(LWCURVEPOLY));
ret->type = CURVEPOLYTYPE;
ret->flags = lwpoly->flags;
int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring)
{
- int i;
+ uint32_t i;
/* Can't do anything with NULLs */
if( ! poly || ! ring )
lwcurvepoly_perimeter(const LWCURVEPOLY *poly)
{
double result=0.0;
- int i;
+ uint32_t i;
for (i=0; i<poly->nrings; i++)
result += lwgeom_length(poly->rings[i]);
lwcurvepoly_perimeter_2d(const LWCURVEPOLY *poly)
{
double result=0.0;
- int i;
+ uint32_t i;
for (i=0; i<poly->nrings; i++)
result += lwgeom_length_2d(poly->rings[i]);
POINT4D p1, p2;
POINT3D q1, q2;
GEOGRAPHIC_POINT g1, g2;
- int i;
+ uint32_t i;
/* Just crap out on crazy input */
if ( ! pa_in )
LWLINE *lwline;
LWPOLY *lwpoly_in, *lwpoly_out;
LWCOLLECTION *lwcol_in, *lwcol_out;
- int i;
+ uint32_t i;
/* Reflect NULL */
if ( ! lwg_in )
double
ptarray_area_sphere(const POINTARRAY *pa)
{
- int i;
+ uint32_t i;
const POINT2D *p;
GEOGRAPHIC_POINT a, b, c;
double area = 0.0;
POINT3D A1, A2, B1, B2;
const POINT2D *p;
double distance;
- int i, j;
+ uint32_t i, j;
int use_sphere = (s->a == s->b ? 1 : 0);
/* Make result really big, so that everything will be smaller than it */
if ( pa1->npoints == 1 || pa2->npoints == 1 )
{
/* Handle one/many case here */
- int i;
+ uint32_t i;
const POINTARRAY *pa_one;
const POINTARRAY *pa_many;
if ( type == POLYGONTYPE )
{
LWPOLY *poly = (LWPOLY*)lwgeom;
- int i;
+ uint32_t i;
double area = 0.0;
/* Just in case there's no rings */
if ( type == MULTIPOLYGONTYPE || type == COLLECTIONTYPE )
{
LWCOLLECTION *col = (LWCOLLECTION*)lwgeom;
- int i;
+ uint32_t i;
double area = 0.0;
for ( i = 0; i < col->ngeoms; i++ )
LWPOLY *lwpoly;
LWPOINT *lwpt;
double distance = FLT_MAX;
- int i;
+ uint32_t i;
if ( type1 == POINTTYPE )
{
LWPOLY *lwpoly;
LWLINE *lwline;
double distance = FLT_MAX;
- int i;
+ uint32_t i;
if ( type1 == LINETYPE )
{
LWPOLY *lwpoly1 = (LWPOLY*)lwgeom1;
LWPOLY *lwpoly2 = (LWPOLY*)lwgeom2;
double distance = FLT_MAX;
- int i, j;
+ uint32_t i, j;
/* Point of 2 in polygon 1 implies zero distance */
p = getPoint2d_cp(lwpoly1->rings[0], 0);
/* Recurse into collections */
if ( lwtype_is_collection(type1) )
{
- int i;
+ uint32_t i;
double distance = FLT_MAX;
LWCOLLECTION *col = (LWCOLLECTION*)lwgeom1;
/* Recurse into collections */
if ( lwtype_is_collection(type2) )
{
- int i;
+ uint32_t i;
double distance = FLT_MAX;
LWCOLLECTION *col = (LWCOLLECTION*)lwgeom2;
/* If any of the first argument parts covers the second argument, it's true */
if ( lwtype_is_collection( type1 ) )
{
- int i;
+ uint32_t i;
LWCOLLECTION *col = (LWCOLLECTION*)lwgeom1;
for ( i = 0; i < col->ngeoms; i++ )
/* Only if all of the second arguments are covered by the first argument is the condition true */
if ( lwtype_is_collection( type2 ) )
{
- int i;
+ uint32_t i;
LWCOLLECTION *col = (LWCOLLECTION*)lwgeom2;
for ( i = 0; i < col->ngeoms; i++ )
*/
int lwpoly_covers_point2d(const LWPOLY *poly, const POINT2D *pt_to_test)
{
- int i;
+ uint32_t i;
int in_hole_count = 0;
POINT3D p;
GEOGRAPHIC_POINT gpt_to_test;
*/
int lwpoly_covers_lwpoly(const LWPOLY *poly1, const LWPOLY *poly2)
{
- int i;
+ uint32_t i;
/* Nulls and empties don't contain anything! */
if ( ! poly1 || lwgeom_is_empty((LWGEOM*)poly1) )
*/
int lwpoly_covers_pointarray(const LWPOLY* lwpoly, const POINTARRAY* pta)
{
- int i;
+ uint32_t i;
for (i = 0; i < pta->npoints; i++) {
const POINT2D* pt_to_test = getPoint2d_cp(pta, i);
*/
int lwpoly_intersects_line(const LWPOLY* lwpoly, const POINTARRAY* line)
{
- int i, j, k;
+ uint32_t i, j, k;
POINT3D pa1, pa2, pb1, pb2;
for (i = 0; i < lwpoly->nrings; i++)
{
*/
int lwline_covers_lwpoint(const LWLINE* lwline, const LWPOINT* lwpoint)
{
- int i;
+ uint32_t i;
GEOGRAPHIC_POINT p;
GEOGRAPHIC_EDGE e;
*/
int lwline_covers_lwline(const LWLINE* lwline1, const LWLINE* lwline2)
{
- int i, j;
+ uint32_t i, j;
GEOGRAPHIC_EDGE e1, e2;
GEOGRAPHIC_POINT p1, p2;
int start = LW_FALSE;
* This function can only be used on LWGEOM that is built on top of
* GSERIALIZED, otherwise alignment errors will ensue.
*/
-int getPoint2d_p_ro(const POINTARRAY *pa, int n, POINT2D **point)
+int getPoint2d_p_ro(const POINTARRAY *pa, uint32_t n, POINT2D **point)
{
uint8_t *pa_ptr = NULL;
assert(pa);
- assert(n >= 0);
assert(n < pa->npoints);
pa_ptr = getPoint_internal(pa, n);
int ptarray_calculate_gbox_geodetic(const POINTARRAY *pa, GBOX *gbox)
{
- int i;
+ uint32_t i;
int first = LW_TRUE;
const POINT2D *p;
POINT3D A1, A2;
static int lwpolygon_calculate_gbox_geodetic(const LWPOLY *poly, GBOX *gbox)
{
GBOX ringbox;
- int i;
+ uint32_t i;
int first = LW_TRUE;
assert(poly);
if ( poly->nrings == 0 )
static int lwcollection_calculate_gbox_geodetic(const LWCOLLECTION *coll, GBOX *gbox)
{
GBOX subbox;
- int i;
+ uint32_t i;
int result = LW_FAILURE;
int first = LW_TRUE;
assert(coll);
static int ptarray_check_geodetic(const POINTARRAY *pa)
{
- int t;
+ uint32_t t;
POINT2D pt;
assert(pa);
static int lwpoly_check_geodetic(const LWPOLY *poly)
{
- int i = 0;
+ uint32_t i = 0;
assert(poly);
for ( i = 0; i < poly->nrings; i++ )
static int lwcollection_check_geodetic(const LWCOLLECTION *col)
{
- int i = 0;
+ uint32_t i = 0;
assert(col);
for ( i = 0; i < col->ngeoms; i++ )
static int ptarray_force_geodetic(POINTARRAY *pa)
{
- int t;
+ uint32_t t;
int changed = LW_FALSE;
POINT4D pt;
static int lwpoly_force_geodetic(LWPOLY *poly)
{
- int i = 0;
+ uint32_t i = 0;
int changed = LW_FALSE;
assert(poly);
static int lwcollection_force_geodetic(LWCOLLECTION *col)
{
- int i = 0;
+ uint32_t i = 0;
int changed = LW_FALSE;
assert(col);
GEOGRAPHIC_POINT a, b;
double za = 0.0, zb = 0.0;
POINT4D p;
- int i;
+ uint32_t i;
int hasz = LW_FALSE;
double length = 0.0;
double seglength = 0.0;
double lwgeom_length_spheroid(const LWGEOM *geom, const SPHEROID *s)
{
int type;
- int i = 0;
+ uint32_t i = 0;
double length = 0.0;
assert(geom);
ptarray_nudge_geodetic(POINTARRAY *pa)
{
- int i;
+ uint32_t i;
POINT4D p;
int altered = LW_FALSE;
int rv = LW_FALSE;
lwgeom_nudge_geodetic(LWGEOM *geom)
{
int type;
- int i = 0;
+ uint32_t i = 0;
int rv = LW_FALSE;
assert(geom);
* Returns non-zero if edges A and B interact. The type of interaction is given in the
* return value with the bitmask elements defined above.
*/
-int
+uint32_t
edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2)
{
POINT3D AN, BN, VN; /* Normals to plane A and plane B */
POINT3D S1, S2; /* Stab line end points */
POINT3D E1, E2; /* Edge end points (3-space) */
POINT2D p; /* Edge end points (lon/lat) */
- int count = 0, i, inter;
+ uint32_t count = 0, i, inter;
/* Null input, not enough points for a ring? You ain't closed! */
if ( ! pa || pa->npoints < 4 )
int edge_calculate_gbox_slow(const GEOGRAPHIC_EDGE *e, GBOX *gbox);
int edge_calculate_gbox(const POINT3D *A1, const POINT3D *A2, GBOX *gbox);
int edge_intersection(const GEOGRAPHIC_EDGE *e1, const GEOGRAPHIC_EDGE *e2, GEOGRAPHIC_POINT *g);
-int edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2);
+uint32_t edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2);
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest);
double edge_distance_to_edge(const GEOGRAPHIC_EDGE *e1, const GEOGRAPHIC_EDGE *e2, GEOGRAPHIC_POINT *closest1, GEOGRAPHIC_POINT *closest2);
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g);
void
circ_tree_free(CIRC_NODE* node)
{
- int i;
+ uint32_t i;
if ( ! node ) return;
for ( i = 0; i < node->num_nodes; i++ )
* and storing pointers to the child nodes.
*/
static CIRC_NODE*
-circ_node_internal_new(CIRC_NODE** c, int num_nodes)
+circ_node_internal_new(CIRC_NODE** c, uint32_t num_nodes)
{
CIRC_NODE *node = NULL;
GEOGRAPHIC_POINT new_center, c1;
double new_radius;
double offset1, dist, D, r1, ri;
- int i, new_geom_type;
+ uint32_t i, new_geom_type;
LWDEBUGF(3, "called with %d nodes --", num_nodes);
GEOGRAPHIC_EDGE stab_edge, edge;
POINT3D S1, S2, E1, E2;
double d;
- int i, c;
+ uint32_t i, c;
/* Construct a stabline edge from our "inside" to our known outside point */
geographic_point_init(pt->x, pt->y, &(stab_edge.start));
{
double max;
double d, d_min;
- int i;
+ uint32_t i;
LWDEBUGF(4, "entered, min_dist=%.8g max_dist=%.8g, type1=%d, type2=%d", *min_dist, *max_dist, n1->geom_type, n2->geom_type);
/*
void circ_tree_print(const CIRC_NODE* node, int depth)
{
- int i;
+ uint32_t i;
if (circ_node_is_leaf(node))
{
static CIRC_NODE*
lwpoly_calculate_circ_tree(const LWPOLY* lwpoly)
{
- int i = 0, j = 0;
+ uint32_t i = 0, j = 0;
CIRC_NODE** nodes;
CIRC_NODE* node;
static CIRC_NODE*
lwcollection_calculate_circ_tree(const LWCOLLECTION* lwcol)
{
- int i = 0, j = 0;
+ uint32_t i = 0, j = 0;
CIRC_NODE** nodes;
CIRC_NODE* node;
{
GEOGRAPHIC_POINT center;
double radius;
- int num_nodes;
+ uint32_t num_nodes;
struct circ_node** nodes;
int edge_num;
- int geom_type;
- POINT2D pt_outside;
+ uint32_t geom_type;
+ POINT2D pt_outside;
POINT2D* p1;
POINT2D* p2;
} CIRC_NODE;
lwgeom_force_clockwise(LWGEOM *lwgeom)
{
LWCOLLECTION *coll;
- int i;
+ uint32_t i;
switch (lwgeom->type)
{
case MULTIPOLYGONTYPE:
case COLLECTIONTYPE:
{
- int i;
+ uint32_t i;
LWCOLLECTION* coll = (LWCOLLECTION *)lwgeom;
for (i=0; i < coll->ngeoms; i++)
void
lwgeom_reverse_in_place(LWGEOM *geom)
{
- int i;
+ uint32_t i;
LWCOLLECTION *col;
if (!geom)
return;
LWPOLY *poly = (LWPOLY *)(geom);
if (!poly->rings)
return;
- int r;
+ uint32_t r;
for (r = 0; r < poly->nrings; r++)
ptarray_reverse_in_place(poly->rings[r]);
return;
if ( lwgeom_is_collection(lwgeom) )
{
- int i;
+ uint32_t i;
LWCOLLECTION *lwcol = (LWCOLLECTION*)lwgeom;
for ( i = 0; i < lwcol->ngeoms; i++ )
lwgeom_force_sfs(LWGEOM *geom, int version)
{
LWCOLLECTION *col;
- int i;
+ uint32_t i;
LWGEOM *g;
/* SFS 1.2 version */
LWLINE *ln;
LWPOLY *ply;
LWCOLLECTION *col;
- int i;
+ uint32_t i;
FLAGS_SET_GEODETIC(geom->flags, value);
if ( geom->bbox )
void
lwgeom_longitude_shift(LWGEOM *lwgeom)
{
- int i;
+ uint32_t i;
switch (lwgeom->type)
{
LWPOINT *point;
if ( lwgeom_is_collection(geom) )
{
LWCOLLECTION *col = lwgeom_as_lwcollection(geom);
- int i;
+ uint32_t i;
int closed;
for ( i = 0; i < col->ngeoms; i++ )
{
/**
* Given an lwtype number, what homogeneous collection can hold it?
*/
-int
+uint32_t
lwtype_get_collectiontype(uint8_t type)
{
switch (type)
/**
* Count points in an #LWGEOM.
+* TODO: Make sure the internal functions don't overflow
*/
-int lwgeom_count_vertices(const LWGEOM *geom)
+uint32_t lwgeom_count_vertices(const LWGEOM *geom)
{
int result = 0;
}
case COLLECTIONTYPE:
{
- int maxdim = 0, i;
+ int maxdim = 0;
+ uint32_t i;
LWCOLLECTION *col = (LWCOLLECTION*)geom;
for( i = 0; i < col->ngeoms; i++ )
{
/**
* Count rings in an #LWGEOM.
*/
-int lwgeom_count_rings(const LWGEOM *geom)
+uint32_t lwgeom_count_rings(const LWGEOM *geom)
{
int result = 0;
case COLLECTIONTYPE:
{
LWCOLLECTION *col = (LWCOLLECTION*)geom;
- int i = 0;
+ uint32_t i = 0;
for( i = 0; i < col->ngeoms; i++ )
result += lwgeom_count_rings(col->geoms[i]);
break;
static int lwcollection_dimensionality(const LWCOLLECTION *col)
{
- int i;
+ uint32_t i;
int dimensionality = 0;
for ( i = 0; i < col->ngeoms; i++ )
{
{
LWCOLLECTION *col;
LWPOLY *poly;
- int i;
+ uint32_t i;
if ( (!in) || lwgeom_is_empty(in) ) return;
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)
{
- int i;
+ uint32_t i;
LWDEBUGF(4,"entered with srid=%d",srid);
}
case POLYGONTYPE:
{
- int i, j = 0;
+ uint32_t i, j = 0;
LWPOLY *g = (LWPOLY*)(geom);
for (i = 0; i < g->nrings; i++)
{
}
case MULTIPOINTTYPE:
{
- static int out_stack_size = 32;
+ static uint32_t out_stack_size = 32;
double tolsq = tolerance*tolerance;
- int i, j, n = 0;
+ uint32_t i, j, n = 0;
LWMPOINT *mpt = (LWMPOINT *)(geom);
LWPOINT **out;
LWPOINT *out_stack[out_stack_size];
case MULTISURFACETYPE:
case COMPOUNDTYPE:
{
- int i, j = 0;
+ uint32_t i, j = 0;
LWCOLLECTION *col = (LWCOLLECTION*)(geom);
for (i = 0; i < col->ngeoms; i++)
{
}
case POLYGONTYPE:
{
- int i, j = 0;
+ uint32_t i, j = 0;
LWPOLY *g = (LWPOLY*)(geom);
for (i = 0; i < g->nrings; i++)
{
case MULTIPOLYGONTYPE:
case COLLECTIONTYPE:
{
- int i, j = 0;
+ uint32_t i, j = 0;
LWCOLLECTION *col = (LWCOLLECTION*)geom;
for (i = 0; i < col->ngeoms; i++)
{
else if ( lwgeom_is_collection(geom) )
{
double area = 0.0;
- int i;
+ uint32_t i;
LWCOLLECTION *col = (LWCOLLECTION*)geom;
for ( i = 0; i < col->ngeoms; i++ )
area += lwgeom_area(col->geoms[i]);
else if ( lwgeom_is_collection(geom) )
{
double perimeter = 0.0;
- int i;
+ uint32_t i;
LWCOLLECTION *col = (LWCOLLECTION*)geom;
for ( i = 0; i < col->ngeoms; i++ )
perimeter += lwgeom_perimeter(col->geoms[i]);
else if ( lwgeom_is_collection(geom) )
{
double perimeter = 0.0;
- int i;
+ uint32_t i;
LWCOLLECTION *col = (LWCOLLECTION*)geom;
for ( i = 0; i < col->ngeoms; i++ )
perimeter += lwgeom_perimeter_2d(col->geoms[i]);
else if ( lwgeom_is_collection(geom) )
{
double length = 0.0;
- int i;
+ uint32_t i;
LWCOLLECTION *col = (LWCOLLECTION*)geom;
for ( i = 0; i < col->ngeoms; i++ )
length += lwgeom_length(col->geoms[i]);
else if ( lwgeom_is_collection(geom) )
{
double length = 0.0;
- int i;
+ uint32_t i;
LWCOLLECTION *col = (LWCOLLECTION*)geom;
for ( i = 0; i < col->ngeoms; i++ )
length += lwgeom_length_2d(col->geoms[i]);
lwgeom_affine(LWGEOM *geom, const AFFINE *affine)
{
int type = geom->type;
- int i;
+ uint32_t i;
switch(type)
{
lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
{
int type = geom->type;
- int i;
+ uint32_t i;
switch(type)
{
if (!ply->rings) return;
/* Check first the external ring */
- int i = 0;
+ uint32_t i = 0;
POINTARRAY *pa = ply->rings[0];
ptarray_grid_in_place(pa, grid);
if (pa->npoints < 4)
}
/* Check the other rings */
- int j = 1;
+ uint32_t j = 1;
for (i = 1; i < ply->nrings; i++)
{
POINTARRAY *pa = ply->rings[i];
case COMPOUNDTYPE:
{
LWCOLLECTION *col = (LWCOLLECTION*)(geom);
- int i, j = 0;
+ uint32_t i, j = 0;
if (!col->geoms) return;
for (i = 0; i < col->ngeoms; i++)
{
/* Prototype for recursion */
static int
-lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, int depth, LWCOLLECTION *col, const GBOX *clip);
+lwgeom_subdivide_recursive(const LWGEOM *geom, uint32_t maxvertices, uint32_t depth, LWCOLLECTION *col, const GBOX *clip);
static int
-lwgeom_subdivide_recursive(const LWGEOM *geom, int maxvertices, int depth, LWCOLLECTION *col, const GBOX *clip)
+lwgeom_subdivide_recursive(const LWGEOM *geom, uint32_t maxvertices, uint32_t depth, LWCOLLECTION *col, const GBOX *clip)
{
- const int maxdepth = 50;
- int nvertices = 0;
- int i, n = 0;
+ const uint32_t maxdepth = 50;
+ uint32_t nvertices = 0;
+ uint32_t i, n = 0;
double width = clip->xmax - clip->xmin;
double height = clip->ymax - clip->ymin;
GBOX subbox1, subbox2;
}
LWCOLLECTION *
-lwgeom_subdivide(const LWGEOM *geom, int maxvertices)
+lwgeom_subdivide(const LWGEOM *geom, uint32_t maxvertices)
{
- static int startdepth = 0;
- static int minmaxvertices = 8;
+ static uint32_t startdepth = 0;
+ static uint32_t minmaxvertices = 8;
LWCOLLECTION *col;
GBOX clip;
* NOTE: point is a real POINT3D *not* a pointer
*/
POINT4D
-getPoint4d(const POINTARRAY *pa, int n)
+getPoint4d(const POINTARRAY *pa, uint32_t n)
{
POINT4D result;
getPoint4d_p(pa, n, &result);
* @return 0 on error, 1 on success
*/
int
-getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *op)
+getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *op)
{
uint8_t *ptr;
int zmflag;
return 0;
}
- if ( (n<0) || (n>=pa->npoints))
+ if ( n>=pa->npoints )
{
lwnotice("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
return 0;
* NOTE: point is a real POINT3DZ *not* a pointer
*/
POINT3DZ
-getPoint3dz(const POINTARRAY *pa, int n)
+getPoint3dz(const POINTARRAY *pa, uint32_t n)
{
POINT3DZ result;
getPoint3dz_p(pa, n, &result);
* NOTE: point is a real POINT3DZ *not* a pointer
*/
POINT3DM
-getPoint3dm(const POINTARRAY *pa, int n)
+getPoint3dm(const POINTARRAY *pa, uint32_t n)
{
POINT3DM result;
getPoint3dm_p(pa, n, &result);
* NOTE: this will modify the point3dz pointed to by 'point'.
*/
int
-getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *op)
+getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *op)
{
uint8_t *ptr;
return 0;
}
- if ( (n<0) || (n>=pa->npoints))
+ if ( n>=pa->npoints )
{
lwnotice("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
return 0;
* NOTE: this will modify the point3dm pointed to by 'point'.
*/
int
-getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *op)
+getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *op)
{
uint8_t *ptr;
int zmflag;
return 0;
}
- if ( (n<0) || (n>=pa->npoints))
+ if ( n>=pa->npoints )
{
lwnotice("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
return 0;
* NOTE: point is a real POINT2D *not* a pointer
*/
POINT2D
-getPoint2d(const POINTARRAY *pa, int n)
+getPoint2d(const POINTARRAY *pa, uint32_t n)
{
const POINT2D *result;
result = getPoint2d_cp(pa, n);
* NOTE: this will modify the point2d pointed to by 'point'.
*/
int
-getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
+getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
{
if ( ! pa )
{
return 0;
}
- if ( (n<0) || (n>=pa->npoints))
+ if ( n>=pa->npoints )
{
lwnotice("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
return 0;
* values, only read them.
*/
const POINT2D*
-getPoint2d_cp(const POINTARRAY *pa, int n)
+getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
{
if ( ! pa ) return 0;
- if ( (n<0) || (n>=pa->npoints))
+ if ( n>=pa->npoints )
{
lwerror("getPoint2d_cp: point offset out of range");
return 0; /*error */
}
const POINT3DZ*
-getPoint3dz_cp(const POINTARRAY *pa, int n)
+getPoint3dz_cp(const POINTARRAY *pa, uint32_t n)
{
if ( ! pa ) return 0;
return 0; /*error */
}
- if ( (n<0) || (n>=pa->npoints))
+ if ( n>=pa->npoints )
{
lwerror("getPoint3dz_cp: point offset out of range");
return 0; /*error */
const POINT4D*
-getPoint4d_cp(const POINTARRAY *pa, int n)
+getPoint4d_cp(const POINTARRAY *pa, uint32_t n)
{
if ( ! pa ) return 0;
return 0; /*error */
}
- if ( (n<0) || (n>=pa->npoints))
+ if ( n>=pa->npoints )
{
lwerror("getPoint4d_cp: point offset out of range");
return 0; /*error */
*
*/
void
-ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
+ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
{
uint8_t *ptr;
- assert(n >= 0 && n < pa->npoints);
+ assert(n < pa->npoints);
ptr=getPoint_internal(pa, n);
switch ( FLAGS_GET_ZM(pa->flags) )
{
}
void
-ptarray_copy_point(POINTARRAY *pa, int from, int to)
+ptarray_copy_point(POINTARRAY *pa, uint32_t from, uint32_t to)
{
int ndims = FLAGS_NDIMS(pa->flags);
switch (ndims)
void printPA(POINTARRAY *pa)
{
- int t;
+ uint32_t t;
POINT4D pt;
char *mflag;
size_t size = 128;
char *result;
char *tmp;
- int i;
+ uint32_t i;
static char *nl = "\n";
char *pad="";
char *zmflags = lwgeom_flagchars((LWGEOM*)col);
char tmp[256];
size_t size = 64*(poly->nrings+1)+128;
char *result;
- int i;
+ uint32_t i;
char *pad="";
static char *nl = "\n";
char *zmflags = lwgeom_flagchars((LWGEOM*)poly);
geoms[i-1] = ptarray_to_GEOSLinearRing(lwpoly->rings[i], autofix);
if ( ! geoms[i-1] )
{
- --i;
- while (i) GEOSGeom_destroy(geoms[--i]);
+ uint32_t k;
+ for (k = 0; k < i-1; k++)
+ GEOSGeom_destroy(geoms[k]);
free(geoms);
GEOSGeom_destroy(shell);
return NULL;
g = LWGEOM2GEOS(lwc->geoms[i], 0);
if ( ! g )
{
- while (j) GEOSGeom_destroy(geoms[--j]);
+ uint32_t k;
+ for (k = 0; k < j; k++)
+ GEOSGeom_destroy(geoms[k]);
free(geoms);
return NULL;
}
LWMPOINT*
-lwpoly_to_points(const LWPOLY *lwpoly, int npoints)
+lwpoly_to_points(const LWPOLY *lwpoly, uint32_t npoints)
{
double area, bbox_area, bbox_width, bbox_height;
GBOX bbox;
const LWGEOM *lwgeom = (LWGEOM*)lwpoly;
- int sample_npoints, sample_sqrt, sample_width, sample_height;
+ uint32_t sample_npoints, sample_sqrt, sample_width, sample_height;
double sample_cell_size;
- int i, j, n;
- int iterations = 0;
- int npoints_generated = 0;
- int npoints_tested = 0;
+ uint32_t i, j, n;
+ uint32_t iterations = 0;
+ uint32_t npoints_generated = 0;
+ uint32_t npoints_tested = 0;
GEOSGeometry *g;
const GEOSPreparedGeometry *gprep;
GEOSGeometry *gpt;
* and bundle up final result in a single multipoint.
*/
LWMPOINT*
-lwmpoly_to_points(const LWMPOLY *lwmpoly, int npoints)
+lwmpoly_to_points(const LWMPOLY *lwmpoly, uint32_t npoints)
{
const LWGEOM *lwgeom = (LWGEOM*)lwmpoly;
double area;
- int i;
+ uint32_t i;
LWMPOINT *mpt = NULL;
if (lwgeom_get_type(lwgeom) != MULTIPOLYGONTYPE)
}
else
{
- int j;
+ uint32_t j;
for (j = 0; j < sub_mpt->ngeoms; j++)
{
mpt = lwmpoint_add_lwpoint(mpt, sub_mpt->geoms[j]);
LWMPOINT*
-lwgeom_to_points(const LWGEOM *lwgeom, int npoints)
+lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints)
{
switch(lwgeom_get_type(lwgeom))
{
{
LWGEOM* ret;
POINTARRAY **new_rings;
- int i;
+ uint32_t i;
/* If the polygon has no rings there's nothing to do */
if ( ! poly->nrings ) return (LWGEOM*)poly;
int nvgeoms;
GEOSGeometry **vgeoms;
GEOSGeom gout;
- unsigned int i;
+ int i;
nvgeoms = GEOSGetNumGeometries(gin);
if ( nvgeoms == -1 ) {
for ( i=0; i<nvgeoms; ++i ) {
vgeoms[i] = LWGEOM_GEOS_makeValid( GEOSGetGeometryN(gin, i) );
if ( ! vgeoms[i] ) {
- while (i--) GEOSGeom_destroy(vgeoms[i]);
+ int j;
+ for (j = 0; j<i-1; j++)
+ GEOSGeom_destroy(vgeoms[j]);
lwfree(vgeoms);
/* we expect lwerror being called already by makeValid */
return NULL;
lwline_split_by_mpoint(const LWLINE* lwline_in, const LWMPOINT* mp)
{
LWMLINE* out;
- int i, j;
+ uint32_t i, j;
out = lwmline_construct_empty(lwline_in->srid,
FLAGS_GET_Z(lwline_in->flags),
POINTARRAY *ipa = lwline_in->points;
POINTARRAY* pa1;
POINTARRAY* pa2;
- int i, nsegs, seg = -1;
+ uint32_t i, nsegs, seg = UINT32_MAX;
/* Possible outcomes:
*
if ( mindist > 0 ) return 0;
/* empty or single-point line, intersection on boundary */
- if ( seg < 0 ) return 1;
+ if ( seg == UINT32_MAX ) return 1;
/*
* We need to project the
static int
_lwt_GetInteriorEdgePoint(const LWLINE* edge, POINT2D* ip)
{
- int i;
+ uint32_t i;
POINT2D fp, lp, tp;
POINTARRAY *pa = edge->points;
POINTARRAY *epa = edge->points;
POINT2D p2, pt;
int match = 0;
- int j;
+ uint32_t j;
/* Skip if the edge is a dangling one */
if ( isoe->face_left == isoe->face_right )
continue;
}
+ if (epa->npoints < 2)
+ {
+ LWDEBUGF(3, "_lwt_FindNextRingEdge: edge %" LWTFMT_ELEMID
+ " has only %"PRIu32" points",
+ isoe->edge_id, epa->npoints);
+ continue;
+ }
+
#if 0
size_t sz;
LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " is %s",
LWDEBUGF(1, "Last point of edge %" LWTFMT_ELEMID
" matches ring vertex %d", isoe->edge_id, from);
/* last point matches, let's check next non-equal one */
- for ( j=epa->npoints-2; j>=0; --j )
+ for ( j=2; j<=epa->npoints; j++ )
{
- getPoint2d_p(epa, j, &p2);
+ getPoint2d_p(epa, epa->npoints - j, &p2);
LWDEBUGF(1, "Edge %" LWTFMT_ELEMID " 'prev' point %d is %g,%g",
- isoe->edge_id, j, p2.x, p2.y);
+ isoe->edge_id, epa->npoints - j, p2.x, p2.y);
/* we won't check duplicated edge points */
if ( p2d_same(&p1, &p2) ) continue;
/* we assume there are no duplicated points in ring */
LWPOLY *facepoly;
LWT_ISO_EDGE *edges;
int numfaceedges;
- int fields, i;
+ int fields;
+ uint32_t i;
int nseid = 0; /* number of signed edge ids */
int prevseid;
LWT_ELEMID *seid; /* signed edge ids */
for ( i=0; i<facepoly->nrings; ++i )
{
const POINTARRAY *ring = facepoly->rings[i];
- int j = 0;
+ int32_t j = 0;
LWT_ISO_EDGE *nextedge;
LWLINE *nextline;
LWDEBUGF(1, "Ring %d has %d points", i, ring->npoints);
- while ( j < ring->npoints-1 )
+ while ( j < (int32_t) ring->npoints-1 )
{
LWDEBUGF(1, "Looking for edge covering ring %d from vertex %d",
i, j);
if ( node_edges[i].edge_id == eid2 ) continue;
commonnode = -1;
/* append to string, for error message */
- if ( bufleft ) {
+ if ( bufleft > 0 ) {
r = snprintf(ptr, bufleft, "%s%" LWTFMT_ELEMID,
( ptr==buf ? "" : "," ), node_edges[i].edge_id);
- if ( r >= bufleft )
+ if ( r >= (int) bufleft )
{
bufleft = 0;
buf[252] = '.';
if ( node_edges[i].edge_id == eid2 ) continue;
commonnode = -1;
/* append to string, for error message */
- if ( bufleft ) {
+ if ( bufleft > 0 ) {
r = snprintf(ptr, bufleft, "%s%" LWTFMT_ELEMID,
( ptr==buf ? "" : "," ), node_edges[i].edge_id);
- if ( r >= bufleft )
+ if ( r >= (int) bufleft )
{
bufleft = 0;
buf[252] = '.';
_lwt_split_by_nodes(const LWGEOM *g, const LWGEOM *nodes)
{
LWCOLLECTION *col = lwgeom_as_lwcollection(nodes);
- int i;
+ uint32_t i;
LWGEOM *bg;
bg = lwgeom_clone_deep(g);
LWT_ELEMID*
lwt_AddPolygon(LWT_TOPOLOGY* topo, LWPOLY* poly, double tol, int* nfaces)
{
- int i;
+ uint32_t i;
*nfaces = -1; /* error condition, by default */
int num;
LWT_ISO_FACE *faces;
int nfacesinbox;
+ int j;
LWT_ELEMID *ids = NULL;
GBOX qbox;
const GEOSPreparedGeometry *ppoly;
}
ppoly = GEOSPrepare(polyg);
ids = lwalloc(sizeof(LWT_ELEMID)*nfacesinbox);
- for ( i=0; i<nfacesinbox; ++i )
+ for ( j=0; j<nfacesinbox; ++j )
{
- LWT_ISO_FACE *f = &(faces[i]);
+ LWT_ISO_FACE *f = &(faces[j]);
LWGEOM *fg;
GEOSGeometry *fgg, *sp;
int covers;
fg = lwt_GetFaceGeometry( topo, f->face_id );
if ( ! fg )
{
- i = f->face_id; /* so we can destroy faces */
+ j = f->face_id; /* so we can destroy faces */
GEOSPreparedGeom_destroy(ppoly);
GEOSGeom_destroy(polyg);
lwfree(ids);
_lwt_release_faces(faces, nfacesinbox);
- lwerror("Could not get geometry of face %" LWTFMT_ELEMID, i);
+ lwerror("Could not get geometry of face %" LWTFMT_ELEMID, j);
return NULL;
}
/* check if a point on this face's surface is covered by our polygon */
getPoint2d_p(pa, it->curidx, pt);
if ( el->left ) {
it->curidx++;
- if ( it->curidx >= pa->npoints ) tonext = 1;
+ if ( it->curidx >= (int) pa->npoints ) tonext = 1;
} else {
it->curidx--;
if ( it->curidx < 0 ) tonext = 1;
int
ptarray_transform(POINTARRAY *pa, projPJ inpj, projPJ outpj)
{
- int i;
+ uint32_t i;
POINT4D p;
for ( i = 0; i < pa->npoints; i++ )
int
lwgeom_transform(LWGEOM *geom, projPJ inpj, projPJ outpj)
{
- int i;
+ uint32_t i;
/* No points to transform in an empty! */
if ( lwgeom_is_empty(geom) )
{
LWGEOM** wrap_geoms;
LWCOLLECTION* out;
- int i;
+ uint32_t i;
int outtype = lwcoll_in->type;
wrap_geoms = lwalloc(lwcoll_in->ngeoms * sizeof(LWGEOM*));
wrap_geoms[i] = lwgeom_wrapx(lwcoll_in->geoms[i], cutx, amount);
/* an exception should prevent this from ever returning NULL */
if ( ! wrap_geoms[i] ) {
+ uint32_t j;
lwnotice("Error wrapping geometry, cleaning up");
- while ((--i)>=0) {
- lwnotice("cleaning geometry %d (%p)", i, wrap_geoms[i]);
- lwgeom_free(wrap_geoms[i]);
+ for (j = 0; j < i; j++)
+ {
+ lwnotice("cleaning geometry %d (%p)", j, wrap_geoms[j]);
+ lwgeom_free(wrap_geoms[j]);
}
lwfree(wrap_geoms);
lwnotice("cleanup complete");
static void
lwcollection_build_buffer(const LWCOLLECTION *col, HomogenizeBuffer *buffer)
{
- int i;
+ uint32_t i;
if ( ! col ) return;
if ( lwgeom_is_empty(lwcollection_as_lwgeom(col)) ) return;
{
POINTARRAY *pa = NULL;
uint32_t ndims = s->ndims;
- int i;
+ uint32_t i;
double *dlist;
LWDEBUG(2,"Entering ptarray_from_twkb_state");
static LWPOLY* lwpoly_from_twkb_state(twkb_parse_state *s)
{
uint32_t nrings;
- int i;
+ uint32_t i;
LWPOLY *poly;
LWDEBUG(2,"Entering lwpoly_from_twkb_state");
{
uint8_t *buf = NULL;
register uint8_t h1, h2;
- int i;
+ uint32_t i;
if( hexsize % 2 )
lwerror("Invalid hex string, length (%d) has to be a multiple of two!", hexsize);
/* Otherwise we have to read each double, separately. */
else
{
- int i = 0;
+ uint32_t i = 0;
double *dlist;
pa = ptarray_construct(s->has_z, s->has_m, npoints);
dlist = (double*)(pa->serialized_pointlist);
/* Otherwise we have to read each double, separately */
else
{
- int i = 0;
+ uint32_t i = 0;
double *dlist;
pa = ptarray_construct(s->has_z, s->has_m, npoints);
dlist = (double*)(pa->serialized_pointlist);
static LWPOLY* lwpoly_from_wkb_state(wkb_parse_state *s)
{
uint32_t nrings = integer_from_wkb_state(s);
- int i = 0;
+ uint32_t i = 0;
LWPOLY *poly = lwpoly_construct_empty(s->srid, s->has_z, s->has_m);
LWDEBUGF(4,"Polygon has %d rings", nrings);
uint32_t ngeoms = integer_from_wkb_state(s);
LWCURVEPOLY *cp = lwcurvepoly_construct_empty(s->srid, s->has_z, s->has_m);
LWGEOM *geom = NULL;
- int i;
+ uint32_t i;
/* Empty collection? */
if ( ngeoms == 0 )
uint32_t ngeoms = integer_from_wkb_state(s);
LWCOLLECTION *col = lwcollection_construct_empty(s->lwtype, s->srid, s->has_z, s->has_m);
LWGEOM *geom = NULL;
- int i;
+ uint32_t i;
LWDEBUGF(4,"Collection has %d components", ngeoms);
static uint8_t wkt_dimensionality(char *dimensionality)
{
- int i = 0;
+ size_t i = 0;
uint8_t flags = 0;
if( ! dimensionality )
{
int hasz = FLAGS_GET_Z(flags);
int hasm = FLAGS_GET_M(flags);
- int i = 0;
+ uint32_t i = 0;
/* Error on junk */
if( ! geom )
/* Apply check for minimum number of points, if requested. */
if( (global_parser_result.parser_check_flags & LW_PARSER_CHECK_MINPOINTS) )
{
- int vertices_needed = 3;
+ uint32_t vertices_needed = 3;
if ( ring->type == LINETYPE )
vertices_needed = 4;
if ( flagdims > 2 )
{
LWCOLLECTION *col = lwgeom_as_lwcollection(geom);
- int i;
+ uint32_t i;
for ( i = 0 ; i < col->ngeoms; i++ )
{
*/
YY_BUFFER_STATE wkt_yy_scan_string (yyconst char * yystr )
{
-
- return wkt_yy_scan_bytes(yystr,strlen(yystr) );
+ return wkt_yy_scan_bytes(yystr, strlen(yystr) );
}
/** Setup the input buffer state to scan the given bytes. The next call to wkt_yylex() will
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- int i;
+ yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
#define KMEANS_MAX_ITERATIONS 1000
static void
-update_r(POINT2D** objs, int* clusters, uint32_t n, POINT2D** centers, unsigned int k)
+update_r(POINT2D** objs, int* clusters, uint32_t n, POINT2D** centers, uint32_t k)
{
POINT2D* obj;
unsigned int i;
double distance, curr_distance;
- int cluster, curr_cluster;
+ uint32_t cluster, curr_cluster;
for (i = 0; i < n; i++)
{
}
/* Store the nearest cluster this object is in */
- clusters[i] = curr_cluster;
+ clusters[i] = (int) curr_cluster;
}
}
static void
-update_means(POINT2D** objs, int* clusters, uint32_t n, POINT2D** centers, unsigned int* weights, unsigned int k)
+update_means(POINT2D** objs, int* clusters, uint32_t n, POINT2D** centers, uint32_t* weights, uint32_t k)
{
- unsigned int i;
+ uint32_t i;
memset(weights, 0, sizeof(int) * k);
for (i = 0; i < k; i++)
}
static int
-kmeans(POINT2D** objs, int* clusters, uint32_t n, POINT2D** centers, unsigned int k)
+kmeans(POINT2D** objs, int* clusters, uint32_t n, POINT2D** centers, uint32_t k)
{
- unsigned int i = 0;
+ uint32_t i = 0;
int* clusters_last;
int converged = LW_FALSE;
- uint32_t clusters_sz = sizeof(int) * n;
- unsigned int* weights;
+ size_t clusters_sz = sizeof(int) * n;
+ uint32_t* weights;
weights = lwalloc(sizeof(int) * k);
}
int*
-lwgeom_cluster_2d_kmeans(const LWGEOM** geoms, int n, int k)
+lwgeom_cluster_2d_kmeans(const LWGEOM** geoms, uint32_t n, uint32_t k)
{
- unsigned int i;
- unsigned int num_centroids = 0;
+ uint32_t i;
+ uint32_t num_centroids = 0;
LWGEOM** centroids;
POINT2D* centers_raw;
double* distances;
const POINT2D* cp;
int result = LW_FALSE;
- unsigned int boundary_point_idx = 0;
+ uint32_t boundary_point_idx = 0;
double max_norm = -DBL_MAX;
double curr_norm;
/* loop i on clusters, skip 0 as it's found already */
for (i = 1; i < k; i++)
{
- unsigned int j;
+ uint32_t j;
double max_distance = -DBL_MAX;
double curr_distance;
- unsigned int candidate_center = 0;
+ uint32_t candidate_center = 0;
/* loop j on objs */
for (j = 0; j < n; j++)
LWLINE *
lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
{
- int i;
+ uint32_t i;
int hasz = LW_FALSE;
int hasm = LW_FALSE;
POINTARRAY *pa;
LWLINE *
lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
{
- int i;
+ uint32_t i;
int hasz = LW_FALSE;
int hasm = LW_FALSE;
POINTARRAY *pa;
* Returns NULL if the geometry is empty or the index invalid.
*/
LWPOINT*
-lwline_get_lwpoint(const LWLINE *line, int where)
+lwline_get_lwpoint(const LWLINE *line, uint32_t where)
{
POINT4D pt;
LWPOINT *lwpoint;
POINTARRAY *pa;
- if ( lwline_is_empty(line) || where < 0 || where >= line->points->npoints )
+ if ( lwline_is_empty(line) || where >= line->points->npoints )
return NULL;
pa = ptarray_construct_empty(FLAGS_GET_Z(line->flags), FLAGS_GET_M(line->flags), 1);
int
-lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where)
+lwline_add_lwpoint(LWLINE *line, LWPOINT *point, uint32_t where)
{
POINT4D pt;
getPoint4d_p(point->point, 0, &pt);
}
-int lwline_count_vertices(LWLINE *line)
+uint32_t lwline_count_vertices(LWLINE *line)
{
assert(line);
if ( ! line->points )
static POINTARRAY*
ptarray_locate_along(const POINTARRAY *pa, double m, double offset)
{
- int i;
+ uint32_t i;
POINT4D p1, p2, pn;
POINTARRAY *dpa = NULL;
{
LWMPOINT *lwmpoint = NULL;
LWGEOM *lwg = lwmline_as_lwgeom(lwmline);
- int i, j;
+ uint32_t i, j;
/* Return degenerates upwards */
if ( (!lwmline) || (lwmline->ngeoms < 1) ) return NULL;
{
LWGEOM *lwg = lwmpoint_as_lwgeom(lwin);
LWMPOINT *lwout = NULL;
- int i;
+ uint32_t i;
/* Construct return */
lwout = lwmpoint_construct_empty(lwgeom_get_srid(lwg), lwgeom_has_z(lwg), lwgeom_has_m(lwg));
{
LWCOLLECTION *lwgeom_out = NULL;
char hasz, hasm;
- int i;
+ uint32_t i;
/* Nothing to do with NULL */
if ( ! mpoint )
LWCOLLECTION *col;
char hasz = lwgeom_has_z(lwmline_as_lwgeom(mline));
char hasm = lwgeom_has_m(lwmline_as_lwgeom(mline));
- int i, j;
+ uint32_t i, j;
char homogeneous = 1;
size_t geoms_size = 0;
lwgeom_out = lwcollection_construct_empty(MULTILINETYPE, mline->srid, hasz, hasm);
POINTARRAY *pa_in = NULL;
LWCOLLECTION *lwgeom_out = NULL;
POINTARRAY *dp = NULL;
- int i;
+ uint32_t i;
int added_last_point = 0;
POINT4D *p = NULL, *q = NULL, *r = NULL;
double ordinate_value_p = 0.0, ordinate_value_q = 0.0;
{
LWCOLLECTION *out_col;
LWCOLLECTION *out_offset;
- int i;
+ uint32_t i;
if ( ! lwin )
lwerror("lwgeom_clip_to_ordinate_range: null input geometry!");
ptarray_collect_mvals(const POINTARRAY *pa, double tmin, double tmax, double *mvals)
{
POINT4D pbuf;
- int i, n=0;
+ uint32_t i, n=0;
for (i=0; i<pa->npoints; ++i)
{
getPoint4d_p(pa, i, &pbuf); /* could be optimized */
* or -1 if given measure was out of the known range.
*/
static int
-ptarray_locate_along_linear(const POINTARRAY *pa, double m, POINT4D *p, int from)
+ptarray_locate_along_linear(const POINTARRAY *pa, double m, POINT4D *p, uint32_t from)
{
- int i = from;
+ uint32_t i = from;
POINT4D p1, p2;
/* Walk through each segment in the point array */
LWMLINE*
lwmline_measured_from_lwmline(const LWMLINE *lwmline, double m_start, double m_end)
{
- int i = 0;
+ uint32_t i = 0;
int hasm = 0, hasz = 0;
double length = 0.0, length_so_far = 0.0;
double m_range = m_end - m_start;
void lwmline_free(LWMLINE *mline)
{
- int i;
+ uint32_t i;
if ( ! mline ) return;
if ( mline->bbox )
LWMPOINT *
lwmpoint_construct(int srid, const POINTARRAY *pa)
{
- int i;
+ uint32_t i;
int hasz = ptarray_has_z(pa);
int hasm = ptarray_has_m(pa);
LWMPOINT *ret = (LWMPOINT*)lwcollection_construct_empty(MULTIPOINTTYPE, srid, hasz, hasm);
void lwmpoint_free(LWMPOINT *mpt)
{
- int i;
+ uint32_t i;
if ( ! mpt ) return;
void lwmpoly_free(LWMPOLY *mpoly)
{
- int i;
+ uint32_t i;
if ( ! mpoly ) return;
if ( mpoly->bbox )
lwfree(mpoly->bbox);
static char*
pointarray_to_encoded_polyline(const POINTARRAY* pa, int precision)
{
- int i;
+ uint32_t i;
const POINT2D* prevPoint;
int* delta;
char* encoded_polyline = NULL;
asgeojson_poly_size(const LWPOLY *poly, char *srs, GBOX *bbox, int precision)
{
size_t size;
- int i;
+ uint32_t i;
size = sizeof("{\"type\":\"Polygon\",");
if (srs) size += asgeojson_srs_size(srs);
static size_t
asgeojson_poly_buf(const LWPOLY *poly, char *srs, char *output, GBOX *bbox, int precision)
{
- int i;
+ uint32_t i;
char *ptr=output;
ptr += sprintf(ptr, "{\"type\":\"Polygon\",");
{
LWPOINT * point;
int size;
- int i;
+ uint32_t i;
size = sizeof("{'type':'MultiPoint',");
if (srs) size += asgeojson_srs_size(srs);
asgeojson_multipoint_buf(const LWMPOINT *mpoint, char *srs, char *output, GBOX *bbox, int precision)
{
LWPOINT *point;
- int i;
+ uint32_t i;
char *ptr=output;
ptr += sprintf(ptr, "{\"type\":\"MultiPoint\",");
{
LWLINE * line;
int size;
- int i;
+ uint32_t i;
size = sizeof("{'type':'MultiLineString',");
if (srs) size += asgeojson_srs_size(srs);
asgeojson_multiline_buf(const LWMLINE *mline, char *srs, char *output, GBOX *bbox, int precision)
{
LWLINE *line;
- int i;
+ uint32_t i;
char *ptr=output;
ptr += sprintf(ptr, "{\"type\":\"MultiLineString\",");
{
LWPOLY *poly;
int size;
- int i, j;
+ uint32_t i, j;
size = sizeof("{'type':'MultiPolygon',");
if (srs) size += asgeojson_srs_size(srs);
asgeojson_multipolygon_buf(const LWMPOLY *mpoly, char *srs, char *output, GBOX *bbox, int precision)
{
LWPOLY *poly;
- int i, j;
+ uint32_t i, j;
char *ptr=output;
ptr += sprintf(ptr, "{\"type\":\"MultiPolygon\",");
static size_t
asgeojson_collection_size(const LWCOLLECTION *col, char *srs, GBOX *bbox, int precision)
{
- int i;
- int size;
+ uint32_t i;
+ size_t size;
LWGEOM *subgeom;
size = sizeof("{'type':'GeometryCollection',");
static size_t
asgeojson_collection_buf(const LWCOLLECTION *col, char *srs, char *output, GBOX *bbox, int precision)
{
- int i;
+ uint32_t i;
char *ptr=output;
LWGEOM *subgeom;
static size_t
pointArray_to_geojson(POINTARRAY *pa, char *output, int precision)
{
- int i;
+ uint32_t i;
char *ptr;
#define BUFSIZE OUT_MAX_DIGS_DOUBLE+OUT_MAX_DOUBLE_PRECISION
char x[BUFSIZE+1];
asgml2_poly_size(const LWPOLY *poly, const char *srs, int precision, const char *prefix)
{
size_t size;
- int i;
+ uint32_t i;
size_t prefixlen = strlen(prefix);
size = sizeof("<polygon></polygon>") + prefixlen*2;
asgml2_poly_buf(const LWPOLY *poly, const char *srs, char *output, int precision,
const char *prefix)
{
- int i;
+ uint32_t i;
char *ptr=output;
ptr += sprintf(ptr, "<%sPolygon", prefix);
asgml2_multi_size(const LWCOLLECTION *col, const char *srs, int precision,
const char *prefix)
{
- int i;
+ uint32_t i;
size_t size;
size_t prefixlen = strlen(prefix);
LWGEOM *subgeom;
{
int type = col->type;
char *ptr, *gmltype;
- int i;
+ uint32_t i;
LWGEOM *subgeom;
ptr = output;
asgml2_collection_size(const LWCOLLECTION *col, const char *srs, int precision,
const char *prefix)
{
- int i;
+ uint32_t i;
size_t size;
size_t prefixlen = strlen(prefix);
LWGEOM *subgeom;
asgml2_collection_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, const char *prefix)
{
char *ptr;
- int i;
+ uint32_t i;
LWGEOM *subgeom;
ptr = output;
static size_t
pointArray_toGML2(POINTARRAY *pa, char *output, int precision)
{
- int i;
+ uint32_t i;
char *ptr;
char x[OUT_MAX_DIGS_DOUBLE+OUT_MAX_DOUBLE_PRECISION+1];
char y[OUT_MAX_DIGS_DOUBLE+OUT_MAX_DOUBLE_PRECISION+1];
{
size_t size;
size_t prefixlen = strlen(prefix);
- int i;
+ uint32_t i;
size = ( sizeof("<PolygonPatch><exterior><LinearRing>///") + (prefixlen*3) ) * 2;
size += ( sizeof("<interior><LinearRing>//") + (prefixlen*2) ) * 2 * (poly->nrings - 1);
static size_t
asgml3_poly_buf(const LWPOLY *poly, const char *srs, char *output, int precision, int opts, int is_patch, const char *prefix, const char *id)
{
- int i;
+ uint32_t i;
char *ptr=output;
int dimension=2;
static size_t
asgml3_compound_size(const LWCOMPOUND *col, const char *srs, int precision, int opts, const char *prefix, const char *id )
{
- int i;
+ uint32_t i;
size_t size;
LWGEOM *subgeom;
size_t prefixlen = strlen(prefix);
asgml3_compound_buf(const LWCOMPOUND *col, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
{
LWGEOM *subgeom;
- int i;
+ uint32_t i;
char* ptr = output;
int dimension=2;
size_t size = sizeof( "<Polygon></Polygon" ) + 2 * prefixlen;
if (srs) size += strlen(srs) + sizeof(" srsName=..");
if (id) size += strlen(id) + strlen(prefix) + sizeof(" id=..");
- int i;
+ uint32_t i;
for( i = 0; i < poly->nrings; ++i )
{
static size_t asgml3_curvepoly_buf(const LWCURVEPOLY* poly, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
{
- int i;
+ uint32_t i;
LWGEOM* subgeom;
char *ptr=output;
int dimension=2;
static size_t
asgml3_multi_size(const LWCOLLECTION *col, const char *srs, int precision, int opts, const char *prefix, const char *id)
{
- int i;
+ uint32_t i;
size_t size;
size_t prefixlen = strlen(prefix);
LWGEOM *subgeom;
{
int type = col->type;
char *ptr, *gmltype;
- int i;
+ uint32_t i;
LWGEOM *subgeom;
ptr = output;
static size_t
asgml3_psurface_size(const LWPSURFACE *psur, const char *srs, int precision, int opts, const char *prefix, const char *id)
{
- int i;
+ uint32_t i;
size_t size;
size_t prefixlen = strlen(prefix);
asgml3_psurface_buf(const LWPSURFACE *psur, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
{
char *ptr;
- int i;
+ uint32_t i;
ptr = output;
static size_t
asgml3_tin_size(const LWTIN *tin, const char *srs, int precision, int opts, const char *prefix, const char *id)
{
- int i;
+ uint32_t i;
size_t size;
size_t prefixlen = strlen(prefix);
asgml3_tin_buf(const LWTIN *tin, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
{
char *ptr;
- int i;
+ uint32_t i;
ptr = output;
static size_t
asgml3_collection_size(const LWCOLLECTION *col, const char *srs, int precision, int opts, const char *prefix, const char *id)
{
- int i;
+ uint32_t i;
size_t size;
size_t prefixlen = strlen(prefix);
LWGEOM *subgeom;
asgml3_collection_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
{
char *ptr;
- int i;
+ uint32_t i;
LWGEOM *subgeom;
ptr = output;
if (srs) size += strlen(srs) + sizeof(" srsName=..");
if (id) size += strlen(id) + strlen(prefix) + sizeof(" id=..");
LWGEOM* subgeom;
- int i;
+ uint32_t i;
for( i = 0; i < cur->ngeoms; ++i )
{
{
char* ptr = output;
LWGEOM* subgeom;
- int i;
+ uint32_t i;
ptr += sprintf(ptr, "<%sMultiCurve", prefix );
if (srs)
if (srs) size += strlen(srs) + sizeof(" srsName=..");
if (id) size += strlen(id) + strlen(prefix) + sizeof(" id=..");
LWGEOM* subgeom;
- int i;
+ uint32_t i;
for( i = 0; i < sur->ngeoms; ++i )
{
static size_t asgml3_multisurface_buf(const LWMSURFACE *sur, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
{
char* ptr = output;
- int i;
+ uint32_t i;
LWGEOM* subgeom;
ptr += sprintf( ptr, "<%sMultiSurface", prefix );
static size_t
pointArray_toGML3(POINTARRAY *pa, char *output, int precision, int opts)
{
- int i;
+ uint32_t i;
char *ptr;
char x[OUT_MAX_DIGS_DOUBLE+OUT_MAX_DOUBLE_PRECISION+1];
char y[OUT_MAX_DIGS_DOUBLE+OUT_MAX_DOUBLE_PRECISION+1];
static int
ptarray_to_kml2_sb(const POINTARRAY *pa, int precision, stringbuffer_t *sb)
{
- int i, j;
- int dims = FLAGS_GET_Z(pa->flags) ? 3 : 2;
+ uint32_t i, j;
+ uint32_t dims = FLAGS_GET_Z(pa->flags) ? 3 : 2;
POINT4D pt;
double *d;
static int
lwpoly_to_kml2_sb(const LWPOLY *poly, int precision, const char *prefix, stringbuffer_t *sb)
{
- int i, rv;
+ uint32_t i;
+ int rv;
/* Open polygon */
if ( stringbuffer_aprintf(sb, "<%sPolygon>", prefix) < 0 ) return LW_FAILURE;
static int
lwcollection_to_kml2_sb(const LWCOLLECTION *col, int precision, const char *prefix, stringbuffer_t *sb)
{
- int i, rv;
+ uint32_t i;
+ int rv;
/* Open geometry */
if ( stringbuffer_aprintf(sb, "<%sMultiGeometry>", prefix) < 0 ) return LW_FAILURE;
/** @file
*
* SVG output routines.
-* Originally written by: Klaus Förster <klaus@svg.cc>
+* Originally written by: Klaus F�rster <klaus@svg.cc>
* Refactored by: Olivier Courtin (Camptocamp)
*
* BNF SVG Path: <http://www.w3.org/TR/SVG/paths.html#PathDataBNF>
static size_t
assvg_polygon_size(const LWPOLY *poly, int relative, int precision)
{
- int i;
+ uint32_t i;
size_t size=0;
for (i=0; i<poly->nrings; i++)
static size_t
assvg_polygon_buf(const LWPOLY *poly, char * output, int relative, int precision)
{
- int i;
+ uint32_t i;
char *ptr=output;
for (i=0; i<poly->nrings; i++)
{
const LWPOINT *point;
size_t size=0;
- int i;
+ uint32_t i;
for (i=0 ; i<mpoint->ngeoms ; i++)
{
assvg_multipoint_buf(const LWMPOINT *mpoint, char *output, int relative, int precision)
{
const LWPOINT *point;
- int i;
+ uint32_t i;
char *ptr=output;
for (i=0 ; i<mpoint->ngeoms ; i++)
{
const LWLINE *line;
size_t size=0;
- int i;
+ uint32_t i;
for (i=0 ; i<mline->ngeoms ; i++)
{
assvg_multiline_buf(const LWMLINE *mline, char *output, int relative, int precision)
{
const LWLINE *line;
- int i;
+ uint32_t i;
char *ptr=output;
for (i=0 ; i<mline->ngeoms ; i++)
{
const LWPOLY *poly;
size_t size=0;
- int i;
+ uint32_t i;
for (i=0 ; i<mpoly->ngeoms ; i++)
{
assvg_multipolygon_buf(const LWMPOLY *mpoly, char *output, int relative, int precision)
{
const LWPOLY *poly;
- int i;
+ uint32_t i;
char *ptr=output;
for (i=0 ; i<mpoly->ngeoms ; i++)
static size_t
assvg_collection_size(const LWCOLLECTION *col, int relative, int precision)
{
- int i = 0;
+ uint32_t i = 0;
size_t size=0;
const LWGEOM *subgeom;
static size_t
assvg_collection_buf(const LWCOLLECTION *col, char *output, int relative, int precision)
{
- int i;
+ uint32_t i;
char *ptr=output;
const LWGEOM *subgeom;
* @register_npoints, controls whether an npoints entry is added to the buffer (used to skip npoints for point types)
* @dimension, states the dimensionality of object this array is part of (0 = point, 1 = linear, 2 = areal)
*/
-static int ptarray_to_twkb_buf(const POINTARRAY *pa, TWKB_GLOBALS *globals, TWKB_STATE *ts, int register_npoints, int minpoints)
+static int ptarray_to_twkb_buf(const POINTARRAY *pa, TWKB_GLOBALS *globals, TWKB_STATE *ts, int register_npoints, uint32_t minpoints)
{
- int ndims = FLAGS_NDIMS(pa->flags);
- int i, j;
+ uint32_t ndims = FLAGS_NDIMS(pa->flags);
+ uint32_t i, j;
bytebuffer_t b;
bytebuffer_t *b_p;
int64_t nextdelta[MAX_N_DIMS];
static int lwpoly_to_twkb_buf(const LWPOLY *poly, TWKB_GLOBALS *globals, TWKB_STATE *ts)
{
- int i;
+ uint32_t i;
/* Set the number of rings */
bytebuffer_append_uvarint(ts->geom_buf, (uint64_t) poly->nrings);
static int lwmulti_to_twkb_buf(const LWCOLLECTION *col, TWKB_GLOBALS *globals, TWKB_STATE *ts)
{
- int i;
+ uint32_t i;
int nempty = 0;
LWDEBUGF(2, "Entered %s", __func__);
static int lwcollection_to_twkb_buf(const LWCOLLECTION *col, TWKB_GLOBALS *globals, TWKB_STATE *ts)
{
- int i;
+ uint32_t i;
LWDEBUGF(2, "Entered %s", __func__);
LWDEBUGF(4, "Number of geometries in collection is %d", col->ngeoms);
char* hexbytes_from_bytes(const uint8_t *bytes, size_t size)
{
char *hex;
- int i;
+ uint32_t i;
if ( ! bytes || ! size )
{
lwerror("hexbutes_from_bytes: invalid input");
static uint8_t* ptarray_to_wkb_buf(const POINTARRAY *pa, uint8_t *buf, uint8_t variant)
{
- int dims = 2;
- int pa_dims = FLAGS_NDIMS(pa->flags);
- int i, j;
+ uint32_t dims = 2;
+ uint32_t pa_dims = FLAGS_NDIMS(pa->flags);
+ uint32_t i, j;
double *dbl_ptr;
/* SFSQL is always 2-d. Extended and ISO use all available dimensions */
{
/* endian flag + type number + number of rings */
size_t size = WKB_BYTE_SIZE + WKB_INT_SIZE + WKB_INT_SIZE;
- int i = 0;
+ uint32_t i = 0;
/* Only process empty at this level in the EXTENDED case */
if ( (variant & WKB_EXTENDED) && lwgeom_is_empty((LWGEOM*)poly) )
static uint8_t* lwpoly_to_wkb_buf(const LWPOLY *poly, uint8_t *buf, uint8_t variant)
{
- int i;
+ uint32_t i;
/* Only process empty at this level in the EXTENDED case */
if ( (variant & WKB_EXTENDED) && lwgeom_is_empty((LWGEOM*)poly) )
{
/* Endian flag + type number + number of subgeoms */
size_t size = WKB_BYTE_SIZE + WKB_INT_SIZE + WKB_INT_SIZE;
- int i = 0;
+ uint32_t i = 0;
/* Extended WKB needs space for optional SRID integer */
if ( lwgeom_wkb_needs_srid((LWGEOM*)col, variant) )
static uint8_t* lwcollection_to_wkb_buf(const LWCOLLECTION *col, uint8_t *buf, uint8_t variant)
{
- int i;
+ uint32_t i;
/* Set the endian flag */
buf = endian_to_wkb_buf(buf, variant);
LWDEBUGF(4,"buf (%p) - wkb_out (%p) = %d", buf, wkb_out, buf - wkb_out);
/* The buffer pointer should now land at the end of the allocated buffer space. Let's check. */
- if ( buf_size != (buf - wkb_out) )
+ if ( buf_size != (size_t) (buf - wkb_out) )
{
LWDEBUG(4,"Output WKB is not the same size as the allocated buffer.");
lwerror("Output WKB is not the same size as the allocated buffer.");
static void ptarray_to_wkt_sb(const POINTARRAY *ptarray, stringbuffer_t *sb, int precision, uint8_t variant)
{
/* OGC only includes X/Y */
- int dimensions = 2;
- int i, j;
+ uint32_t dimensions = 2;
+ uint32_t i, j;
/* ISO and extended formats include all dimensions */
if ( variant & ( WKT_ISO | WKT_EXTENDED ) )
*/
static void lwpoly_to_wkt_sb(const LWPOLY *poly, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
stringbuffer_append(sb, "POLYGON"); /* "POLYGON" */
*/
static void lwmpoint_to_wkt_sb(const LWMPOINT *mpoint, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
stringbuffer_append(sb, "MULTIPOINT"); /* "MULTIPOINT" */
*/
static void lwmline_to_wkt_sb(const LWMLINE *mline, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
*/
static void lwmpoly_to_wkt_sb(const LWMPOLY *mpoly, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
*/
static void lwcompound_to_wkt_sb(const LWCOMPOUND *comp, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
*/
static void lwcurvepoly_to_wkt_sb(const LWCURVEPOLY *cpoly, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
*/
static void lwmcurve_to_wkt_sb(const LWMCURVE *mcurv, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
*/
static void lwmsurface_to_wkt_sb(const LWMSURFACE *msurf, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
*/
static void lwcollection_to_wkt_sb(const LWCOLLECTION *collection, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
*/
static void lwtin_to_wkt_sb(const LWTIN *tin, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
*/
static void lwpsurface_to_wkt_sb(const LWPSURFACE *psurf, stringbuffer_t *sb, int precision, uint8_t variant)
{
- int i = 0;
+ uint32_t i = 0;
if ( ! (variant & WKT_NO_TYPE) )
{
asx3d3_mline_coordindex_sb(const LWMLINE *mgeom, stringbuffer_t *sb)
{
LWLINE *geom;
- int i, j, k, si;
+ uint32_t i, j, k, si;
POINTARRAY *pa;
- int np;
+ uint32_t np;
j = 0;
for (i=0; i < mgeom->ngeoms; i++)
* and don't increment the index **/
if (!lwline_is_closed(geom) || k < (np -1) )
{
- stringbuffer_aprintf(sb, "%d", j);
+ stringbuffer_aprintf(sb, "%u", j);
j += 1;
}
else
{
- stringbuffer_aprintf(sb,"%d", si);
+ stringbuffer_aprintf(sb,"%u", si);
}
}
if (i < (mgeom->ngeoms - 1) )
asx3d3_mpoly_coordindex_sb(const LWMPOLY *psur, stringbuffer_t *sb)
{
LWPOLY *patch;
- int i, j, k, l;
- int np;
+ uint32_t i, j, k, l;
+ uint32_t np;
j = 0;
for (i=0; i<psur->ngeoms; i++)
{
static int
asx3d3_poly_sb(const LWPOLY *poly, char *srs, int precision, int opts, int is_patch, const char *defid, stringbuffer_t *sb)
{
- int i;
+ uint32_t i;
for (i=0; i<poly->nrings; i++)
{
if (i) stringbuffer_aprintf(sb, " "); /* inner ring points start */
asx3d3_multi_sb(const LWCOLLECTION *col, char *srs, int precision, int opts, const char *defid, stringbuffer_t *sb)
{
char *x3dtype;
- int i;
+ uint32_t i;
int dimension=2;
if (FLAGS_GET_Z(col->flags)) dimension = 3;
static int
asx3d3_psurface_sb(const LWPSURFACE *psur, char *srs, int precision, int opts, const char *defid, stringbuffer_t *sb)
{
- int i;
- int j;
- int k;
- int np;
+ uint32_t i;
+ uint32_t j;
+ uint32_t k;
+ uint32_t np;
LWPOLY *patch;
/* Open outmost tag */
static int
asx3d3_tin_sb(const LWTIN *tin, char *srs, int precision, int opts, const char *defid, stringbuffer_t *sb)
{
- int i;
- int k;
+ uint32_t i;
+ uint32_t k;
/* int dimension=2; */
stringbuffer_aprintf(sb,"<IndexedTriangleSet %s index='",defid);
static int
asx3d3_collection_sb(const LWCOLLECTION *col, char *srs, int precision, int opts, const char *defid, stringbuffer_t *sb)
{
- int i;
+ uint32_t i;
LWGEOM *subgeom;
/* Open outmost tag */
static int
ptarray_to_x3d3_sb(POINTARRAY *pa, int precision, int opts, int is_closed, stringbuffer_t *sb )
{
- int i;
+ uint32_t i;
char x[OUT_MAX_DIGS_DOUBLE+OUT_MAX_DOUBLE_PRECISION+1];
char y[OUT_MAX_DIGS_DOUBLE+OUT_MAX_DOUBLE_PRECISION+1];
char z[OUT_MAX_DIGS_DOUBLE+OUT_MAX_DOUBLE_PRECISION+1];
LWPOLY*
lwpoly_construct_circle(int srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
{
- const int segments = 4*segments_per_quarter;
+ const uint32_t segments = 4*segments_per_quarter;
const double theta = 2*M_PI / segments;
LWPOLY *lwpoly;
POINTARRAY *pa;
void lwpoly_free(LWPOLY *poly)
{
- int t;
+ uint32_t t;
if( ! poly ) return;
void printLWPOLY(LWPOLY *poly)
{
- int t;
+ uint32_t t;
lwnotice("LWPOLY {");
lwnotice(" ndims = %i", (int)FLAGS_NDIMS(poly->flags));
lwnotice(" SRID = %i", (int)poly->srid);
LWPOLY *
lwpoly_clone(const LWPOLY *g)
{
- int i;
+ uint32_t i;
LWPOLY *ret = lwalloc(sizeof(LWPOLY));
memcpy(ret, g, sizeof(LWPOLY));
ret->rings = lwalloc(sizeof(POINTARRAY *)*g->nrings);
LWPOLY *
lwpoly_clone_deep(const LWPOLY *g)
{
- int i;
+ uint32_t i;
LWPOLY *ret = lwalloc(sizeof(LWPOLY));
memcpy(ret, g, sizeof(LWPOLY));
if ( g->bbox ) ret->bbox = gbox_copy(g->bbox);
void
lwpoly_force_clockwise(LWPOLY *poly)
{
- int i;
+ uint32_t i;
/* No-op empties */
if ( lwpoly_is_empty(poly) )
int
lwpoly_is_clockwise(LWPOLY *poly)
{
- int i;
+ uint32_t i;
if ( lwpoly_is_empty(poly) )
return LW_TRUE;
for (i=0; i<poly->nrings; i++)
{
newrings[i] = ptarray_segmentize2d(poly->rings[i], dist);
- if ( ! newrings[i] ) {
- while (i--) ptarray_free(newrings[i]);
+ if ( ! newrings[i] )
+ {
+ uint32_t j = 0;
+ for (j = 0; j < i; j++)
+ ptarray_free(newrings[j]);
lwfree(newrings);
return NULL;
}
else
{
POINTARRAY **rings = NULL;
- int i;
+ uint32_t i;
rings = lwalloc(sizeof(POINTARRAY*) * poly->nrings);
for( i = 0; i < poly->nrings; i++ )
{
return LW_FALSE;
}
-int lwpoly_count_vertices(LWPOLY *poly)
+uint32_t lwpoly_count_vertices(LWPOLY *poly)
{
- int i = 0;
- int v = 0; /* vertices */
+ uint32_t i = 0;
+ uint32_t v = 0; /* vertices */
assert(poly);
for ( i = 0; i < poly->nrings; i ++ )
{
lwpoly_area(const LWPOLY *poly)
{
double poly_area = 0.0;
- int i;
+ uint32_t i;
if ( ! poly )
lwerror("lwpoly_area called with null polygon pointer!");
lwpoly_perimeter(const LWPOLY *poly)
{
double result=0.0;
- int i;
+ uint32_t i;
LWDEBUGF(2, "in lwgeom_polygon_perimeter (%d rings)", poly->nrings);
lwpoly_perimeter_2d(const LWPOLY *poly)
{
double result=0.0;
- int i;
+ uint32_t i;
LWDEBUGF(2, "in lwgeom_polygon_perimeter (%d rings)", poly->nrings);
int
lwpoly_is_closed(const LWPOLY *poly)
{
- int i = 0;
+ uint32_t i = 0;
if ( poly->nrings == 0 )
return LW_TRUE;
int
lwpoly_contains_point(const LWPOLY *poly, const POINT2D *pt)
{
- int i;
+ uint32_t i;
if ( lwpoly_is_empty(poly) )
return LW_FALSE;
void lwpsurface_free(LWPSURFACE *psurf)
{
- int i;
+ uint32_t i;
if ( ! psurf ) return;
if ( psurf->bbox )
lwfree(psurf->bbox);
void printLWPSURFACE(LWPSURFACE *psurf)
{
- int i, j;
+ uint32_t i, j;
LWPOLY *patch;
if (psurf->type != POLYHEDRALSURFACETYPE)
{
double ax, ay, az;
double bx, by, bz;
- int cnt, face;
+ uint32_t cnt, face;
};
typedef struct struct_psurface_arcs *psurface_arcs;
we could have wrong result if not */
int lwpsurface_is_closed(const LWPSURFACE *psurface)
{
- int i, j, k;
- int narcs, carc;
+ uint32_t i, j, k;
+ uint32_t narcs, carc;
int found;
psurface_arcs arcs;
POINT4D pa, pb;
geod_init(&gd, spheroid->a, spheroid->f);
struct geod_polygon poly;
geod_polygon_init(&poly, 0);
- int i;
+ uint32_t i;
double area; /* returned polygon area */
POINT2D p; /* long/lat units are degrees */
if ( type == POLYGONTYPE )
{
LWPOLY *poly = (LWPOLY*)lwgeom;
- int i;
+ uint32_t i;
double area = 0.0;
/* Just in case there's no rings */
if ( type == MULTIPOLYGONTYPE || type == COLLECTIONTYPE )
{
LWCOLLECTION *col = (LWCOLLECTION*)lwgeom;
- int i;
+ uint32_t i;
double area = 0.0;
for ( i = 0; i < col->ngeoms; i++ )
lwgeom_has_arc(const LWGEOM *geom)
{
LWCOLLECTION *col;
- int i;
+ uint32_t i;
LWDEBUG(2, "lwgeom_has_arc called.");
LWGEOM *tmp;
LWLINE *line;
POINTARRAY **ptarray;
- int i;
+ uint32_t i;
LWDEBUG(2, "lwcurvepoly_linearize called.");
{
LWMLINE *ogeom;
LWGEOM **lines;
- int i;
+ uint32_t i;
LWDEBUGF(2, "lwmcurve_linearize called, geoms=%d, dim=%d.", mcurve->ngeoms, FLAGS_NDIMS(mcurve->flags));
LWPOLY *poly;
LWGEOM **polys;
POINTARRAY **ptarray;
- int i, j;
+ uint32_t i, j;
LWDEBUG(2, "lwmsurface_linearize called.");
LWCOLLECTION *ocol;
LWGEOM *tmp;
LWGEOM **geoms;
- int i;
+ uint32_t i;
LWDEBUG(2, "lwcollection_linearize called.");
lwpolygon_unstroke(const LWPOLY *poly)
{
LWGEOM **geoms;
- int i, hascurve = 0;
+ uint32_t i, hascurve = 0;
LWDEBUG(2, "lwpolygon_unstroke called.");
lwmline_unstroke(const LWMLINE *mline)
{
LWGEOM **geoms;
- int i, hascurve = 0;
+ uint32_t i, hascurve = 0;
LWDEBUG(2, "lwmline_unstroke called.");
lwmpolygon_unstroke(const LWMPOLY *mpoly)
{
LWGEOM **geoms;
- int i, hascurve = 0;
+ uint32_t i, hascurve = 0;
LWDEBUG(2, "lwmpoly_unstroke called.");
void lwtin_free(LWTIN *tin)
{
- int i;
+ uint32_t i;
if ( ! tin ) return;
if ( tin->bbox )
lwfree(tin->bbox);
void printLWTIN(LWTIN *tin)
{
- int i;
+ uint32_t i;
LWTRIANGLE *triangle;
if (tin->type != TINTYPE)
{
double ax, ay, az;
double bx, by, bz;
- int cnt, face;
+ uint32_t cnt, face;
};
typedef struct struct_tin_arcs *tin_arcs;
we could have wrong result if not */
int lwtin_is_closed(const LWTIN *tin)
{
- int i, j, k;
- int narcs, carc;
+ uint32_t i, j, k;
+ uint32_t narcs, carc;
int found;
tin_arcs arcs;
POINT4D pa, pb;
lwtriangle_area(const LWTRIANGLE *triangle)
{
double area=0.0;
- int i;
+ uint32_t i;
POINT2D p1;
POINT2D p2;
lw_dist2d_point_poly(LWPOINT *point, LWPOLY *poly, DISTPTS *dl)
{
const POINT2D *p;
- int i;
+ uint32_t i;
LWDEBUG(2, "lw_dist2d_point_poly called");
lw_dist2d_point_curvepoly(LWPOINT *point, LWCURVEPOLY *poly, DISTPTS *dl)
{
const POINT2D *p;
- int i;
+ uint32_t i;
p = getPoint2d_cp(point->point, 0);
lw_dist2d_line_poly(LWLINE *line, LWPOLY *poly, DISTPTS *dl)
{
const POINT2D *pt;
- int i;
+ uint32_t i;
LWDEBUGF(2, "lw_dist2d_line_poly called (%d rings)", poly->nrings);
lw_dist2d_line_curvepoly(LWLINE *line, LWCURVEPOLY *poly, DISTPTS *dl)
{
const POINT2D *pt = getPoint2d_cp(line->points, 0);
- int i;
+ uint32_t i;
if ( lwgeom_contains_point(poly->rings[0], pt) == LW_OUTSIDE )
{
{
const POINT2D *pt;
- int i;
+ uint32_t i;
LWDEBUG(2, "lw_dist2d_poly_poly called");
lw_dist2d_curvepoly_curvepoly(LWCURVEPOLY *poly1, LWCURVEPOLY *poly2, DISTPTS *dl)
{
const POINT2D *pt;
- int i;
+ uint32_t i;
LWDEBUG(2, "lw_dist2d_curvepoly_curvepoly called");
int
lw_dist2d_pt_ptarray(const POINT2D *p, POINTARRAY *pa,DISTPTS *dl)
{
- int t;
+ uint32_t t;
const POINT2D *start, *end;
int twist = dl->twisted;
int
lw_dist2d_pt_ptarrayarc(const POINT2D *p, const POINTARRAY *pa, DISTPTS *dl)
{
- int t;
+ uint32_t t;
const POINT2D *A1;
const POINT2D *A2;
const POINT2D *A3;
int
lw_dist2d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2,DISTPTS *dl)
{
- int t,u;
+ uint32_t t,u;
const POINT2D *start, *end;
const POINT2D *start2, *end2;
int twist = dl->twisted;
int
lw_dist2d_ptarray_ptarrayarc(const POINTARRAY *pa, const POINTARRAY *pb, DISTPTS *dl)
{
- int t, u;
+ uint32_t t, u;
const POINT2D *A1;
const POINT2D *A2;
const POINT2D *B1;
int
lw_dist2d_ptarrayarc_ptarrayarc(const POINTARRAY *pa, const POINTARRAY *pb, DISTPTS *dl)
{
- int t, u;
+ uint32_t t, u;
const POINT2D *A1;
const POINT2D *A2;
const POINT2D *A3;
int
lw_dist3d_pt_ptarray(POINT3DZ *p, POINTARRAY *pa,DISTPTS3D *dl)
{
- int t;
+ uint32_t t;
POINT3DZ start, end;
int twist = dl->twisted;
int
lw_dist3d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2,DISTPTS3D *dl)
{
- int t,u;
+ uint32_t t,u;
POINT3DZ start, end;
POINT3DZ start2, end2;
int twist = dl->twisted;
int
lw_dist3d_pt_poly(POINT3DZ *p, LWPOLY *poly, PLANE3D *plane,POINT3DZ *projp, DISTPTS3D *dl)
{
- int i;
+ uint32_t i;
LWDEBUG(2, "lw_dist3d_point_poly called");
{
- int i,j,k;
+ uint32_t i,j,k;
double f, s1, s2;
VECTOR3D projp1_projp2;
POINT3DZ p1, p2,projp1, projp2, intersectionp;
int
define_plane(POINTARRAY *pa, PLANE3D *pl)
{
- int i,j, numberofvectors, pointsinslice;
+ uint32_t i,j, numberofvectors, pointsinslice;
POINT3DZ p, p1, p2;
double sumx=0;
}
else
{
- pointsinslice=(int) floor((pa->npoints-1)/4); /*divide the pointarray into 4 slices*/
+ pointsinslice=(uint32_t) floor((pa->npoints-1)/4); /*divide the pointarray into 4 slices*/
}
/*find the avg point*/
pt_in_ring_3d(const POINT3DZ *p, const POINTARRAY *ring,PLANE3D *plane)
{
- int cn = 0; /* the crossing number counter */
- int i;
+ uint32_t cn = 0; /* the crossing number counter */
+ uint32_t i;
POINT3DZ v1, v2;
POINT3DZ first, last;
* Size of point represeneted in the POINTARRAY
* 16 for 2d, 24 for 3d, 32 for 4d
*/
-int inline
+inline size_t
ptarray_point_size(const POINTARRAY *pa)
{
LWDEBUGF(5, "ptarray_point_size: FLAGS_NDIMS(pa->flags)=%x",FLAGS_NDIMS(pa->flags));
* pointarray supports.
*/
int
-ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
+ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
{
size_t point_size = ptarray_point_size(pa);
LWDEBUGF(5,"pa = %p; p = %p; where = %d", pa, p, where);
}
/* Error on invalid offset value */
- if ( where > pa->npoints || where < 0)
+ if ( where > pa->npoints )
{
lwerror("ptarray_insert_point: offset out of range (%d)", where);
return LW_FAILURE;
* pointarray supports.
*/
int
-ptarray_remove_point(POINTARRAY *pa, int where)
+ptarray_remove_point(POINTARRAY *pa, uint32_t where)
{
size_t ptsize = ptarray_point_size(pa);
}
/* Error on invalid offset value */
- if ( where >= pa->npoints || where < 0)
+ if ( where >= pa->npoints )
{
lwerror("ptarray_remove_point: offset out of range (%d)", where);
return LW_FAILURE;
POINTARRAY*
ptarray_flip_coordinates(POINTARRAY *pa)
{
- int i;
+ uint32_t i;
double d;
POINT4D p;
void
ptarray_swap_ordinates(POINTARRAY *pa, LWORD o1, LWORD o2)
{
- int i;
+ uint32_t i;
double d, *dp1, *dp2;
POINT4D p;
POINT4D p1, p2;
POINT4D pbuf;
POINTARRAY *opa;
- int ipoff=0; /* input point offset */
+ uint32_t ipoff=0; /* input point offset */
int hasz = FLAGS_GET_Z(ipa->flags);
int hasm = FLAGS_GET_M(ipa->flags);
ret = ptarray_construct(FLAGS_GET_Z(pa->flags),
FLAGS_GET_M(pa->flags), pa->npoints+1);
- if ( where == -1 ) where = pa->npoints;
if ( where )
{
ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
{
int wn = 0;
- int i;
+ uint32_t i;
double side;
const POINT2D *seg1;
const POINT2D *seg2;
ptarrayarc_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
{
int wn = 0;
- int i, side;
+ uint32_t i;
+ int side;
const POINT2D *seg1;
const POINT2D *seg2;
const POINT2D *seg3;
const POINT2D *P3;
double sum = 0.0;
double x0, x, y1, y2;
- int i;
+ uint32_t i;
if (! pa || pa->npoints < 3 )
return 0.0;
ptarray_force_dims(const POINTARRAY *pa, int hasz, int hasm)
{
/* TODO handle zero-length point arrays */
- int i;
+ uint32_t i;
int in_hasz = FLAGS_GET_Z(pa->flags);
int in_hasm = FLAGS_GET_M(pa->flags);
POINT4D pt;
double
ptarray_locate_point(const POINTARRAY *pa, const POINT4D *p4d, double *mindistout, POINT4D *proj4d)
{
- double mindist=-1;
+ double mindist=DBL_MAX;
double tlen, plen;
- int t, seg=-1;
+ uint32_t t, seg=0;
POINT4D start4d, end4d, projtmp;
POINT2D proj, p;
const POINT2D *start = NULL, *end = NULL;
if ( ! proj4d ) proj4d = &projtmp;
- start = getPoint2d_cp(pa, 0);
-
- /* If the pointarray has only one point, the nearest point is */
- /* just that point */
- if ( pa->npoints == 1 )
+ /* Check for special cases (length 0 and 1) */
+ if ( pa->npoints <= 1 )
{
- getPoint4d_p(pa, 0, proj4d);
- if ( mindistout )
- *mindistout = distance2d_pt_pt(&p, start);
+ if ( pa->npoints == 1 )
+ {
+ getPoint4d_p(pa, 0, proj4d);
+ if ( mindistout )
+ *mindistout = distance2d_pt_pt(&p, getPoint2d_cp(pa, 0));
+ }
return 0.0;
}
+ start = getPoint2d_cp(pa, 0);
/* Loop through pointarray looking for nearest segment */
for (t=1; t<pa->npoints; t++)
{
end = getPoint2d_cp(pa, t);
dist = distance2d_pt_seg(&p, start, end);
- if (t==1 || dist < mindist )
+ if ( dist < mindist )
{
mindist = dist;
seg=t-1;
- }
-
- if ( mindist == 0 )
- {
- LWDEBUG(3, "Breaking on mindist=0");
- break;
+ if ( mindist == 0 )
+ {
+ LWDEBUG(3, "Breaking on mindist=0");
+ break;
+ }
}
start = end;
void
ptarray_longitude_shift(POINTARRAY *pa)
{
- int i;
+ uint32_t i;
double x;
for (i=0; i<pa->npoints; i++)
void
-ptarray_remove_repeated_points_in_place(POINTARRAY *pa, double tolerance, int min_points)
+ptarray_remove_repeated_points_in_place(POINTARRAY *pa, double tolerance, uint32_t min_points)
{
- int i;
+ uint32_t i;
double tolsq = tolerance * tolerance;
const POINT2D *last = NULL;
const POINT2D *pt;
- int n_points = pa->npoints;
- int n_points_out = 1;
+ uint32_t n_points = pa->npoints;
+ uint32_t n_points_out = 1;
+ size_t pt_size = ptarray_point_size(pa);
+
double dsq = FLT_MAX;
/* No-op on short inputs */
pt = getPoint2d_cp(pa, i);
/* Don't drop points if we are running short of points */
- if (n_points - i > min_points - n_points_out)
+ if (n_points + n_points_out > min_points + i)
{
if (tolerance > 0.0)
{
else
{
/* At tolerance zero, only skip exact dupes */
- if (memcmp((char*)pt, (char*)last, ptarray_point_size(pa)) == 0)
+ if (memcmp((char*)pt, (char*)last, pt_size) == 0)
continue;
}
}
void
-ptarray_simplify_in_place(POINTARRAY *pa, double epsilon, unsigned int minpts)
+ptarray_simplify_in_place(POINTARRAY *pa, double epsilon, uint32_t minpts)
{
static size_t stack_size = 256;
int *stack, *outlist; /* recursion stack */
int outlist_static[stack_size];
int sp = -1; /* recursion stack pointer */
int p1, split;
- int outn = 0;
+ uint32_t outn = 0;
int pai = 0;
- int i;
+ uint32_t i;
double dist;
double eps_sqr = epsilon * epsilon;
ptarray_arc_length_2d(const POINTARRAY *pts)
{
double dist = 0.0;
- int i;
+ uint32_t i;
const POINT2D *a1;
const POINT2D *a2;
const POINT2D *a3;
ptarray_length_2d(const POINTARRAY *pts)
{
double dist = 0.0;
- int i;
+ uint32_t i;
const POINT2D *frm;
const POINT2D *to;
ptarray_length(const POINTARRAY *pts)
{
double dist = 0.0;
- int i;
+ uint32_t i;
POINT3DZ frm;
POINT3DZ to;
* aligned to double boundary.
*/
uint8_t *
-getPoint_internal(const POINTARRAY *pa, int n)
+getPoint_internal(const POINTARRAY *pa, uint32_t n)
{
size_t size;
uint8_t *ptr;
void
ptarray_affine(POINTARRAY *pa, const AFFINE *a)
{
- int i;
+ uint32_t i;
double x,y,z;
POINT4D p4d;
void
ptarray_scale(POINTARRAY *pa, const POINT4D *fact)
{
- int i;
+ uint32_t i;
POINT4D p4d;
LWDEBUG(3, "ptarray_scale start");
for (i=0; i<pa->npoints; i++)
void
ptarray_grid_in_place(POINTARRAY *pa, const gridspec *grid)
{
- int i, j = 0;
+ uint32_t i, j = 0;
POINT4D *p, *p_out = NULL;
int ndims = FLAGS_NDIMS(pa->flags);
int has_z = FLAGS_GET_Z(pa->flags);
{
const POINT2D *pt;
int n = 0;
- int i;
+ uint32_t i;
for ( i = 0; i < pa->npoints; i++ )
{
pt = getPoint2d_cp(pa, i);
*/
void gidx_expand(GIDX *a, float d)
{
- int i;
+ uint32_t i;
POSTGIS_DEBUG(5, "entered function");
{
SHPObject *obj;
POINT4D p4d;
- int i;
+ uint32_t i;
double *xpts, *ypts, *zpts, *mpts;
{
SHPObject *obj;
POINT4D p4d;
- int i, j;
+ uint32_t i, j;
double *xpts, *ypts, *zpts, *mpts;
{
SHPObject *obj;
POINT4D p4d;
- int i, j, k;
+ uint32_t i, j, k;
double *xpts, *ypts, *zpts, *mpts;
{
SHPObject *obj;
POINT4D p4d;
- int i;
+ uint32_t i;
double *xpts, *ypts, *zpts, *mpts;
{
SHPObject *obj;
POINT4D p4d;
- int i, j;
+ uint32_t i, j;
double *xpts, *ypts, *zpts, *mpts;
char *convert_bytes_to_hex(uint8_t *ewkb, size_t size)
{
- int i;
+ size_t i;
char *hexewkb;
/* Convert the byte stream to a hex string using liblwgeom's deparse_hex function */
{
if (!strncasecmp(dbffieldname, state->dbffieldnames[j], 10))
{
- sprintf(dbffieldname, "%.7s_%.2d", ptr, tmpint++);
+ sprintf(dbffieldname, "%.7s_%.2d", ptr, tmpint % 100);
+ tmpint++;
continue;
}
}
/* make UPPERCASE if keep_fieldname_case = 0 */
if (!state->config->keep_fieldname_case)
- for (j = 0; j < strlen(dbffieldname); j++)
- dbffieldname[j] = toupper(dbffieldname[j]);
+ {
+ size_t nameit;
+ for (nameit = 0; nameit < strlen(dbffieldname); nameit++)
+ dbffieldname[nameit] = toupper(dbffieldname[nameit]);
+ }
/* Issue warning if column has been renamed */
if (strcasecmp(dbffieldname, pgfieldname))
outputptr = *outputbuf;
/* Does this string convert cleanly? */
- if ( iconv(cd, &inputbuf, &inbytesleft, &outputptr, &outbytesleft) == -1 )
+ if ( iconv(cd, &inputbuf, &inbytesleft, &outputptr, &outbytesleft) == (size_t)-1 )
{
#ifdef HAVE_ICONVCTL
int on = 1;
void
strtolower(char *s)
{
- int j;
+ size_t j;
for (j = 0; j < strlen(s); j++)
s[j] = tolower(s[j]);
SHPReadObject( SHPHandle psSHP, int hEntity )
{
- int nEntitySize, nRequiredSize;
+ int32 nEntitySize, nRequiredSize;
SHPObject *psShape;
char szErrorMsg[128];
/* Ensure our record buffer is large enough. */
/* -------------------------------------------------------------------- */
nEntitySize = psSHP->panRecSize[hEntity]+8;
- if( nEntitySize > psSHP->nBufSize )
+ if( nEntitySize > (int32) psSHP->nBufSize )
{
psSHP->pabyRec = (uchar *) SfRealloc(psSHP->pabyRec,nEntitySize);
if (psSHP->pabyRec == NULL)
|| psShape->nSHPType == SHPT_MULTIPATCH )
{
int32 nPoints, nParts;
- int i, nOffset;
+ int32 i, nOffset;
if ( 40 + 8 + 4 > nEntitySize )
{
|| psShape->nSHPType == SHPT_MULTIPOINTZ )
{
int32 nPoints;
- int i, nOffset;
+ int32 i, nOffset;
if ( 44 + 4 > nEntitySize )
{
|| psShape->nSHPType == SHPT_POINTM
|| psShape->nSHPType == SHPT_POINTZ )
{
- int nOffset;
+ int32 nOffset;
psShape->nVertices = 1;
psShape->padfX = (double *) calloc(1,sizeof(double));
static void encode_keys(struct geobuf_agg_context *ctx)
{
TupleDesc tupdesc = get_tuple_desc(ctx);
- int natts = tupdesc->natts;
+ uint32_t natts = (uint32_t) tupdesc->natts;
char **keys = palloc(natts * sizeof(*keys));
uint32_t i, k = 0;
bool geom_found = false;
Data__Value **values;
uint32_t i, k = 0, c = 0;
TupleDesc tupdesc = get_tuple_desc(ctx);
- int natts = tupdesc->natts;
+ uint32_t natts = (uint32_t) tupdesc->natts;
properties = palloc(sizeof (*properties) * (natts - 1) * 2);
values = palloc (sizeof (*values) * (natts - 1));
static void analyze_pa(struct geobuf_agg_context *ctx, POINTARRAY *pa)
{
- int i;
+ uint32_t i;
POINT4D pt;
for (i = 0; i < pa->npoints; i++) {
getPoint4d_p(pa, i, &pt);
static void analyze_geometry(struct geobuf_agg_context *ctx, LWGEOM *lwgeom)
{
- int i, type;
+ uint32_t i, type;
LWLINE *lwline;
LWPOLY *lwpoly;
LWCOLLECTION *lwcollection;
*/
uint8_t *geobuf_agg_finalfn(struct geobuf_agg_context *ctx)
{
- int i;
+ size_t i;
Data *data;
Data__FeatureCollection *fc;
LWGEOM *lwgeom;
GSERIALIZED *geom;
POINTARRAY *pa;
- int i;
+ uint32_t i;
const POINT2D *pt;
size_t size;
GSERIALIZED *geom;
POINTARRAY *pa;
GBOX gbox;
- int i;
+ uint32_t i;
size_t size;
POSTGIS_DEBUG(2, "geometry_to_polygon called");
pa = lwpoly->rings[0];
- size = offsetof(POLYGON, p[0]) + sizeof(polygon->p[0]) * pa->npoints;
- polygon = (POLYGON*)palloc0(size); /* zero any holes */
+ size = offsetof(POLYGON, p[0]) + sizeof(polygon->p[0]) * pa->npoints;
+ polygon = (POLYGON*)palloc0(size); /* zero any holes */
SET_VARSIZE(polygon, size);
polygon->npts = pa->npoints;
*/
do
{
- ND_BOX nd_cell;
+ ND_BOX nd_cell = { {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0} };
double ratio;
/* Create a box for this histogram cell */
for ( d = 0; d < nd_stats->ndims; d++ )
do
{
float cell_count, ratio;
- ND_BOX nd_cell;
+ ND_BOX nd_cell = { {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0} };
/* We have to pro-rate partially overlapped cells. */
for ( d = 0; d < nd_stats->ndims; d++ )
/* Ensure all minimums are below maximums. */
static inline void gidx_validate(GIDX *b)
{
- int i;
+ uint32_t i;
Assert(b);
POSTGIS_DEBUGF(5,"validating gidx (%s)", gidx_to_string(b));
for ( i = 0; i < GIDX_NDIMS(b); i++ )
static float gidx_volume(GIDX *a)
{
float result;
- int i;
+ uint32_t i;
if ( a == NULL || gidx_is_unknown(a) )
{
/* elog(ERROR, "gidx_volume received a null argument"); */
static float gidx_edge(GIDX *a)
{
float result;
- int i;
+ uint32_t i;
if ( a == NULL || gidx_is_unknown(a) )
{
return 0.0;
/* Calculate the volume of the intersection of the boxes. */
static float gidx_inter_volume(GIDX *a, GIDX *b)
{
- int i;
+ uint32_t i;
float result;
POSTGIS_DEBUG(5,"entered function");
*/
static bool gidx_equals(GIDX *a, GIDX *b)
{
- int i;
+ uint32_t i;
POSTGIS_DEBUG(5, "entered function");
char gidxmem[GIDX_MAX_SIZE];
GIDX *bbox_out = (GIDX*)gidxmem;
int result = LW_SUCCESS;
- int i;
+ uint32_t i;
POSTGIS_DEBUG(4, "[GIST] 'compress' function called");
LWPOLY *poly;
/* Initialize the 4 vertices of the polygon */
- points[0] = (POINT4D) { box->xmin, box->ymin };
- points[1] = (POINT4D) { box->xmin, box->ymax };
- points[2] = (POINT4D) { box->xmax, box->ymax };
- points[3] = (POINT4D) { box->xmax, box->ymin };
+ points[0] = (POINT4D) { box->xmin, box->ymin, 0.0, 0.0 };
+ points[1] = (POINT4D) { box->xmin, box->ymax, 0.0, 0.0 };
+ points[2] = (POINT4D) { box->xmax, box->ymax, 0.0, 0.0 };
+ points[3] = (POINT4D) { box->xmax, box->ymin, 0.0, 0.0 };
/* Construct polygon */
poly = lwpoly_construct_rectangle(LW_FALSE, LW_FALSE, &points[0], &points[1],
LWPOLY *lwpoly;
/* Initialize the 4 vertices of the polygon */
- points[0] = (POINT4D) { box->xmin, box->ymin, box->zmin };
- points[1] = (POINT4D) { box->xmin, box->ymax, box->zmin };
- points[2] = (POINT4D) { box->xmin, box->ymax, box->zmax };
- points[3] = (POINT4D) { box->xmin, box->ymin, box->zmax };
+ points[0] = (POINT4D) { box->xmin, box->ymin, box->zmin, 0.0 };
+ points[1] = (POINT4D) { box->xmin, box->ymax, box->zmin, 0.0 };
+ points[2] = (POINT4D) { box->xmin, box->ymax, box->zmax, 0.0 };
+ points[3] = (POINT4D) { box->xmin, box->ymin, box->zmax, 0.0 };
lwpoly = lwpoly_construct_rectangle(LW_TRUE, LW_FALSE,
&points[0], &points[1], &points[2], &points[3]);
LWPOLY *lwpoly;
/* Initialize the 4 vertices of the polygon */
- points[0] = (POINT4D) { box->xmin, box->ymin, box->zmin };
- points[1] = (POINT4D) { box->xmax, box->ymin, box->zmin };
- points[2] = (POINT4D) { box->xmax, box->ymin, box->zmax };
- points[3] = (POINT4D) { box->xmin, box->ymin, box->zmax };
+ points[0] = (POINT4D) { box->xmin, box->ymin, box->zmin, 0.0 };
+ points[1] = (POINT4D) { box->xmax, box->ymin, box->zmin, 0.0 };
+ points[2] = (POINT4D) { box->xmax, box->ymin, box->zmax, 0.0 };
+ points[3] = (POINT4D) { box->xmin, box->ymin, box->zmax, 0.0 };
lwpoly = lwpoly_construct_rectangle(LW_TRUE, LW_FALSE,
&points[0], &points[1], &points[2], &points[3]);
LWPOLY *lwpoly;
/* Initialize the 4 vertices of the polygon */
- points[0] = (POINT4D) { box->xmin, box->ymin, box->zmin };
- points[1] = (POINT4D) { box->xmin, box->ymax, box->zmin };
- points[2] = (POINT4D) { box->xmax, box->ymax, box->zmin };
- points[3] = (POINT4D) { box->xmax, box->ymin, box->zmin };
+ points[0] = (POINT4D) { box->xmin, box->ymin, box->zmin, 0.0 };
+ points[1] = (POINT4D) { box->xmin, box->ymax, box->zmin, 0.0 };
+ points[2] = (POINT4D) { box->xmax, box->ymax, box->zmin, 0.0 };
+ points[3] = (POINT4D) { box->xmax, box->ymin, box->zmin, 0.0 };
lwpoly = lwpoly_construct_rectangle(LW_TRUE, LW_FALSE,
&points[0], &points[1], &points[2], &points[3]);
LWGEOM *geom = NULL;
/* Initialize the 8 vertices of the box */
- points[0] = (POINT4D) { box->xmin, box->ymin, box->zmin };
- points[1] = (POINT4D) { box->xmin, box->ymax, box->zmin };
- points[2] = (POINT4D) { box->xmax, box->ymax, box->zmin };
- points[3] = (POINT4D) { box->xmax, box->ymin, box->zmin };
- points[4] = (POINT4D) { box->xmin, box->ymin, box->zmax };
- points[5] = (POINT4D) { box->xmin, box->ymax, box->zmax };
- points[6] = (POINT4D) { box->xmax, box->ymax, box->zmax };
- points[7] = (POINT4D) { box->xmax, box->ymin, box->zmax };
+ points[0] = (POINT4D) { box->xmin, box->ymin, box->zmin, 0.0 };
+ points[1] = (POINT4D) { box->xmin, box->ymax, box->zmin, 0.0 };
+ points[2] = (POINT4D) { box->xmax, box->ymax, box->zmin, 0.0 };
+ points[3] = (POINT4D) { box->xmax, box->ymin, box->zmin, 0.0 };
+ points[4] = (POINT4D) { box->xmin, box->ymin, box->zmax, 0.0 };
+ points[5] = (POINT4D) { box->xmin, box->ymax, box->zmax, 0.0 };
+ points[6] = (POINT4D) { box->xmax, box->ymax, box->zmax, 0.0 };
+ points[7] = (POINT4D) { box->xmax, box->ymin, box->zmax, 0.0 };
/* add bottom polygon */
geoms[0] = lwpoly_as_lwgeom(lwpoly_construct_rectangle(LW_TRUE, LW_FALSE,
typedef struct GEOMDUMPNODE_T
{
- int idx;
+ uint32_t idx;
LWGEOM *geom;
}
GEOMDUMPNODE;
Datum result;
char address[256];
char *ptr;
- uint32 i;
+ int i;
char *values[2];
if (SRF_IS_FIRSTCALL())
struct POLYDUMPSTATE
{
- int ringnum;
+ uint32_t ringnum;
LWPOLY *poly;
};
struct dumpnode {
LWGEOM *geom;
- int idx; /* which member geom we're working on */
+ uint32_t idx; /* which member geom we're working on */
} ;
/* 32 is the max depth for st_dump, so it seems reasonable
bool byval;
char align;
- int ring; /* ring of top polygon */
- int pt; /* point of top geom or current ring */
+ uint32_t ring; /* ring of top polygon */
+ uint32_t pt; /* point of top geom or current ring */
};
PG_FUNCTION_INFO_V1(LWGEOM_dumppoints);
else if ( type == MULTILINETYPE )
{
LWMLINE *iline;
- int i = 0, g = 0;
+ uint32_t i = 0, g = 0;
int homogeneous = LW_TRUE;
LWGEOM **geoms = NULL;
double length = 0.0, sublength = 0.0, minprop = 0.0, maxprop = 0.0;
static int point_in_ring_rtree(RTREE_NODE *root, const POINT2D *point)
{
int wn = 0;
- int i;
+ uint32_t i;
double side;
const POINT2D *seg1;
const POINT2D *seg2;
static int point_in_ring(POINTARRAY *pts, const POINT2D *point)
{
int wn = 0;
- int i;
+ uint32_t i;
double side;
const POINT2D* seg1;
const POINT2D* seg2;
POSTGIS_DEBUG(2, "point_in_ring called.");
- seg2 = getPoint2d_cp(pts, 0);
+ seg2 = getPoint2d_cp(pts, 0);
for (i=0; i<pts->npoints-1; i++)
{
seg1 = seg2;
*/
int point_in_polygon(LWPOLY *polygon, LWPOINT *point)
{
- int i, result, in_ring;
+ uint32_t i;
+ int result, in_ring;
POINT2D pt;
POSTGIS_DEBUG(2, "point_in_polygon called.");
*/
int point_in_multipolygon(LWMPOLY *mpolygon, LWPOINT *point)
{
- int i, j, result, in_ring;
+ uint32_t i, j;
+ int result, in_ring;
POINT2D pt;
POSTGIS_DEBUG(2, "point_in_polygon called.");
holes = lwalloc(sizeof(LWLINE *)*nholes);
for (i=0; i<nholes; i++)
{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-compare"
GSERIALIZED *g = (GSERIALIZED *)(ARR_DATA_PTR(array)+offset);
+#pragma GCC diagnostic pop
LWLINE *hole;
offset += INTALIGN(VARSIZE(g));
if ( gserialized_get_type(g) != LINETYPE )
GSERIALIZED *pglwg1, *pglwg2, *result;
LWPOINT *point;
LWLINE *line, *linecopy;
- int where = -1;
+ int32 where = -1;
POSTGIS_DEBUGF(2, "%s called.", __func__);
pglwg1 = PG_GETARG_GSERIALIZED_P(0);
pglwg2 = PG_GETARG_GSERIALIZED_P(1);
- if ( PG_NARGS() > 2 )
- {
- where = PG_GETARG_INT32(2);
- }
if ( gserialized_get_type(pglwg1) != LINETYPE )
{
line = lwgeom_as_lwline(lwgeom_from_gserialized(pglwg1));
- if ( where == -1 ) where = line->points->npoints;
- else if ( where < 0 || where > line->points->npoints )
+ if ( PG_NARGS() > 2 )
+ {
+ where = PG_GETARG_INT32(2);
+ }
+ else
+ {
+ where = line->points->npoints;
+ }
+
+ if ( where < 0 || where > (int32) line->points->npoints )
{
elog(ERROR, "Invalid offset");
PG_RETURN_NULL();
linecopy = lwgeom_as_lwline(lwgeom_clone_deep(lwline_as_lwgeom(line)));
lwline_free(line);
- if ( lwline_add_lwpoint(linecopy, point, where) == LW_FAILURE )
+ if ( lwline_add_lwpoint(linecopy, point, (uint32_t) where) == LW_FAILURE )
{
elog(ERROR, "Point insert failed");
PG_RETURN_NULL();
/* Use backward indexing for negative values */
which = which + line->points->npoints ;
}
- if ( which > line->points->npoints-1 || which < 0 )
+ if ( (uint32_t)which + 1 > line->points->npoints )
{
elog(ERROR, "abs(Point index) out of range (-)(%d..%d)", 0, line->points->npoints-1);
PG_RETURN_NULL();
/*
* This will change pointarray of the serialized pglwg1,
*/
- lwline_setPoint4d(line, which, &newpoint);
+ lwline_setPoint4d(line, (uint32_t)which, &newpoint);
result = geometry_serialize((LWGEOM *)line);
/* Release memory */
{
POINTARRAYSET ret;
POINTARRAY *dpa=NULL;
- int i;
+ uint32_t i;
ret.nptarrays=0;
static LWGEOM *
lwcollection_locate_between_m(LWCOLLECTION *lwcoll, double m0, double m1)
{
- int i;
+ uint32_t i;
int ngeoms=0;
LWGEOM **geoms;
/* One geom, good geom? Return it */
if ( count == 1 && nelems == 1 )
+ {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-compare"
PG_RETURN_POINTER((GSERIALIZED *)(ARR_DATA_PTR(array)));
+#pragma GCC diagnostic pop
+ }
/* Ok, we really need GEOS now ;) */
initGEOS(lwpgnotice, lwgeom_geos_error);
char *patt;
bool result;
GEOSGeometry *g1, *g2;
- int i;
+ size_t i;
geom1 = PG_GETARG_GSERIALIZED_P(0);
geom2 = PG_GETARG_GSERIALIZED_P(1);
Datum val_geom, val_id;
int is_homogeneous = true;
- int subtype = 0;
+ uint32_t subtype = 0;
int has_z = 0;
int has_m = 0;
LWCOLLECTION *col = NULL;
coll = lwgeom_as_lwcollection(lwgeom_from_gserialized(geom));
if ( idx < 0 ) PG_RETURN_NULL();
- if ( idx >= coll->ngeoms ) PG_RETURN_NULL();
+ if ( idx >= (int32) coll->ngeoms ) PG_RETURN_NULL();
subgeom = coll->geoms[idx];
subgeom->srid = coll->srid;
poly = lwgeom_as_lwpoly(lwgeom_from_gserialized(geom));
/* Ok, now we have a polygon. Let's see if it has enough holes */
- if ( wanted_index >= poly->nrings )
+ if ( wanted_index >= (int32)poly->nrings )
{
lwpoly_free(poly);
PG_FREE_IF_COPY(geom, 0);
{
curvepoly = lwgeom_as_lwcurvepoly(lwgeom_from_gserialized(geom));
- if (wanted_index >= curvepoly->nrings)
+ if (wanted_index >= (int32)curvepoly->nrings)
{
PG_FREE_IF_COPY(geom, 0);
lwgeom_release((LWGEOM *)curvepoly);
* Creates a leaf node given the pointer to the start point of the segment.
*/
static RTREE_NODE*
-RTreeCreateLeafNode(POINTARRAY* pa, int startPoint)
+RTreeCreateLeafNode(POINTARRAY* pa, uint32_t startPoint)
{
RTREE_NODE *parent;
LWLINE *line;
{
RTREE_NODE* root;
RTREE_NODE** nodes = lwalloc(pointArray->npoints * sizeof(RTREE_NODE*));
- int i, nodeCount;
- int childNodes, parentNodes;
+ uint32_t i, nodeCount;
+ uint32_t childNodes, parentNodes;
POSTGIS_DEBUGF(2, "RTreeCreate called with pointarray %p", pointArray);
{
LWGEOM **geoms;
LWCOLLECTION *col;
- int i, j, ngeoms;
+ uint32_t i, j, ngeoms;
POSTGIS_DEBUGF(2, "RTreeMergeMultiLines called on %p, %d, %d; %p, %d, %d", line1, line1->ngeoms, line1->type, line2, line2->ngeoms, line2->type);
static int
RTreeBuilder(const LWGEOM* lwgeom, GeomCache* cache)
{
- int i, p, r;
+ uint32_t i, p, r;
LWMPOLY *mpoly;
LWPOLY *poly;
int nrings;
size_t size = strlen(name);
HASH_FIND(hh, ctx->keys_hash, name, size, kv);
if (!kv)
- return -1;
+ return UINT32_MAX;
return kv->id;
}
static void parse_column_keys(mvt_agg_context *ctx)
{
TupleDesc tupdesc = get_tuple_desc(ctx);
- int natts = tupdesc->natts;
+ uint32_t natts = (uint32_t) tupdesc->natts;
uint32_t i;
bool geom_found = false;
char *key;
key[v.val.string.len] = '\0';
k = get_key_index(ctx, key);
- if (k == -1) {
+ if (k == UINT32_MAX) {
uint32_t newSize = ctx->keys_hash_i + 1;
tags = repalloc(tags, newSize * 2 * sizeof(*tags));
k = add_key(ctx, key);
bool isnull;
uint32_t i, k;
TupleDesc tupdesc = get_tuple_desc(ctx);
- int natts = tupdesc->natts;
+ uint32_t natts = (uint32_t) tupdesc->natts;
ctx->c = 0;
POSTGIS_DEBUGF(3, "parse_values natts: %d", natts);
continue;
}
#if POSTGIS_PGSQL_VERSION >= 94
- if (k == -1 && typoid != JSONBOID)
+ if (k == UINT32_MAX && typoid != JSONBOID)
elog(ERROR, "parse_values: unexpectedly could not find parsed key name '%s'", key);
if (typoid == JSONBOID) {
tags = parse_jsonb(ctx, DatumGetJsonbP(datum), tags);
/* by finding the largest basic type available and */
/* using that as the basis of a typed collection. */
LWCOLLECTION *g = (LWCOLLECTION*)geom;
- int i, maxtype = 0;
+ uint32_t i, maxtype = 0;
for (i = 0; i < g->ngeoms; i++)
{
LWGEOM *sg = g->geoms[i];
static VectorTile__Tile__Feature *
tile_feature_copy(const VectorTile__Tile__Feature *feature, int key_offset, int value_offset)
{
- int i;
+ uint32_t i;
/* Null in => Null out */
if (!feature) return NULL;
static VectorTile__Tile__Layer *
vectortile_layer_combine(const VectorTile__Tile__Layer *layer1, const VectorTile__Tile__Layer *layer2)
{
- int i, j;
+ uint32_t i, j;
int key2_offset, value2_offset;
VectorTile__Tile__Layer *layer = palloc(sizeof(VectorTile__Tile__Layer));
vector_tile__tile__layer__init(layer);
/* Take globals from layer1 */
layer->version = layer1->version;
layer->name = pstrdup(layer1->name);
- layer->has_extent = layer1->has_extent;
+ layer->has_extent = layer1->has_extent;
layer->extent = layer1->extent;
/* Copy keys into new layer */
static VectorTile__Tile *
vectortile_tile_combine(VectorTile__Tile *tile1, VectorTile__Tile *tile2)
{
- int i, j;
+ uint32_t i, j;
/* Hopelessly messing up memory ownership here */
if (tile1->n_layers == 0 && tile2->n_layers == 0)
}
static int
-array_range(int min, int max, int step, int **range, int *len) {
+array_range(int min, int max, int step, int **range, uint32_t *len) {
int i = 0;
int j = 0;
step = abs(step);
- *len = (abs(max - min) + 1 + (step / 2)) / step;
+ *len = (uint32_t) ((abs(max - min) + 1 + (step / 2)) / step);
*range = rtalloc(sizeof(int) * *len);
if (min < max) {
/* split a string based on a delimiter */
static char**
-strsplit(const char *str, const char *delimiter, int *n) {
+strsplit(const char *str, const char *delimiter, uint32_t *n) {
char *tmp = NULL;
char **rtn = NULL;
char *token = NULL;
static void
diff_rastinfo(RASTERINFO *x, RASTERINFO *ref) {
static uint8_t msg[6] = {0};
- int i = 0;
+ uint32_t i = 0;
/* # of bands */
if (
static void
dump_stringbuffer(STRINGBUFFER *buffer) {
- int i = 0;
+ uint32_t i = 0;
for (i = 0; i < buffer->length; i++) {
printf("%s\n", buffer->line[i]);
}
static int
-build_overview(int idx, RTLOADERCFG *config, RASTERINFO *info, int ovx, STRINGBUFFER *tileset, STRINGBUFFER *buffer) {
+build_overview(int idx, RTLOADERCFG *config, RASTERINFO *info, uint32_t ovx, STRINGBUFFER *tileset, STRINGBUFFER *buffer) {
GDALDatasetH hdsSrc;
VRTDatasetH hdsOv;
VRTSourcedRasterBandH hbandOv;
double gtOv[6] = {0.};
int dimOv[2] = {0};
- int j = 0;
+ uint32_t j = 0;
int factor;
const char *ovtable = NULL;
GDALDatasetH hdsSrc;
GDALRasterBandH hbandSrc;
int nband = 0;
- int i = 0;
+ uint32_t i = 0;
int ntiles[2] = {1, 1};
int _tile_size[2] = {0, 0};
int xtile = 0;
int tilesize = 0;
rt_raster rast = NULL;
- int numbands = 0;
+ uint32_t numbands = 0;
rt_band band = NULL;
char *hex;
uint32_t hexlen = 0;
info->tile_size[1] = config->tile_size[1];
/* number of tiles */
- if (info->tile_size[0] != info->dim[0])
+ if ((uint32_t)info->tile_size[0] != info->dim[0])
ntiles[0] = (info->dim[0] + info->tile_size[0] - 1) / info->tile_size[0];
- if (info->tile_size[1] != info->dim[1])
+ if ((uint32_t)info->tile_size[1] != info->dim[1])
ntiles[1] = (info->dim[1] + info->tile_size[1] - 1) / info->tile_size[1];
/* estimate size of 1 tile */
static int
process_rasters(RTLOADERCFG *config, STRINGBUFFER *buffer) {
- int i = 0;
+ uint32_t i = 0;
assert(config != NULL);
assert(config->table != NULL);
/* overviews */
if (config->overview_count) {
- int j = 0;
+ uint32_t j = 0;
for (j = 0; j < config->overview_count; j++) {
main(int argc, char **argv) {
RTLOADERCFG *config = NULL;
STRINGBUFFER *buffer = NULL;
- int i = 0;
- int j = 0;
+ uint32_t i = 0;
+ uint32_t j = 0;
char **elements = NULL;
- int n = 0;
+ uint32_t n = 0;
GDALDriverH drv = NULL;
char *tmp = NULL;
+ int argit = 0;
rt_init_allocators();
* parse arguments
****************************************************************************/
- for (i = 1; i < argc; i++) {
+ for (argit = 1; argit < argc; argit++) {
char *optarg, *ptr;
/* srid */
- if (CSEQUAL(argv[i], "-s") && i < argc - 1) {
- optarg = argv[++i];
+
+ if (CSEQUAL(argv[argit], "-s") && argit < argc - 1) {
+ optarg = argv[++argit];
ptr = strchr(optarg, ':');
if (ptr) {
*ptr++ = '\0';
}
}
/* band index */
- else if (CSEQUAL(argv[i], "-b") && i < argc - 1) {
- elements = strsplit(argv[++i], ",", &n);
+ else if (CSEQUAL(argv[argit], "-b") && argit < argc - 1) {
+ elements = strsplit(argv[++argit], ",", &n);
if (n < 1) {
rterror(_("Could not process -b"));
rtdealloc_config(config);
char *t = trim(elements[j]);
char **minmax = NULL;
int *range = NULL;
- int p = 0;
- int l = 0;
+ uint32_t p = 0;
+ uint32_t l = 0;
int m = 0;
- int o = 0;
+ uint32_t o = 0;
/* is t a range? */
minmax = strsplit(t, "-", &o);
}
}
/* tile size */
- else if (CSEQUAL(argv[i], "-t") && i < argc - 1) {
- if (CSEQUAL(argv[++i], "auto")) {
+ else if (CSEQUAL(argv[argit], "-t") && argit < argc - 1) {
+ if (CSEQUAL(argv[++argit], "auto")) {
config->tile_size[0] = -1;
config->tile_size[1] = -1;
}
else {
- elements = strsplit(argv[i], "x", &n);
+ elements = strsplit(argv[argit], "x", &n);
if (n != 2) {
rterror(_("Could not process -t"));
rtdealloc_config(config);
}
}
/* pad tiles */
- else if (CSEQUAL(argv[i], "-P")) {
+ else if (CSEQUAL(argv[argit], "-P")) {
config->pad_tile = 1;
}
/* out-of-db raster */
- else if (CSEQUAL(argv[i], "-R")) {
+ else if (CSEQUAL(argv[argit], "-R")) {
config->outdb = 1;
}
/* drop table and recreate */
- else if (CSEQUAL(argv[i], "-d")) {
+ else if (CSEQUAL(argv[argit], "-d")) {
config->opt = 'd';
}
/* append to table */
- else if (CSEQUAL(argv[i], "-a")) {
+ else if (CSEQUAL(argv[argit], "-a")) {
config->opt = 'a';
}
/* create new table */
- else if (CSEQUAL(argv[i], "-c")) {
+ else if (CSEQUAL(argv[argit], "-c")) {
config->opt = 'c';
}
/* prepare only */
- else if (CSEQUAL(argv[i], "-p")) {
+ else if (CSEQUAL(argv[argit], "-p")) {
config->opt = 'p';
}
/* raster column name */
- else if (CSEQUAL(argv[i], "-f") && i < argc - 1) {
- config->raster_column = rtalloc(sizeof(char) * (strlen(argv[++i]) + 1));
+ else if (CSEQUAL(argv[argit], "-f") && argit < argc - 1) {
+ config->raster_column = rtalloc(sizeof(char) * (strlen(argv[++argit]) + 1));
if (config->raster_column == NULL) {
rterror(_("Could not allocate memory for storing raster column name"));
rtdealloc_config(config);
exit(1);
}
- strncpy(config->raster_column, argv[i], strlen(argv[i]) + 1);
+ strncpy(config->raster_column, argv[argit], strlen(argv[argit]) + 1);
}
/* filename column */
- else if (CSEQUAL(argv[i], "-F")) {
+ else if (CSEQUAL(argv[argit], "-F")) {
config->file_column = 1;
}
/* filename column name */
- else if (CSEQUAL(argv[i], "-n") && i < argc - 1) {
- config->file_column_name = rtalloc(sizeof(char) * (strlen(argv[++i]) + 1));
+ else if (CSEQUAL(argv[argit], "-n") && argit < argc - 1) {
+ config->file_column_name = rtalloc(sizeof(char) * (strlen(argv[++argit]) + 1));
if (config->file_column_name == NULL) {
rterror(_("Could not allocate memory for storing filename column name"));
rtdealloc_config(config);
exit(1);
}
- strncpy(config->file_column_name, argv[i], strlen(argv[i]) + 1);
+ strncpy(config->file_column_name, argv[argit], strlen(argv[argit]) + 1);
config->file_column = 1;
}
/* overview factors */
- else if (CSEQUAL(argv[i], "-l") && i < argc - 1) {
- elements = strsplit(argv[++i], ",", &n);
+ else if (CSEQUAL(argv[argit], "-l") && argit < argc - 1) {
+ elements = strsplit(argv[++argit], ",", &n);
if (n < 1) {
rterror(_("Could not process -l"));
rtdealloc_config(config);
elements = NULL;
n = 0;
- for (j = 0; j < config->overview_count; j++) {
+ for (j = 0; j < (uint32_t)config->overview_count; j++) {
if (config->overview[j] < MINOVFACTOR || config->overview[j] > MAXOVFACTOR) {
rterror(_("Overview factor %d is not between %d and %d"), config->overview[j], MINOVFACTOR, MAXOVFACTOR);
rtdealloc_config(config);
}
}
/* quote identifiers */
- else if (CSEQUAL(argv[i], "-q")) {
+ else if (CSEQUAL(argv[argit], "-q")) {
config->quoteident = 1;
}
/* create index */
- else if (CSEQUAL(argv[i], "-I")) {
+ else if (CSEQUAL(argv[argit], "-I")) {
config->idx = 1;
}
/* maintenance */
- else if (CSEQUAL(argv[i], "-M")) {
+ else if (CSEQUAL(argv[argit], "-M")) {
config->maintenance = 1;
}
/* set constraints */
- else if (CSEQUAL(argv[i], "-C")) {
+ else if (CSEQUAL(argv[argit], "-C")) {
config->constraints = 1;
}
/* disable extent constraint */
- else if (CSEQUAL(argv[i], "-x")) {
+ else if (CSEQUAL(argv[argit], "-x")) {
config->max_extent = 0;
}
/* enable regular_blocking */
- else if (CSEQUAL(argv[i], "-r")) {
+ else if (CSEQUAL(argv[argit], "-r")) {
config->regular_blocking = 1;
}
/* tablespace of new table */
- else if (CSEQUAL(argv[i], "-T") && i < argc - 1) {
- config->tablespace = rtalloc(sizeof(char) * (strlen(argv[++i]) + 1));
+ else if (CSEQUAL(argv[argit], "-T") && argit < argc - 1) {
+ config->tablespace = rtalloc(sizeof(char) * (strlen(argv[++argit]) + 1));
if (config->tablespace == NULL) {
rterror(_("Could not allocate memory for storing tablespace of new table"));
rtdealloc_config(config);
exit(1);
}
- strncpy(config->tablespace, argv[i], strlen(argv[i]) + 1);
+ strncpy(config->tablespace, argv[argit], strlen(argv[argit]) + 1);
}
/* tablespace of new index */
- else if (CSEQUAL(argv[i], "-X") && i < argc - 1) {
- config->idx_tablespace = rtalloc(sizeof(char) * (strlen(argv[++i]) + 1));
+ else if (CSEQUAL(argv[argit], "-X") && argit < argc - 1) {
+ config->idx_tablespace = rtalloc(sizeof(char) * (strlen(argv[++argit]) + 1));
if (config->idx_tablespace == NULL) {
rterror(_("Could not allocate memory for storing tablespace of new indices"));
rtdealloc_config(config);
exit(1);
}
- strncpy(config->idx_tablespace, argv[i], strlen(argv[i]) + 1);
+ strncpy(config->idx_tablespace, argv[argit], strlen(argv[argit]) + 1);
}
/* nodata value */
- else if (CSEQUAL(argv[i], "-N") && i < argc - 1) {
+ else if (CSEQUAL(argv[argit], "-N") && argit < argc - 1) {
config->hasnodata = 1;
- config->nodataval = atof(argv[++i]);
+ config->nodataval = atof(argv[++argit]);
}
/* skip NODATA value check for bands */
- else if (CSEQUAL(argv[i], "-k")) {
+ else if (CSEQUAL(argv[argit], "-k")) {
config->skip_nodataval_check = 1;
}
/* endianness */
- else if (CSEQUAL(argv[i], "-E") && i < argc - 1) {
- config->endian = atoi(argv[++i]);
+ else if (CSEQUAL(argv[argit], "-E") && argit < argc - 1) {
+ config->endian = atoi(argv[++argit]);
config->endian = 1;
}
/* version */
- else if (CSEQUAL(argv[i], "-V") && i < argc - 1) {
- config->version = atoi(argv[++i]);
+ else if (CSEQUAL(argv[argit], "-V") && argit < argc - 1) {
+ config->version = atoi(argv[++argit]);
config->version = 0;
}
/* transaction */
- else if (CSEQUAL(argv[i], "-e")) {
+ else if (CSEQUAL(argv[argit], "-e")) {
config->transaction = 0;
}
/* COPY statements */
- else if (CSEQUAL(argv[i], "-Y")) {
+ else if (CSEQUAL(argv[argit], "-Y")) {
config->copy_statements = 1;
}
/* GDAL formats */
- else if (CSEQUAL(argv[i], "-G")) {
+ else if (CSEQUAL(argv[argit], "-G")) {
uint32_t drv_count = 0;
rt_gdaldriver drv_set = rt_raster_gdal_drivers(&drv_count, 0);
if (drv_set == NULL || !drv_count) {
exit(0);
}
/* help */
- else if (CSEQUAL(argv[i], "-?")) {
+ else if (CSEQUAL(argv[argit], "-?")) {
usage();
rtdealloc_config(config);
exit(0);
exit(1);
}
- config->rt_file[config->rt_file_count - 1] = rtalloc(sizeof(char) * (strlen(argv[i]) + 1));
+ config->rt_file[config->rt_file_count - 1] = rtalloc(sizeof(char) * (strlen(argv[argit]) + 1));
if (config->rt_file[config->rt_file_count - 1] == NULL) {
rterror(_("Could not allocate memory for storing raster filename"));
rtdealloc_config(config);
exit(1);
}
- strncpy(config->rt_file[config->rt_file_count - 1], argv[i], strlen(argv[i]) + 1);
+ strncpy(config->rt_file[config->rt_file_count - 1], argv[argit], strlen(argv[argit]) + 1);
}
}
typedef struct raster_loader_config {
/* raster filename */
- int rt_file_count;
+ uint32_t rt_file_count;
char **rt_file;
char **rt_filename;
char *file_column_name;
/* overview factor */
- int overview_count;
+ uint32_t overview_count;
int *overview;
char **overview_table;
/* bands to extract */
int *nband; /* 1-based */
- int nband_count;
+ uint32_t nband_count;
/* tile size */
int tile_size[2];
/* number of bands */
int *nband; /* 1-based */
- int nband_count;
+ uint32_t nband_count;
/* array of pixeltypes */
GDALDataType *gdalbandtype;
* @return ES_NONE on success, ES_ERROR on error
*/
rt_errorstate rt_pixel_set_to_array(
- rt_pixel npixel,int count,
+ rt_pixel npixel,uint32_t count,
rt_mask mask,
int x, int y,
uint16_t distancex, uint16_t distancey,
* @return -1 on error, otherwise the number of rt_pixel objects
* in npixels
*/
-int rt_band_get_nearest_pixel(
+uint32_t rt_band_get_nearest_pixel(
rt_band band,
int x, int y,
uint16_t distancex, uint16_t distancey,
*/
rt_histogram rt_band_get_histogram(
rt_bandstats stats,
- int bin_count, double *bin_widths, int bin_widths_count,
+ uint32_t bin_count, double *bin_widths, uint32_t bin_widths_count,
int right, double min, double max,
uint32_t *rtn_count
);
int exclude_nodata_value, double sample,
uint64_t cov_count,
struct quantile_llist **qlls, uint32_t *qlls_count,
- double *quantiles, int quantiles_count,
+ double *quantiles, uint32_t quantiles_count,
uint32_t *rtn_count
);
void rt_raster_destroy(rt_raster raster);
/* Get number of bands */
-int rt_raster_get_num_bands(rt_raster raster);
+uint16_t rt_raster_get_num_bands(rt_raster raster);
/**
* Return Nth band, or NULL if unavailable
* @return -1 on error, otherwise the number of rt_pixel objects
* in npixels
*/
-int rt_band_get_nearest_pixel(
+uint32_t rt_band_get_nearest_pixel(
rt_band band,
int x, int y,
uint16_t distancex, uint16_t distancey,
int extent[4] = {0};
int max_extent[4] = {0};
int d0 = 0;
- int distance[2] = {0};
+ uint32_t distance[2] = {0};
uint32_t _d[2] = {0};
uint32_t i = 0;
uint32_t j = 0;
if distances won't capture extent of band, return 0
*/
else if (
- ((x < 0 && abs(x) > distance[0]) || (x - band->width >= distance[0])) ||
- ((y < 0 && abs(y) > distance[1]) || (y - band->height >= distance[1]))
+ ((x < 0 && (uint32_t) abs(x) > distance[0]) || (x - band->width >= (int)distance[0])) ||
+ ((y < 0 && (uint32_t) abs(y) > distance[1]) || (y - band->height >= (int)distance[1]))
) {
RASTER_DEBUG(4, "No nearest pixels possible for provided pixel and distances");
return 0;
}
RASTER_DEBUGF(4, "_min, _max: %d, %d", *_min, _max);
- for (k = 0; k < _max; k++) {
+ for (k = 0; k < (uint32_t) _max; k++) {
/* check that _x and _y are not outside max extent */
if (
_x < max_extent[0] || _x > max_extent[2] ||
typedef struct _rti_iterator_arg_t* _rti_iterator_arg;
struct _rti_iterator_arg_t {
- int count;
+ uint32_t count;
rt_raster *raster;
int *isempty;
static void
_rti_iterator_arg_destroy(_rti_iterator_arg _param) {
- int i = 0;
+ uint32_t i = 0;
if (_param->raster != NULL)
rtdealloc(_param->raster);
static int
_rti_iterator_arg_empty_init(_rti_iterator_arg _param) {
- int x = 0;
- int y = 0;
+ uint32_t x = 0;
+ uint32_t y = 0;
_param->empty.values = rtalloc(sizeof(double *) * _param->dimension.rows);
_param->empty.nodata = rtalloc(sizeof(int *) * _param->dimension.rows);
static int
_rti_iterator_arg_callback_init(_rti_iterator_arg _param) {
- int i = 0;
+ uint32_t i = 0;
_param->arg = rtalloc(sizeof(struct rt_iterator_arg_t));
if (_param->arg == NULL) {
static void
_rti_iterator_arg_callback_clean(_rti_iterator_arg _param) {
- int i = 0;
- int y = 0;
+ uint32_t i = 0;
+ uint32_t y = 0;
for (i = 0; i < _param->count; i++) {
RASTER_DEBUGF(5, "empty at @ %p", _param->empty.values);
* @return ES_NONE on success, ES_ERROR on error
*/
rt_errorstate rt_pixel_set_to_array(
- rt_pixel npixel, int count, rt_mask mask,
+ rt_pixel npixel, uint32_t count, rt_mask mask,
int x, int y,
uint16_t distancex, uint16_t distancey,
double ***value,
_rt_raster_geotransform_warn_offline_band(raster);
}
-int
+uint16_t
rt_raster_get_num_bands(rt_raster raster) {
int allocNodataValues = 0;
int i;
- int numBands;
+ uint32_t numBands;
uint32_t width = 0;
uint32_t height = 0;
rt_band rtband = NULL;
/* PT_8BSI requires manual setting of pixels */
if (pt == PT_8BSI) {
- int nXBlocks, nYBlocks;
+ uint32_t nXBlocks, nYBlocks;
int nXBlockSize, nYBlockSize;
- int iXBlock, iYBlock;
+ uint32_t iXBlock, iYBlock;
int nXValid, nYValid;
int iX, iY;
int iXMax, iYMax;
uint32_t width = 0;
uint32_t height = 0;
uint32_t numBands = 0;
- int i = 0;
+ uint32_t i = 0;
char *authname = NULL;
char *authcode = NULL;
int x;
int y;
- int nXBlocks, nYBlocks;
+ uint32_t nXBlocks, nYBlocks;
int nXBlockSize, nYBlockSize;
- int iXBlock, iYBlock;
- int nXValid, nYValid;
- int iY;
+ uint32_t iXBlock, iYBlock;
+ uint32_t nXValid, nYValid;
+ uint32_t iY;
uint8_t *values = NULL;
uint32_t valueslen = 0;
char **options
) {
rt_raster rast = NULL;
- int i = 0;
+ uint32_t i = 0;
int err = 0;
_rti_rasterize_arg arg = NULL;
rt_histogram
rt_band_get_histogram(
rt_bandstats stats,
- int bin_count, double *bin_width, int bin_width_count,
+ uint32_t bin_count, double *bin_width, uint32_t bin_width_count,
int right, double min, double max,
uint32_t *rtn_count
) {
rt_histogram bins = NULL;
int init_width = 0;
- int i;
- int j;
+ uint32_t i;
+ uint32_t j;
double tmp;
double value;
int sum = 0;
int exclude_nodata_value, double sample,
uint64_t cov_count,
struct quantile_llist **qlls, uint32_t *qlls_count,
- double *quantiles, int quantiles_count,
+ double *quantiles, uint32_t quantiles_count,
uint32_t *rtn_count
) {
rt_quantile rtn = NULL;
int scale = 0;
int doround = 0;
double tmpd = 0;
- int i = 0;
+ uint32_t i = 0;
uint32_t x = 0;
uint32_t y = 0;
int isnodata = 0;
double rpxlval;
uint32_t total = 0;
- int vcnts_count = 0;
- int new_valuecount = 0;
+ uint32_t vcnts_count = 0;
+ uint32_t new_valuecount = 0;
#if POSTGIS_DEBUG_LEVEL > 0
clock_t start, stop;
}
/* tenths, hundredths, thousandths, etc */
else if (roundto < 1) {
- switch (pixtype) {
+ switch (pixtype) {
/* integer band types don't have digits after the decimal place */
case PT_1BB:
case PT_2BUI:
/* split a string based on a delimiter */
char**
-rtpg_strsplit(const char *str, const char *delimiter, int *n) {
+rtpg_strsplit(const char *str, const char *delimiter, uint32_t *n) {
char *tmp = NULL;
char **rtn = NULL;
char *token = NULL;
rtpg_chartrim(const char* input, char *remove);
char **
-rtpg_strsplit(const char *str, const char *delimiter, int *n);
+rtpg_strsplit(const char *str, const char *delimiter, uint32_t *n);
char *
rtpg_removespaces(char *str);
bool *_null = NULL;
int i = 0;
- int x = 0;
- int y = 0;
+ uint32_t x = 0;
+ uint32_t y = 0;
int z = 0;
int dim[3] = {0};
int lbound[3] = {1, 1, 1};
char *expr = NULL;
char *tmp = NULL;
char *sql = NULL;
- char place[5] = "$1";
+ char place[12] = "$1";
if (PG_ARGISNULL(exprpos[i]))
continue;
int j = 0;
int k = 0;
- int a = 0;
- int b = 0;
- int c = 0;
+ uint32_t a = 0;
+ uint32_t b = 0;
+ uint32_t c = 0;
rt_reclassexpr *exprset = NULL;
HeapTupleHeader tup;
bool hasnodata = FALSE;
char **comma_set = NULL;
- int comma_n = 0;
+ uint32_t comma_n = 0;
char **colon_set = NULL;
- int colon_n = 0;
+ uint32_t colon_n = 0;
char **dash_set = NULL;
- int dash_n = 0;
+ uint32_t dash_n = 0;
POSTGIS_RT_DEBUG(3, "RASTER_reclass: Starting");
strchr(dash_set[c], ']') != NULL
)
) {
+ uint32_t dash_it;
junk = palloc(sizeof(char) * (strlen(dash_set[c + 1]) + 2));
if (NULL == junk) {
for (k = 0; k <= j; k++) pfree(exprset[k]);
pfree(junk);
/* rebuild dash_set */
- for (k = 1; k < dash_n; k++) {
- dash_set[k - 1] = repalloc(dash_set[k - 1], (strlen(dash_set[k]) + 1) * sizeof(char));
- strcpy(dash_set[k - 1], dash_set[k]);
+ for (dash_it = 1; dash_it < dash_n; dash_it++) {
+ dash_set[dash_it - 1] = repalloc(dash_set[dash_it - 1], (strlen(dash_set[dash_it]) + 1) * sizeof(char));
+ strcpy(dash_set[dash_it - 1], dash_set[dash_it]);
}
dash_n--;
c--;
int nodataentry;
char **entry;
- int nentry;
+ uint32_t nentry;
char **element;
- int nelement;
+ uint32_t nelement;
};
static rtpg_colormap_arg
static void
rtpg_colormap_arg_destroy(rtpg_colormap_arg arg) {
- int i = 0;
+ uint32_t i = 0;
if (arg->raster != NULL)
rt_raster_destroy(arg->raster);
char *colormap = text_to_cstring(PG_GETARG_TEXT_P(2));
char *_entry;
char *_element;
- int i = 0;
- int j = 0;
+ uint32_t i = 0;
+ uint32_t j = 0;
POSTGIS_RT_DEBUGF(4, "colormap = %s", colormap);
}
/* smallest # of colors */
- if ((arg->nelement - 1) < arg->colormap->ncolor)
+ if (((int)arg->nelement - 1) < arg->colormap->ncolor)
arg->colormap->ncolor = arg->nelement - 1;
/* each element of entry */
int argcount = 0;
Oid argtype[] = { FLOAT8OID, INT4OID, INT4OID };
uint8_t argpos[3] = {0};
- char place[5];
+ char place[12];
int idx = 0;
int ret = -1;
TupleDesc tupdesc;
PG_FUNCTION_INFO_V1(RASTER_mapAlgebra2);
Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
- rt_pgraster *pgrast[2];
+ const uint32_t set_count = 2;
+ rt_pgraster *pgrast[2] = { NULL, NULL };
int pgrastpos[2] = {-1, -1};
rt_pgraster *pgrtn;
rt_raster rast[2] = {NULL};
Oid calltype = InvalidOid;
- const int spi_count = 3;
+ const uint32_t spi_count = 3;
uint16_t spi_exprpos[3] = {4, 7, 8};
uint32_t spi_argcount[3] = {0};
char *expr = NULL;
SPIPlanPtr spi_plan[3] = {NULL};
uint16_t spi_empty = 0;
Oid *argtype = NULL;
- const int argkwcount = 8;
+ const uint32_t argkwcount = 8;
uint8_t argpos[3][8] = {{0}};
char *argkw[] = {"[rast1.x]", "[rast1.y]", "[rast1.val]", "[rast1]", "[rast2.x]", "[rast2.y]", "[rast2.val]", "[rast2]"};
Datum values[argkwcount];
size_t wkb_len;
int i = 0;
- int j = 0;
+ uint32_t j = 0;
int noerr = 1;
/* pgraster is null, return null */
PG_FUNCTION_INFO_V1(RASTER_intersects);
Datum RASTER_intersects(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
rtn = rt_raster_intersects(
- rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
- rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
+ rast[0], (hasbandindex[0] ? (int)bandindex[0] - 1 : -1),
+ rast[1], (hasbandindex[1] ? (int)bandindex[1] - 1 : -1),
&result
);
for (k = 0; k < set_count; k++) {
PG_FUNCTION_INFO_V1(RASTER_overlaps);
Datum RASTER_overlaps(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
rtn = rt_raster_overlaps(
- rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
- rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
+ rast[0], (hasbandindex[0] ? (int)bandindex[0] - 1 : -1),
+ rast[1], (hasbandindex[1] ? (int)bandindex[1] - 1 : -1),
&result
);
for (k = 0; k < set_count; k++) {
PG_FUNCTION_INFO_V1(RASTER_touches);
Datum RASTER_touches(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
rtn = rt_raster_touches(
- rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
- rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
+ rast[0], (hasbandindex[0] ? (int)bandindex[0] - 1 : -1),
+ rast[1], (hasbandindex[1] ? (int)bandindex[1] - 1 : -1),
&result
);
for (k = 0; k < set_count; k++) {
PG_FUNCTION_INFO_V1(RASTER_contains);
Datum RASTER_contains(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
rtn = rt_raster_contains(
- rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
- rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
+ rast[0], (hasbandindex[0] ? (int)bandindex[0] - 1 : -1),
+ rast[1], (hasbandindex[1] ? (int)bandindex[1] - 1 : -1),
&result
);
for (k = 0; k < set_count; k++) {
PG_FUNCTION_INFO_V1(RASTER_containsProperly);
Datum RASTER_containsProperly(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
rtn = rt_raster_contains_properly(
- rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
- rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
+ rast[0], (hasbandindex[0] ? (int)bandindex[0] - 1 : -1),
+ rast[1], (hasbandindex[1] ? (int)bandindex[1] - 1 : -1),
&result
);
for (k = 0; k < set_count; k++) {
PG_FUNCTION_INFO_V1(RASTER_covers);
Datum RASTER_covers(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
rtn = rt_raster_covers(
- rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
- rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
+ rast[0], (hasbandindex[0] ? (int)bandindex[0] - 1 : -1),
+ rast[1], (hasbandindex[1] ? (int)bandindex[1] - 1 : -1),
&result
);
for (k = 0; k < set_count; k++) {
PG_FUNCTION_INFO_V1(RASTER_coveredby);
Datum RASTER_coveredby(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
rtn = rt_raster_coveredby(
- rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
- rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
+ rast[0], (hasbandindex[0] ? (int)bandindex[0] - 1 : -1),
+ rast[1], (hasbandindex[1] ? (int)bandindex[1] - 1 : -1),
&result
);
for (k = 0; k < set_count; k++) {
PG_FUNCTION_INFO_V1(RASTER_dwithin);
Datum RASTER_dwithin(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
rtn = rt_raster_within_distance(
- rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
- rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
+ rast[0], (hasbandindex[0] ? (int)bandindex[0] - 1 : -1),
+ rast[1], (hasbandindex[1] ? (int)bandindex[1] - 1 : -1),
distance,
&result
);
PG_FUNCTION_INFO_V1(RASTER_dfullywithin);
Datum RASTER_dfullywithin(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
rtn = rt_raster_fully_within_distance(
- rast[0], (hasbandindex[0] ? bandindex[0] - 1 : -1),
- rast[1], (hasbandindex[1] ? bandindex[1] - 1 : -1),
+ rast[0], (hasbandindex[0] ? (int)bandindex[0] - 1 : -1),
+ rast[1], (hasbandindex[1] ? (int)bandindex[1] - 1 : -1),
distance,
&result
);
PG_FUNCTION_INFO_V1(RASTER_sameAlignment);
Datum RASTER_sameAlignment(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
PG_FUNCTION_INFO_V1(RASTER_notSameAlignmentReason);
Datum RASTER_notSameAlignmentReason(PG_FUNCTION_ARGS)
{
- const int set_count = 2;
+ const uint32_t set_count = 2;
rt_pgraster *pgrast[2];
int pgrastpos[2] = {-1, -1};
rt_raster rast[2] = {NULL};
}
/* get histogram */
- hist = rt_band_get_histogram(stats, bin_count, bin_width, bin_width_count, right, min, max, &count);
+ hist = rt_band_get_histogram(stats, (uint32_t)bin_count, bin_width, bin_width_count, right, min, max, &count);
if (bin_width_count) pfree(bin_width);
pfree(stats);
if (NULL == hist || !count) {
FuncCallContext *funcctx;
TupleDesc tupdesc;
- int i;
+ uint32_t i;
rt_histogram covhist = NULL;
rt_histogram covhist2;
int call_cntr;
&nulls, &n);
bin_width = palloc(sizeof(double) * n);
- for (i = 0, j = 0; i < n; i++) {
+ for (i = 0, j = 0; i < (uint32_t) n; i++) {
if (nulls[i]) continue;
switch (etype) {
FuncCallContext *funcctx;
TupleDesc tupdesc;
- int i;
+ uint32_t i;
rt_quantile covquant = NULL;
rt_quantile covquant2;
int call_cntr;
&nulls, &n);
quantiles = palloc(sizeof(double) * n);
- for (i = 0, j = 0; i < n; i++) {
+ for (i = 0, j = 0; i < (uint32_t) n; i++) {
if (nulls[i]) continue;
switch (etype) {
FuncCallContext *funcctx;
TupleDesc tupdesc;
- int i;
+ uint32_t i;
uint64_t covcount = 0;
uint64_t covtotal = 0;
rt_valuecount covvcnts = NULL;
rt_valuecount vcnts = NULL;
int exists = 0;
- int j;
+ uint32_t j;
int n;
ArrayType *array;
&nulls, &n);
search_values = palloc(sizeof(double) * n);
- for (i = 0, j = 0; i < n; i++) {
+ for (i = 0, j = 0; i < (uint32_t) n; i++) {
if (nulls[i]) continue;
switch (etype) {
int disable_all = 0;
char **enabled_drivers_array = NULL;
- int enabled_drivers_count = 0;
+ uint32_t enabled_drivers_count = 0;
bool *enabled_drivers_found = NULL;
char *gdal_skip = NULL;
static void test_band_get_nearest_pixel() {
rt_raster rast;
rt_band band;
- uint32_t x, y;
- int rtn;
+ int x, y;
+ uint32_t rtn;
const int maxX = 10;
const int maxY = 10;
rt_pixel npixels = NULL;
rt_raster rast;
rt_band band;
rt_mask mask = NULL;
- uint32_t x, y;
+ int x, y;
int rtn;
const int maxX = 10;
const int maxY = 10;
}
static void test_gdal_drivers() {
- int i;
+ uint32_t i;
uint32_t size;
rt_gdaldriver drv = NULL;
-- create table and load\r
CREATE TABLE knn_recheck_geom_nd(gid serial primary key, geom geometry);\r
INSERT INTO knn_recheck_geom_nd(gid,geom)\r
-SELECT ROW_NUMBER() OVER(ORDER BY x,y) AS gid, ST_MakePoint(x*0.777,y*0.887,z*1.05) As geom\r
+SELECT ROW_NUMBER() OVER(ORDER BY x,y,z) AS gid, ST_MakePoint(x*0.777,y*0.887,z*1.05) As geom\r
FROM generate_series(-100,1000, 7) AS x , \r
generate_series(-300,1000,9) As y,\r
generate_series(1005,10000,5555) As z ;\r
#2g|30512|25313.2118|25313.2118
#3g|1000|t
#3g|500000|t
-#1nd-3|290|260.6797|260.6797
+#1nd-3|289|260.6797|260.6797
#1nd-3|287|264.3000|264.3000
#1nd-3|579|265.4356|265.4356
#1nd-3|285|268.1092|268.1092
-#1nd-3|578|268.9919|268.9919
+#1nd-3|577|268.9919|268.9919
#2nd-3|9749|3.7272|3.7272
#2nd-3|600001|3.9451|3.9451
#2nd-3|600002|3.9950|3.9950
-#2nd-3|9748|4.1707|4.1707
-#2nd-3|10040|6.1761|6.1761
-#3nd-3|1|292|5.4390|5.4390
+#2nd-3|9747|4.1707|4.1707
+#2nd-3|10039|6.1761|6.1761
+#3nd-3|1|291|5.4390|5.4390
#3nd-3|1|3|7.9830|7.9830
-#3nd-3|1|294|9.6598|9.6598
-#3nd-3|1|582|10.8780|10.8780
+#3nd-3|1|293|9.6598|9.6598
+#3nd-3|1|581|10.8780|10.8780
#3nd-3|1|583|13.4929|13.4929
#3nd-3|600001|600002|0.0000|0.0000
-#3nd-3|600001|9752|54.2730|54.2730
+#3nd-3|600001|9751|54.2730|54.2730
#3nd-3|600001|9461|54.3900|54.3900
#3nd-3|600001|9749|54.5453|54.5453
#3nd-3|600001|10041|54.6233|54.6233
-#1nd-3|290|260.6797|260.6797
+#1nd-3|289|260.6797|260.6797
#1nd-3|287|264.3000|264.3000
#1nd-3|579|265.4356|265.4356
#1nd-3|285|268.1092|268.1092
-#1nd-3|578|268.9919|268.9919
+#1nd-3|577|268.9919|268.9919
#2nd-3|9749|3.7272|3.7272
#2nd-3|600001|3.9451|3.9451
#2nd-3|600002|3.9950|3.9950
-#2nd-3|9748|4.1707|4.1707
-#2nd-3|10040|6.1761|6.1761
-#3nd-3|1|292|5.4390|5.4390
+#2nd-3|9747|4.1707|4.1707
+#2nd-3|10039|6.1761|6.1761
+#3nd-3|1|291|5.4390|5.4390
#3nd-3|1|3|7.9830|7.9830
-#3nd-3|1|294|9.6598|9.6598
-#3nd-3|1|582|10.8780|10.8780
+#3nd-3|1|293|9.6598|9.6598
+#3nd-3|1|581|10.8780|10.8780
#3nd-3|1|583|13.4929|13.4929
#3nd-3|600001|600002|0.0000|0.0000
-#3nd-3|600001|9752|54.2730|54.2730
+#3nd-3|600001|9751|54.2730|54.2730
#3nd-3|600001|9461|54.3900|54.3900
#3nd-3|600001|9749|54.5453|54.5453
#3nd-3|600001|10041|54.6233|54.6233
FROM t.relation r, t.f f WHERE
r.layer_id = layer_id(f.g) AND r.topogeo_id = id(f.g)
AND r.topogeo_id in (2,3)
- ORDER BY r.layer_id, r.topogeo_id;
+ ORDER BY r.layer_id, r.topogeo_id, r.element_id;
-- This is fine, but will have to tweak definition of
-- 'F+E3-E4' and 'F-E3+E4'
FROM t.relation r, t.f f WHERE
r.layer_id = layer_id(f.g) AND r.topogeo_id = id(f.g)
AND r.topogeo_id in (2,3)
- ORDER BY r.layer_id, r.topogeo_id;
+ ORDER BY r.layer_id, r.topogeo_id, r.element_id;
SELECT topology.DropTopology('t');
E4
2|-4
2|3
-3|4
3|-3
+3|4
MH(3,4)|5
ERROR: SQL/MM Spatial exception - non-connected edges
2|3
FROM t.relation r, t.f f WHERE
r.layer_id = layer_id(f.g) AND r.topogeo_id = id(f.g)
AND r.topogeo_id in (2,3)
- ORDER BY r.layer_id, r.topogeo_id;
+ ORDER BY r.layer_id, r.topogeo_id, r.element_id;
-- This is fine, but will have to tweak definition of
-- 'F+E3-E4' and 'F-E3+E4'
FROM t.relation r, t.f f WHERE
r.layer_id = layer_id(f.g) AND r.topogeo_id = id(f.g)
AND r.topogeo_id in (2,3)
- ORDER BY r.layer_id, r.topogeo_id;
+ ORDER BY r.layer_id, r.topogeo_id, r.element_id;
SELECT topology.DropTopology('t');
E4
2|-4
2|3
-3|4
3|-3
+3|4
MH(3,4)|5
ERROR: SQL/MM Spatial exception - non-connected edges
2|5