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

Definition at line 980 of file g_serialized.c.

References LWPOINT::bbox, LWPOINT::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, lw_get_uint32_t(), lwalloc(), LWPOINT::point, POINTTYPE, ptarray_construct(), ptarray_construct_reference_data(), LWPOINT::srid, SRID_UNKNOWN, and LWPOINT::type.

Referenced by lwgeom_from_gserialized_buffer().

981 {
982  uint8_t *start_ptr = data_ptr;
983  LWPOINT *point;
984  uint32_t npoints = 0;
985 
986  assert(data_ptr);
987 
988  point = (LWPOINT*)lwalloc(sizeof(LWPOINT));
989  point->srid = SRID_UNKNOWN; /* Default */
990  point->bbox = NULL;
991  point->type = POINTTYPE;
992  point->flags = g_flags;
993 
994  data_ptr += 4; /* Skip past the type. */
995  npoints = lw_get_uint32_t(data_ptr); /* Zero => empty geometry */
996  data_ptr += 4; /* Skip past the npoints. */
997 
998  if ( npoints > 0 )
999  point->point = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 1, data_ptr);
1000  else
1001  point->point = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty point */
1002 
1003  data_ptr += npoints * FLAGS_NDIMS(g_flags) * sizeof(double);
1004 
1005  if ( g_size )
1006  *g_size = data_ptr - start_ptr;
1007 
1008  return point;
1009 }
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 type
Definition: liblwgeom.h:363
POINTARRAY * point
Definition: liblwgeom.h:367
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
int32_t srid
Definition: liblwgeom.h:366
uint8_t flags
Definition: liblwgeom.h:364
GBOX * bbox
Definition: liblwgeom.h:365
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
#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

Here is the call graph for this function:

Here is the caller graph for this function: