PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ double_from_wkb_state()

static double double_from_wkb_state ( wkb_parse_state s)
static

Double Read an 8-byte double and advance the parse state forward.

Definition at line 297 of file lwin_wkb.c.

References wkb_parse_state::pos, wkb_parse_state::swap_bytes, WKB_DOUBLE_SIZE, and wkb_parse_state_check().

Referenced by lwpoint_from_wkb_state(), and ptarray_from_wkb_state().

298 {
299  double d = 0;
300 
302 
303  memcpy(&d, s->pos, WKB_DOUBLE_SIZE);
304 
305  /* Swap? Copy into a stack-allocated integer. */
306  if( s->swap_bytes )
307  {
308  int i = 0;
309  uint8_t tmp;
310 
311  for( i = 0; i < WKB_DOUBLE_SIZE/2; i++ )
312  {
313  tmp = ((uint8_t*)(&d))[i];
314  ((uint8_t*)(&d))[i] = ((uint8_t*)(&d))[WKB_DOUBLE_SIZE - i - 1];
315  ((uint8_t*)(&d))[WKB_DOUBLE_SIZE - i - 1] = tmp;
316  }
317 
318  }
319 
320  s->pos += WKB_DOUBLE_SIZE;
321  return d;
322 }
#define WKB_DOUBLE_SIZE
Well-Known Binary (WKB) Output Variant Types.
static void wkb_parse_state_check(wkb_parse_state *s, size_t next)
Check that we are not about to read off the end of the WKB array.
Definition: lwin_wkb.c:125
unsigned char uint8_t
Definition: uthash.h:79
const uint8_t * pos
Definition: lwin_wkb.c:46
Here is the call graph for this function:
Here is the caller graph for this function: