PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ gserialized2_from_lwpoly()

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

Definition at line 875 of file gserialized2.c.

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

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: