PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gserialized_from_lwtriangle()

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

Definition at line 958 of file g_serialized.c.

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

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().

Here is the call graph for this function:
Here is the caller graph for this function: