PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ gserialized1_from_lwtriangle()

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

Definition at line 871 of file gserialized1.c.

872 {
873  uint8_t *loc;
874  int ptsize;
875  size_t size;
876  int type = TRIANGLETYPE;
877 
878  assert(triangle);
879  assert(buf);
880 
881  LWDEBUGF(2, "%s (%p, %p) called", __func__, triangle, buf);
882 
883  if ( FLAGS_GET_ZM(triangle->flags) != FLAGS_GET_ZM(triangle->points->flags) )
884  lwerror("Dimensions mismatch in lwtriangle");
885 
886  ptsize = ptarray_point_size(triangle->points);
887 
888  loc = buf;
889 
890  /* Write in the type. */
891  memcpy(loc, &type, sizeof(uint32_t));
892  loc += sizeof(uint32_t);
893 
894  /* Write in the npoints. */
895  memcpy(loc, &(triangle->points->npoints), sizeof(uint32_t));
896  loc += sizeof(uint32_t);
897 
898  LWDEBUGF(3, "%s added npoints (%d)", __func__, triangle->points->npoints);
899 
900  /* Copy in the ordinates. */
901  if ( triangle->points->npoints > 0 )
902  {
903  size = triangle->points->npoints * ptsize;
904  memcpy(loc, getPoint_internal(triangle->points, 0), size);
905  loc += size;
906  }
907  LWDEBUGF(3, "%s copied serialized_pointlist (%d bytes)", __func__, ptsize * triangle->points->npoints);
908 
909  return (size_t)(loc - buf);
910 }
#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 gserialized1_from_lwgeom_any().

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