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

Definition at line 1129 of file g_serialized.c.

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

1130 {
1131  uint8_t *start_ptr = data_ptr;
1132  LWCIRCSTRING *circstring;
1133  uint32_t npoints = 0;
1134 
1135  assert(data_ptr);
1136 
1137  circstring = (LWCIRCSTRING*)lwalloc(sizeof(LWCIRCSTRING));
1138  circstring->srid = SRID_UNKNOWN; /* Default */
1139  circstring->bbox = NULL;
1140  circstring->type = CIRCSTRINGTYPE;
1141  circstring->flags = g_flags;
1142 
1143  data_ptr += 4; /* Skip past the circstringtype. */
1144  npoints = lw_get_uint32_t(data_ptr); /* Zero => empty geometry */
1145  data_ptr += 4; /* Skip past the npoints. */
1146 
1147  if ( npoints > 0 )
1148  circstring->points = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), npoints, data_ptr);
1149  else
1150  circstring->points = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty circularstring */
1151 
1152  data_ptr += FLAGS_NDIMS(g_flags) * npoints * sizeof(double);
1153 
1154  if ( g_size )
1155  *g_size = data_ptr - start_ptr;
1156 
1157  return circstring;
1158 }
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
uint8_t flags
Definition: liblwgeom.h:397
int32_t srid
Definition: liblwgeom.h:399
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
uint8_t type
Definition: liblwgeom.h:396
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
GBOX * bbox
Definition: liblwgeom.h:398
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
tuple g_size
Definition: genraster.py:42
POINTARRAY * points
Definition: liblwgeom.h:400
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
void * lwalloc(size_t size)
Definition: lwutil.c:175
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:118

Here is the call graph for this function:

Here is the caller graph for this function: