PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gserialized_get_gbox_p()

int gserialized_get_gbox_p ( const GSERIALIZED g,
GBOX box 
)

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

If it is not, calculate it from the geometry. If that doesn't work (null or empty) return LW_FAILURE.

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

Definition at line 640 of file g_serialized.c.

641 {
642  /* Try to just read the serialized box. */
643  if ( gserialized_read_gbox_p(g, box) == LW_SUCCESS )
644  {
645  return LW_SUCCESS;
646  }
647  /* No box? Try to peek into simpler geometries and */
648  /* derive a box without creating an lwgeom */
649  else if ( gserialized_peek_gbox_p(g, box) == LW_SUCCESS )
650  {
651  return LW_SUCCESS;
652  }
653  /* Damn! Nothing for it but to create an lwgeom... */
654  /* See http://trac.osgeo.org/postgis/ticket/1023 */
655  else
656  {
657  LWGEOM *lwgeom = lwgeom_from_gserialized(g);
658  int ret = lwgeom_calculate_gbox(lwgeom, box);
659  gbox_float_round(box);
660  lwgeom_free(lwgeom);
661  return ret;
662  }
663 }
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
Definition: g_box.c:712
static int gserialized_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: g_serialized.c:461
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
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:414
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_SUCCESS
Definition: liblwgeom.h:80
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

References gbox_float_round(), 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_cmp(), gserialized_datum_get_box2df_p(), LWGEOM_to_BOX2DF(), optimistic_overlap(), overlaps(), ST_Equals(), ST_Voronoi(), and touches().

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