PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gserialized_from_gbox()

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

Definition at line 1110 of file g_serialized.c.

References floatuint::f, 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().

1111 {
1112  uint8_t *loc = buf;
1113  float f;
1114  size_t return_size;
1115 
1116  assert(buf);
1117 
1118  f = next_float_down(gbox->xmin);
1119  memcpy(loc, &f, sizeof(float));
1120  loc += sizeof(float);
1121 
1122  f = next_float_up(gbox->xmax);
1123  memcpy(loc, &f, sizeof(float));
1124  loc += sizeof(float);
1125 
1126  f = next_float_down(gbox->ymin);
1127  memcpy(loc, &f, sizeof(float));
1128  loc += sizeof(float);
1129 
1130  f = next_float_up(gbox->ymax);
1131  memcpy(loc, &f, sizeof(float));
1132  loc += sizeof(float);
1133 
1134  if ( FLAGS_GET_GEODETIC(gbox->flags) )
1135  {
1136  f = next_float_down(gbox->zmin);
1137  memcpy(loc, &f, sizeof(float));
1138  loc += sizeof(float);
1139 
1140  f = next_float_up(gbox->zmax);
1141  memcpy(loc, &f, sizeof(float));
1142  loc += sizeof(float);
1143 
1144  return_size = (size_t)(loc - buf);
1145  LWDEBUGF(4, "returning size %d", return_size);
1146  return return_size;
1147  }
1148 
1149  if ( FLAGS_GET_Z(gbox->flags) )
1150  {
1151  f = next_float_down(gbox->zmin);
1152  memcpy(loc, &f, sizeof(float));
1153  loc += sizeof(float);
1154 
1155  f = next_float_up(gbox->zmax);
1156  memcpy(loc, &f, sizeof(float));
1157  loc += sizeof(float);
1158 
1159  }
1160 
1161  if ( FLAGS_GET_M(gbox->flags) )
1162  {
1163  f = next_float_down(gbox->mmin);
1164  memcpy(loc, &f, sizeof(float));
1165  loc += sizeof(float);
1166 
1167  f = next_float_up(gbox->mmax);
1168  memcpy(loc, &f, sizeof(float));
1169  loc += sizeof(float);
1170  }
1171  return_size = (size_t)(loc - buf);
1172  LWDEBUGF(4, "returning size %d", return_size);
1173  return return_size;
1174 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:143
double xmax
Definition: liblwgeom.h:293
float next_float_down(double d)
Definition: lwgeom_api.c:51
float next_float_up(double d)
Definition: lwgeom_api.c:72
double zmax
Definition: liblwgeom.h:297
double ymin
Definition: liblwgeom.h:294
double xmin
Definition: liblwgeom.h:292
double ymax
Definition: liblwgeom.h:295
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
uint8_t flags
Definition: liblwgeom.h:291
double mmin
Definition: liblwgeom.h:298
double zmin
Definition: liblwgeom.h:296
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
double mmax
Definition: liblwgeom.h:299
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
unsigned char uint8_t
Definition: uthash.h:79
Here is the call graph for this function:
Here is the caller graph for this function: