PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwcircstring_from_gserialized_buffer()

static LWCIRCSTRING* lwcircstring_from_gserialized_buffer ( uint8_t data_ptr,
uint8_t  g_flags,
size_t *  g_size 
)
static

Definition at line 1401 of file g_serialized.c.

References LWCIRCSTRING::bbox, CIRCSTRINGTYPE, LWCIRCSTRING::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, gserialized_get_uint32_t(), lwalloc(), LWCIRCSTRING::points, ptarray_construct(), ptarray_construct_reference_data(), LWCIRCSTRING::srid, SRID_UNKNOWN, and LWCIRCSTRING::type.

Referenced by lwgeom_from_gserialized_buffer().

1402 {
1403  uint8_t *start_ptr = data_ptr;
1404  LWCIRCSTRING *circstring;
1405  uint32_t npoints = 0;
1406 
1407  assert(data_ptr);
1408 
1409  circstring = (LWCIRCSTRING*)lwalloc(sizeof(LWCIRCSTRING));
1410  circstring->srid = SRID_UNKNOWN; /* Default */
1411  circstring->bbox = NULL;
1412  circstring->type = CIRCSTRINGTYPE;
1413  circstring->flags = g_flags;
1414 
1415  data_ptr += 4; /* Skip past the circstringtype. */
1416  npoints = gserialized_get_uint32_t(data_ptr); /* Zero => empty geometry */
1417  data_ptr += 4; /* Skip past the npoints. */
1418 
1419  if ( npoints > 0 )
1420  circstring->points = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), npoints, data_ptr);
1421  else
1422  circstring->points = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty circularstring */
1423 
1424  data_ptr += FLAGS_NDIMS(g_flags) * npoints * sizeof(double);
1425 
1426  if ( g_size )
1427  *g_size = data_ptr - start_ptr;
1428 
1429  return circstring;
1430 }
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
uint8_t flags
Definition: liblwgeom.h:441
int32_t srid
Definition: liblwgeom.h:443
unsigned int uint32_t
Definition: uthash.h:78
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
uint8_t type
Definition: liblwgeom.h:440
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:295
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
GBOX * bbox
Definition: liblwgeom.h:442
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
tuple g_size
Definition: genraster.py:41
POINTARRAY * points
Definition: liblwgeom.h:444
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
void * lwalloc(size_t size)
Definition: lwutil.c:229
static uint32_t gserialized_get_uint32_t(const uint8_t *loc)
Definition: g_serialized.c:35
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
unsigned char uint8_t
Definition: uthash.h:79
Here is the call graph for this function:
Here is the caller graph for this function: