Allocate a new GSERIALIZED from an LWGEOM.
For all non-point types, a bounding box will be calculated and embedded in the serialization. The geodetic flag is used to control the box calculation (cartesian or geocentric). If set, the size pointer will contain the size of the final output, which is useful for setting the PgSQL VARSIZE information.
Definition at line 1090 of file gserialized1.c.
1092 size_t expected_size = 0;
1093 size_t return_size = 0;
1094 uint8_t *serialized = NULL;
1095 uint8_t *ptr = NULL;
1117 serialized =
lwalloc(expected_size);
1131 return_size = ptr - serialized;
1133 if ( expected_size != return_size )
1135 lwerror(
"Return size (%d) not equal to expected size (%d)!", return_size, expected_size);
1140 *size = return_size;
1148 g->
size = return_size << 2;
static size_t gserialized1_from_lwgeom_any(const LWGEOM *geom, uint8_t *buf)
static size_t gserialized1_from_gbox(const GBOX *gbox, uint8_t *buf)
size_t gserialized1_from_lwgeom_size(const LWGEOM *geom)
Return the memory size a GSERIALIZED will occupy for a given LWGEOM.
uint8_t lwflags_get_g1flags(lwflags_t lwflags)
void gserialized1_set_srid(GSERIALIZED *s, int32_t srid)
Write the SRID into the serialized form (it is packed into three bytes so this is a handy function).
#define FLAGS_SET_BBOX(flags, value)
int lwgeom_needs_bbox(const LWGEOM *geom)
Check whether or not a lwgeom is big enough to warrant a bounding box.
void * lwalloc(size_t size)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
References LWGEOM::bbox, LWGEOM::flags, FLAGS_SET_BBOX, GSERIALIZED::gflags, gserialized1_from_gbox(), gserialized1_from_lwgeom_any(), gserialized1_from_lwgeom_size(), gserialized1_set_srid(), lwalloc(), lwerror(), lwflags_get_g1flags(), lwgeom_add_bbox(), lwgeom_is_empty(), lwgeom_needs_bbox(), GSERIALIZED::size, and LWGEOM::srid.
Referenced by peek1_point_helper(), test_gbox_same_2d(), test_gserialized1_is_empty(), test_gserialized1_peek_gbox_p_gets_correct_box(), test_gserialized1_peek_gbox_p_no_box_when_empty(), test_lwgeom_from_gserialized(), and test_on_gser_lwgeom_count_vertices().