PostGIS  2.4.9dev-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 996 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().

997 {
998  int type = geom->type;
1000  if( lwgeom_is_empty(geom) )
1001  return LW_FALSE;
1003  /* Test linear types for closure */
1004  switch (type)
1005  {
1006  case LINETYPE:
1007  return lwline_is_closed((LWLINE*)geom);
1008  case POLYGONTYPE:
1009  return lwpoly_is_closed((LWPOLY*)geom);
1011  return lwcircstring_is_closed((LWCIRCSTRING*)geom);
1012  case COMPOUNDTYPE:
1013  return lwcompound_is_closed((LWCOMPOUND*)geom);
1014  case TINTYPE:
1015  return lwtin_is_closed((LWTIN*)geom);
1017  return lwpsurface_is_closed((LWPSURFACE*)geom);
1018  }
1020  /* Recurse into collections and see if anything is not closed */
1021  if ( lwgeom_is_collection(geom) )
1022  {
1023  LWCOLLECTION *col = lwgeom_as_lwcollection(geom);
1024  int i;
1025  int closed;
1026  for ( i = 0; i < col->ngeoms; i++ )
1027  {
1028  closed = lwgeom_is_closed(col->geoms[i]);
1029  if ( ! closed )
1030  return LW_FALSE;
1031  }
1032  return LW_TRUE;
1033  }
1035  /* All non-linear non-collection types we will call closed */
1036  return LW_TRUE;
1037 }
#define LINETYPE
Definition: liblwgeom.h:86
int lwtin_is_closed(const LWTIN *tin)
Definition: lwtin.c:93
Definition: liblwgeom.h:87
Definition: liblwgeom.h:93
Definition: liblwgeom.h:97
int lwcompound_is_closed(const LWCOMPOUND *curve)
Definition: lwcompound.c:35
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:996
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
LWGEOM ** geoms
Definition: liblwgeom.h:509
int lwpoly_is_closed(const LWPOLY *poly)
Definition: lwpoly.c:589
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
Definition: lwcircstring.c:268
#define TINTYPE
Definition: liblwgeom.h:99
int lwpsurface_is_closed(const LWPSURFACE *psurface)
Definition: lwpsurface.c:99
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:192
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:1346
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1040
int lwline_is_closed(const LWLINE *line)
Definition: lwline.c:468
uint8_t type
Definition: liblwgeom.h:396
Definition: liblwgeom.h:92
Here is the call graph for this function:
Here is the caller graph for this function: