PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ gserialized_read_gbox_p()

int gserialized_read_gbox_p ( const GSERIALIZED g,
GBOX gbox 
)

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

If it is not, return LW_FAILURE.

Definition at line 413 of file g_serialized.c.

References GSERIALIZED::data, GBOX::flags, GSERIALIZED::flags, FLAGS_GET_BBOX, FLAGS_GET_GEODETIC, FLAGS_GET_M, FLAGS_GET_Z, LW_FAILURE, LW_SUCCESS, GBOX::mmax, GBOX::mmin, GBOX::xmax, GBOX::xmin, GBOX::ymax, GBOX::ymin, GBOX::zmax, and GBOX::zmin.

Referenced by gserialized_get_gbox_p(), lwgeom_from_gserialized(), and test_gbox_same_2d().

414 {
415 
416  /* Null input! */
417  if ( ! ( g && gbox ) ) return LW_FAILURE;
418 
419  /* Initialize the flags on the box */
420  gbox->flags = g->flags;
421 
422  /* Has pre-calculated box */
423  if ( FLAGS_GET_BBOX(g->flags) )
424  {
425  int i = 0;
426  float *fbox = (float*)(g->data);
427  gbox->xmin = fbox[i++];
428  gbox->xmax = fbox[i++];
429  gbox->ymin = fbox[i++];
430  gbox->ymax = fbox[i++];
431 
432  /* Geodetic? Read next dimension (geocentric Z) and return */
433  if ( FLAGS_GET_GEODETIC(g->flags) )
434  {
435  gbox->zmin = fbox[i++];
436  gbox->zmax = fbox[i++];
437  return LW_SUCCESS;
438  }
439  /* Cartesian? Read extra dimensions (if there) and return */
440  if ( FLAGS_GET_Z(g->flags) )
441  {
442  gbox->zmin = fbox[i++];
443  gbox->zmax = fbox[i++];
444  }
445  if ( FLAGS_GET_M(g->flags) )
446  {
447  gbox->mmin = fbox[i++];
448  gbox->mmax = fbox[i++];
449  }
450  return LW_SUCCESS;
451  }
452 
453  return LW_FAILURE;
454 }
uint8_t data[1]
Definition: liblwgeom.h:386
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:142
double xmax
Definition: liblwgeom.h:295
#define LW_SUCCESS
Definition: liblwgeom.h:79
#define LW_FAILURE
Definition: liblwgeom.h:78
double zmax
Definition: liblwgeom.h:299
double ymin
Definition: liblwgeom.h:296
double xmin
Definition: liblwgeom.h:294
#define FLAGS_GET_BBOX(flags)
Definition: liblwgeom.h:141
double ymax
Definition: liblwgeom.h:297
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
uint8_t flags
Definition: liblwgeom.h:293
double mmin
Definition: liblwgeom.h:300
double zmin
Definition: liblwgeom.h:298
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
double mmax
Definition: liblwgeom.h:301
uint8_t flags
Definition: liblwgeom.h:385
Here is the caller graph for this function: