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 1508 of file gserialized1.c.
1509{
1510
1514 size_t box_size = 2 * g_ndims * sizeof(float);
1515 float *fbox;
1516 int fbox_pos = 0;
1517
1518
1519 if ( g_ndims != box_ndims )
1520 {
1521 return NULL;
1522 }
1523
1524
1526 {
1527 g_out = g;
1528 }
1529
1530
1531
1532
1533 else
1534 {
1536 uint8_t *ptr;
1538
1539 memcpy(g_out, g, 8);
1540
1542 ptr += box_size;
1546 }
1547
1548
1550
1551 fbox = (
float*)(g_out->
data);
1552
1553 fbox[fbox_pos++] = gbox->
xmin;
1554 fbox[fbox_pos++] = gbox->
xmax;
1555 fbox[fbox_pos++] = gbox->
ymin;
1556 fbox[fbox_pos++] = gbox->
ymax;
1557
1559 {
1560 fbox[fbox_pos++] = gbox->
zmin;
1561 fbox[fbox_pos++] = gbox->
zmax;
1562 }
1564 {
1565 fbox[fbox_pos++] = gbox->
mmin;
1566 fbox[fbox_pos++] = gbox->
mmax;
1567 }
1568
1569 return g_out;
1570}
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)
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, G1FLAGS_GET_BBOX, G1FLAGS_NDIMS_BOX, G1FLAGS_SET_BBOX, gbox_float_round(), GSERIALIZED::gflags, gserialized1_has_m(), gserialized1_has_z(), gserialized1_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().