PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gbox_to_string()

char* gbox_to_string ( const GBOX gbox)

Allocate a string representation of the GBOX, based on dimensionality of flags.

Definition at line 404 of file g_box.c.

References GBOX::flags, FLAGS_GET_GEODETIC, FLAGS_GET_M, FLAGS_GET_Z, lwalloc(), GBOX::mmax, GBOX::mmin, GBOX::xmax, GBOX::xmin, GBOX::ymax, GBOX::ymin, GBOX::zmax, and GBOX::zmin.

Referenced by _postgis_gserialized_sel(), gbox_check_poles(), geography_bestsrid(), geography_point_outside(), gserialized_gist_sel(), lwpoly_covers_point2d(), nd_box_from_gbox(), test_gbox_from_spherical_coordinates(), test_gbox_to_string_truncated(), and test_gserialized_get_gbox_geocentric().

405 {
406  static int sz = 138;
407  char *str = NULL;
408 
409  if ( ! gbox )
410  return strdup("NULL POINTER");
411 
412  str = (char*)lwalloc(sz);
413 
414  if ( FLAGS_GET_GEODETIC(gbox->flags) )
415  {
416  snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->zmin, gbox->xmax, gbox->ymax, gbox->zmax);
417  return str;
418  }
419  if ( FLAGS_GET_Z(gbox->flags) && FLAGS_GET_M(gbox->flags) )
420  {
421  snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->zmin, gbox->mmin, gbox->xmax, gbox->ymax, gbox->zmax, gbox->mmax);
422  return str;
423  }
424  if ( FLAGS_GET_Z(gbox->flags) )
425  {
426  snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->zmin, gbox->xmax, gbox->ymax, gbox->zmax);
427  return str;
428  }
429  if ( FLAGS_GET_M(gbox->flags) )
430  {
431  snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->mmin, gbox->xmax, gbox->ymax, gbox->mmax);
432  return str;
433  }
434  snprintf(str, sz, "GBOX((%.8g,%.8g),(%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->xmax, gbox->ymax);
435  return str;
436 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:143
double xmax
Definition: liblwgeom.h:293
double zmax
Definition: liblwgeom.h:297
double ymin
Definition: liblwgeom.h:294
double xmin
Definition: liblwgeom.h:292
double ymax
Definition: liblwgeom.h:295
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
uint8_t flags
Definition: liblwgeom.h:291
double mmin
Definition: liblwgeom.h:298
double zmin
Definition: liblwgeom.h:296
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
double mmax
Definition: liblwgeom.h:299
void * lwalloc(size_t size)
Definition: lwutil.c:229
Here is the call graph for this function:
Here is the caller graph for this function: