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

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

716 {
717  uint8_t *loc;
718  int ptsize;
719  size_t size;
720  int type = TRIANGLETYPE;
721 
722  assert(triangle);
723  assert(buf);
724 
725  LWDEBUGF(2, "lwtriangle_to_gserialized(%p, %p) called", triangle, buf);
726 
727  if ( FLAGS_GET_ZM(triangle->flags) != FLAGS_GET_ZM(triangle->points->flags) )
728  lwerror("Dimensions mismatch in lwtriangle");
729 
730  ptsize = ptarray_point_size(triangle->points);
731 
732  loc = buf;
733 
734  /* Write in the type. */
735  memcpy(loc, &type, sizeof(uint32_t));
736  loc += sizeof(uint32_t);
737 
738  /* Write in the npoints. */
739  memcpy(loc, &(triangle->points->npoints), sizeof(uint32_t));
740  loc += sizeof(uint32_t);
741 
742  LWDEBUGF(3, "lwtriangle_to_gserialized added npoints (%d)", triangle->points->npoints);
743 
744  /* Copy in the ordinates. */
745  if ( triangle->points->npoints > 0 )
746  {
747  size = triangle->points->npoints * ptsize;
748  memcpy(loc, getPoint_internal(triangle->points, 0), size);
749  loc += size;
750  }
751  LWDEBUGF(3, "lwtriangle_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * triangle->points->npoints);
752 
753  return (size_t)(loc - buf);
754 }
POINTARRAY * points
Definition: liblwgeom.h:432
int npoints
Definition: liblwgeom.h:370
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:152
#define TRIANGLETYPE
Definition: liblwgeom.h:97
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 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
uint8_t flags
Definition: liblwgeom.h:429

Here is the call graph for this function:

Here is the caller graph for this function: