PostGIS  2.3.8dev-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 172 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().

173 {
174 
175  /* Null input! */
176  if ( ! ( g && gbox ) ) return LW_FAILURE;
177 
178  /* Initialize the flags on the box */
179  gbox->flags = g->flags;
180 
181  /* Has pre-calculated box */
182  if ( FLAGS_GET_BBOX(g->flags) )
183  {
184  int i = 0;
185  float *fbox = (float*)(g->data);
186  gbox->xmin = fbox[i++];
187  gbox->xmax = fbox[i++];
188  gbox->ymin = fbox[i++];
189  gbox->ymax = fbox[i++];
190 
191  /* Geodetic? Read next dimension (geocentric Z) and return */
192  if ( FLAGS_GET_GEODETIC(g->flags) )
193  {
194  gbox->zmin = fbox[i++];
195  gbox->zmax = fbox[i++];
196  return LW_SUCCESS;
197  }
198  /* Cartesian? Read extra dimensions (if there) and return */
199  if ( FLAGS_GET_Z(g->flags) )
200  {
201  gbox->zmin = fbox[i++];
202  gbox->zmax = fbox[i++];
203  }
204  if ( FLAGS_GET_M(g->flags) )
205  {
206  gbox->mmin = fbox[i++];
207  gbox->mmax = fbox[i++];
208  }
209  return LW_SUCCESS;
210  }
211 
212  return LW_FAILURE;
213 }
uint8_t data[1]
Definition: liblwgeom.h:383
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:142
double xmax
Definition: liblwgeom.h:292
#define LW_SUCCESS
Definition: liblwgeom.h:79
#define LW_FAILURE
Definition: liblwgeom.h:78
double zmax
Definition: liblwgeom.h:296
double ymin
Definition: liblwgeom.h:293
double xmin
Definition: liblwgeom.h:291
#define FLAGS_GET_BBOX(flags)
Definition: liblwgeom.h:141
double ymax
Definition: liblwgeom.h:294
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
uint8_t flags
Definition: liblwgeom.h:290
double mmin
Definition: liblwgeom.h:297
double zmin
Definition: liblwgeom.h:295
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
double mmax
Definition: liblwgeom.h:298
uint8_t flags
Definition: liblwgeom.h:382
Here is the caller graph for this function: