[postgis-tickets] r16014 - Quiet compile warnings
Paul Ramsey
pramsey at cleverelephant.ca
Wed Oct 18 12:28:29 PDT 2017
Author: pramsey
Date: 2017-10-18 12:28:28 -0700 (Wed, 18 Oct 2017)
New Revision: 16014
Modified:
branches/2.4/liblwgeom/lwgeom_geos.c
branches/2.4/postgis/geobuf.c
branches/2.4/postgis/geography_centroid.c
branches/2.4/postgis/gserialized_gist_2d.c
branches/2.4/postgis/lwgeom_functions_basic.c
branches/2.4/postgis/mvt.c
Log:
Quiet compile warnings
Modified: branches/2.4/liblwgeom/lwgeom_geos.c
===================================================================
--- branches/2.4/liblwgeom/lwgeom_geos.c 2017-10-18 18:46:27 UTC (rev 16013)
+++ branches/2.4/liblwgeom/lwgeom_geos.c 2017-10-18 19:28:28 UTC (rev 16014)
@@ -209,14 +209,14 @@
-GEOSCoordSeq ptarray_to_GEOSCoordSeq(const POINTARRAY *);
+GEOSCoordSeq ptarray_to_GEOSCoordSeq(const POINTARRAY *, int fix_ring);
-
GEOSCoordSeq
-ptarray_to_GEOSCoordSeq(const POINTARRAY *pa)
+ptarray_to_GEOSCoordSeq(const POINTARRAY *pa, int fix_ring)
{
uint32_t dims = 2;
uint32_t i;
+ int append_points = 0;
const POINT3DZ *p3d;
const POINT2D *p2d;
GEOSCoordSeq sq;
@@ -224,8 +224,28 @@
if ( FLAGS_GET_Z(pa->flags) )
dims = 3;
- if ( ! (sq = GEOSCoordSeq_create(pa->npoints, dims)) )
+ if ( fix_ring )
{
+ if (pa->npoints < 1)
+ {
+ lwerror("ptarray_to_GEOSCoordSeq called with fix_ring and 0 vertices in ring, cannot fix");
+ return NULL;
+ }
+ else
+ {
+ if ( pa->npoints < 4 )
+ {
+ append_points = 4 - pa->npoints;
+ }
+ if ( ! ptarray_is_closed_2d(pa) && append_points == 0 )
+ {
+ append_points = 1;
+ }
+ }
+ }
+
+ if ( ! (sq = GEOSCoordSeq_create(pa->npoints + append_points, dims)) )
+ {
lwerror("Error creating GEOS Coordinate Sequence");
return NULL;
}
@@ -248,47 +268,48 @@
GEOSCoordSeq_setY(sq, i, p2d->y);
if ( dims == 3 )
+ {
GEOSCoordSeq_setZ(sq, i, p3d->z);
+ }
}
- return sq;
-}
-static GEOSGeometry *
-ptarray_to_GEOSLinearRing(const POINTARRAY *pa, int autofix)
-{
- GEOSCoordSeq sq;
- GEOSGeom g;
- POINTARRAY *npa = 0;
-
- if ( autofix )
+ if ( append_points )
{
- if (pa->npoints < 1)
+ if ( dims == 3 )
{
- lwerror("ptarray_to_GEOSLinearRing called with autofix and 0 vertices in ring, cannot fix");
+ p3d = getPoint3dz_cp(pa, 0);
+ p2d = (const POINT2D *)p3d;
}
-
- /*
- * Check ring for being closed and fix if not.
- * Also create a copy of geometry to operate on.
- */
- if ( ! ptarray_is_closed_2d(pa) || pa->npoints < 4 )
+ else
{
- pa = ptarray_addPoint(pa, getPoint_internal(pa, 0), FLAGS_NDIMS(pa->flags), pa->npoints);
- npa = pa;
+ p2d = getPoint2d_cp(pa, 0);
}
- /* Check ring for having at least 4 vertices */
- while ( pa->npoints < 4 )
+ for ( i = pa->npoints; i < pa->npoints + append_points; i++ )
{
- ptarray_append_point(pa, getPoint_internal(pa, 0), LW_TRUE);
+ GEOSCoordSeq_setX(sq, i, p2d->x);
+ GEOSCoordSeq_setY(sq, i, p2d->y);
+
+ if ( dims == 3 )
+ {
+ GEOSCoordSeq_setZ(sq, i, p3d->z);
+ }
}
}
- sq = ptarray_to_GEOSCoordSeq(pa);
- if ( npa ) ptarray_free(npa);
+ return sq;
+}
+
+static inline GEOSGeometry *
+ptarray_to_GEOSLinearRing(const POINTARRAY *pa, int autofix)
+{
+ GEOSCoordSeq sq;
+ GEOSGeom g;
+ sq = ptarray_to_GEOSCoordSeq(pa, autofix);
g = GEOSGeom_createLinearRing(sq);
return g;
}
+
GEOSGeometry *
GBOX2GEOS(const GBOX *box)
{
@@ -373,7 +394,7 @@
}
else
{
- sq = ptarray_to_GEOSCoordSeq(lwp->point);
+ sq = ptarray_to_GEOSCoordSeq(lwp->point, 0);
g = GEOSGeom_createPoint(sq);
}
if ( ! g )
@@ -388,11 +409,11 @@
if ( lwl->points->npoints == 1 ) {
/* Duplicate point, to make geos-friendly */
lwl->points = ptarray_addPoint(lwl->points,
- getPoint_internal(lwl->points, 0),
- FLAGS_NDIMS(lwl->points->flags),
- lwl->points->npoints);
+ getPoint_internal(lwl->points, 0),
+ FLAGS_NDIMS(lwl->points->flags),
+ lwl->points->npoints);
}
- sq = ptarray_to_GEOSCoordSeq(lwl->points);
+ sq = ptarray_to_GEOSCoordSeq(lwl->points, 0);
g = GEOSGeom_createLineString(sq);
if ( ! g )
{
@@ -568,8 +589,7 @@
if (result == NULL)
{
- lwerror("Error performing intersection: GEOS2LWGEOM: %s",
- lwgeom_geos_errmsg);
+ lwerror("Error performing intersection: GEOS2LWGEOM: %s", lwgeom_geos_errmsg);
return NULL ; /* never get here */
}
Modified: branches/2.4/postgis/geobuf.c
===================================================================
--- branches/2.4/postgis/geobuf.c 2017-10-18 18:46:27 UTC (rev 16013)
+++ branches/2.4/postgis/geobuf.c 2017-10-18 19:28:28 UTC (rev 16014)
@@ -564,7 +564,6 @@
bool isnull = false;
Datum datum;
Data__FeatureCollection *fc = ctx->data->feature_collection;
- Data__Feature **features = fc->features;
Data__Feature *feature;
GSERIALIZED *gs;
if (fc->n_features >= ctx->features_capacity) {
Modified: branches/2.4/postgis/geography_centroid.c
===================================================================
--- branches/2.4/postgis/geography_centroid.c 2017-10-18 18:46:27 UTC (rev 16013)
+++ branches/2.4/postgis/geography_centroid.c 2017-10-18 19:28:28 UTC (rev 16014)
@@ -316,8 +316,6 @@
POINT3DM points[size];
uint32_t j = 0;
- GBOX gbox;
-
/* use first point as reference to create triangles */
const POINT4D* reference_point = (const POINT4D*) getPoint2d_cp(mpoly->geoms[0]->rings[0], 0);
Modified: branches/2.4/postgis/gserialized_gist_2d.c
===================================================================
--- branches/2.4/postgis/gserialized_gist_2d.c 2017-10-18 18:46:27 UTC (rev 16013)
+++ branches/2.4/postgis/gserialized_gist_2d.c 2017-10-18 19:28:28 UTC (rev 16014)
@@ -589,7 +589,6 @@
GSERIALIZED *gpart;
uint8_t flags;
int result = LW_SUCCESS;
- int gpart_is_slice = FALSE;
POSTGIS_DEBUG(4, "entered function");
Modified: branches/2.4/postgis/lwgeom_functions_basic.c
===================================================================
--- branches/2.4/postgis/lwgeom_functions_basic.c 2017-10-18 18:46:27 UTC (rev 16013)
+++ branches/2.4/postgis/lwgeom_functions_basic.c 2017-10-18 19:28:28 UTC (rev 16014)
@@ -2060,8 +2060,6 @@
{
LWPOLY *poly;
GSERIALIZED *result;
- POINTARRAY **pa;
- POINT4D p;
double x1, y1, x2, y2;
int srid = SRID_UNKNOWN;
Modified: branches/2.4/postgis/mvt.c
===================================================================
--- branches/2.4/postgis/mvt.c 2017-10-18 18:46:27 UTC (rev 16013)
+++ branches/2.4/postgis/mvt.c 2017-10-18 19:28:28 UTC (rev 16014)
@@ -478,7 +478,6 @@
static void parse_datum_as_string(struct mvt_agg_context *ctx, Oid typoid,
Datum datum, uint32_t *tags, uint32_t k)
{
- struct mvt_kv_string_value *kv;
Oid foutoid;
bool typisvarlena;
char *value;
@@ -667,11 +666,9 @@
double width = gbox->xmax - gbox->xmin;
double height = gbox->ymax - gbox->ymin;
double resx = width / extent;
- double resy = height / extent;
double fx = extent / width;
double fy = -(extent / height);
double buffer_map_xunits = resx * buffer;
- double buffer_map_yunits = resy * buffer;
const GBOX *ggbox;
POSTGIS_DEBUG(2, "mvt_geom called");
@@ -812,7 +809,6 @@
LWGEOM *lwgeom;
VectorTile__Tile__Feature *feature;
VectorTile__Tile__Layer *layer = ctx->layer;
- VectorTile__Tile__Feature **features = layer->features;
POSTGIS_DEBUG(2, "mvt_agg_transfn called");
if (layer->n_features >= ctx->features_capacity) {
More information about the postgis-tickets
mailing list