PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_to_BOX()

Datum LWGEOM_to_BOX ( PG_FUNCTION_ARGS  )

Definition at line 1667 of file lwgeom_functions_basic.c.

1668 {
1669  GSERIALIZED *pg_lwgeom = PG_GETARG_GSERIALIZED_P(0);
1670  LWGEOM *lwgeom = lwgeom_from_gserialized(pg_lwgeom);
1671  GBOX gbox;
1672  int result;
1673  BOX *out = NULL;
1674 
1675  /* Zero out flags */
1676  gbox_init(&gbox);
1677 
1678  /* Calculate the GBOX of the geometry */
1679  result = lwgeom_calculate_gbox(lwgeom, &gbox);
1680 
1681  /* Clean up memory */
1682  lwfree(lwgeom);
1683  PG_FREE_IF_COPY(pg_lwgeom, 0);
1684 
1685  /* Null on failure */
1686  if ( ! result )
1687  PG_RETURN_NULL();
1688 
1689  out = lwalloc(sizeof(BOX));
1690  out->low.x = gbox.xmin;
1691  out->low.y = gbox.ymin;
1692  out->high.x = gbox.xmax;
1693  out->high.y = gbox.ymax;
1694  PG_RETURN_POINTER(out);
1695 }
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:47
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwfree(void *mem)
Definition: lwutil.c:244
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:746
void * lwalloc(size_t size)
Definition: lwutil.c:229
double ymax
Definition: liblwgeom.h:298
double xmax
Definition: liblwgeom.h:296
double ymin
Definition: liblwgeom.h:297
double xmin
Definition: liblwgeom.h:295

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

Here is the call graph for this function: