PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ 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 1036 of file lwgeom.c.

1037 {
1038  int type = geom->type;
1039 
1040  if( lwgeom_is_empty(geom) )
1041  return LW_FALSE;
1042 
1043  /* Test linear types for closure */
1044  switch (type)
1045  {
1046  case LINETYPE:
1047  return lwline_is_closed((LWLINE*)geom);
1048  case POLYGONTYPE:
1049  return lwpoly_is_closed((LWPOLY*)geom);
1050  case CIRCSTRINGTYPE:
1051  return lwcircstring_is_closed((LWCIRCSTRING*)geom);
1052  case COMPOUNDTYPE:
1053  return lwcompound_is_closed((LWCOMPOUND*)geom);
1054  case TINTYPE:
1055  return lwtin_is_closed((LWTIN*)geom);
1056  case POLYHEDRALSURFACETYPE:
1057  return lwpsurface_is_closed((LWPSURFACE*)geom);
1058  }
1059 
1060  /* Recurse into collections and see if anything is not closed */
1061  if ( lwgeom_is_collection(geom) )
1062  {
1063  LWCOLLECTION *col = lwgeom_as_lwcollection(geom);
1064  uint32_t i;
1065  int closed;
1066  for ( i = 0; i < col->ngeoms; i++ )
1067  {
1068  closed = lwgeom_is_closed(col->geoms[i]);
1069  if ( ! closed )
1070  return LW_FALSE;
1071  }
1072  return LW_TRUE;
1073  }
1074 
1075  /* All non-linear non-collection types we will call closed */
1076  return LW_TRUE;
1077 }
#define LW_FALSE
Definition: liblwgeom.h:108
#define COMPOUNDTYPE
Definition: liblwgeom.h:124
#define LINETYPE
Definition: liblwgeom.h:117
#define TINTYPE
Definition: liblwgeom.h:130
#define POLYGONTYPE
Definition: liblwgeom.h:118
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:128
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:123
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:107
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
Definition: lwcircstring.c:261
int lwline_is_closed(const LWLINE *line)
Definition: lwline.c:445
int lwcompound_is_closed(const LWCOMPOUND *curve)
Definition: lwcompound.c:35
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:499
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:1036
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1080
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:216
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:203
type
Definition: ovdump.py:42
uint32_t ngeoms
Definition: liblwgeom.h:594
LWGEOM ** geoms
Definition: liblwgeom.h:589
uint8_t type
Definition: liblwgeom.h:476

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, LWGEOM::type, and ovdump::type.

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

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