PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ gserialized_get_gbox_p()

int gserialized_get_gbox_p ( const GSERIALIZED g,
GBOX box 

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

Pull a GBOX from the header of a GSERIALIZED, if one is available.

Definition at line 398 of file g_serialized.c.

References gbox_float_round(), gserialized_from_any_size(), gserialized_peek_gbox_p(), gserialized_read_gbox_p(), LW_SUCCESS, lwgeom_calculate_gbox(), lwgeom_free(), and lwgeom_from_gserialized().

Referenced by BOX2D_combine(), CircTreePIP(), compute_gserialized_stats_mode(), contains(), containsproperly(), convexhull(), coveredby(), covers(), crosses(), disjoint(), geography_bestsrid(), geography_point_outside(), geos_intersects(), gserialized_datum_get_box2df_p(), lwgeom_cmp(), lwgeom_eq(), lwgeom_ge(), lwgeom_gt(), lwgeom_le(), lwgeom_lt(), LWGEOM_to_BOX2DF(), optimistic_overlap(), overlaps(), ST_Equals(), ST_Voronoi(), and touches().

399 {
400  /* Try to just read the serialized box. */
401  if ( gserialized_read_gbox_p(g, box) == LW_SUCCESS )
402  {
403  return LW_SUCCESS;
404  }
405  /* No box? Try to peek into simpler geometries and */
406  /* derive a box without creating an lwgeom */
407  else if ( gserialized_peek_gbox_p(g, box) == LW_SUCCESS )
408  {
409  return LW_SUCCESS;
410  }
411  /* Damn! Nothing for it but to create an lwgeom... */
412  /* See */
413  else
414  {
415  LWGEOM *lwgeom = lwgeom_from_gserialized(g);
416  int ret = lwgeom_calculate_gbox(lwgeom, box);
417  gbox_float_round(box);
418  lwgeom_free(lwgeom);
419  return ret;
420  }
421 }
int gserialized_read_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Pull a GBOX from the header of a GSERIALIZED, if one is available.
Definition: g_serialized.c:172
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
static int gserialized_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: g_serialized.c:219
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
#define LW_SUCCESS
Definition: liblwgeom.h:79
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:665
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
Definition: g_box.c:717
Here is the call graph for this function:
Here is the caller graph for this function: