PostGIS  2.4.9dev-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 416 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().

417 {
418 
419  /* Null input! */
420  if ( ! ( g && gbox ) ) return LW_FAILURE;
421 
422  /* Initialize the flags on the box */
423  gbox->flags = g->flags;
424 
425  /* Has pre-calculated box */
426  if ( FLAGS_GET_BBOX(g->flags) )
427  {
428  int i = 0;
429  float *fbox = (float*)(g->data);
430  gbox->xmin = fbox[i++];
431  gbox->xmax = fbox[i++];
432  gbox->ymin = fbox[i++];
433  gbox->ymax = fbox[i++];
434 
435  /* Geodetic? Read next dimension (geocentric Z) and return */
436  if ( FLAGS_GET_GEODETIC(g->flags) )
437  {
438  gbox->zmin = fbox[i++];
439  gbox->zmax = fbox[i++];
440  return LW_SUCCESS;
441  }
442  /* Cartesian? Read extra dimensions (if there) and return */
443  if ( FLAGS_GET_Z(g->flags) )
444  {
445  gbox->zmin = fbox[i++];
446  gbox->zmax = fbox[i++];
447  }
448  if ( FLAGS_GET_M(g->flags) )
449  {
450  gbox->mmin = fbox[i++];
451  gbox->mmax = fbox[i++];
452  }
453  return LW_SUCCESS;
454  }
455 
456  return LW_FAILURE;
457 }
uint8_t data[1]
Definition: liblwgeom.h:384
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:143
double xmax
Definition: liblwgeom.h:293
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define LW_FAILURE
Definition: liblwgeom.h:79
double zmax
Definition: liblwgeom.h:297
double ymin
Definition: liblwgeom.h:294
double xmin
Definition: liblwgeom.h:292
#define FLAGS_GET_BBOX(flags)
Definition: liblwgeom.h:142
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
uint8_t flags
Definition: liblwgeom.h:383
Here is the caller graph for this function: