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

◆ lwtriangle_from_lwline()

LWTRIANGLE * lwtriangle_from_lwline ( const LWLINE shell)

Definition at line 153 of file lwtriangle.c.

154{
155 LWTRIANGLE *ret;
156 POINTARRAY *pa;
157
158 if ( shell->points->npoints != 4 )
159 lwerror("lwtriangle_from_lwline: shell must have exactly 4 points");
160
161 if ( (!FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_2d(shell->points)) ||
162 (FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_3d(shell->points)) )
163 lwerror("lwtriangle_from_lwline: shell must be closed");
164
165 pa = ptarray_clone_deep(shell->points);
166 ret = lwtriangle_construct(shell->srid, NULL, pa);
167
169 lwerror("lwtriangle_from_lwline: some points are repeated in triangle");
170
171 return ret;
172}
int ptarray_is_closed_3d(const POINTARRAY *pa)
Definition ptarray.c:714
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:179
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition ptarray.c:701
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition ptarray.c:634
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition lwutil.c:190
static char lwtriangle_is_repeated_points(LWTRIANGLE *triangle)
Definition lwtriangle.c:134
LWTRIANGLE * lwtriangle_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition lwtriangle.c:40
lwflags_t flags
Definition liblwgeom.h:471
POINTARRAY * points
Definition liblwgeom.h:469
int32_t srid
Definition liblwgeom.h:470
uint32_t npoints
Definition liblwgeom.h:413

References LWLINE::flags, FLAGS_GET_Z, lwerror(), lwtriangle_construct(), lwtriangle_is_repeated_points(), POINTARRAY::npoints, LWLINE::points, ptarray_clone_deep(), ptarray_is_closed_2d(), ptarray_is_closed_3d(), and LWLINE::srid.

Here is the call graph for this function: