PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ 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:708
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:628
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:695
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(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:40
uint8_t flags
Definition: liblwgeom.h:422
POINTARRAY * points
Definition: liblwgeom.h:425
int32_t srid
Definition: liblwgeom.h:424
uint32_t npoints
Definition: liblwgeom.h:374

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: