PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ gserialized_from_gbox()

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

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

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