PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ gserialized_from_lwtriangle()

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

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

957 {
958  uint8_t *loc;
959  int ptsize;
960  size_t size;
961  int type = TRIANGLETYPE;
962 
963  assert(triangle);
964  assert(buf);
965 
966  LWDEBUGF(2, "lwtriangle_to_gserialized(%p, %p) called", triangle, buf);
967 
968  if ( FLAGS_GET_ZM(triangle->flags) != FLAGS_GET_ZM(triangle->points->flags) )
969  lwerror("Dimensions mismatch in lwtriangle");
970 
971  ptsize = ptarray_point_size(triangle->points);
972 
973  loc = buf;
974 
975  /* Write in the type. */
976  memcpy(loc, &type, sizeof(uint32_t));
977  loc += sizeof(uint32_t);
978 
979  /* Write in the npoints. */
980  memcpy(loc, &(triangle->points->npoints), sizeof(uint32_t));
981  loc += sizeof(uint32_t);
982 
983  LWDEBUGF(3, "lwtriangle_to_gserialized added npoints (%d)", triangle->points->npoints);
984 
985  /* Copy in the ordinates. */
986  if ( triangle->points->npoints > 0 )
987  {
988  size = triangle->points->npoints * ptsize;
989  memcpy(loc, getPoint_internal(triangle->points, 0), size);
990  loc += size;
991  }
992  LWDEBUGF(3, "lwtriangle_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * triangle->points->npoints);
993 
994  return (size_t)(loc - buf);
995 }
size_t ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
POINTARRAY * points
Definition: liblwgeom.h:435
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:152
#define TRIANGLETYPE
Definition: liblwgeom.h:97
unsigned int uint32_t
Definition: uthash.h:78
uint8_t flags
Definition: liblwgeom.h:371
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1743
type
Definition: ovdump.py:41
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
unsigned char uint8_t
Definition: uthash.h:79
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
uint8_t flags
Definition: liblwgeom.h:432
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: