PostGIS  2.3.7dev-r@@SVN_REVISION@@
LWTRIANGLE* lwtriangle_from_lwline ( const LWLINE shell)

Definition at line 141 of file lwtriangle.c.

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.

142 {
143  LWTRIANGLE *ret;
144  POINTARRAY *pa;
145 
146  if ( shell->points->npoints != 4 )
147  lwerror("lwtriangle_from_lwline: shell must have exactly 4 points");
148 
149  if ( (!FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_2d(shell->points)) ||
150  (FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_3d(shell->points)) )
151  lwerror("lwtriangle_from_lwline: shell must be closed");
152 
153  pa = ptarray_clone_deep(shell->points);
154  ret = lwtriangle_construct(shell->srid, NULL, pa);
155 
157  lwerror("lwtriangle_from_lwline: some points are repeated in triangle");
158 
159  return ret;
160 }
int npoints
Definition: liblwgeom.h:370
int ptarray_is_closed_3d(const POINTARRAY *pa)
Definition: ptarray.c:707
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:40
int32_t srid
Definition: liblwgeom.h:420
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:694
char lwtriangle_is_repeated_points(LWTRIANGLE *triangle)
Definition: lwtriangle.c:163
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:634
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
uint8_t flags
Definition: liblwgeom.h:418
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function: