]> granicus.if.org Git - postgis/commitdiff
Quiet compile warnings
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 18 Oct 2017 19:28:28 +0000 (19:28 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 18 Oct 2017 19:28:28 +0000 (19:28 +0000)
git-svn-id: http://svn.osgeo.org/postgis/branches/2.4@16014 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwgeom_geos.c
postgis/geobuf.c
postgis/geography_centroid.c
postgis/gserialized_gist_2d.c
postgis/lwgeom_functions_basic.c
postgis/mvt.c

index 1d3ccf707324accf7202d430430a1a0fd900a0ac..b9cad015b9ad23182caf2beeeba595131ce416c4 100644 (file)
@@ -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 */
        }
 
index 7340ccc8047c784afd16c54daf3b3856bfd2b4cc..74bd36db97229b3061d46a93b3468d9066bb8d32 100644 (file)
@@ -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) {
index 00b8b83c43325c348dbfded1f6bc981586795e3c..e234a51cccb235d0ae726dcc9c378947618f6648 100644 (file)
@@ -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);
 
index 68d32b22db5899a0142ae09a859b90dab35e0d7b..2c5ba6a73128064746ab01c9fe45002f9541b7d0 100644 (file)
@@ -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");
 
index 5147ac7a287b20dedfee56aa544e317fa756ac14..d298844ebf33403c1cbfc3a081e0ae14dae12d7a 100644 (file)
@@ -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;
 
index 5c7fcb18e77196ac636b2841186ece862c6ca4a0..9fe04822f1609d3544e27266f7f110caac76e9fb 100644 (file)
@@ -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) {