PostGIS  2.1.10dev-r@@SVN_REVISION@@
static size_t gserialized_from_lwtriangle ( const LWTRIANGLE triangle,
uint8_t *  buf 
)
static

Definition at line 690 of file g_serialized.c.

References POINTARRAY::flags, LWTRIANGLE::flags, FLAGS_GET_ZM, getPoint_internal(), LWDEBUGF, lwerror(), POINTARRAY::npoints, LWTRIANGLE::points, ptarray_point_size(), and TRIANGLETYPE.

Referenced by gserialized_from_lwgeom_any().

691 {
692  uint8_t *loc;
693  int ptsize;
694  size_t size;
695  int type = TRIANGLETYPE;
696 
697  assert(triangle);
698  assert(buf);
699 
700  LWDEBUGF(2, "lwtriangle_to_gserialized(%p, %p) called", triangle, buf);
701 
702  if ( FLAGS_GET_ZM(triangle->flags) != FLAGS_GET_ZM(triangle->points->flags) )
703  lwerror("Dimensions mismatch in lwtriangle");
704 
705  ptsize = ptarray_point_size(triangle->points);
706 
707  loc = buf;
708 
709  /* Write in the type. */
710  memcpy(loc, &type, sizeof(uint32_t));
711  loc += sizeof(uint32_t);
712 
713  /* Write in the npoints. */
714  memcpy(loc, &(triangle->points->npoints), sizeof(uint32_t));
715  loc += sizeof(uint32_t);
716 
717  LWDEBUGF(3, "lwtriangle_to_gserialized added npoints (%d)", triangle->points->npoints);
718 
719  /* Copy in the ordinates. */
720  if ( triangle->points->npoints > 0 )
721  {
722  size = triangle->points->npoints * ptsize;
723  memcpy(loc, getPoint_internal(triangle->points, 0), size);
724  loc += size;
725  }
726  LWDEBUGF(3, "lwtriangle_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * triangle->points->npoints);
727 
728  return (size_t)(loc - buf);
729 }
POINTARRAY * points
Definition: liblwgeom.h:389
int npoints
Definition: liblwgeom.h:327
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:119
#define TRIANGLETYPE
Definition: liblwgeom.h:73
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 LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
uint8_t flags
Definition: liblwgeom.h:386

Here is the call graph for this function:

Here is the caller graph for this function: