PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gserialized_from_lwpoly()

static size_t gserialized_from_lwpoly ( const LWPOLY poly,
uint8_t buf 
)
static

Definition at line 904 of file g_serialized.c.

905 {
906  uint32_t i;
907  uint8_t *loc;
908  int ptsize;
909  int type = POLYGONTYPE;
910 
911  assert(poly);
912  assert(buf);
913 
914  LWDEBUG(2, "lwpoly_to_gserialized called");
915 
916  ptsize = sizeof(double) * FLAGS_NDIMS(poly->flags);
917  loc = buf;
918 
919  /* Write in the type. */
920  memcpy(loc, &type, sizeof(uint32_t));
921  loc += sizeof(uint32_t);
922 
923  /* Write in the nrings. */
924  memcpy(loc, &(poly->nrings), sizeof(uint32_t));
925  loc += sizeof(uint32_t);
926 
927  /* Write in the npoints per ring. */
928  for ( i = 0; i < poly->nrings; i++ )
929  {
930  memcpy(loc, &(poly->rings[i]->npoints), sizeof(uint32_t));
931  loc += sizeof(uint32_t);
932  }
933 
934  /* Add in padding if necessary to remain double aligned. */
935  if ( poly->nrings % 2 )
936  {
937  memset(loc, 0, sizeof(uint32_t));
938  loc += sizeof(uint32_t);
939  }
940 
941  /* Copy in the ordinates. */
942  for ( i = 0; i < poly->nrings; i++ )
943  {
944  POINTARRAY *pa = poly->rings[i];
945  size_t pasize;
946 
947  if ( FLAGS_GET_ZM(poly->flags) != FLAGS_GET_ZM(pa->flags) )
948  lwerror("Dimensions mismatch in lwpoly");
949 
950  pasize = pa->npoints * ptsize;
951  if ( pa->npoints > 0 )
952  memcpy(loc, getPoint_internal(pa, 0), pasize);
953  loc += pasize;
954  }
955  return (size_t)(loc - buf);
956 }
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1750
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
type
Definition: ovdump.py:41
POINTARRAY ** rings
Definition: liblwgeom.h:460
uint32_t nrings
Definition: liblwgeom.h:458
uint8_t flags
Definition: liblwgeom.h:455
uint32_t npoints
Definition: liblwgeom.h:374
uint8_t flags
Definition: liblwgeom.h:372
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

References POINTARRAY::flags, LWPOLY::flags, FLAGS_GET_ZM, FLAGS_NDIMS, getPoint_internal(), LWDEBUG, lwerror(), POINTARRAY::npoints, LWPOLY::nrings, POLYGONTYPE, LWPOLY::rings, and ovdump::type.

Referenced by gserialized_from_lwgeom_any().

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