PostGIS  2.5.0dev-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 301 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().

302 {
303  double d = 0;
304 
306 
307  memcpy(&d, s->pos, WKB_DOUBLE_SIZE);
308 
309  /* Swap? Copy into a stack-allocated integer. */
310  if( s->swap_bytes )
311  {
312  int i = 0;
313  uint8_t tmp;
314 
315  for( i = 0; i < WKB_DOUBLE_SIZE/2; i++ )
316  {
317  tmp = ((uint8_t*)(&d))[i];
318  ((uint8_t*)(&d))[i] = ((uint8_t*)(&d))[WKB_DOUBLE_SIZE - i - 1];
319  ((uint8_t*)(&d))[WKB_DOUBLE_SIZE - i - 1] = tmp;
320  }
321 
322  }
323 
324  s->pos += WKB_DOUBLE_SIZE;
325  return d;
326 }
#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:126
unsigned char uint8_t
Definition: uthash.h:79
const uint8_t * pos
Definition: lwin_wkb.c:47
Here is the call graph for this function:
Here is the caller graph for this function: