PostGIS  2.1.10dev-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 159 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(), and lwgeom_from_gserialized().

160 {
161 
162  /* Null input! */
163  if ( ! ( g && gbox ) ) return LW_FAILURE;
164 
165  /* Initialize the flags on the box */
166  gbox->flags = g->flags;
167 
168  /* Has pre-calculated box */
169  if ( FLAGS_GET_BBOX(g->flags) )
170  {
171  int i = 0;
172  float *fbox = (float*)(g->data);
173  gbox->xmin = fbox[i++];
174  gbox->xmax = fbox[i++];
175  gbox->ymin = fbox[i++];
176  gbox->ymax = fbox[i++];
177 
178  /* Geodetic? Read next dimension (geocentric Z) and return */
179  if ( FLAGS_GET_GEODETIC(g->flags) )
180  {
181  gbox->zmin = fbox[i++];
182  gbox->zmax = fbox[i++];
183  return LW_SUCCESS;
184  }
185  /* Cartesian? Read extra dimensions (if there) and return */
186  if ( FLAGS_GET_Z(g->flags) )
187  {
188  gbox->zmin = fbox[i++];
189  gbox->zmax = fbox[i++];
190  }
191  if ( FLAGS_GET_M(g->flags) )
192  {
193  gbox->mmin = fbox[i++];
194  gbox->mmax = fbox[i++];
195  }
196  return LW_SUCCESS;
197  }
198 
199  return LW_FAILURE;
200 }
uint8_t data[1]
Definition: liblwgeom.h:340
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:109
double xmax
Definition: liblwgeom.h:249
#define LW_SUCCESS
Definition: liblwgeom.h:55
#define LW_FAILURE
Definition: liblwgeom.h:54
double zmax
Definition: liblwgeom.h:253
double ymin
Definition: liblwgeom.h:250
double xmin
Definition: liblwgeom.h:248
#define FLAGS_GET_BBOX(flags)
Definition: liblwgeom.h:108
double ymax
Definition: liblwgeom.h:251
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
uint8_t flags
Definition: liblwgeom.h:247
double mmin
Definition: liblwgeom.h:254
double zmin
Definition: liblwgeom.h:252
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
double mmax
Definition: liblwgeom.h:255
uint8_t flags
Definition: liblwgeom.h:339

Here is the caller graph for this function: