PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gserialized_from_lwtriangle()

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

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

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