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

Definition at line 128 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.

129 {
130  LWTRIANGLE *ret;
131  POINTARRAY *pa;
133  if ( shell->points->npoints != 4 )
134  lwerror("lwtriangle_from_lwline: shell must have exactly 4 points");
136  if ( (!FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_2d(shell->points)) ||
137  (FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_3d(shell->points)) )
138  lwerror("lwtriangle_from_lwline: shell must be closed");
140  pa = ptarray_clone_deep(shell->points);
141  ret = lwtriangle_construct(shell->srid, NULL, pa);
144  lwerror("lwtriangle_from_lwline: some points are repeated in triangle");
146  return ret;
147 }
int npoints
Definition: liblwgeom.h:327
int ptarray_is_closed_3d(const POINTARRAY *pa)
Definition: ptarray.c:678
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:27
int32_t srid
Definition: liblwgeom.h:377
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:672
char lwtriangle_is_repeated_points(LWTRIANGLE *triangle)
Definition: lwtriangle.c:150
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:619
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
uint8_t flags
Definition: liblwgeom.h:375
Definition: liblwgeom.h:378

Here is the call graph for this function: