PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ gserialized2_from_lwtriangle()

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

Definition at line 929 of file gserialized2.c.

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

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: