PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwpoly_from_gserialized_buffer()

static LWPOLY* lwpoly_from_gserialized_buffer ( uint8_t data_ptr,
uint8_t  g_flags,
size_t *  g_size 
)
static

Definition at line 1313 of file g_serialized.c.

1314 {
1315  uint8_t *start_ptr = data_ptr;
1316  LWPOLY *poly;
1317  uint8_t *ordinate_ptr;
1318  uint32_t nrings = 0;
1319  uint32_t i = 0;
1320 
1321  assert(data_ptr);
1322 
1323  poly = (LWPOLY*)lwalloc(sizeof(LWPOLY));
1324  poly->srid = SRID_UNKNOWN; /* Default */
1325  poly->bbox = NULL;
1326  poly->type = POLYGONTYPE;
1327  poly->flags = g_flags;
1328 
1329  data_ptr += 4; /* Skip past the polygontype. */
1330  nrings = gserialized_get_uint32_t(data_ptr); /* Zero => empty geometry */
1331  poly->nrings = nrings;
1332  LWDEBUGF(4, "nrings = %d", nrings);
1333  data_ptr += 4; /* Skip past the nrings. */
1334 
1335  ordinate_ptr = data_ptr; /* Start the ordinate pointer. */
1336  if ( nrings > 0)
1337  {
1338  poly->rings = (POINTARRAY**)lwalloc( sizeof(POINTARRAY*) * nrings );
1339  poly->maxrings = nrings;
1340  ordinate_ptr += nrings * 4; /* Move past all the npoints values. */
1341  if ( nrings % 2 ) /* If there is padding, move past that too. */
1342  ordinate_ptr += 4;
1343  }
1344  else /* Empty polygon */
1345  {
1346  poly->rings = NULL;
1347  poly->maxrings = 0;
1348  }
1349 
1350  for ( i = 0; i < nrings; i++ )
1351  {
1352  uint32_t npoints = 0;
1353 
1354  /* Read in the number of points. */
1355  npoints = gserialized_get_uint32_t(data_ptr);
1356  data_ptr += 4;
1357 
1358  /* Make a point array for the ring, and move the ordinate pointer past the ring ordinates. */
1359  poly->rings[i] = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), npoints, ordinate_ptr);
1360 
1361  ordinate_ptr += sizeof(double) * FLAGS_NDIMS(g_flags) * npoints;
1362  }
1363 
1364  if ( g_size )
1365  *g_size = ordinate_ptr - start_ptr;
1366 
1367  return poly;
1368 }
static uint32_t gserialized_get_uint32_t(const uint8_t *loc)
Definition: g_serialized.c:35
POINTARRAY * ptarray_construct_reference_data(char hasz, char hasm, uint32_t npoints, uint8_t *ptlist)
Construct a new POINTARRAY, referencing to the data from ptlist.
Definition: ptarray.c:293
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
tuple g_size
Definition: genraster.py:41
POINTARRAY ** rings
Definition: liblwgeom.h:460
uint8_t type
Definition: liblwgeom.h:454
uint32_t maxrings
Definition: liblwgeom.h:459
uint32_t nrings
Definition: liblwgeom.h:458
uint8_t flags
Definition: liblwgeom.h:455
GBOX * bbox
Definition: liblwgeom.h:456
int32_t srid
Definition: liblwgeom.h:457
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

References LWPOLY::bbox, LWPOLY::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, genraster::g_size, gserialized_get_uint32_t(), lwalloc(), LWDEBUGF, LWPOLY::maxrings, LWPOLY::nrings, POLYGONTYPE, ptarray_construct_reference_data(), LWPOLY::rings, LWPOLY::srid, SRID_UNKNOWN, and LWPOLY::type.

Referenced by lwgeom_from_gserialized_buffer().

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