]> granicus.if.org Git - postgis/commitdiff
Strip out direct calls to FLAGS macros where easy
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 11 Jun 2019 20:49:13 +0000 (20:49 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 11 Jun 2019 20:49:13 +0000 (20:49 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@17502 b70326c6-7e19-0410-871a-916f4a2858ee

15 files changed:
liblwgeom/gserialized.c [new file with mode: 0644]
liblwgeom/gserialized.h [new file with mode: 0644]
liblwgeom/gserialized1.h [new file with mode: 0644]
liblwgeom/gserialized2.c [new file with mode: 0644]
liblwgeom/gserialized2.h [new file with mode: 0644]
liblwgeom/liblwgeom.h.in
liblwgeom/lwgeom.c
postgis/geobuf.c
postgis/gserialized_gist_2d.c
postgis/lwgeom_dumppoints.c
postgis/lwgeom_functions_analytic.c
postgis/lwgeom_functions_basic.c
postgis/lwgeom_ogc.c
postgis/lwgeom_rtree.c
postgis/lwgeom_sfcgal.c

diff --git a/liblwgeom/gserialized.c b/liblwgeom/gserialized.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/liblwgeom/gserialized.h b/liblwgeom/gserialized.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/liblwgeom/gserialized1.h b/liblwgeom/gserialized1.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/liblwgeom/gserialized2.c b/liblwgeom/gserialized2.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/liblwgeom/gserialized2.h b/liblwgeom/gserialized2.h
new file mode 100644 (file)
index 0000000..e69de29
index 90a8b0ed8279eefccd918208525785c9813dc7d1..cd60e95c95b9c93680491f97352ca45b42b17374 100644 (file)
@@ -1428,6 +1428,11 @@ extern int lwgeom_has_z(const LWGEOM *geom);
 */
 extern int lwgeom_has_m(const LWGEOM *geom);
 
+/**
+* Return #LW_TRUE if geometry has SOLID flag.
+*/
+extern int lwgeom_is_solid(const LWGEOM *geom);
+
 /**
 * Return the number of dimensions (2, 3, 4) in a geometry
 */
index faee3722816fe9ac25a8d3430144957c83a94784..6e36e7b57bd45a8fe21a5fa8dcdc1065c086f9c1 100644 (file)
@@ -924,6 +924,13 @@ lwgeom_has_m(const LWGEOM *geom)
        return FLAGS_GET_M(geom->flags);
 }
 
+int
+lwgeom_is_solid(const LWGEOM *geom)
+{
+       if ( ! geom ) return LW_FALSE;
+       return FLAGS_GET_GEODETIC(geom->flags);
+}
+
 int
 lwgeom_ndims(const LWGEOM *geom)
 {
@@ -932,6 +939,8 @@ lwgeom_ndims(const LWGEOM *geom)
 }
 
 
+
+
 void
 lwgeom_set_geodetic(LWGEOM *geom, int value)
 {
index fd7eef82fa7e66797069968a35d8c782a609e2a4..d6439046f15273fb73148d871971231abe8c44d9 100644 (file)
@@ -490,11 +490,12 @@ static void analyze_geometry(struct geobuf_agg_context *ctx, LWGEOM *lwgeom)
 static void analyze_geometry_flags(struct geobuf_agg_context *ctx,
        LWGEOM *lwgeom)
 {
-       if (!ctx->has_dimensions) {
-               if (FLAGS_GET_Z(lwgeom->flags) || FLAGS_GET_M(lwgeom->flags))
-                       ctx->dimensions = 3;
-               else if (FLAGS_GET_ZM(lwgeom->flags))
+       if (!ctx->has_dimensions)
+       {
+               if (lwgeom_has_z(lwgeom) && lwgeom_has_m(lwgeom))
                        ctx->dimensions = 4;
+               else if (lwgeom_has_z(lwgeom) || lwgeom_has_m(lwgeom))
+                       ctx->dimensions = 3;
                else
                        ctx->dimensions = 2;
                ctx->has_dimensions = 1;
index 65d2c600b8cacea864048a90c6f9b731337b2135..1c6f0ab8141553b92c3c82eb4d2ed4f3e783f258 100644 (file)
@@ -561,7 +561,6 @@ int
 gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
 {
        GSERIALIZED *gpart;
-       uint8_t flags;
        int result = LW_SUCCESS;
 
        POSTGIS_DEBUG(4, "entered function");
@@ -577,12 +576,11 @@ gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
        ** which makes slicing worthwhile.
        */
        gpart = (GSERIALIZED*)PG_DETOAST_DATUM(gsdatum);
-       flags = gpart->flags;
 
        POSTGIS_DEBUGF(4, "got flags %d", gpart->flags);
 
        /* Do we even have a serialized bounding box? */
-       if ( FLAGS_GET_BBOX(flags) )
+       if (gserialized_has_bbox(gpart))
        {
                /* Yes! Copy it out into the box! */
                POSTGIS_DEBUG(4, "copying box out of serialization");
index 45842888988c4500060e9f2def221b35c328e208..6507ff0d86aa2ca3aa16feedbdcecdb6ee603562 100644 (file)
@@ -176,8 +176,8 @@ Datum LWGEOM_dumppoints(PG_FUNCTION_ARGS) {
                                        if (state->pt <= 3) {
                                                getPoint4d_p(tri->points, state->pt, &pt);
                                                lwpoint = lwpoint_make(tri->srid,
-                                                               FLAGS_GET_Z(tri->points->flags),
-                                                               FLAGS_GET_M(tri->points->flags),
+                                                               lwgeom_has_z(lwgeom),
+                                                               lwgeom_has_m(lwgeom),
                                                                &pt);
                                        }
                                        if (state->pt > 3) {
@@ -210,8 +210,8 @@ Datum LWGEOM_dumppoints(PG_FUNCTION_ARGS) {
                                         */
                                                getPoint4d_p(poly->rings[state->ring], state->pt, &pt);
                                                lwpoint = lwpoint_make(poly->srid,
-                                                               FLAGS_GET_Z(poly->rings[state->ring]->flags),
-                                                               FLAGS_GET_M(poly->rings[state->ring]->flags),
+                                                               lwgeom_has_z(lwgeom),
+                                                               lwgeom_has_m(lwgeom),
                                                                &pt);
                                        }
                                        break;
@@ -291,21 +291,4 @@ Datum LWGEOM_dumppoints(PG_FUNCTION_ARGS) {
        }
 }
 
-/*
- * Geometry types of collection types for reference
- */
-
-#if 0
-        case MULTIPOINTTYPE:
-        case MULTILINETYPE:
-        case MULTIPOLYGONTYPE:
-        case COLLECTIONTYPE:
-        case CURVEPOLYTYPE:
-        case COMPOUNDTYPE:
-        case MULTICURVETYPE:
-        case MULTISURFACETYPE:
-        case POLYHEDRALSURFACETYPE:
-        case TINTYPE:
-
-#endif
 
index 3e32b29bbd359ec0647726e236bac2ef7b662d5c..4bb6aa4a7f6804ebb103f157bef24c069f24d31a 100644 (file)
@@ -433,9 +433,9 @@ Datum LWGEOM_snaptogrid_pointoff(PG_FUNCTION_ARGS)
        getPoint4d_p(in_lwpoint->point, 0, &offsetpoint);
        grid.ipx = offsetpoint.x;
        grid.ipy = offsetpoint.y;
-       if (FLAGS_GET_Z(in_lwpoint->flags) ) grid.ipz = offsetpoint.z;
+       if (lwgeom_has_z(in_lwpoint) ) grid.ipz = offsetpoint.z;
        else grid.ipz=0;
-       if (FLAGS_GET_M(in_lwpoint->flags) ) grid.ipm = offsetpoint.m;
+       if (lwgeom_has_m(in_lwpoint) ) grid.ipm = offsetpoint.m;
        else grid.ipm=0;
 
 #if POSTGIS_DEBUG_LEVEL >= 4
index faec65dbf3b165a80f2c1b0530288329fa830682..9fc0a9d67408f60251c27b5b91b970f8fd91b590 100644 (file)
@@ -1151,7 +1151,8 @@ Datum LWGEOM_collect(PG_FUNCTION_ARGS)
                       lwtype_name(gserialized_get_type(gser1)),
                       lwtype_name(gserialized_get_type(gser2)));
 
-       if (FLAGS_GET_ZM(gser1->flags) != FLAGS_GET_ZM(gser2->flags))
+       if ((gserialized_has_z(gser1) != gserialized_has_z(gser2)) ||
+               (gserialized_has_m(gser1) != gserialized_has_m(gser2)))
        {
                elog(ERROR, "Cannot ST_Collect geometries with differing dimensionality.");
                PG_RETURN_NULL();
@@ -2675,7 +2676,7 @@ Datum ST_CollectionExtract(PG_FUNCTION_ARGS)
                else
                {
                        lwcol = lwgeom_construct_empty(
-                           type, lwgeom->srid, FLAGS_GET_Z(lwgeom->flags), FLAGS_GET_M(lwgeom->flags));
+                           type, lwgeom->srid, lwgeom_has_z(lwgeom), lwgeom_has_m(lwgeom));
                }
        }
        else
@@ -3092,7 +3093,7 @@ Datum LWGEOM_FilterByM(PG_FUNCTION_ARGS)
 
        lwgeom_in = lwgeom_from_gserialized(geom_in);
 
-       hasm = FLAGS_GET_M(lwgeom_in->flags);
+       hasm = lwgeom_has_m(lwgeom_in);
 
        if (!hasm)
        {
index 3ae38c2988770f1bb8b625b42cfe20db1664aad9..38dbbc07456ffacacf0e2953cbca5b243db8a7e0 100644 (file)
@@ -697,12 +697,9 @@ Datum LWGEOM_m_point(PG_FUNCTION_ARGS)
        lwgeom = lwgeom_from_gserialized(geom);
        point = lwgeom_as_lwpoint(lwgeom);
 
-       if ( lwgeom_is_empty(lwgeom) )
+       if (lwgeom_is_empty(lwgeom) || !lwgeom_has_m(lwgeom))
                PG_RETURN_NULL();
 
-       /* no M in input */
-       if ( ! FLAGS_GET_M(point->flags) ) PG_RETURN_NULL();
-
        getPoint3dm_p(point->point, 0, &p);
 
        PG_FREE_IF_COPY(geom, 0);
index e30b23761d8db5bd8f50754a31295a5364369caa..90e885f03e545b61d96e5c2614a546f239eca12c 100644 (file)
@@ -471,7 +471,7 @@ LWMLINE *RTreeFindLineSegments(RTREE_NODE *root, double value)
                lwgeoms = lwalloc(sizeof(LWGEOM *));
                lwgeoms[0] = (LWGEOM *)root->segment;
 
-               POSTGIS_DEBUGF(3, "Found geom %p, type %d, dim %d", root->segment, root->segment->type, FLAGS_GET_Z(root->segment->flags));
+               POSTGIS_DEBUGF(3, "Found geom %p, type %d, dim %d", root->segment, root->segment->type, lwgeom_has_z(root->segment));
 
                result = (LWMLINE *)lwcollection_construct(MULTILINETYPE, SRID_UNKNOWN, NULL, 1, lwgeoms);
        }
@@ -484,7 +484,7 @@ LWMLINE *RTreeFindLineSegments(RTREE_NODE *root, double value)
                tmp = RTreeFindLineSegments(root->leftNode, value);
                if (tmp)
                {
-                       POSTGIS_DEBUGF(3, "Found geom %p, type %d, dim %d", tmp, tmp->type, FLAGS_GET_Z(tmp->flags));
+                       POSTGIS_DEBUGF(3, "Found geom %p, type %d, dim %d", tmp, tmp->type, lwgeom_has_z(tmp));
 
                        if (result)
                                result = RTreeMergeMultiLines(result, tmp);
@@ -501,7 +501,7 @@ LWMLINE *RTreeFindLineSegments(RTREE_NODE *root, double value)
                tmp = RTreeFindLineSegments(root->rightNode, value);
                if (tmp)
                {
-                       POSTGIS_DEBUGF(3, "Found geom %p, type %d, dim %d", tmp, tmp->type, FLAGS_GET_Z(tmp->flags));
+                       POSTGIS_DEBUGF(3, "Found geom %p, type %d, dim %d", tmp, tmp->type, lwgeom_has_z(tmp));
 
                        if (result)
                                result = RTreeMergeMultiLines(result, tmp);
index 749988b883f6fa7cb0854da3e5d3c8ad3e1b3eba..f15ac6db6e9a70d22ec9500ee3087340fddf1c9d 100644 (file)
@@ -503,7 +503,7 @@ Datum sfcgal_is_solid(PG_FUNCTION_ARGS)
        if (!lwgeom)
                elog(ERROR, "sfcgal_is_solid: Unable to deserialize input");
 
-       result = FLAGS_GET_SOLID(lwgeom->flags);
+       result = lwgeom_is_solid(lwgeom);
 
        lwgeom_free(lwgeom);