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

◆ lwgeom_is_closed()

int lwgeom_is_closed ( const LWGEOM geom)

Return true or false depending on whether a geometry is a linear feature that closes on itself.

Definition at line 1081 of file lwgeom.c.

1082{
1083 int type = geom->type;
1084
1085 if( lwgeom_is_empty(geom) )
1086 return LW_FALSE;
1087
1088 /* Test linear types for closure */
1089 switch (type)
1090 {
1091 case LINETYPE:
1092 return lwline_is_closed((LWLINE*)geom);
1093 case POLYGONTYPE:
1094 return lwpoly_is_closed((LWPOLY*)geom);
1095 case CIRCSTRINGTYPE:
1096 return lwcircstring_is_closed((LWCIRCSTRING*)geom);
1097 case COMPOUNDTYPE:
1098 return lwcompound_is_closed((LWCOMPOUND*)geom);
1099 case TINTYPE:
1100 return lwtin_is_closed((LWTIN*)geom);
1102 return lwpsurface_is_closed((LWPSURFACE*)geom);
1103 }
1104
1105 /* Recurse into collections and see if anything is not closed */
1106 if ( lwgeom_is_collection(geom) )
1107 {
1109 uint32_t i;
1110 int closed;
1111 for ( i = 0; i < col->ngeoms; i++ )
1112 {
1113 closed = lwgeom_is_closed(col->geoms[i]);
1114 if ( ! closed )
1115 return LW_FALSE;
1116 }
1117 return LW_TRUE;
1118 }
1119
1120 /* All non-linear non-collection types we will call closed */
1121 return LW_TRUE;
1122}
#define LW_FALSE
Definition liblwgeom.h:94
#define COMPOUNDTYPE
Definition liblwgeom.h:110
#define LINETYPE
Definition liblwgeom.h:103
#define TINTYPE
Definition liblwgeom.h:116
#define POLYGONTYPE
Definition liblwgeom.h:104
#define POLYHEDRALSURFACETYPE
Definition liblwgeom.h:114
#define CIRCSTRINGTYPE
Definition liblwgeom.h:109
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
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
int lwpsurface_is_closed(const LWPSURFACE *psurface)
Definition lwpsurface.c:99
int lwtin_is_closed(const LWTIN *tin)
Definition lwtin.c:93
int lwpoly_is_closed(const LWPOLY *poly)
Definition lwpoly.c:498
int lwgeom_is_closed(const LWGEOM *geom)
Return true or false depending on whether a geometry is a linear feature that closes on itself.
Definition lwgeom.c:1081
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM contains sub-geometries or not This basically just checks that the struct ...
Definition lwgeom.c:1125
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition lwgeom.c:261
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:199
uint32_t ngeoms
Definition liblwgeom.h:580
LWGEOM ** geoms
Definition liblwgeom.h:575
uint8_t type
Definition liblwgeom.h:462

References CIRCSTRINGTYPE, COMPOUNDTYPE, LWCOLLECTION::geoms, LINETYPE, LW_FALSE, LW_TRUE, lwcircstring_is_closed(), lwcompound_is_closed(), lwgeom_as_lwcollection(), lwgeom_is_closed(), lwgeom_is_collection(), lwgeom_is_empty(), lwline_is_closed(), lwpoly_is_closed(), lwpsurface_is_closed(), lwtin_is_closed(), LWCOLLECTION::ngeoms, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, and LWGEOM::type.

Referenced by lwgeom_boundary(), lwgeom_dimensionality(), lwgeom_is_closed(), and LWGEOM_isclosed().

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