PostGIS  3.0.6dev-r@@SVN_REVISION@@
gserialized1.h
Go to the documentation of this file.
1 
7 #define G1FLAG_Z 0x01
8 #define G1FLAG_M 0x02
9 #define G1FLAG_BBOX 0x04
10 #define G1FLAG_GEODETIC 0x08
11 #define G1FLAG_READONLY 0x10
12 #define G1FLAG_SOLID 0x20
13 /* VERSION BITS 0x40 */
14 /* VERSION BITS 0x80 */
15 
16 #define G1FLAGS_GET_Z(gflags) ((gflags) & G1FLAG_Z)
17 #define G1FLAGS_GET_M(gflags) (((gflags) & G1FLAG_M)>>1)
18 #define G1FLAGS_GET_BBOX(gflags) (((gflags) & G1FLAG_BBOX)>>2)
19 #define G1FLAGS_GET_GEODETIC(gflags) (((gflags) & G1FLAG_GEODETIC)>>3)
20 #define G1FLAGS_GET_SOLID(gflags) (((gflags) & G1FLAG_SOLID)>>5)
21 
22 
23 #define G1FLAGS_SET_Z(gflags, value) ((gflags) = (value) ? ((gflags) | G1FLAG_Z) : ((gflags) & ~G1FLAG_Z))
24 #define G1FLAGS_SET_M(gflags, value) ((gflags) = (value) ? ((gflags) | G1FLAG_M) : ((gflags) & ~G1FLAG_M))
25 #define G1FLAGS_SET_BBOX(gflags, value) ((gflags) = (value) ? ((gflags) | G1FLAG_BBOX) : ((gflags) & ~G1FLAG_BBOX))
26 #define G1FLAGS_SET_GEODETIC(gflags, value) ((gflags) = (value) ? ((gflags) | G1FLAG_GEODETIC) : ((gflags) & ~G1FLAG_GEODETIC))
27 #define G1FLAGS_SET_SOLID(gflags, value) ((gflags) = (value) ? ((gflags) | G1FLAG_SOLID) : ((gflags) & ~G1FLAG_SOLID))
28 
29 #define G1FLAGS_NDIMS(gflags) (2 + G1FLAGS_GET_Z(gflags) + G1FLAGS_GET_M(gflags))
30 #define G1FLAGS_GET_ZM(gflags) (G1FLAGS_GET_M(gflags) + G1FLAGS_GET_Z(gflags) * 2)
31 #define G1FLAGS_NDIMS_BOX(gflags) (G1FLAGS_GET_GEODETIC(gflags) ? 3 : G1FLAGS_NDIMS(gflags))
32 
33 uint8_t g1flags(int has_z, int has_m, int is_geodetic);
35 
36 /*
37 * GSERIALIZED PUBLIC API
38 */
39 
45 
52 
58 
64 int gserialized1_get_gbox_p(const GSERIALIZED *g, GBOX *gbox);
65 
70 int gserialized1_fast_gbox_p(const GSERIALIZED *g, GBOX *gbox);
71 
76 uint32_t gserialized1_get_type(const GSERIALIZED *g);
77 
82 uint32_t gserialized1_max_header_size(void);
83 
89 int32_t gserialized1_hash(const GSERIALIZED *g);
90 
95 int32_t gserialized1_get_srid(const GSERIALIZED *g);
96 
101 void gserialized1_set_srid(GSERIALIZED *g, int32_t srid);
102 
109 int gserialized1_is_empty(const GSERIALIZED *g);
110 
114 int gserialized1_has_bbox(const GSERIALIZED *gser);
115 
119 int gserialized1_has_z(const GSERIALIZED *gser);
120 
124 int gserialized1_has_m(const GSERIALIZED *gser);
125 
129 int gserialized1_is_geodetic(const GSERIALIZED *gser);
130 
134 int gserialized1_ndims(const GSERIALIZED *gser);
135 
143 GSERIALIZED* gserialized1_from_lwgeom(LWGEOM *geom, size_t *size);
144 
148 size_t gserialized1_from_lwgeom_size(const LWGEOM *geom);
149 
155 
159 const float * gserialized1_get_float_box_p(const GSERIALIZED *g, size_t *ndims);
160 
161 int gserialized1_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox);
162 
163 int gserialized1_peek_first_point(const GSERIALIZED *g, POINT4D *out_point);
void gserialized1_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).
Definition: gserialized1.c:159
int gserialized1_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: gserialized1.c:203
uint8_t g1flags(int has_z, int has_m, int is_geodetic)
Definition: gserialized1.c:77
int gserialized1_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: gserialized1.c:94
int gserialized1_get_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Read the box from the GSERIALIZED or calculate it if necessary.
Definition: gserialized1.c:528
int gserialized1_ndims(const GSERIALIZED *gser)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: gserialized1.c:104
lwflags_t gserialized1_get_lwflags(const GSERIALIZED *g)
Read the flags from a GSERIALIZED and return a standard lwflag integer.
Definition: gserialized1.c:39
int32_t gserialized1_hash(const GSERIALIZED *g)
Returns a hash code for the srid/type/geometry information in the GSERIALIZED.
Definition: gserialized1.c:226
uint32_t gserialized1_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized1.c:131
int gserialized1_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: gserialized1.c:298
int gserialized1_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: gserialized1.c:89
GSERIALIZED * gserialized1_set_gbox(GSERIALIZED *g, GBOX *gbox)
Copy a new bounding box into an existing gserialized.
uint32_t gserialized1_max_header_size(void)
Returns the size in bytes to read from toast to get the basic information from a geometry: GSERIALIZE...
Definition: gserialized1.c:114
LWGEOM * lwgeom_from_gserialized1(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized1_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: gserialized1.c:99
GSERIALIZED * gserialized1_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
const float * gserialized1_get_float_box_p(const GSERIALIZED *g, size_t *ndims)
Point into the float box area of the serialization.
int gserialized1_peek_first_point(const GSERIALIZED *g, POINT4D *out_point)
Definition: gserialized1.c:491
int gserialized1_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
Definition: gserialized1.c:109
size_t gserialized1_from_lwgeom_size(const LWGEOM *geom)
Return the memory size a GSERIALIZED will occupy for a given LWGEOM.
Definition: gserialized1.c:721
int gserialized1_fast_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Read the box from the GSERIALIZED or return #LWFAILURE if box is unavailable.
Definition: gserialized1.c:557
int32_t gserialized1_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: gserialized1.c:142
uint8_t lwflags_get_g1flags(lwflags_t lwflags)
Definition: gserialized1.c:51
GSERIALIZED * gserialized1_drop_gbox(GSERIALIZED *g)
Remove the bounding box from a GSERIALIZED.
uint16_t lwflags_t
Definition: liblwgeom.h:313
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition: lwutil.c:471