PostGIS  2.1.10dev-r@@SVN_REVISION@@
static size_t gserialized_from_lwline ( const LWLINE line,
uint8_t *  buf 
)
static

Definition at line 596 of file g_serialized.c.

References POINTARRAY::flags, LWLINE::flags, FLAGS_GET_Z, getPoint_internal(), LINETYPE, LWDEBUGF, lwerror(), POINTARRAY::npoints, LWLINE::points, and ptarray_point_size().

Referenced by gserialized_from_lwgeom_any().

597 {
598  uint8_t *loc;
599  int ptsize;
600  size_t size;
601  int type = LINETYPE;
602 
603  assert(line);
604  assert(buf);
605 
606  LWDEBUGF(2, "lwline_to_gserialized(%p, %p) called", line, buf);
607 
608  if ( FLAGS_GET_Z(line->flags) != FLAGS_GET_Z(line->points->flags) )
609  lwerror("Dimensions mismatch in lwline");
610 
611  ptsize = ptarray_point_size(line->points);
612 
613  loc = buf;
614 
615  /* Write in the type. */
616  memcpy(loc, &type, sizeof(uint32_t));
617  loc += sizeof(uint32_t);
618 
619  /* Write in the npoints. */
620  memcpy(loc, &(line->points->npoints), sizeof(uint32_t));
621  loc += sizeof(uint32_t);
622 
623  LWDEBUGF(3, "lwline_to_gserialized added npoints (%d)", line->points->npoints);
624 
625  /* Copy in the ordinates. */
626  if ( line->points->npoints > 0 )
627  {
628  size = line->points->npoints * ptsize;
629  memcpy(loc, getPoint_internal(line->points, 0), size);
630  loc += size;
631  }
632  LWDEBUGF(3, "lwline_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * line->points->npoints);
633 
634  return (size_t)(loc - buf);
635 }
#define LINETYPE
Definition: liblwgeom.h:61
int npoints
Definition: liblwgeom.h:327
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
uint8_t flags
Definition: liblwgeom.h:325
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1645
int ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:41
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
uint8_t flags
Definition: liblwgeom.h:375
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: