From: Paul Ramsey Date: Wed, 18 Oct 2017 19:28:28 +0000 (+0000) Subject: Quiet compile warnings X-Git-Tag: 2.4.2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13fbaa1363e9c6c89931be973db1c00580ecc217;p=postgis Quiet compile warnings git-svn-id: http://svn.osgeo.org/postgis/branches/2.4@16014 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/lwgeom_geos.c b/liblwgeom/lwgeom_geos.c index 1d3ccf707..b9cad015b 100644 --- a/liblwgeom/lwgeom_geos.c +++ b/liblwgeom/lwgeom_geos.c @@ -209,14 +209,14 @@ GEOS2LWGEOM(const GEOSGeometry *geom, char want3d) -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,7 +224,27 @@ ptarray_to_GEOSCoordSeq(const POINTARRAY *pa) 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 @@ ptarray_to_GEOSCoordSeq(const POINTARRAY *pa) 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 @@ LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix) } else { - sq = ptarray_to_GEOSCoordSeq(lwp->point); + sq = ptarray_to_GEOSCoordSeq(lwp->point, 0); g = GEOSGeom_createPoint(sq); } if ( ! g ) @@ -388,11 +409,11 @@ LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix) 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 @@ lwgeom_normalize(const LWGEOM *geom1) 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 */ } diff --git a/postgis/geobuf.c b/postgis/geobuf.c index 7340ccc80..74bd36db9 100644 --- a/postgis/geobuf.c +++ b/postgis/geobuf.c @@ -564,7 +564,6 @@ void geobuf_agg_transfn(struct geobuf_agg_context *ctx) 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) { diff --git a/postgis/geography_centroid.c b/postgis/geography_centroid.c index 00b8b83c4..e234a51cc 100644 --- a/postgis/geography_centroid.c +++ b/postgis/geography_centroid.c @@ -316,8 +316,6 @@ LWPOINT* geography_centroid_from_mpoly(const LWMPOLY* mpoly, bool use_spheroid, 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); diff --git a/postgis/gserialized_gist_2d.c b/postgis/gserialized_gist_2d.c index 68d32b22d..2c5ba6a73 100644 --- a/postgis/gserialized_gist_2d.c +++ b/postgis/gserialized_gist_2d.c @@ -589,7 +589,6 @@ gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df) GSERIALIZED *gpart; uint8_t flags; int result = LW_SUCCESS; - int gpart_is_slice = FALSE; POSTGIS_DEBUG(4, "entered function"); diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c index 5147ac7a2..d298844eb 100644 --- a/postgis/lwgeom_functions_basic.c +++ b/postgis/lwgeom_functions_basic.c @@ -2060,8 +2060,6 @@ Datum ST_MakeEnvelope(PG_FUNCTION_ARGS) { LWPOLY *poly; GSERIALIZED *result; - POINTARRAY **pa; - POINT4D p; double x1, y1, x2, y2; int srid = SRID_UNKNOWN; diff --git a/postgis/mvt.c b/postgis/mvt.c index 5c7fcb18e..9fe04822f 100644 --- a/postgis/mvt.c +++ b/postgis/mvt.c @@ -478,7 +478,6 @@ static void add_value_as_string(struct mvt_agg_context *ctx, 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 @@ LWGEOM *mvt_geom(const LWGEOM *lwgeom, const GBOX *gbox, uint32_t extent, uint32 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 @@ void mvt_agg_transfn(struct mvt_agg_context *ctx) 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) {