PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ gserialized2_from_lwtriangle()

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

Definition at line 931 of file gserialized2.c.

932 {
933  uint8_t *loc;
934  int ptsize;
935  size_t size;
936  int type = TRIANGLETYPE;
937 
938  assert(triangle);
939  assert(buf);
940 
941  LWDEBUGF(2, "%s (%p, %p) called", __func__, triangle, buf);
942 
943  if (FLAGS_GET_ZM(triangle->flags) != FLAGS_GET_ZM(triangle->points->flags))
944  lwerror("Dimensions mismatch in lwtriangle");
945 
946  ptsize = ptarray_point_size(triangle->points);
947 
948  loc = buf;
949 
950  /* Write in the type. */
951  memcpy(loc, &type, sizeof(uint32_t));
952  loc += sizeof(uint32_t);
953 
954  /* Write in the npoints. */
955  memcpy(loc, &(triangle->points->npoints), sizeof(uint32_t));
956  loc += sizeof(uint32_t);
957 
958  LWDEBUGF(3, "%s added npoints (%d)", __func__, triangle->points->npoints);
959 
960  /* Copy in the ordinates. */
961  if (triangle->points->npoints > 0)
962  {
963  size = triangle->points->npoints * ptsize;
964  memcpy(loc, getPoint_internal(triangle->points, 0), size);
965  loc += size;
966  }
967  LWDEBUGF(3, "%s copied serialized_pointlist (%d bytes)", __func__, ptsize * triangle->points->npoints);
968 
969  return (size_t)(loc - buf);
970 }
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:180
#define TRIANGLETYPE
Definition: liblwgeom.h:115
#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
static size_t ptarray_point_size(const POINTARRAY *pa)
Definition: lwinline.h:58
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: lwinline.h:77
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: