PostGIS 3.6.2dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_to_BOX()

Datum LWGEOM_to_BOX ( PG_FUNCTION_ARGS  )

Definition at line 1691 of file lwgeom_functions_basic.c.

1692{
1693 GSERIALIZED *pg_lwgeom = PG_GETARG_GSERIALIZED_P(0);
1694 LWGEOM *lwgeom = lwgeom_from_gserialized(pg_lwgeom);
1695 GBOX gbox;
1696 int result;
1697 BOX *out = NULL;
1698
1699 /* Zero out flags */
1700 gbox_init(&gbox);
1701
1702 /* Calculate the GBOX of the geometry */
1703 result = lwgeom_calculate_gbox(lwgeom, &gbox);
1704
1705 /* Clean up memory */
1706 lwfree(lwgeom);
1707 PG_FREE_IF_COPY(pg_lwgeom, 0);
1708
1709 /* Null on failure */
1710 if (!result)
1711 PG_RETURN_NULL();
1712
1713 out = lwalloc(sizeof(BOX));
1714 out->low.x = gbox.xmin;
1715 out->low.y = gbox.ymin;
1716 out->high.x = gbox.xmax;
1717 out->high.y = gbox.ymax;
1718 PG_RETURN_POINTER(out);
1719}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition gbox.c:40
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:248
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
Definition lwgeom.c:755
double ymax
Definition liblwgeom.h:357
double xmax
Definition liblwgeom.h:355
double ymin
Definition liblwgeom.h:356
double xmin
Definition liblwgeom.h:354

References gbox_init(), lwalloc(), lwfree(), lwgeom_calculate_gbox(), lwgeom_from_gserialized(), result, GBOX::xmax, GBOX::xmin, GBOX::ymax, and GBOX::ymin.

Here is the call graph for this function: