PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ gserialized2_from_lwtriangle()

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

Definition at line 932 of file gserialized2.c.

933 {
934  uint8_t *loc;
935  int ptsize;
936  size_t size;
937  int type = TRIANGLETYPE;
938 
939  assert(triangle);
940  assert(buf);
941 
942  LWDEBUGF(2, "%s (%p, %p) called", __func__, triangle, buf);
943 
944  if (FLAGS_GET_ZM(triangle->flags) != FLAGS_GET_ZM(triangle->points->flags))
945  lwerror("Dimensions mismatch in lwtriangle");
946 
947  ptsize = ptarray_point_size(triangle->points);
948 
949  loc = buf;
950 
951  /* Write in the type. */
952  memcpy(loc, &type, sizeof(uint32_t));
953  loc += sizeof(uint32_t);
954 
955  /* Write in the npoints. */
956  memcpy(loc, &(triangle->points->npoints), sizeof(uint32_t));
957  loc += sizeof(uint32_t);
958 
959  LWDEBUGF(3, "%s added npoints (%d)", __func__, triangle->points->npoints);
960 
961  /* Copy in the ordinates. */
962  if (triangle->points->npoints > 0)
963  {
964  size = (size_t)triangle->points->npoints * ptsize;
965  memcpy(loc, getPoint_internal(triangle->points, 0), size);
966  loc += size;
967  }
968  LWDEBUGF(3, "%s copied serialized_pointlist (%d bytes)", __func__, ptsize * triangle->points->npoints);
969 
970  return (size_t)(loc - buf);
971 }
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:180
#define TRIANGLETYPE
Definition: liblwgeom.h:115
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static size_t ptarray_point_size(const POINTARRAY *pa)
Definition: lwinline.h:56
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: lwinline.h:75
type
Definition: ovdump.py:42
lwflags_t flags
Definition: liblwgeom.h:497
POINTARRAY * points
Definition: liblwgeom.h:495
lwflags_t flags
Definition: liblwgeom.h:431
uint32_t npoints
Definition: liblwgeom.h:427

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

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