PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gserialized_from_lwline()

static size_t gserialized_from_lwline ( const LWLINE line,
uint8_t *  buf 
)
static

Definition at line 594 of file g_serialized.c.

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

Referenced by gserialized_from_lwgeom_any().

595 {
596  uint8_t *loc;
597  int ptsize;
598  size_t size;
599  int type = LINETYPE;
600 
601  assert(line);
602  assert(buf);
603 
604  LWDEBUGF(2, "lwline_to_gserialized(%p, %p) called", line, buf);
605 
606  if ( FLAGS_GET_Z(line->flags) != FLAGS_GET_Z(line->points->flags) )
607  lwerror("Dimensions mismatch in lwline");
608 
609  ptsize = ptarray_point_size(line->points);
610 
611  loc = buf;
612 
613  /* Write in the type. */
614  memcpy(loc, &type, sizeof(uint32_t));
615  loc += sizeof(uint32_t);
616 
617  /* Write in the npoints. */
618  memcpy(loc, &(line->points->npoints), sizeof(uint32_t));
619  loc += sizeof(uint32_t);
620 
621  LWDEBUGF(3, "lwline_to_gserialized added npoints (%d)", line->points->npoints);
622 
623  /* Copy in the ordinates. */
624  if ( line->points->npoints > 0 )
625  {
626  size = line->points->npoints * ptsize;
627  memcpy(loc, getPoint_internal(line->points, 0), size);
628  loc += size;
629  }
630  LWDEBUGF(3, "lwline_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * line->points->npoints);
631 
632  return (size_t)(loc - buf);
633 }
#define LINETYPE
Definition: liblwgeom.h:71
int npoints
Definition: liblwgeom.h:355
uint8_t flags
Definition: liblwgeom.h:353
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:124
type
Definition: ovdump.py:41
uint8_t flags
Definition: liblwgeom.h:403
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
POINTARRAY * points
Definition: liblwgeom.h:406
Here is the call graph for this function:
Here is the caller graph for this function: