PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ wkt_parser_triangle_new()

LWGEOM* wkt_parser_triangle_new ( POINTARRAY pa,
char *  dimensionality 
)

Definition at line 410 of file lwin_wkt.c.

References FLAGS_GET_M, FLAGS_GET_Z, LW_FALSE, LWDEBUG, lwtriangle_as_lwgeom(), lwtriangle_construct(), lwtriangle_construct_empty(), POINTARRAY::npoints, PARSER_ERROR_MIXDIMS, PARSER_ERROR_TRIANGLEPOINTS, PARSER_ERROR_UNCLOSED, ptarray_free(), ptarray_is_closed(), SET_PARSER_ERROR, SRID_UNKNOWN, wkt_dimensionality(), and wkt_pointarray_dimensionality().

Referenced by yyparse().

411 {
412  uint8_t flags = wkt_dimensionality(dimensionality);
413  LWDEBUG(4,"entered");
414 
415  /* No pointarray means it is empty */
416  if( ! pa )
418 
419  /* If the number of dimensions is not consistent, we have a problem. */
420  if( wkt_pointarray_dimensionality(pa, flags) == LW_FALSE )
421  {
422  ptarray_free(pa);
424  return NULL;
425  }
426 
427  /* Triangles need four points. */
428  if( (pa->npoints != 4) )
429  {
430  ptarray_free(pa);
432  return NULL;
433  }
434 
435  /* Triangles need closure. */
436  if( ! ptarray_is_closed(pa) )
437  {
438  ptarray_free(pa);
440  return NULL;
441  }
442 
444 }
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
Definition: lwtriangle.c:45
int npoints
Definition: liblwgeom.h:355
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:1895
#define LW_FALSE
Definition: liblwgeom.h:62
static uint8_t wkt_dimensionality(char *dimensionality)
Definition: lwin_wkt.c:61
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:172
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
Definition: lwgeom.c:244
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:27
#define PARSER_ERROR_UNCLOSED
Definition: liblwgeom.h:1894
#define PARSER_ERROR_TRIANGLEPOINTS
Definition: liblwgeom.h:1899
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:38
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
static int wkt_pointarray_dimensionality(POINTARRAY *pa, uint8_t flags)
Read the dimensionality from a flag, if provided.
Definition: lwin_wkt.c:169
int ptarray_is_closed(const POINTARRAY *pa)
Check for ring closure using whatever dimensionality is declared on the pointarray.
Definition: ptarray.c:680
Here is the call graph for this function:
Here is the caller graph for this function: