PostGIS  2.2.7dev-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;
132 
133  if ( shell->points->npoints != 4 )
134  lwerror("lwtriangle_from_lwline: shell must have exactly 4 points");
135 
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");
139 
140  pa = ptarray_clone_deep(shell->points);
141  ret = lwtriangle_construct(shell->srid, NULL, pa);
142 
144  lwerror("lwtriangle_from_lwline: some points are repeated in triangle");
145 
146  return ret;
147 }
int npoints
Definition: liblwgeom.h:355
int ptarray_is_closed_3d(const POINTARRAY *pa)
Definition: ptarray.c:707
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:27
int32_t srid
Definition: liblwgeom.h:405
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:694
char lwtriangle_is_repeated_points(LWTRIANGLE *triangle)
Definition: lwtriangle.c:150
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:124
uint8_t flags
Definition: liblwgeom.h:403
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
POINTARRAY * points
Definition: liblwgeom.h:406

Here is the call graph for this function: