PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ LWGEOM_to_BOX()

Datum LWGEOM_to_BOX ( PG_FUNCTION_ARGS  )

Definition at line 1724 of file lwgeom_functions_basic.c.

1725 {
1726  GSERIALIZED *pg_lwgeom = PG_GETARG_GSERIALIZED_P(0);
1727  LWGEOM *lwgeom = lwgeom_from_gserialized(pg_lwgeom);
1728  GBOX gbox;
1729  int result;
1730  BOX *out = NULL;
1731 
1732  /* Zero out flags */
1733  gbox_init(&gbox);
1734 
1735  /* Calculate the GBOX of the geometry */
1736  result = lwgeom_calculate_gbox(lwgeom, &gbox);
1737 
1738  /* Clean up memory */
1739  lwfree(lwgeom);
1740  PG_FREE_IF_COPY(pg_lwgeom, 0);
1741 
1742  /* Null on failure */
1743  if (!result)
1744  PG_RETURN_NULL();
1745 
1746  out = lwalloc(sizeof(BOX));
1747  out->low.x = gbox.xmin;
1748  out->low.y = gbox.ymin;
1749  out->high.x = gbox.xmax;
1750  out->high.y = gbox.ymax;
1751  PG_RETURN_POINTER(out);
1752 }
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.
Definition: gserialized.c:239
void lwfree(void *mem)
Definition: lwutil.c:242
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
void * lwalloc(size_t size)
Definition: lwutil.c:227
double ymax
Definition: liblwgeom.h:372
double xmax
Definition: liblwgeom.h:370
double ymin
Definition: liblwgeom.h:371
double xmin
Definition: liblwgeom.h:369

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: