PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWPOLY* lwpoly_from_lwlines ( const LWLINE shell,
uint32_t  nholes,
const LWLINE **  holes 
)

Definition at line 250 of file lwpoly.c.

References lwalloc(), lwerror(), lwpoly_construct(), POINTARRAY::npoints, LWLINE::points, ptarray_clone_deep(), ptarray_is_closed_2d(), and LWLINE::srid.

Referenced by lwgeom_force_sfs(), and LWGEOM_makepoly().

252 {
253  uint32_t nrings;
254  POINTARRAY **rings = lwalloc((nholes+1)*sizeof(POINTARRAY *));
255  int srid = shell->srid;
256  LWPOLY *ret;
257 
258  if ( shell->points->npoints < 4 )
259  lwerror("lwpoly_from_lwlines: shell must have at least 4 points");
260  if ( ! ptarray_is_closed_2d(shell->points) )
261  lwerror("lwpoly_from_lwlines: shell must be closed");
262  rings[0] = ptarray_clone_deep(shell->points);
263 
264  for (nrings=1; nrings<=nholes; nrings++)
265  {
266  const LWLINE *hole = holes[nrings-1];
267 
268  if ( hole->srid != srid )
269  lwerror("lwpoly_from_lwlines: mixed SRIDs in input lines");
270 
271  if ( hole->points->npoints < 4 )
272  lwerror("lwpoly_from_lwlines: holes must have at least 4 points");
273  if ( ! ptarray_is_closed_2d(hole->points) )
274  lwerror("lwpoly_from_lwlines: holes must be closed");
275 
276  rings[nrings] = ptarray_clone_deep(hole->points);
277  }
278 
279  ret = lwpoly_construct(srid, NULL, nrings, rings);
280  return ret;
281 }
int npoints
Definition: liblwgeom.h:327
int32_t srid
Definition: liblwgeom.h:377
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:672
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:29
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:619
void * lwalloc(size_t size)
Definition: lwutil.c:175
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: