PostGIS  2.1.10dev-r@@SVN_REVISION@@
static LWPOINT* lwpoint_from_wkb_state ( wkb_parse_state s)
static

POINT Read a WKB point, starting just after the endian byte, type number and optional srid number.

Advance the parse state forward appropriately. WKB point has just a set of doubles, with the quantity depending on the dimension of the point, so this looks like a special case of the above with only one point.

Definition at line 363 of file lwin_wkb.c.

References double_from_wkb_state(), wkb_parse_state::has_m, wkb_parse_state::has_z, lwpoint_construct(), wkb_parse_state::pos, ptarray_construct(), ptarray_construct_copy_data(), POINTARRAY::serialized_pointlist, wkb_parse_state::srid, wkb_parse_state::swap_bytes, WKB_DOUBLE_SIZE, and wkb_parse_state_check().

Referenced by lwgeom_from_wkb_state().

364 {
365  static uint32_t npoints = 1;
366  POINTARRAY *pa = NULL;
367  size_t pa_size;
368  uint32_t ndims = 2;
369 
370  /* Count the dimensions. */
371  if( s->has_z ) ndims++;
372  if( s->has_m ) ndims++;
373  pa_size = ndims * WKB_DOUBLE_SIZE;
374 
375  /* Does the data we want to read exist? */
376  wkb_parse_state_check(s, pa_size);
377 
378  /* If we're in a native endianness, we can just copy the data directly! */
379  if( ! s->swap_bytes )
380  {
381  pa = ptarray_construct_copy_data(s->has_z, s->has_m, npoints, (uint8_t*)s->pos);
382  s->pos += pa_size;
383  }
384  /* Otherwise we have to read each double, separately */
385  else
386  {
387  int i = 0;
388  double *dlist;
389  pa = ptarray_construct(s->has_z, s->has_m, npoints);
390  dlist = (double*)(pa->serialized_pointlist);
391  for( i = 0; i < ndims; i++ )
392  {
393  dlist[i] = double_from_wkb_state(s);
394  }
395  }
396 
397  return lwpoint_construct(s->srid, NULL, pa);
398 }
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition: ptarray.c:49
uint8_t * serialized_pointlist
Definition: liblwgeom.h:322
#define WKB_DOUBLE_SIZE
Well-Known Binary (WKB) Output Variant Types.
POINTARRAY * ptarray_construct_copy_data(char hasz, char hasm, uint32_t npoints, const uint8_t *ptlist)
Construct a new POINTARRAY, copying in the data from ptlist.
Definition: ptarray.c:294
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:108
uint32_t srid
Definition: lwin_wkb.c:25
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
Definition: lwpoint.c:96
static double double_from_wkb_state(wkb_parse_state *s)
Double Read an 8-byte double and advance the parse state forward.
Definition: lwin_wkb.c:280
const uint8_t * pos
Definition: lwin_wkb.c:29

Here is the call graph for this function:

Here is the caller graph for this function: