PostGIS  2.2.7dev-r@@SVN_REVISION@@
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 158 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().

159 {
160 
161  /* Null input! */
162  if ( ! ( g && gbox ) ) return LW_FAILURE;
163 
164  /* Initialize the flags on the box */
165  gbox->flags = g->flags;
166 
167  /* Has pre-calculated box */
168  if ( FLAGS_GET_BBOX(g->flags) )
169  {
170  int i = 0;
171  float *fbox = (float*)(g->data);
172  gbox->xmin = fbox[i++];
173  gbox->xmax = fbox[i++];
174  gbox->ymin = fbox[i++];
175  gbox->ymax = fbox[i++];
176 
177  /* Geodetic? Read next dimension (geocentric Z) and return */
178  if ( FLAGS_GET_GEODETIC(g->flags) )
179  {
180  gbox->zmin = fbox[i++];
181  gbox->zmax = fbox[i++];
182  return LW_SUCCESS;
183  }
184  /* Cartesian? Read extra dimensions (if there) and return */
185  if ( FLAGS_GET_Z(g->flags) )
186  {
187  gbox->zmin = fbox[i++];
188  gbox->zmax = fbox[i++];
189  }
190  if ( FLAGS_GET_M(g->flags) )
191  {
192  gbox->mmin = fbox[i++];
193  gbox->mmax = fbox[i++];
194  }
195  return LW_SUCCESS;
196  }
197 
198  return LW_FAILURE;
199 }
uint8_t data[1]
Definition: liblwgeom.h:368
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:127
double xmax
Definition: liblwgeom.h:277
#define LW_SUCCESS
Definition: liblwgeom.h:65
#define LW_FAILURE
Definition: liblwgeom.h:64
double zmax
Definition: liblwgeom.h:281
double ymin
Definition: liblwgeom.h:278
double xmin
Definition: liblwgeom.h:276
#define FLAGS_GET_BBOX(flags)
Definition: liblwgeom.h:126
double ymax
Definition: liblwgeom.h:279
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
uint8_t flags
Definition: liblwgeom.h:275
double mmin
Definition: liblwgeom.h:282
double zmin
Definition: liblwgeom.h:280
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
double mmax
Definition: liblwgeom.h:283
uint8_t flags
Definition: liblwgeom.h:367

Here is the caller graph for this function: