PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ gserialized2_from_lwtriangle()

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

Definition at line 962 of file gserialized2.c.

963{
964 uint8_t *loc;
965 int ptsize;
966 size_t size;
967 int type = TRIANGLETYPE;
968
969 assert(triangle);
970 assert(buf);
971
972 LWDEBUGF(2, "%s (%p, %p) called", __func__, triangle, buf);
973
974 if (FLAGS_GET_ZM(triangle->flags) != FLAGS_GET_ZM(triangle->points->flags))
975 lwerror("Dimensions mismatch in lwtriangle");
976
977 ptsize = ptarray_point_size(triangle->points);
978
979 loc = buf;
980
981 /* Write in the type. */
982 memcpy(loc, &type, sizeof(uint32_t));
983 loc += sizeof(uint32_t);
984
985 /* Write in the npoints. */
986 memcpy(loc, &(triangle->points->npoints), sizeof(uint32_t));
987 loc += sizeof(uint32_t);
988
989 LWDEBUGF(3, "%s added npoints (%d)", __func__, triangle->points->npoints);
990
991 /* Copy in the ordinates. */
992 if (triangle->points->npoints > 0)
993 {
994 size = triangle->points->npoints * ptsize;
995 memcpy(loc, getPoint_internal(triangle->points, 0), size);
996 loc += size;
997 }
998 LWDEBUGF(3, "%s copied serialized_pointlist (%d bytes)", __func__, ptsize * triangle->points->npoints);
999
1000 return (size_t)(loc - buf);
1001}
#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 uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition lwinline.h:67
static size_t ptarray_point_size(const POINTARRAY *pa)
Definition lwinline.h:48
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(), and TRIANGLETYPE.

Referenced by gserialized2_from_lwgeom_any().

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