Copy a new bounding box into an existing gserialized.
If necessary a new GSERIALIZED will be allocated. Test that input != output before freeing input.
Copy a new bounding box into an existing gserialized.
WARNING if a new object needs to be created, the input pointer will have to be freed by the caller! Check to see if input == output. Returns null if there's a problem like mismatched dimensions.
Definition at line 1559 of file gserialized2.c.
1565 size_t box_size = 2 * g_ndims *
sizeof(float);
1570 if (g_ndims != box_ndims)
1587 size_t varsize_out = varsize_in + box_size;
1588 uint8_t *ptr_out, *ptr_in, *ptr;
1590 ptr_out = (uint8_t*)g_out;
1591 ptr = ptr_in = (uint8_t*)g;
1593 memcpy(ptr_out, ptr_in, 8); ptr_out += 8; ptr_in += 8;
1597 memcpy(ptr_out, ptr_in, 8); ptr_out += 8; ptr_in += 8;
1600 ptr_out += box_size;
1601 memcpy(ptr_out, ptr_in, varsize_in - (ptr_in - ptr));
1609 fbox = (
float*)(g_out->
data);
1611 fbox[fbox_pos++] = gbox->
xmin;
1612 fbox[fbox_pos++] = gbox->
xmax;
1613 fbox[fbox_pos++] = gbox->
ymin;
1614 fbox[fbox_pos++] = gbox->
ymax;
1618 fbox[fbox_pos++] = gbox->
zmin;
1619 fbox[fbox_pos++] = gbox->
zmax;
1623 fbox[fbox_pos++] = gbox->
mmin;
1624 fbox[fbox_pos++] = gbox->
mmax;
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
int gserialized2_is_geodetic(const GSERIALIZED *g)
Check if a GSERIALIZED is a geography.
int gserialized2_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
int gserialized2_has_m(const GSERIALIZED *g)
Check if a GSERIALIZED has an M ordinate.
#define G2FLAGS_NDIMS_BOX(gflags)
#define G2FLAGS_GET_BBOX(gflags)
#define G2FLAGS_GET_EXTENDED(gflags)
#define G2FLAGS_SET_BBOX(gflags, value)
#define FLAGS_NDIMS_BOX(flags)
#define LWSIZE_GET(varsize)
Macro for reading the size from the GSERIALIZED size attribute.
#define LWSIZE_SET(varsize, len)
void * lwalloc(size_t size)
References GSERIALIZED::data, GBOX::flags, FLAGS_NDIMS_BOX, G2FLAGS_GET_BBOX, G2FLAGS_GET_EXTENDED, G2FLAGS_NDIMS_BOX, G2FLAGS_SET_BBOX, gbox_float_round(), GSERIALIZED::gflags, gserialized2_has_m(), gserialized2_has_z(), gserialized2_is_geodetic(), lwalloc(), LWSIZE_GET, LWSIZE_SET, GBOX::mmax, GBOX::mmin, GSERIALIZED::size, GBOX::xmax, GBOX::xmin, GBOX::ymax, GBOX::ymin, GBOX::zmax, and GBOX::zmin.
Referenced by gserialized_set_gbox().