PostGIS  2.2.8dev-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 947 of file lwgeom.c.

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

Referenced by lwgeom_dimensionality(), and LWGEOM_isclosed().

948 {
949  int type = geom->type;
950 
951  if( lwgeom_is_empty(geom) )
952  return LW_FALSE;
953 
954  /* Test linear types for closure */
955  switch (type)
956  {
957  case LINETYPE:
958  return lwline_is_closed((LWLINE*)geom);
959  case POLYGONTYPE:
960  return lwpoly_is_closed((LWPOLY*)geom);
961  case CIRCSTRINGTYPE:
962  return lwcircstring_is_closed((LWCIRCSTRING*)geom);
963  case COMPOUNDTYPE:
964  return lwcompound_is_closed((LWCOMPOUND*)geom);
965  case TINTYPE:
966  return lwtin_is_closed((LWTIN*)geom);
968  return lwpsurface_is_closed((LWPSURFACE*)geom);
969  }
970 
971  /* Recurse into collections and see if anything is not closed */
972  if ( lwgeom_is_collection(geom) )
973  {
975  int i;
976  int closed;
977  for ( i = 0; i < col->ngeoms; i++ )
978  {
979  closed = lwgeom_is_closed(col->geoms[i]);
980  if ( ! closed )
981  return LW_FALSE;
982  }
983  return LW_TRUE;
984  }
985 
986  /* All non-linear non-collection types we will call closed */
987  return LW_TRUE;
988 }
#define LINETYPE
Definition: liblwgeom.h:71
int lwtin_is_closed(const LWTIN *tin)
Definition: lwtin.c:80
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:82
int lwcompound_is_closed(const LWCOMPOUND *curve)
Definition: lwcompound.c:22
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:947
#define LW_FALSE
Definition: liblwgeom.h:62
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
LWGEOM ** geoms
Definition: liblwgeom.h:493
int lwpoly_is_closed(const LWPOLY *poly)
Definition: lwpoly.c:476
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
Definition: lwcircstring.c:255
#define TINTYPE
Definition: liblwgeom.h:84
int lwpsurface_is_closed(const LWPSURFACE *psurface)
Definition: lwpsurface.c:86
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:143
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1297
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:991
int lwline_is_closed(const LWLINE *line)
Definition: lwline.c:439
uint8_t type
Definition: liblwgeom.h:380
type
Definition: ovdump.py:41
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
Here is the call graph for this function:
Here is the caller graph for this function: