PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwtriangle_from_lwline()

LWTRIANGLE* lwtriangle_from_lwline ( const LWLINE shell)

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

148 {
149  LWTRIANGLE *ret;
150  POINTARRAY *pa;
151 
152  if ( shell->points->npoints != 4 )
153  lwerror("lwtriangle_from_lwline: shell must have exactly 4 points");
154 
155  if ( (!FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_2d(shell->points)) ||
156  (FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_3d(shell->points)) )
157  lwerror("lwtriangle_from_lwline: shell must be closed");
158 
159  pa = ptarray_clone_deep(shell->points);
160  ret = lwtriangle_construct(shell->srid, NULL, pa);
161 
163  lwerror("lwtriangle_from_lwline: some points are repeated in triangle");
164 
165  return ret;
166 }
int npoints
Definition: liblwgeom.h:371
int ptarray_is_closed_3d(const POINTARRAY *pa)
Definition: ptarray.c:710
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:40
int32_t srid
Definition: liblwgeom.h:421
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:697
char lwtriangle_is_repeated_points(LWTRIANGLE *triangle)
Definition: lwtriangle.c:169
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:630
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
uint8_t flags
Definition: liblwgeom.h:419
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function: