Update the bounding box of a GSERIALIZED, allocating a fresh one if there is not enough space to just write the new box in.
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 1509 of file gserialized1.c.
1510{
1511
1515 size_t box_size = 2 * g_ndims * sizeof(float);
1516 float *fbox;
1517 int fbox_pos = 0;
1518
1519
1520 if ( g_ndims != box_ndims )
1521 {
1522 return NULL;
1523 }
1524
1525
1527 {
1528 g_out = g;
1529 }
1530
1531
1532
1533
1534 else
1535 {
1537 uint8_t *ptr;
1539
1540 memcpy(g_out, g, 8);
1541
1543 ptr += box_size;
1547 }
1548
1549
1551
1552 fbox = (
float*)(g_out->
data);
1553
1554 fbox[fbox_pos++] = gbox->
xmin;
1555 fbox[fbox_pos++] = gbox->
xmax;
1556 fbox[fbox_pos++] = gbox->
ymin;
1557 fbox[fbox_pos++] = gbox->
ymax;
1558
1560 {
1561 fbox[fbox_pos++] = gbox->
zmin;
1562 fbox[fbox_pos++] = gbox->
zmax;
1563 }
1565 {
1566 fbox[fbox_pos++] = gbox->
mmin;
1567 fbox[fbox_pos++] = gbox->
mmax;
1568 }
1569
1570 return g_out;
1571}
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
int gserialized1_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
int gserialized1_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
int gserialized1_is_geodetic(const GSERIALIZED *gser)
Check if a GSERIALIZED is a geography.
#define G1FLAGS_SET_BBOX(gflags, value)
#define G1FLAGS_GET_BBOX(gflags)
#define G1FLAGS_NDIMS_BOX(gflags)
#define FLAGS_NDIMS_BOX(flags)
#define LWSIZE_GET(varsize)
Macro for reading the size from the GSERIALIZED size attribute.
void * lwalloc(size_t size)
#define LWSIZE_SET(varsize, len)
References GSERIALIZED::data, GBOX::flags, FLAGS_NDIMS_BOX, G1FLAGS_GET_BBOX, G1FLAGS_NDIMS_BOX, G1FLAGS_SET_BBOX, gbox_float_round(), GSERIALIZED::gflags, gserialized1_has_m(), gserialized1_has_z(), gserialized1_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().