PostGIS  3.0.6dev-r@@SVN_REVISION@@
gserialized2.h
Go to the documentation of this file.
1 
4 #define G2FLAG_Z 0x01
5 #define G2FLAG_M 0x02
6 #define G2FLAG_BBOX 0x04
7 #define G2FLAG_GEODETIC 0x08
8 #define G2FLAG_EXTENDED 0x10
9 #define G2FLAG_RESERVED1 0x20 /* RESERVED FOR FUTURE USES */
10 #define G2FLAG_VER_0 0x40
11 #define G2FLAG_RESERVED2 0x80 /* RESERVED FOR FUTURE VERSIONS */
12 
16 #define G2FLAG_X_SOLID 0x00000001
17 #define G2FLAG_X_CHECKED_VALID 0x00000002 // To Be Implemented?
18 #define G2FLAG_X_IS_VALID 0x00000004 // To Be Implemented?
19 #define G2FLAG_X_HAS_HASH 0x00000008 // To Be Implemented?
20 
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)
28 
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))
35 
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))
39 
40 uint8_t g2flags(int has_z, int has_m, int is_geodetic);
42 
43 /*
44 * GSERIALIZED PUBLIC API
45 */
46 
52 
59 
65 
71 int gserialized2_get_gbox_p(const GSERIALIZED *g, GBOX *gbox);
72 
77 int gserialized2_fast_gbox_p(const GSERIALIZED *g, GBOX *gbox);
78 
83 uint32_t gserialized2_get_type(const GSERIALIZED *g);
84 
89 uint32_t gserialized2_max_header_size(void);
90 
96 int32_t gserialized2_hash(const GSERIALIZED *g);
97 
102 int32_t gserialized2_get_srid(const GSERIALIZED *g);
103 
108 void gserialized2_set_srid(GSERIALIZED *g, int32_t srid);
109 
116 int gserialized2_is_empty(const GSERIALIZED *g);
117 
121 int gserialized2_has_bbox(const GSERIALIZED *gser);
122 
127 
131 int gserialized2_has_z(const GSERIALIZED *gser);
132 
136 int gserialized2_has_m(const GSERIALIZED *gser);
137 
141 int gserialized2_is_geodetic(const GSERIALIZED *gser);
142 
146 int gserialized2_ndims(const GSERIALIZED *gser);
147 
155 GSERIALIZED* gserialized2_from_lwgeom(LWGEOM *geom, size_t *size);
156 
160 size_t gserialized2_from_lwgeom_size(const LWGEOM *geom);
161 
167 
171 const float * gserialized2_get_float_box_p(const GSERIALIZED *g, size_t *ndims);
172 
173 int gserialized2_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox);
174 
175 int gserialized2_peek_first_point(const GSERIALIZED *g, POINT4D *out_point);
int gserialized2_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
Definition: gserialized2.c:171
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)...
Definition: gserialized2.c:190
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).
Definition: gserialized2.c:207
int gserialized2_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: gserialized2.c:161
int gserialized2_fast_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Read the box from the GSERIALIZED or return #LWFAILURE if box is unavailable.
Definition: gserialized2.c:610
const float * gserialized2_get_float_box_p(const GSERIALIZED *g, size_t *ndims)
Point into the float box area of the serialization.
Definition: gserialized2.c:294
int gserialized2_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: gserialized2.c:146
uint32_t gserialized2_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized2.c:184
int gserialized2_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: gserialized2.c:251
int gserialized2_peek_first_point(const GSERIALIZED *g, POINT4D *out_point)
Definition: gserialized2.c:548
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.
Definition: gserialized2.c:581
int gserialized2_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: gserialized2.c:360
uint8_t lwflags_get_g2flags(lwflags_t lwflags)
Definition: gserialized2.c:116
int gserialized2_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: gserialized2.c:156
size_t gserialized2_from_lwgeom_size(const LWGEOM *geom)
Return the memory size a GSERIALIZED will occupy for a given LWGEOM.
Definition: gserialized2.c:774
int gserialized2_has_extended(const GSERIALIZED *g)
Check if a GSERIALIZED has an extended flags section.
Definition: gserialized2.c:151
int32_t gserialized2_hash(const GSERIALIZED *g)
Returns a hash code for the srid/type/geometry information in the GSERIALIZED.
Definition: gserialized2.c:268
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.
Definition: gserialized2.c:166
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...
Definition: gserialized2.c:176
lwflags_t gserialized2_get_lwflags(const GSERIALIZED *g)
Read the flags from a GSERIALIZED and return a standard lwflag integer.
Definition: gserialized2.c:57
uint8_t g2flags(int has_z, int has_m, int is_geodetic)
Definition: gserialized2.c:134
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