PostGIS  3.0.0dev-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 1399 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().

1400 {
1401  int dim;
1402 
1403  LWDEBUGF(3, "lwgeom_dimensionality got type %s",
1404  lwtype_name(geom->type));
1405 
1406  switch (geom->type)
1407  {
1408  case POINTTYPE:
1409  case MULTIPOINTTYPE:
1410  return 0;
1411  break;
1412  case LINETYPE:
1413  case CIRCSTRINGTYPE:
1414  case MULTILINETYPE:
1415  case COMPOUNDTYPE:
1416  case MULTICURVETYPE:
1417  return 1;
1418  break;
1419  case POLYGONTYPE:
1420  case TRIANGLETYPE:
1421  case CURVEPOLYTYPE:
1422  case MULTIPOLYGONTYPE:
1423  case MULTISURFACETYPE:
1424  return 2;
1425  break;
1426 
1427  case POLYHEDRALSURFACETYPE:
1428  case TINTYPE:
1429  dim = lwgeom_is_closed(geom)?3:2;
1430  return dim;
1431  break;
1432 
1433  case COLLECTIONTYPE:
1434  return lwcollection_dimensionality((const LWCOLLECTION *)geom);
1435  break;
1436  default:
1437  lwerror("lwgeom_dimensionality: unsupported input geometry type: %s",
1438  lwtype_name(geom->type));
1439  break;
1440  }
1441  return 0;
1442 }
#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:1025
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
#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:1386
Here is the call graph for this function:
Here is the caller graph for this function: