PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ gserialized1_from_lwtriangle()

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

Definition at line 872 of file gserialized1.c.

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

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