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 1580 of file gserialized2.c.
1586 size_t box_size = 2 * g_ndims *
sizeof(float);
1591 if (g_ndims != box_ndims)
1608 size_t varsize_out = varsize_in + box_size;
1609 uint8_t *ptr_out, *ptr_in, *ptr;
1611 ptr_out = (uint8_t*)g_out;
1612 ptr = ptr_in = (uint8_t*)g;
1614 memcpy(ptr_out, ptr_in, 8); ptr_out += 8; ptr_in += 8;
1618 memcpy(ptr_out, ptr_in, 8); ptr_out += 8; ptr_in += 8;
1621 ptr_out += box_size;
1622 memcpy(ptr_out, ptr_in, varsize_in - (ptr_in - ptr));
1630 fbox = (
float*)(g_out->
data);
1632 fbox[fbox_pos++] = gbox->
xmin;
1633 fbox[fbox_pos++] = gbox->
xmax;
1634 fbox[fbox_pos++] = gbox->
ymin;
1635 fbox[fbox_pos++] = gbox->
ymax;
1639 fbox[fbox_pos++] = gbox->
zmin;
1640 fbox[fbox_pos++] = gbox->
zmax;
1644 fbox[fbox_pos++] = gbox->
mmin;
1645 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)
void * lwalloc(size_t size)
#define SIZE_GET(varsize)
Macro for reading the size from the GSERIALIZED size attribute.
#define SIZE_SET(varsize, len)
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(), GBOX::mmax, GBOX::mmin, GSERIALIZED::size, SIZE_GET, SIZE_SET, GBOX::xmax, GBOX::xmin, GBOX::ymax, GBOX::ymin, GBOX::zmax, and GBOX::zmin.
Referenced by gserialized_set_gbox().