PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ gserialized2_from_lwpoly()

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

Definition at line 878 of file gserialized2.c.

879 {
880  uint32_t i;
881  uint8_t *loc;
882  int ptsize;
883  int type = POLYGONTYPE;
884 
885  assert(poly);
886  assert(buf);
887 
888  LWDEBUGF(2, "%s called", __func__);
889 
890  ptsize = sizeof(double) * FLAGS_NDIMS(poly->flags);
891  loc = buf;
892 
893  /* Write in the type. */
894  memcpy(loc, &type, sizeof(uint32_t));
895  loc += sizeof(uint32_t);
896 
897  /* Write in the nrings. */
898  memcpy(loc, &(poly->nrings), sizeof(uint32_t));
899  loc += sizeof(uint32_t);
900 
901  /* Write in the npoints per ring. */
902  for (i = 0; i < poly->nrings; i++)
903  {
904  memcpy(loc, &(poly->rings[i]->npoints), sizeof(uint32_t));
905  loc += sizeof(uint32_t);
906  }
907 
908  /* Add in padding if necessary to remain double aligned. */
909  if (poly->nrings % 2)
910  {
911  memset(loc, 0, sizeof(uint32_t));
912  loc += sizeof(uint32_t);
913  }
914 
915  /* Copy in the ordinates. */
916  for (i = 0; i < poly->nrings; i++)
917  {
918  POINTARRAY *pa = poly->rings[i];
919  size_t pasize;
920 
921  if (FLAGS_GET_ZM(poly->flags) != FLAGS_GET_ZM(pa->flags))
922  lwerror("Dimensions mismatch in lwpoly");
923 
924  pasize = (size_t)pa->npoints * ptsize;
925  if ( pa->npoints > 0 )
926  memcpy(loc, getPoint_internal(pa, 0), pasize);
927  loc += pasize;
928  }
929  return (size_t)(loc - buf);
930 }
#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:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
if(!(yy_init))
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: lwinline.h:75
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(), if(), 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: