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

Definition at line 621 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().

622 {
623  uint8_t *loc;
624  int ptsize;
625  size_t size;
626  int type = LINETYPE;
627 
628  assert(line);
629  assert(buf);
630 
631  LWDEBUGF(2, "lwline_to_gserialized(%p, %p) called", line, buf);
632 
633  if ( FLAGS_GET_Z(line->flags) != FLAGS_GET_Z(line->points->flags) )
634  lwerror("Dimensions mismatch in lwline");
635 
636  ptsize = ptarray_point_size(line->points);
637 
638  loc = buf;
639 
640  /* Write in the type. */
641  memcpy(loc, &type, sizeof(uint32_t));
642  loc += sizeof(uint32_t);
643 
644  /* Write in the npoints. */
645  memcpy(loc, &(line->points->npoints), sizeof(uint32_t));
646  loc += sizeof(uint32_t);
647 
648  LWDEBUGF(3, "lwline_to_gserialized added npoints (%d)", line->points->npoints);
649 
650  /* Copy in the ordinates. */
651  if ( line->points->npoints > 0 )
652  {
653  size = line->points->npoints * ptsize;
654  memcpy(loc, getPoint_internal(line->points, 0), size);
655  loc += size;
656  }
657  LWDEBUGF(3, "lwline_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * line->points->npoints);
658 
659  return (size_t)(loc - buf);
660 }
#define LINETYPE
Definition: liblwgeom.h:85
int npoints
Definition: liblwgeom.h:370
uint8_t flags
Definition: liblwgeom.h:368
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1706
int ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
uint8_t flags
Definition: liblwgeom.h:418
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: