PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwpoint_from_gserialized_buffer()

static LWPOINT* lwpoint_from_gserialized_buffer ( uint8_t *  data_ptr,
uint8_t  g_flags,
size_t *  g_size 
)
static

Definition at line 978 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().

979 {
980  uint8_t *start_ptr = data_ptr;
981  LWPOINT *point;
982  uint32_t npoints = 0;
983 
984  assert(data_ptr);
985 
986  point = (LWPOINT*)lwalloc(sizeof(LWPOINT));
987  point->srid = SRID_UNKNOWN; /* Default */
988  point->bbox = NULL;
989  point->type = POINTTYPE;
990  point->flags = g_flags;
991 
992  data_ptr += 4; /* Skip past the type. */
993  npoints = lw_get_uint32_t(data_ptr); /* Zero => empty geometry */
994  data_ptr += 4; /* Skip past the npoints. */
995 
996  if ( npoints > 0 )
997  point->point = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 1, data_ptr);
998  else
999  point->point = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty point */
1000 
1001  data_ptr += npoints * FLAGS_NDIMS(g_flags) * sizeof(double);
1002 
1003  if ( g_size )
1004  *g_size = data_ptr - start_ptr;
1005 
1006  return point;
1007 }
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 type
Definition: liblwgeom.h:391
POINTARRAY * point
Definition: liblwgeom.h:395
uint32_t lw_get_uint32_t(const uint8_t *loc)
Definition: lwgeom_api.c:569
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:172
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:124
int32_t srid
Definition: liblwgeom.h:394
uint8_t flags
Definition: liblwgeom.h:392
GBOX * bbox
Definition: liblwgeom.h:393
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
tuple g_size
Definition: genraster.py:41
void * lwalloc(size_t size)
Definition: lwutil.c:199
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:136
Here is the call graph for this function:
Here is the caller graph for this function: