[postgis-tickets] r17504 - Use flags values instead of raw numbers

Paul Ramsey pramsey at cleverelephant.ca
Tue Jun 11 02:26:14 PDT 2019


Author: pramsey
Date: 2019-06-11 14:26:14 -0700 (Tue, 11 Jun 2019)
New Revision: 17504

Modified:
   trunk/liblwgeom/liblwgeom.h.in
   trunk/liblwgeom/lwgeom.c
Log:
Use flags values instead of raw numbers


Modified: trunk/liblwgeom/liblwgeom.h.in
===================================================================
--- trunk/liblwgeom/liblwgeom.h.in	2019-06-11 21:24:03 UTC (rev 17503)
+++ trunk/liblwgeom/liblwgeom.h.in	2019-06-11 21:26:14 UTC (rev 17504)
@@ -148,18 +148,27 @@
 * 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))

Modified: trunk/liblwgeom/lwgeom.c
===================================================================
--- trunk/liblwgeom/lwgeom.c	2019-06-11 21:24:03 UTC (rev 17503)
+++ trunk/liblwgeom/lwgeom.c	2019-06-11 21:26:14 UTC (rev 17504)
@@ -940,7 +940,6 @@
 
 
 
-
 void
 lwgeom_set_geodetic(LWGEOM *geom, int value)
 {



More information about the postgis-tickets mailing list