PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwpoly_from_gserialized1_buffer()

static LWPOLY * lwpoly_from_gserialized1_buffer ( uint8_t *  data_ptr,
lwflags_t  lwflags,
size_t *  size 
)
static

Definition at line 1226 of file gserialized1.c.

1227{
1228 uint8_t *start_ptr = data_ptr;
1229 LWPOLY *poly;
1230 uint8_t *ordinate_ptr;
1231 uint32_t nrings = 0;
1232 uint32_t i = 0;
1233
1234 assert(data_ptr);
1235
1236 poly = (LWPOLY*)lwalloc(sizeof(LWPOLY));
1237 poly->srid = SRID_UNKNOWN; /* Default */
1238 poly->bbox = NULL;
1239 poly->type = POLYGONTYPE;
1240 poly->flags = lwflags;
1241
1242 data_ptr += 4; /* Skip past the polygontype. */
1243 nrings = gserialized1_get_uint32_t(data_ptr); /* Zero => empty geometry */
1244 poly->nrings = nrings;
1245 LWDEBUGF(4, "nrings = %d", nrings);
1246 data_ptr += 4; /* Skip past the nrings. */
1247
1248 ordinate_ptr = data_ptr; /* Start the ordinate pointer. */
1249 if ( nrings > 0)
1250 {
1251 poly->rings = (POINTARRAY**)lwalloc( sizeof(POINTARRAY*) * nrings );
1252 poly->maxrings = nrings;
1253 ordinate_ptr += nrings * 4; /* Move past all the npoints values. */
1254 if ( nrings % 2 ) /* If there is padding, move past that too. */
1255 ordinate_ptr += 4;
1256 }
1257 else /* Empty polygon */
1258 {
1259 poly->rings = NULL;
1260 poly->maxrings = 0;
1261 }
1262
1263 for ( i = 0; i < nrings; i++ )
1264 {
1265 uint32_t npoints = 0;
1266
1267 /* Read in the number of points. */
1268 npoints = gserialized1_get_uint32_t(data_ptr);
1269 data_ptr += 4;
1270
1271 /* Make a point array for the ring, and move the ordinate pointer past the ring ordinates. */
1272 poly->rings[i] = ptarray_construct_reference_data(FLAGS_GET_Z(lwflags), FLAGS_GET_M(lwflags), npoints, ordinate_ptr);
1273
1274 ordinate_ptr += sizeof(double) * FLAGS_NDIMS(lwflags) * npoints;
1275 }
1276
1277 if ( size )
1278 *size = ordinate_ptr - start_ptr;
1279
1280 return poly;
1281}
static uint32_t gserialized1_get_uint32_t(const uint8_t *loc)
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:291
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:179
void * lwalloc(size_t size)
Definition lwutil.c:227
#define FLAGS_NDIMS(flags)
Definition liblwgeom.h:193
#define POLYGONTYPE
Definition liblwgeom.h:118
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:180
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition lwutil.c:471
#define SRID_UNKNOWN
Unknown SRID value.
Definition liblwgeom.h:229
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:88
POINTARRAY ** rings
Definition liblwgeom.h:505
uint8_t type
Definition liblwgeom.h:508
uint32_t maxrings
Definition liblwgeom.h:511
uint32_t nrings
Definition liblwgeom.h:510
GBOX * bbox
Definition liblwgeom.h:504
lwflags_t flags
Definition liblwgeom.h:507
int32_t srid
Definition liblwgeom.h:506

References LWPOLY::bbox, LWPOLY::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, gserialized1_get_uint32_t(), lwalloc(), LWDEBUGF, lwflags(), LWPOLY::maxrings, LWPOLY::nrings, POLYGONTYPE, ptarray_construct_reference_data(), LWPOLY::rings, LWPOLY::srid, SRID_UNKNOWN, and LWPOLY::type.

Referenced by lwgeom_from_gserialized1_buffer().

Here is the call graph for this function:
Here is the caller graph for this function: