PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwgeom_dimensionality()

int lwgeom_dimensionality ( LWGEOM geom)

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

Definition at line 1375 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().

1376 {
1377  int dim;
1378 
1379  LWDEBUGF(3, "lwgeom_dimensionality got type %s",
1380  lwtype_name(geom->type));
1381 
1382  switch (geom->type)
1383  {
1384  case POINTTYPE:
1385  case MULTIPOINTTYPE:
1386  return 0;
1387  break;
1388  case LINETYPE:
1389  case CIRCSTRINGTYPE:
1390  case MULTILINETYPE:
1391  case COMPOUNDTYPE:
1392  case MULTICURVETYPE:
1393  return 1;
1394  break;
1395  case POLYGONTYPE:
1396  case TRIANGLETYPE:
1397  case CURVEPOLYTYPE:
1398  case MULTIPOLYGONTYPE:
1399  case MULTISURFACETYPE:
1400  return 2;
1401  break;
1402 
1403  case POLYHEDRALSURFACETYPE:
1404  case TINTYPE:
1405  dim = lwgeom_is_closed(geom)?3:2;
1406  return dim;
1407  break;
1408 
1409  case COLLECTIONTYPE:
1410  return lwcollection_dimensionality((LWCOLLECTION *)geom);
1411  break;
1412  default:
1413  lwerror("lwgeom_dimensionality: unsupported input geometry type: %s",
1414  lwtype_name(geom->type));
1415  break;
1416  }
1417  return 0;
1418 }
#define LINETYPE
Definition: liblwgeom.h:85
static int lwcollection_dimensionality(LWCOLLECTION *col)
Definition: lwgeom.c:1362
#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:960
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:395
#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:102
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function:
Here is the caller graph for this function: