PostGIS  2.5.1dev-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 1248 of file g_serialized.c.

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

1249 {
1250  uint8_t *start_ptr = data_ptr;
1251  LWPOINT *point;
1252  uint32_t npoints = 0;
1253 
1254  assert(data_ptr);
1255 
1256  point = (LWPOINT*)lwalloc(sizeof(LWPOINT));
1257  point->srid = SRID_UNKNOWN; /* Default */
1258  point->bbox = NULL;
1259  point->type = POINTTYPE;
1260  point->flags = g_flags;
1261 
1262  data_ptr += 4; /* Skip past the type. */
1263  npoints = gserialized_get_uint32_t(data_ptr); /* Zero => empty geometry */
1264  data_ptr += 4; /* Skip past the npoints. */
1265 
1266  if ( npoints > 0 )
1267  point->point = ptarray_construct_reference_data(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 1, data_ptr);
1268  else
1269  point->point = ptarray_construct(FLAGS_GET_Z(g_flags), FLAGS_GET_M(g_flags), 0); /* Empty point */
1270 
1271  data_ptr += npoints * FLAGS_NDIMS(g_flags) * sizeof(double);
1272 
1273  if ( g_size )
1274  *g_size = data_ptr - start_ptr;
1275 
1276  return point;
1277 }
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:409
POINTARRAY * point
Definition: liblwgeom.h:413
unsigned int uint32_t
Definition: uthash.h:78
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:187
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:293
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
int32_t srid
Definition: liblwgeom.h:412
uint8_t flags
Definition: liblwgeom.h:410
GBOX * bbox
Definition: liblwgeom.h:411
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
tuple g_size
Definition: genraster.py:41
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:151
unsigned char uint8_t
Definition: uthash.h:79
Here is the call graph for this function:
Here is the caller graph for this function: