PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ wkt_parser_triangle_new()

LWGEOM* wkt_parser_triangle_new ( POINTARRAY pa,
char *  dimensionality 
)

Definition at line 424 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_z(), SET_PARSER_ERROR, SRID_UNKNOWN, wkt_dimensionality(), and wkt_pointarray_dimensionality().

Referenced by yyparse().

425 {
426  uint8_t flags = wkt_dimensionality(dimensionality);
427  LWDEBUG(4,"entered");
428 
429  /* No pointarray means it is empty */
430  if( ! pa )
432 
433  /* If the number of dimensions is not consistent, we have a problem. */
434  if( wkt_pointarray_dimensionality(pa, flags) == LW_FALSE )
435  {
436  ptarray_free(pa);
438  return NULL;
439  }
440 
441  /* Triangles need four points. */
442  if( (pa->npoints != 4) )
443  {
444  ptarray_free(pa);
446  return NULL;
447  }
448 
449  /* Triangles need closure. */
450  if( ! ptarray_is_closed_z(pa) )
451  {
452  ptarray_free(pa);
454  return NULL;
455  }
456 
458 }
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
Definition: lwtriangle.c:58
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:328
int ptarray_is_closed_z(const POINTARRAY *pa)
Definition: ptarray.c:714
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:2030
#define LW_FALSE
Definition: liblwgeom.h:76
static uint8_t wkt_dimensionality(char *dimensionality)
Definition: lwin_wkt.c:75
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:187
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
Definition: lwgeom.c:325
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:40
#define PARSER_ERROR_UNCLOSED
Definition: liblwgeom.h:2029
#define PARSER_ERROR_TRIANGLEPOINTS
Definition: liblwgeom.h:2034
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:52
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
unsigned char uint8_t
Definition: uthash.h:79
static int wkt_pointarray_dimensionality(POINTARRAY *pa, uint8_t flags)
Read the dimensionality from a flag, if provided.
Definition: lwin_wkt.c:183
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: