PostGIS  2.5.0beta2dev-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 1041 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().

1042 {
1043  int type = geom->type;
1044 
1045  if( lwgeom_is_empty(geom) )
1046  return LW_FALSE;
1047 
1048  /* Test linear types for closure */
1049  switch (type)
1050  {
1051  case LINETYPE:
1052  return lwline_is_closed((LWLINE*)geom);
1053  case POLYGONTYPE:
1054  return lwpoly_is_closed((LWPOLY*)geom);
1055  case CIRCSTRINGTYPE:
1056  return lwcircstring_is_closed((LWCIRCSTRING*)geom);
1057  case COMPOUNDTYPE:
1058  return lwcompound_is_closed((LWCOMPOUND*)geom);
1059  case TINTYPE:
1060  return lwtin_is_closed((LWTIN*)geom);
1061  case POLYHEDRALSURFACETYPE:
1062  return lwpsurface_is_closed((LWPSURFACE*)geom);
1063  }
1064 
1065  /* Recurse into collections and see if anything is not closed */
1066  if ( lwgeom_is_collection(geom) )
1067  {
1068  LWCOLLECTION *col = lwgeom_as_lwcollection(geom);
1069  uint32_t i;
1070  int closed;
1071  for ( i = 0; i < col->ngeoms; i++ )
1072  {
1073  closed = lwgeom_is_closed(col->geoms[i]);
1074  if ( ! closed )
1075  return LW_FALSE;
1076  }
1077  return LW_TRUE;
1078  }
1079 
1080  /* All non-linear non-collection types we will call closed */
1081  return LW_TRUE;
1082 }
#define LINETYPE
Definition: liblwgeom.h:85
int lwtin_is_closed(const LWTIN *tin)
Definition: lwtin.c:93
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:96
int lwcompound_is_closed(const LWCOMPOUND *curve)
Definition: lwcompound.c:35
uint32_t ngeoms
Definition: liblwgeom.h:509
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:1041
unsigned int uint32_t
Definition: uthash.h:78
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
LWGEOM ** geoms
Definition: liblwgeom.h:511
int lwpoly_is_closed(const LWPOLY *poly)
Definition: lwpoly.c:506
int lwcircstring_is_closed(const LWCIRCSTRING *curve)
Definition: lwcircstring.c:261
#define TINTYPE
Definition: liblwgeom.h:98
int lwpsurface_is_closed(const LWPSURFACE *psurface)
Definition: lwpsurface.c:99
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:224
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:1393
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1085
int lwline_is_closed(const LWLINE *line)
Definition: lwline.c:454
uint8_t type
Definition: liblwgeom.h:398
type
Definition: ovdump.py:41
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: