PostGIS  3.0.6dev-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 392 of file gbox.c.

393 {
394  const size_t sz = 138;
395  char *str = NULL;
396 
397  if ( ! gbox )
398  return lwstrdup("NULL POINTER");
399 
400  str = (char*)lwalloc(sz);
401 
402  if ( FLAGS_GET_GEODETIC(gbox->flags) )
403  {
404  snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->zmin, gbox->xmax, gbox->ymax, gbox->zmax);
405  return str;
406  }
407  if ( FLAGS_GET_Z(gbox->flags) && FLAGS_GET_M(gbox->flags) )
408  {
409  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);
410  return str;
411  }
412  if ( FLAGS_GET_Z(gbox->flags) )
413  {
414  snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->zmin, gbox->xmax, gbox->ymax, gbox->zmax);
415  return str;
416  }
417  if ( FLAGS_GET_M(gbox->flags) )
418  {
419  snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->mmin, gbox->xmax, gbox->ymax, gbox->mmax);
420  return str;
421  }
422  snprintf(str, sz, "GBOX((%.8g,%.8g),(%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->xmax, gbox->ymax);
423  return str;
424 }
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:179
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:180
void * lwalloc(size_t size)
Definition: lwutil.c:227
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:182
char * lwstrdup(const char *a)
Definition: lwutil.c:248
#define str(s)
double ymax
Definition: liblwgeom.h:343
double zmax
Definition: liblwgeom.h:345
double xmax
Definition: liblwgeom.h:341
double zmin
Definition: liblwgeom.h:344
double mmax
Definition: liblwgeom.h:347
double ymin
Definition: liblwgeom.h:342
double xmin
Definition: liblwgeom.h:340
double mmin
Definition: liblwgeom.h:346
lwflags_t flags
Definition: liblwgeom.h:339

References GBOX::flags, FLAGS_GET_GEODETIC, FLAGS_GET_M, FLAGS_GET_Z, lwalloc(), lwstrdup(), GBOX::mmax, GBOX::mmin, str, 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(), lwpoly_covers_point2d(), nd_box_from_gbox(), test_gbox_from_spherical_coordinates(), test_gbox_to_string_truncated(), and test_gserialized_get_gbox_geocentric().

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