PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gserialized_from_gbox()

static size_t gserialized_from_gbox ( const GBOX gbox,
uint8_t *  buf 
)
static

Definition at line 838 of file g_serialized.c.

References GBOX::flags, FLAGS_GET_GEODETIC, FLAGS_GET_M, FLAGS_GET_Z, LWDEBUGF, GBOX::mmax, GBOX::mmin, next_float_down(), next_float_up(), GBOX::xmax, GBOX::xmin, GBOX::ymax, GBOX::ymin, GBOX::zmax, and GBOX::zmin.

Referenced by gserialized_from_lwgeom().

839 {
840  uint8_t *loc = buf;
841  float f;
842  size_t return_size;
843 
844  assert(buf);
845 
846  f = next_float_down(gbox->xmin);
847  memcpy(loc, &f, sizeof(float));
848  loc += sizeof(float);
849 
850  f = next_float_up(gbox->xmax);
851  memcpy(loc, &f, sizeof(float));
852  loc += sizeof(float);
853 
854  f = next_float_down(gbox->ymin);
855  memcpy(loc, &f, sizeof(float));
856  loc += sizeof(float);
857 
858  f = next_float_up(gbox->ymax);
859  memcpy(loc, &f, sizeof(float));
860  loc += sizeof(float);
861 
862  if ( FLAGS_GET_GEODETIC(gbox->flags) )
863  {
864  f = next_float_down(gbox->zmin);
865  memcpy(loc, &f, sizeof(float));
866  loc += sizeof(float);
867 
868  f = next_float_up(gbox->zmax);
869  memcpy(loc, &f, sizeof(float));
870  loc += sizeof(float);
871 
872  return_size = (size_t)(loc - buf);
873  LWDEBUGF(4, "returning size %d", return_size);
874  return return_size;
875  }
876 
877  if ( FLAGS_GET_Z(gbox->flags) )
878  {
879  f = next_float_down(gbox->zmin);
880  memcpy(loc, &f, sizeof(float));
881  loc += sizeof(float);
882 
883  f = next_float_up(gbox->zmax);
884  memcpy(loc, &f, sizeof(float));
885  loc += sizeof(float);
886 
887  }
888 
889  if ( FLAGS_GET_M(gbox->flags) )
890  {
891  f = next_float_down(gbox->mmin);
892  memcpy(loc, &f, sizeof(float));
893  loc += sizeof(float);
894 
895  f = next_float_up(gbox->mmax);
896  memcpy(loc, &f, sizeof(float));
897  loc += sizeof(float);
898  }
899  return_size = (size_t)(loc - buf);
900  LWDEBUGF(4, "returning size %d", return_size);
901  return return_size;
902 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:127
double xmax
Definition: liblwgeom.h:277
float next_float_down(double d)
Definition: lwgeom_api.c:143
float next_float_up(double d)
Definition: lwgeom_api.c:159
double zmax
Definition: liblwgeom.h:281
double ymin
Definition: liblwgeom.h:278
double xmin
Definition: liblwgeom.h:276
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
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
Here is the call graph for this function:
Here is the caller graph for this function: