PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ lwtriangle_from_gserialized2_buffer()

static LWTRIANGLE* lwtriangle_from_gserialized2_buffer ( uint8_t *  data_ptr,
lwflags_t  lwflags,
size_t *  size,
int32_t  srid 
)
static

Definition at line 1336 of file gserialized2.c.

1337 {
1338  uint8_t *start_ptr = data_ptr;
1339  LWTRIANGLE *triangle;
1340  uint32_t npoints = 0;
1341 
1342  assert(data_ptr);
1343 
1344  triangle = (LWTRIANGLE*)lwalloc(sizeof(LWTRIANGLE));
1345  triangle->srid = srid; /* Default */
1346  triangle->bbox = NULL;
1347  triangle->type = TRIANGLETYPE;
1348  triangle->flags = lwflags;
1349 
1350  data_ptr += 4; /* Skip past the type. */
1351  npoints = gserialized2_get_uint32_t(data_ptr); /* Zero => empty geometry */
1352  data_ptr += 4; /* Skip past the npoints. */
1353 
1354  if (npoints > 0)
1356  else
1357  triangle->points = ptarray_construct(FLAGS_GET_Z(lwflags), FLAGS_GET_M(lwflags), 0); /* Empty triangle */
1358 
1359  data_ptr += FLAGS_NDIMS(lwflags) * npoints * sizeof(double);
1360 
1361  if (size)
1362  *size = data_ptr - start_ptr;
1363 
1364  return triangle;
1365 }
static uint32_t gserialized2_get_uint32_t(const uint8_t *loc)
Definition: gserialized2.c:131
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:291
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition: ptarray.c:51
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:180
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:194
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:181
#define TRIANGLETYPE
Definition: liblwgeom.h:130
void * lwalloc(size_t size)
Definition: lwutil.c:227
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition: lwutil.c:471
int32_t srid
Definition: liblwgeom.h:511
uint8_t type
Definition: liblwgeom.h:513
GBOX * bbox
Definition: liblwgeom.h:509
lwflags_t flags
Definition: liblwgeom.h:512
POINTARRAY * points
Definition: liblwgeom.h:510

References LWTRIANGLE::bbox, LWTRIANGLE::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, gserialized2_get_uint32_t(), lwalloc(), lwflags(), LWTRIANGLE::points, ptarray_construct(), ptarray_construct_reference_data(), LWTRIANGLE::srid, TRIANGLETYPE, and LWTRIANGLE::type.

Referenced by lwgeom_from_gserialized2_buffer().

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