From bd0e3165d4260ce44b15b5e00a19534ee6ae3aea Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 11 Jun 2019 21:26:14 +0000 Subject: [PATCH] Use flags values instead of raw numbers git-svn-id: http://svn.osgeo.org/postgis/trunk@17504 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/liblwgeom.h.in | 33 +++++++++++++++++++++------------ liblwgeom/lwgeom.c | 1 - 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/liblwgeom/liblwgeom.h.in b/liblwgeom/liblwgeom.h.in index cd60e95c9..b25fc3042 100644 --- a/liblwgeom/liblwgeom.h.in +++ b/liblwgeom/liblwgeom.h.in @@ -148,18 +148,27 @@ typedef enum LWORD_T { * Version bit, followed by * Validty, Solid, ReadOnly, Geodetic, HasBBox, HasM and HasZ flags. */ -#define FLAGS_GET_Z(flags) ((flags) & 0x01) -#define FLAGS_GET_M(flags) (((flags) & 0x02)>>1) -#define FLAGS_GET_BBOX(flags) (((flags) & 0x04)>>2) -#define FLAGS_GET_GEODETIC(flags) (((flags) & 0x08)>>3) -#define FLAGS_GET_READONLY(flags) (((flags) & 0x10)>>4) -#define FLAGS_GET_SOLID(flags) (((flags) & 0x20)>>5) -#define FLAGS_SET_Z(flags, value) ((flags) = (value) ? ((flags) | 0x01) : ((flags) & 0xFE)) -#define FLAGS_SET_M(flags, value) ((flags) = (value) ? ((flags) | 0x02) : ((flags) & 0xFD)) -#define FLAGS_SET_BBOX(flags, value) ((flags) = (value) ? ((flags) | 0x04) : ((flags) & 0xFB)) -#define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ? ((flags) | 0x08) : ((flags) & 0xF7)) -#define FLAGS_SET_READONLY(flags, value) ((flags) = (value) ? ((flags) | 0x10) : ((flags) & 0xEF)) -#define FLAGS_SET_SOLID(flags, value) ((flags) = (value) ? ((flags) | 0x20) : ((flags) & 0xDF)) +#define LWFLAG_Z 0x01 +#define LWFLAG_M 0x02 +#define LWFLAG_BBOX 0x04 +#define LWFLAG_GEODETIC 0x08 +#define LWFLAG_READONLY 0x10 +#define LWFLAG_SOLID 0x20 + +#define FLAGS_GET_Z(flags) ((flags) & LWFLAG_Z) +#define FLAGS_GET_M(flags) (((flags) & LWFLAG_M)>>1) +#define FLAGS_GET_BBOX(flags) (((flags) & LWFLAG_BBOX)>>2) +#define FLAGS_GET_GEODETIC(flags) (((flags) & LWFLAG_GEODETIC)>>3) +#define FLAGS_GET_READONLY(flags) (((flags) & LWFLAG_READONLY)>>4) +#define FLAGS_GET_SOLID(flags) (((flags) & LWFLAG_SOLID)>>5) + +#define FLAGS_SET_Z(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_Z) : ((flags) & ~LWFLAG_Z)) +#define FLAGS_SET_M(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_M) : ((flags) & ~LWFLAG_M)) +#define FLAGS_SET_BBOX(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_BBOX) : ((flags) & ~LWFLAG_BBOX)) +#define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_GEODETIC) : ((flags) & ~LWFLAG_GEODETIC)) +#define FLAGS_SET_READONLY(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_READONLY) : ((flags) & ~LWFLAG_READONLY)) +#define FLAGS_SET_SOLID(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_SOLID) : ((flags) & ~LWFLAG_SOLID)) + #define FLAGS_NDIMS(flags) (2 + FLAGS_GET_Z(flags) + FLAGS_GET_M(flags)) #define FLAGS_GET_ZM(flags) (FLAGS_GET_M(flags) + FLAGS_GET_Z(flags) * 2) #define FLAGS_NDIMS_BOX(flags) (FLAGS_GET_GEODETIC(flags) ? 3 : FLAGS_NDIMS(flags)) diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c index 6e36e7b57..ff7c7e165 100644 --- a/liblwgeom/lwgeom.c +++ b/liblwgeom/lwgeom.c @@ -940,7 +940,6 @@ lwgeom_ndims(const LWGEOM *geom) - void lwgeom_set_geodetic(LWGEOM *geom, int value) { -- 2.40.0