PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gserialized_from_lwtriangle()

static size_t gserialized_from_lwtriangle ( const LWTRIANGLE triangle,
uint8_t *  buf 
)
static

Definition at line 688 of file g_serialized.c.

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

Referenced by gserialized_from_lwgeom_any().

689 {
690  uint8_t *loc;
691  int ptsize;
692  size_t size;
693  int type = TRIANGLETYPE;
694 
695  assert(triangle);
696  assert(buf);
697 
698  LWDEBUGF(2, "lwtriangle_to_gserialized(%p, %p) called", triangle, buf);
699 
700  if ( FLAGS_GET_ZM(triangle->flags) != FLAGS_GET_ZM(triangle->points->flags) )
701  lwerror("Dimensions mismatch in lwtriangle");
702 
703  ptsize = ptarray_point_size(triangle->points);
704 
705  loc = buf;
706 
707  /* Write in the type. */
708  memcpy(loc, &type, sizeof(uint32_t));
709  loc += sizeof(uint32_t);
710 
711  /* Write in the npoints. */
712  memcpy(loc, &(triangle->points->npoints), sizeof(uint32_t));
713  loc += sizeof(uint32_t);
714 
715  LWDEBUGF(3, "lwtriangle_to_gserialized added npoints (%d)", triangle->points->npoints);
716 
717  /* Copy in the ordinates. */
718  if ( triangle->points->npoints > 0 )
719  {
720  size = triangle->points->npoints * ptsize;
721  memcpy(loc, getPoint_internal(triangle->points, 0), size);
722  loc += size;
723  }
724  LWDEBUGF(3, "lwtriangle_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * triangle->points->npoints);
725 
726  return (size_t)(loc - buf);
727 }
POINTARRAY * points
Definition: liblwgeom.h:417
int npoints
Definition: liblwgeom.h:355
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:137
#define TRIANGLETYPE
Definition: liblwgeom.h:83
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
type
Definition: ovdump.py:41
#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
uint8_t flags
Definition: liblwgeom.h:414
Here is the call graph for this function:
Here is the caller graph for this function: