6 #define G2FLAG_BBOX      0x04 
    7 #define G2FLAG_GEODETIC  0x08 
    8 #define G2FLAG_EXTENDED  0x10 
    9 #define G2FLAG_RESERVED1 0x20  
   10 #define G2FLAG_VER_0     0x40 
   11 #define G2FLAG_RESERVED2 0x80  
   16 #define G2FLAG_X_SOLID            0x00000001 
   17 #define G2FLAG_X_CHECKED_VALID    0x00000002  
   18 #define G2FLAG_X_IS_VALID         0x00000004  
   19 #define G2FLAG_X_HAS_HASH         0x00000008  
   21 #define G2FLAGS_GET_VERSION(gflags)  (((gflags) & G2FLAG_VER_0)>>6) 
   22 #define G2FLAGS_GET_Z(gflags)         ((gflags) & G2FLAG_Z) 
   23 #define G2FLAGS_GET_M(gflags)        (((gflags) & G2FLAG_M)>>1) 
   24 #define G2FLAGS_GET_BBOX(gflags)     (((gflags) & G2FLAG_BBOX)>>2) 
   25 #define G2FLAGS_GET_GEODETIC(gflags) (((gflags) & G2FLAG_GEODETIC)>>3) 
   26 #define G2FLAGS_GET_EXTENDED(gflags) (((gflags) & G2FLAG_EXTENDED)>>4) 
   27 #define G2FLAGS_GET_UNUSED(gflags)   (((gflags) & G2FLAG_UNUSED)>>5) 
   29 #define G2FLAGS_SET_Z(gflags, value) ((gflags) = (value) ? ((gflags) | G2FLAG_Z) : ((gflags) & ~G2FLAG_Z)) 
   30 #define G2FLAGS_SET_M(gflags, value) ((gflags) = (value) ? ((gflags) | G2FLAG_M) : ((gflags) & ~G2FLAG_M)) 
   31 #define G2FLAGS_SET_BBOX(gflags, value) ((gflags) = (value) ? ((gflags) | G2FLAG_BBOX) : ((gflags) & ~G2FLAG_BBOX)) 
   32 #define G2FLAGS_SET_GEODETIC(gflags, value) ((gflags) = (value) ? ((gflags) | G2FLAG_GEODETIC) : ((gflags) & ~G2FLAG_GEODETIC)) 
   33 #define G2FLAGS_SET_EXTENDED(gflags, value) ((gflags) = (value) ? ((gflags) | G2FLAG_EXTENDED) : ((gflags) & ~G2FLAG_EXTENDED)) 
   34 #define G2FLAGS_SET_VERSION(gflags, value) ((gflags) = (value) ? ((gflags) | G2FLAG_VER_0) : ((gflags) & ~G2FLAG_VER_0)) 
   36 #define G2FLAGS_NDIMS(gflags) (2 + G2FLAGS_GET_Z(gflags) + G2FLAGS_GET_M(gflags)) 
   37 #define G2FLAGS_GET_ZM(gflags) (G2FLAGS_GET_M(gflags) + G2FLAGS_GET_Z(gflags) * 2) 
   38 #define G2FLAGS_NDIMS_BOX(gflags) (G2FLAGS_GET_GEODETIC(gflags) ? 3 : G2FLAGS_NDIMS(gflags)) 
   40 uint8_t 
g2flags(
int has_z, 
int has_m, 
int is_geodetic);
 
int gserialized2_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
int32_t gserialized2_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
void gserialized2_set_srid(GSERIALIZED *g, int32_t srid)
Write the SRID into the serialized form (it is packed into three bytes so this is a handy function).
int gserialized2_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
int gserialized2_fast_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Read the box from the GSERIALIZED or return #LWFAILURE if box is unavailable.
const float * gserialized2_get_float_box_p(const GSERIALIZED *g, size_t *ndims)
Point into the float box area of the serialization.
int gserialized2_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
uint32_t gserialized2_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
int gserialized2_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
int gserialized2_peek_first_point(const GSERIALIZED *g, POINT4D *out_point)
LWGEOM * lwgeom_from_gserialized2(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized2_get_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Read the box from the GSERIALIZED or calculate it if necessary.
int gserialized2_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
uint8_t lwflags_get_g2flags(lwflags_t lwflags)
int gserialized2_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
size_t gserialized2_from_lwgeom_size(const LWGEOM *geom)
Return the memory size a GSERIALIZED will occupy for a given LWGEOM.
int gserialized2_has_extended(const GSERIALIZED *g)
Check if a GSERIALIZED has an extended flags section.
int32_t gserialized2_hash(const GSERIALIZED *g)
Returns a hash code for the srid/type/geometry information in the GSERIALIZED.
GSERIALIZED * gserialized2_set_gbox(GSERIALIZED *g, GBOX *gbox)
Copy a new bounding box into an existing gserialized.
int gserialized2_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
GSERIALIZED * gserialized2_drop_gbox(GSERIALIZED *g)
Remove the bounding box from a GSERIALIZED.
GSERIALIZED * gserialized2_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
uint32_t gserialized2_max_header_size(void)
Returns the size in bytes to read from toast to get the basic information from a geometry: GSERIALIZE...
lwflags_t gserialized2_get_lwflags(const GSERIALIZED *g)
Read the flags from a GSERIALIZED and return a standard lwflag integer.
uint8_t g2flags(int has_z, int has_m, int is_geodetic)
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.