PostGIS  2.5.7dev-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.

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 }
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:2031
#define LW_FALSE
Definition: liblwgeom.h:77
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
int ptarray_is_closed_z(const POINTARRAY *pa)
Definition: ptarray.c:721
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:328
LWTRIANGLE * lwtriangle_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwtriangle.c:40
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
Definition: lwgeom.c:325
#define PARSER_ERROR_TRIANGLEPOINTS
Definition: liblwgeom.h:2035
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
#define PARSER_ERROR_UNCLOSED
Definition: liblwgeom.h:2030
LWTRIANGLE * lwtriangle_construct_empty(int srid, char hasz, char hasm)
Definition: lwtriangle.c:58
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
static uint8_t wkt_dimensionality(char *dimensionality)
Definition: lwin_wkt.c:75
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:52
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:374
unsigned char uint8_t
Definition: uthash.h:79

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().

Here is the call graph for this function: