PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWGEOM* wkt_parser_triangle_new ( POINTARRAY pa,
char *  dimensionality 
)

Definition at line 397 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().

398 {
399  uint8_t flags = wkt_dimensionality(dimensionality);
400  LWDEBUG(4,"entered");
401 
402  /* No pointarray means it is empty */
403  if( ! pa )
405 
406  /* If the number of dimensions is not consistent, we have a problem. */
407  if( wkt_pointarray_dimensionality(pa, flags) == LW_FALSE )
408  {
409  ptarray_free(pa);
411  return NULL;
412  }
413 
414  /* Triangles need four points. */
415  if( (pa->npoints != 4) )
416  {
417  ptarray_free(pa);
419  return NULL;
420  }
421 
422  /* Triangles need closure. */
423  if( ! ptarray_is_closed(pa) )
424  {
425  ptarray_free(pa);
427  return NULL;
428  }
429 
431 }
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
Definition: lwtriangle.c:45
int npoints
Definition: liblwgeom.h:327
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:315
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:1732
#define LW_FALSE
Definition: liblwgeom.h:52
static uint8_t wkt_dimensionality(char *dimensionality)
Definition: lwin_wkt.c:61
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:154
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:106
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:27
#define PARSER_ERROR_UNCLOSED
Definition: liblwgeom.h:1731
#define PARSER_ERROR_TRIANGLEPOINTS
Definition: liblwgeom.h:1736
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:38
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
static int wkt_pointarray_dimensionality(POINTARRAY *pa, uint8_t flags)
Read the dimensionality from a flag, if provided.
Definition: lwin_wkt.c:156
int ptarray_is_closed(const POINTARRAY *pa)
Check for ring closure using whatever dimensionality is declared on the pointarray.
Definition: ptarray.c:665

Here is the call graph for this function:

Here is the caller graph for this function: