PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwpoly_add_ring()

int lwpoly_add_ring ( LWPOLY poly,
POINTARRAY pa 
)

Add a ring, allocating extra space if necessary.

The polygon takes ownership of the passed point array.

Add a ring, allocating extra space if necessary.

Point array will be referenced, not copied.

Definition at line 249 of file lwpoly.c.

References LW_FAILURE, LW_SUCCESS, lwrealloc(), LWPOLY::maxrings, LWPOLY::nrings, and LWPOLY::rings.

Referenced by GeneratePolygonGeometry(), geography_centroid_from_mpoly(), lwgeom_segmentize_sphere(), lwpoly_construct_circle(), lwpoly_construct_rectangle(), lwpoly_from_twkb_state(), lwpoly_from_wkb_state(), lwpoly_grid(), lwpoly_set_effective_area(), lwpoly_simplify(), parse_geojson_multipolygon(), and wkt_parser_polygon_add_ring().

250 {
251  if( ! poly || ! pa )
252  return LW_FAILURE;
253 
254  /* We have used up our storage, add some more. */
255  if( poly->nrings >= poly->maxrings )
256  {
257  int new_maxrings = 2 * (poly->nrings + 1);
258  poly->rings = lwrealloc(poly->rings, new_maxrings * sizeof(POINTARRAY*));
259  poly->maxrings = new_maxrings;
260  }
261 
262  /* Add the new ring entry. */
263  poly->rings[poly->nrings] = pa;
264  poly->nrings++;
265 
266  return LW_SUCCESS;
267 }
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define LW_FAILURE
Definition: liblwgeom.h:79
POINTARRAY ** rings
Definition: liblwgeom.h:457
int nrings
Definition: liblwgeom.h:455
int maxrings
Definition: liblwgeom.h:456
void * lwrealloc(void *mem, size_t size)
Definition: lwutil.c:237
Here is the call graph for this function:
Here is the caller graph for this function: