PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ wkt_parser_polygon_add_ring()

LWGEOM * wkt_parser_polygon_add_ring ( LWGEOM poly,
POINTARRAY pa,
char  dimcheck 
)

Definition at line 485 of file lwin_wkt.c.

486{
487 LWDEBUG(4,"entered");
488
489 /* Bad inputs are a problem */
490 if( ! (pa && poly) )
491 {
493 return NULL;
494 }
495
496 /* Rings must agree on dimensionality */
497 if( FLAGS_NDIMS(poly->flags) != FLAGS_NDIMS(pa->flags) )
498 {
499 ptarray_free(pa);
500 lwgeom_free(poly);
502 return NULL;
503 }
504
505 /* Apply check for minimum number of points, if requested. */
507 {
508 ptarray_free(pa);
509 lwgeom_free(poly);
511 return NULL;
512 }
513
514 /* Apply check for not closed rings, if requested. */
516 ! (dimcheck == 'Z' ? ptarray_is_closed_z(pa) : ptarray_is_closed_2d(pa)) )
517 {
518 ptarray_free(pa);
519 lwgeom_free(poly);
521 return NULL;
522 }
523
524 /* If something goes wrong adding a ring, error out. */
525 if ( LW_FAILURE == lwpoly_add_ring(lwgeom_as_lwpoly(poly), pa) )
526 {
527 ptarray_free(pa);
528 lwgeom_free(poly);
530 return NULL;
531 }
532 return poly;
533}
#define PARSER_ERROR_MIXDIMS
Definition liblwgeom.h:2175
#define LW_PARSER_CHECK_CLOSURE
Definition liblwgeom.h:2146
#define LW_FAILURE
Definition liblwgeom.h:96
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
#define PARSER_ERROR_MOREPOINTS
Definition liblwgeom.h:2172
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
Definition lwpoly.c:247
#define PARSER_ERROR_OTHER
Definition liblwgeom.h:2181
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition lwgeom.c:243
#define FLAGS_NDIMS(flags)
Definition liblwgeom.h:179
int ptarray_is_closed_z(const POINTARRAY *pa)
Definition ptarray.c:736
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
Definition liblwgeom.h:2144
void ptarray_free(POINTARRAY *pa)
Definition ptarray.c:327
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition ptarray.c:710
#define PARSER_ERROR_UNCLOSED
Definition liblwgeom.h:2174
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
#define SET_PARSER_ERROR(errno)
Definition lwin_wkt.c:52
LWGEOM_PARSER_RESULT global_parser_result
lwflags_t flags
Definition liblwgeom.h:461
lwflags_t flags
Definition liblwgeom.h:431
uint32_t npoints
Definition liblwgeom.h:427

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

Here is the call graph for this function:
Here is the caller graph for this function: