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

◆ wkt_parser_curvepolygon_add_ring()

LWGEOM * wkt_parser_curvepolygon_add_ring ( LWGEOM poly,
LWGEOM ring 
)

Definition at line 585 of file lwin_wkt.c.

586{
587 LWDEBUG(4,"entered");
588
589 /* Toss error on null input */
590 if( ! (ring && poly) )
591 {
593 LWDEBUG(4,"inputs are null");
594 return NULL;
595 }
596
597 /* All the elements must agree on dimensionality */
598 if( FLAGS_NDIMS(poly->flags) != FLAGS_NDIMS(ring->flags) )
599 {
600 LWDEBUG(4,"dimensionality does not match");
601 lwgeom_free(ring);
602 lwgeom_free(poly);
604 return NULL;
605 }
606
607 /* Apply check for minimum number of points, if requested. */
609 {
610 uint32_t vertices_needed = 3;
611
612 if ( ring->type == LINETYPE )
613 vertices_needed = 4;
614
615 if (lwgeom_count_vertices(ring) < vertices_needed)
616 {
617 LWDEBUG(4,"number of points is incorrect");
618 lwgeom_free(ring);
619 lwgeom_free(poly);
621 return NULL;
622 }
623 }
624
625 /* Apply check for not closed rings, if requested. */
627 {
628 int is_closed = 1;
629 LWDEBUG(4,"checking ring closure");
630 switch ( ring->type )
631 {
632 case LINETYPE:
633 is_closed = lwline_is_closed(lwgeom_as_lwline(ring));
634 break;
635
636 case CIRCSTRINGTYPE:
638 break;
639
640 case COMPOUNDTYPE:
642 break;
643 }
644 if ( ! is_closed )
645 {
646 LWDEBUG(4,"ring is not closed");
647 lwgeom_free(ring);
648 lwgeom_free(poly);
650 return NULL;
651 }
652 }
653
655 {
656 LWDEBUG(4,"failed to add ring");
657 lwgeom_free(ring);
658 lwgeom_free(poly);
660 return NULL;
661 }
662
663 return poly;
664}
#define PARSER_ERROR_MIXDIMS
Definition liblwgeom.h:2175
#define COMPOUNDTYPE
Definition liblwgeom.h:110
#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 LINETYPE
Definition liblwgeom.h:103
#define PARSER_ERROR_MOREPOINTS
Definition liblwgeom.h:2172
#define PARSER_ERROR_OTHER
Definition liblwgeom.h:2181
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
Definition lwgeom.c:234
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition lwgeom.c:1337
#define FLAGS_NDIMS(flags)
Definition liblwgeom.h:179
LWCOMPOUND * lwgeom_as_lwcompound(const LWGEOM *lwgeom)
Definition lwgeom.c:225
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
Definition lwgeom.c:216
int lwcurvepoly_add_ring(LWCURVEPOLY *poly, LWGEOM *ring)
Add a ring, allocating extra space if necessary.
Definition lwcurvepoly.c:71
#define CIRCSTRINGTYPE
Definition liblwgeom.h:109
#define LW_PARSER_CHECK_MINPOINTS
Parser check flags.
Definition liblwgeom.h:2144
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition lwgeom.c:207
#define PARSER_ERROR_UNCLOSED
Definition liblwgeom.h:2174
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
int lwline_is_closed(const LWLINE *line)
Definition lwline.c:455
int lwcompound_is_closed(const LWCOMPOUND *curve)
Definition lwcompound.c:48
#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
uint8_t type
Definition liblwgeom.h:462
lwflags_t flags
Definition liblwgeom.h:461

References CIRCSTRINGTYPE, COMPOUNDTYPE, LWGEOM::flags, FLAGS_NDIMS, global_parser_result, LINETYPE, LW_FAILURE, LW_PARSER_CHECK_CLOSURE, LW_PARSER_CHECK_MINPOINTS, lwcircstring_is_closed(), lwcompound_is_closed(), lwcurvepoly_add_ring(), LWDEBUG, lwgeom_as_lwcircstring(), lwgeom_as_lwcompound(), lwgeom_as_lwcurvepoly(), lwgeom_as_lwline(), lwgeom_count_vertices(), lwgeom_free(), lwline_is_closed(), struct_lwgeom_parser_result::parser_check_flags, PARSER_ERROR_MIXDIMS, PARSER_ERROR_MOREPOINTS, PARSER_ERROR_OTHER, PARSER_ERROR_UNCLOSED, SET_PARSER_ERROR, and LWGEOM::type.

Referenced by wkt_parser_curvepolygon_new().

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