PostGIS  2.5.7dev-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 414 of file g_serialized.c.

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

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().

Here is the caller graph for this function: