From: Paul Ramsey Date: Tue, 11 Jun 2019 20:49:13 +0000 (+0000) Subject: Strip out direct calls to FLAGS macros where easy X-Git-Tag: 3.0.0alpha3~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23f9cefa6fe00640ce06b62c706b01753c5962d6;p=postgis Strip out direct calls to FLAGS macros where easy git-svn-id: http://svn.osgeo.org/postgis/trunk@17502 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/gserialized.c b/liblwgeom/gserialized.c new file mode 100644 index 000000000..e69de29bb diff --git a/liblwgeom/gserialized.h b/liblwgeom/gserialized.h new file mode 100644 index 000000000..e69de29bb diff --git a/liblwgeom/gserialized1.h b/liblwgeom/gserialized1.h new file mode 100644 index 000000000..e69de29bb diff --git a/liblwgeom/gserialized2.c b/liblwgeom/gserialized2.c new file mode 100644 index 000000000..e69de29bb diff --git a/liblwgeom/gserialized2.h b/liblwgeom/gserialized2.h new file mode 100644 index 000000000..e69de29bb diff --git a/liblwgeom/liblwgeom.h.in b/liblwgeom/liblwgeom.h.in index 90a8b0ed8..cd60e95c9 100644 --- a/liblwgeom/liblwgeom.h.in +++ b/liblwgeom/liblwgeom.h.in @@ -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 */ diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c index faee37228..6e36e7b57 100644 --- a/liblwgeom/lwgeom.c +++ b/liblwgeom/lwgeom.c @@ -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) { diff --git a/postgis/geobuf.c b/postgis/geobuf.c index fd7eef82f..d6439046f 100644 --- a/postgis/geobuf.c +++ b/postgis/geobuf.c @@ -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; diff --git a/postgis/gserialized_gist_2d.c b/postgis/gserialized_gist_2d.c index 65d2c600b..1c6f0ab81 100644 --- a/postgis/gserialized_gist_2d.c +++ b/postgis/gserialized_gist_2d.c @@ -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"); diff --git a/postgis/lwgeom_dumppoints.c b/postgis/lwgeom_dumppoints.c index 458428889..6507ff0d8 100644 --- a/postgis/lwgeom_dumppoints.c +++ b/postgis/lwgeom_dumppoints.c @@ -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 diff --git a/postgis/lwgeom_functions_analytic.c b/postgis/lwgeom_functions_analytic.c index 3e32b29bb..4bb6aa4a7 100644 --- a/postgis/lwgeom_functions_analytic.c +++ b/postgis/lwgeom_functions_analytic.c @@ -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 diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c index faec65dbf..9fc0a9d67 100644 --- a/postgis/lwgeom_functions_basic.c +++ b/postgis/lwgeom_functions_basic.c @@ -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) { diff --git a/postgis/lwgeom_ogc.c b/postgis/lwgeom_ogc.c index 3ae38c298..38dbbc074 100644 --- a/postgis/lwgeom_ogc.c +++ b/postgis/lwgeom_ogc.c @@ -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); diff --git a/postgis/lwgeom_rtree.c b/postgis/lwgeom_rtree.c index e30b23761..90e885f03 100644 --- a/postgis/lwgeom_rtree.c +++ b/postgis/lwgeom_rtree.c @@ -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); diff --git a/postgis/lwgeom_sfcgal.c b/postgis/lwgeom_sfcgal.c index 749988b88..f15ac6db6 100644 --- a/postgis/lwgeom_sfcgal.c +++ b/postgis/lwgeom_sfcgal.c @@ -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);