PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWGEOM* wkt_parser_polygon_add_ring ( LWGEOM poly,
POINTARRAY pa,
char  dimcheck 
)

Definition at line 458 of file lwin_wkt.c.

References POINTARRAY::flags, LWGEOM::flags, FLAGS_NDIMS, global_parser_result, LW_FAILURE, LW_PARSER_CHECK_CLOSURE, LW_PARSER_CHECK_MINPOINTS, LWDEBUG, lwgeom_as_lwpoly(), lwgeom_free(), lwpoly_add_ring(), POINTARRAY::npoints, struct_lwgeom_parser_result::parser_check_flags, PARSER_ERROR_MIXDIMS, PARSER_ERROR_MOREPOINTS, PARSER_ERROR_OTHER, PARSER_ERROR_UNCLOSED, ptarray_free(), ptarray_is_closed_2d(), ptarray_is_closed_z(), and SET_PARSER_ERROR.

Referenced by wkt_parser_polygon_new(), and yyparse().

459 {
460  LWDEBUG(4,"entered");
461 
462  /* Bad inputs are a problem */
463  if( ! (pa && poly) )
464  {
466  return NULL;
467  }
468 
469  /* Rings must agree on dimensionality */
470  if( FLAGS_NDIMS(poly->flags) != FLAGS_NDIMS(pa->flags) )
471  {
472  ptarray_free(pa);
473  lwgeom_free(poly);
475  return NULL;
476  }
477 
478  /* Apply check for minimum number of points, if requested. */
480  {
481  ptarray_free(pa);
482  lwgeom_free(poly);
484  return NULL;
485  }
486 
487  /* Apply check for not closed rings, if requested. */
489  ! (dimcheck == 'Z' ? ptarray_is_closed_z(pa) : ptarray_is_closed_2d(pa)) )
490  {
491  ptarray_free(pa);
492  lwgeom_free(poly);
494  return NULL;
495  }
496 
497  /* If something goes wrong adding a ring, error out. */
498  if ( LW_FAILURE == lwpoly_add_ring(lwgeom_as_lwpoly(poly), pa) )
499  {
500  ptarray_free(pa);
501  lwgeom_free(poly);
503  return NULL;
504  }
505  return poly;
506 }
int npoints
Definition: liblwgeom.h:327
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
Definition: liblwgeom.h:1701
uint8_t flags
Definition: liblwgeom.h:353
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:315
int ptarray_is_closed_z(const POINTARRAY *pa)
Definition: ptarray.c:684
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:125
LWGEOM_PARSER_RESULT global_parser_result
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:1732
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:672
#define LW_FAILURE
Definition: liblwgeom.h:54
uint8_t flags
Definition: liblwgeom.h:325
#define PARSER_ERROR_MOREPOINTS
Definition: liblwgeom.h:1729
#define PARSER_ERROR_UNCLOSED
Definition: liblwgeom.h:1731
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:38
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
Definition: lwpoly.c:154
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:118
#define LW_PARSER_CHECK_CLOSURE
Definition: liblwgeom.h:1703
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:1738

Here is the call graph for this function:

Here is the caller graph for this function: