PostGIS  2.1.10dev-r@@SVN_REVISION@@
static LWTRIANGLE* lwtriangle_from_gserialized_buffer ( uint8_t *  data_ptr,
uint8_t  g_flags,
size_t *  g_size 
)
static

Definition at line 1098 of file g_serialized.c.

References LWTRIANGLE::bbox, LWTRIANGLE::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, lw_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().

1099 {
1100  uint8_t *start_ptr = data_ptr;
1101  LWTRIANGLE *triangle;
1102  uint32_t npoints = 0;
1103 
1104  assert(data_ptr);
1105 
1106  triangle = (LWTRIANGLE*)lwalloc(sizeof(LWTRIANGLE));
1107  triangle->srid = SRID_UNKNOWN; /* Default */
1108  triangle->bbox = NULL;
1109  triangle->type = TRIANGLETYPE;
1110  triangle->flags = g_flags;
1111 
1112  data_ptr += 4; /* Skip past the type. */
1113  npoints = lw_get_uint32_t(data_ptr); /* Zero => empty geometry */
1114  data_ptr += 4; /* Skip past the npoints. */
1115 
1116  if ( npoints > 0 )
1117  triangle->points = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), npoints, data_ptr);
1118  else
1119  triangle->points = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty triangle */
1120 
1121  data_ptr += FLAGS_NDIMS(g_flags) * npoints * sizeof(double);
1122 
1123  if ( g_size )
1124  *g_size = data_ptr - start_ptr;
1125 
1126  return triangle;
1127 }
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:49
POINTARRAY * points
Definition: liblwgeom.h:389
#define TRIANGLETYPE
Definition: liblwgeom.h:73
GBOX * bbox
Definition: liblwgeom.h:387
uint8_t type
Definition: liblwgeom.h:385
uint32_t lw_get_uint32_t(const uint8_t *loc)
Definition: lwgeom_api.c:534
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:154
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:280
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
tuple g_size
Definition: genraster.py:42
void * lwalloc(size_t size)
Definition: lwutil.c:175
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:118
int32_t srid
Definition: liblwgeom.h:388
uint8_t flags
Definition: liblwgeom.h:386

Here is the call graph for this function:

Here is the caller graph for this function: