PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ gserialized_from_lwtriangle()

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

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

958 {
959  uint8_t *loc;
960  int ptsize;
961  size_t size;
962  int type = TRIANGLETYPE;
963 
964  assert(triangle);
965  assert(buf);
966 
967  LWDEBUGF(2, "lwtriangle_to_gserialized(%p, %p) called", triangle, buf);
968 
969  if ( FLAGS_GET_ZM(triangle->flags) != FLAGS_GET_ZM(triangle->points->flags) )
970  lwerror("Dimensions mismatch in lwtriangle");
971 
972  ptsize = ptarray_point_size(triangle->points);
973 
974  loc = buf;
975 
976  /* Write in the type. */
977  memcpy(loc, &type, sizeof(uint32_t));
978  loc += sizeof(uint32_t);
979 
980  /* Write in the npoints. */
981  memcpy(loc, &(triangle->points->npoints), sizeof(uint32_t));
982  loc += sizeof(uint32_t);
983 
984  LWDEBUGF(3, "lwtriangle_to_gserialized added npoints (%d)", triangle->points->npoints);
985 
986  /* Copy in the ordinates. */
987  if ( triangle->points->npoints > 0 )
988  {
989  size = triangle->points->npoints * ptsize;
990  memcpy(loc, getPoint_internal(triangle->points, 0), size);
991  loc += size;
992  }
993  LWDEBUGF(3, "lwtriangle_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * triangle->points->npoints);
994 
995  return (size_t)(loc - buf);
996 }
size_t ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
POINTARRAY * points
Definition: liblwgeom.h:436
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
#define TRIANGLETYPE
Definition: liblwgeom.h:98
unsigned int uint32_t
Definition: uthash.h:78
uint8_t flags
Definition: liblwgeom.h:372
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1750
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:433
uint32_t npoints
Definition: liblwgeom.h:374
Here is the call graph for this function:
Here is the caller graph for this function: