PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwtriangle_from_gserialized_buffer()

static LWTRIANGLE* lwtriangle_from_gserialized_buffer ( uint8_t data_ptr,
uint8_t  g_flags,
size_t *  g_size 
)
static

Definition at line 1370 of file g_serialized.c.

1371 {
1372  uint8_t *start_ptr = data_ptr;
1373  LWTRIANGLE *triangle;
1374  uint32_t npoints = 0;
1375 
1376  assert(data_ptr);
1377 
1378  triangle = (LWTRIANGLE*)lwalloc(sizeof(LWTRIANGLE));
1379  triangle->srid = SRID_UNKNOWN; /* Default */
1380  triangle->bbox = NULL;
1381  triangle->type = TRIANGLETYPE;
1382  triangle->flags = g_flags;
1383 
1384  data_ptr += 4; /* Skip past the type. */
1385  npoints = gserialized_get_uint32_t(data_ptr); /* Zero => empty geometry */
1386  data_ptr += 4; /* Skip past the npoints. */
1387 
1388  if ( npoints > 0 )
1389  triangle->points = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), npoints, data_ptr);
1390  else
1391  triangle->points = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty triangle */
1392 
1393  data_ptr += FLAGS_NDIMS(g_flags) * npoints * sizeof(double);
1394 
1395  if ( g_size )
1396  *g_size = data_ptr - start_ptr;
1397 
1398  return triangle;
1399 }
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
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:62
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
#define TRIANGLETYPE
Definition: liblwgeom.h:98
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
tuple g_size
Definition: genraster.py:41
int32_t srid
Definition: liblwgeom.h:435
uint8_t type
Definition: liblwgeom.h:432
GBOX * bbox
Definition: liblwgeom.h:434
POINTARRAY * points
Definition: liblwgeom.h:436
uint8_t flags
Definition: liblwgeom.h:433
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

References LWTRIANGLE::bbox, LWTRIANGLE::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, genraster::g_size, gserialized_get_uint32_t(), lwalloc(), LWTRIANGLE::points, ptarray_construct(), ptarray_construct_reference_data(), LWTRIANGLE::srid, SRID_UNKNOWN, TRIANGLETYPE, and LWTRIANGLE::type.

Referenced by lwgeom_from_gserialized_buffer().

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