PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ gserialized_from_gbox()

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

Definition at line 1106 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().

1107 {
1108  uint8_t *loc = buf;
1109  float f;
1110  size_t return_size;
1111 
1112  assert(buf);
1113 
1114  f = next_float_down(gbox->xmin);
1115  memcpy(loc, &f, sizeof(float));
1116  loc += sizeof(float);
1117 
1118  f = next_float_up(gbox->xmax);
1119  memcpy(loc, &f, sizeof(float));
1120  loc += sizeof(float);
1121 
1122  f = next_float_down(gbox->ymin);
1123  memcpy(loc, &f, sizeof(float));
1124  loc += sizeof(float);
1125 
1126  f = next_float_up(gbox->ymax);
1127  memcpy(loc, &f, sizeof(float));
1128  loc += sizeof(float);
1129 
1130  if ( FLAGS_GET_GEODETIC(gbox->flags) )
1131  {
1132  f = next_float_down(gbox->zmin);
1133  memcpy(loc, &f, sizeof(float));
1134  loc += sizeof(float);
1135 
1136  f = next_float_up(gbox->zmax);
1137  memcpy(loc, &f, sizeof(float));
1138  loc += sizeof(float);
1139 
1140  return_size = (size_t)(loc - buf);
1141  LWDEBUGF(4, "returning size %d", return_size);
1142  return return_size;
1143  }
1144 
1145  if ( FLAGS_GET_Z(gbox->flags) )
1146  {
1147  f = next_float_down(gbox->zmin);
1148  memcpy(loc, &f, sizeof(float));
1149  loc += sizeof(float);
1150 
1151  f = next_float_up(gbox->zmax);
1152  memcpy(loc, &f, sizeof(float));
1153  loc += sizeof(float);
1154 
1155  }
1156 
1157  if ( FLAGS_GET_M(gbox->flags) )
1158  {
1159  f = next_float_down(gbox->mmin);
1160  memcpy(loc, &f, sizeof(float));
1161  loc += sizeof(float);
1162 
1163  f = next_float_up(gbox->mmax);
1164  memcpy(loc, &f, sizeof(float));
1165  loc += sizeof(float);
1166  }
1167  return_size = (size_t)(loc - buf);
1168  LWDEBUGF(4, "returning size %d", return_size);
1169  return return_size;
1170 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:142
double xmax
Definition: liblwgeom.h:295
float next_float_down(double d)
Definition: lwgeom_api.c:51
float next_float_up(double d)
Definition: lwgeom_api.c:67
double zmax
Definition: liblwgeom.h:299
double ymin
Definition: liblwgeom.h:296
double xmin
Definition: liblwgeom.h:294
double ymax
Definition: liblwgeom.h:297
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
uint8_t flags
Definition: liblwgeom.h:293
double mmin
Definition: liblwgeom.h:300
double zmin
Definition: liblwgeom.h:298
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
double mmax
Definition: liblwgeom.h:301
#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: