PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ lwgeom_dimensionality()

int lwgeom_dimensionality ( const LWGEOM geom)

Return the dimensionality (relating to point/line/poly) of an lwgeom.

Definition at line 1458 of file lwgeom.c.

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LINETYPE, lwcollection_dimensionality(), LWDEBUGF, lwerror(), lwgeom_is_closed(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, LWGEOM::type, and LWCOLLECTION::type.

Referenced by check_dimension(), lwcollection_dimensionality(), and lwgeom_clean().

1459 {
1460  int dim;
1461 
1462  LWDEBUGF(3, "lwgeom_dimensionality got type %s",
1463  lwtype_name(geom->type));
1464 
1465  switch (geom->type)
1466  {
1467  case POINTTYPE:
1468  case MULTIPOINTTYPE:
1469  return 0;
1470  break;
1471  case LINETYPE:
1472  case CIRCSTRINGTYPE:
1473  case MULTILINETYPE:
1474  case COMPOUNDTYPE:
1475  case MULTICURVETYPE:
1476  return 1;
1477  break;
1478  case POLYGONTYPE:
1479  case TRIANGLETYPE:
1480  case CURVEPOLYTYPE:
1481  case MULTIPOLYGONTYPE:
1482  case MULTISURFACETYPE:
1483  return 2;
1484  break;
1485 
1486  case POLYHEDRALSURFACETYPE:
1487  case TINTYPE:
1488  dim = lwgeom_is_closed(geom)?3:2;
1489  return dim;
1490  break;
1491 
1492  case COLLECTIONTYPE:
1493  return lwcollection_dimensionality((const LWCOLLECTION *)geom);
1494  break;
1495  default:
1496  lwerror("lwgeom_dimensionality: unsupported input geometry type: %s",
1497  lwtype_name(geom->type));
1498  break;
1499  }
1500  return 0;
1501 }
#define LINETYPE
Definition: liblwgeom.h:85
#define MULTICURVETYPE
Definition: liblwgeom.h:94
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
#define TRIANGLETYPE
Definition: liblwgeom.h:97
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:96
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
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define TINTYPE
Definition: liblwgeom.h:98
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:398
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
#define MULTILINETYPE
Definition: liblwgeom.h:88
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
static int lwcollection_dimensionality(const LWCOLLECTION *col)
Definition: lwgeom.c:1445
Here is the call graph for this function:
Here is the caller graph for this function: