PostGIS  2.5.7dev-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 305 of file lwin_wkb.c.

306 {
307  double d = 0;
308 
310 
311  memcpy(&d, s->pos, WKB_DOUBLE_SIZE);
312 
313  /* Swap? Copy into a stack-allocated integer. */
314  if( s->swap_bytes )
315  {
316  int i = 0;
317  uint8_t tmp;
318 
319  for( i = 0; i < WKB_DOUBLE_SIZE/2; i++ )
320  {
321  tmp = ((uint8_t*)(&d))[i];
322  ((uint8_t*)(&d))[i] = ((uint8_t*)(&d))[WKB_DOUBLE_SIZE - i - 1];
323  ((uint8_t*)(&d))[WKB_DOUBLE_SIZE - i - 1] = tmp;
324  }
325 
326  }
327 
328  s->pos += WKB_DOUBLE_SIZE;
329  return d;
330 }
char * s
Definition: cu_in_wkt.c:23
#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:130
unsigned char uint8_t
Definition: uthash.h:79

References s, WKB_DOUBLE_SIZE, and wkb_parse_state_check().

Referenced by lwpoint_from_wkb_state(), and ptarray_from_wkb_state().

Here is the call graph for this function:
Here is the caller graph for this function: