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

◆ lwpoly_from_lwlines()

LWPOLY * lwpoly_from_lwlines ( const LWLINE shell,
uint32_t  nholes,
const LWLINE **  holes 
)
extern

Definition at line 359 of file lwpoly.c.

361{
362 uint32_t nrings;
363 POINTARRAY **rings = lwalloc((nholes+1)*sizeof(POINTARRAY *));
364 int32_t srid = shell->srid;
365 LWPOLY *ret;
366
367 if ( shell->points->npoints < 4 )
368 lwerror("lwpoly_from_lwlines: shell must have at least 4 points");
369 if ( ! ptarray_is_closed_2d(shell->points) )
370 lwerror("lwpoly_from_lwlines: shell must be closed");
371 rings[0] = ptarray_clone_deep(shell->points);
372
373 for (nrings=1; nrings<=nholes; nrings++)
374 {
375 const LWLINE *hole = holes[nrings-1];
376
377 if ( hole->srid != srid )
378 lwerror("lwpoly_from_lwlines: mixed SRIDs in input lines");
379
380 if ( hole->points->npoints < 4 )
381 lwerror("lwpoly_from_lwlines: holes must have at least 4 points");
382 if ( ! ptarray_is_closed_2d(hole->points) )
383 lwerror("lwpoly_from_lwlines: holes must be closed");
384
385 rings[nrings] = ptarray_clone_deep(hole->points);
386 }
387
388 ret = lwpoly_construct(srid, NULL, nrings, rings);
389 return ret;
390}
void * lwalloc(size_t size)
Definition lwutil.c:227
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition ptarray.c:710
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition ptarray.c:643
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition lwpoly.c:43
POINTARRAY * points
Definition liblwgeom.h:483
int32_t srid
Definition liblwgeom.h:484
uint32_t npoints
Definition liblwgeom.h:427

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

Referenced by _lwt_SnapEdge_checkMotion(), lwgeom_force_sfs(), and LWGEOM_makepoly().

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