PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ gserialized2_get_gbox_p()

int gserialized2_get_gbox_p ( const GSERIALIZED g,
GBOX box 
)

Read the bounding box off a serialization and calculate one if it is not already there.

Read the box from the GSERIALIZED or calculate it if necessary.

Definition at line 581 of file gserialized2.c.

582 {
583  /* Try to just read the serialized box. */
584  if (gserialized2_read_gbox_p(g, box) == LW_SUCCESS)
585  {
586  return LW_SUCCESS;
587  }
588  /* No box? Try to peek into simpler geometries and */
589  /* derive a box without creating an lwgeom */
590  else if (gserialized2_peek_gbox_p(g, box) == LW_SUCCESS)
591  {
592  return LW_SUCCESS;
593  }
594  /* Damn! Nothing for it but to create an lwgeom... */
595  /* See http://trac.osgeo.org/postgis/ticket/1023 */
596  else
597  {
598  LWGEOM *lwgeom = lwgeom_from_gserialized(g);
599  int ret = lwgeom_calculate_gbox(lwgeom, box);
600  gbox_float_round(box);
601  lwgeom_free(lwgeom);
602  return ret;
603  }
604 }
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
Definition: gbox.c:774
static int gserialized2_read_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: gserialized2.c:313
int gserialized2_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: gserialized2.c:360
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
#define LW_SUCCESS
Definition: liblwgeom.h:111
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:737

References gbox_float_round(), gserialized2_peek_gbox_p(), gserialized2_read_gbox_p(), LW_SUCCESS, lwgeom_calculate_gbox(), lwgeom_free(), and lwgeom_from_gserialized().

Referenced by gserialized_get_gbox_p().

Here is the call graph for this function:
Here is the caller graph for this function: