PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ gserialized2_from_lwpoly()

static size_t gserialized2_from_lwpoly ( const LWPOLY poly,
uint8_t *  buf 
)
static

Definition at line 877 of file gserialized2.c.

878 {
879  uint32_t i;
880  uint8_t *loc;
881  int ptsize;
882  int type = POLYGONTYPE;
883 
884  assert(poly);
885  assert(buf);
886 
887  LWDEBUGF(2, "%s called", __func__);
888 
889  ptsize = sizeof(double) * FLAGS_NDIMS(poly->flags);
890  loc = buf;
891 
892  /* Write in the type. */
893  memcpy(loc, &type, sizeof(uint32_t));
894  loc += sizeof(uint32_t);
895 
896  /* Write in the nrings. */
897  memcpy(loc, &(poly->nrings), sizeof(uint32_t));
898  loc += sizeof(uint32_t);
899 
900  /* Write in the npoints per ring. */
901  for (i = 0; i < poly->nrings; i++)
902  {
903  memcpy(loc, &(poly->rings[i]->npoints), sizeof(uint32_t));
904  loc += sizeof(uint32_t);
905  }
906 
907  /* Add in padding if necessary to remain double aligned. */
908  if (poly->nrings % 2)
909  {
910  memset(loc, 0, sizeof(uint32_t));
911  loc += sizeof(uint32_t);
912  }
913 
914  /* Copy in the ordinates. */
915  for (i = 0; i < poly->nrings; i++)
916  {
917  POINTARRAY *pa = poly->rings[i];
918  size_t pasize;
919 
920  if (FLAGS_GET_ZM(poly->flags) != FLAGS_GET_ZM(pa->flags))
921  lwerror("Dimensions mismatch in lwpoly");
922 
923  pasize = pa->npoints * ptsize;
924  if ( pa->npoints > 0 )
925  memcpy(loc, getPoint_internal(pa, 0), pasize);
926  loc += pasize;
927  }
928  return (size_t)(loc - buf);
929 }
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:179
#define POLYGONTYPE
Definition: liblwgeom.h:104
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:180
#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:77
type
Definition: ovdump.py:42
POINTARRAY ** rings
Definition: liblwgeom.h:519
uint32_t nrings
Definition: liblwgeom.h:524
lwflags_t flags
Definition: liblwgeom.h:521
lwflags_t flags
Definition: liblwgeom.h:431
uint32_t npoints
Definition: liblwgeom.h:427

References POINTARRAY::flags, LWPOLY::flags, FLAGS_GET_ZM, FLAGS_NDIMS, getPoint_internal(), LWDEBUGF, lwerror(), POINTARRAY::npoints, LWPOLY::nrings, POLYGONTYPE, LWPOLY::rings, 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: