PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_dimensionality()

int lwgeom_dimensionality ( LWGEOM geom)

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

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

1412 {
1413  int dim;
1414 
1415  LWDEBUGF(3, "lwgeom_dimensionality got type %s",
1416  lwtype_name(geom->type));
1417 
1418  switch (geom->type)
1419  {
1420  case POINTTYPE:
1421  case MULTIPOINTTYPE:
1422  return 0;
1423  break;
1424  case LINETYPE:
1425  case CIRCSTRINGTYPE:
1426  case MULTILINETYPE:
1427  case COMPOUNDTYPE:
1428  case MULTICURVETYPE:
1429  return 1;
1430  break;
1431  case POLYGONTYPE:
1432  case TRIANGLETYPE:
1433  case CURVEPOLYTYPE:
1434  case MULTIPOLYGONTYPE:
1435  case MULTISURFACETYPE:
1436  return 2;
1437  break;
1438 
1439  case POLYHEDRALSURFACETYPE:
1440  case TINTYPE:
1441  dim = lwgeom_is_closed(geom)?3:2;
1442  return dim;
1443  break;
1444 
1445  case COLLECTIONTYPE:
1446  return lwcollection_dimensionality((LWCOLLECTION *)geom);
1447  break;
1448  default:
1449  lwerror("lwgeom_dimensionality: unsupported input geometry type: %s",
1450  lwtype_name(geom->type));
1451  break;
1452  }
1453  return 0;
1454 }
#define LINETYPE
Definition: liblwgeom.h:86
static int lwcollection_dimensionality(LWCOLLECTION *col)
Definition: lwgeom.c:1398
#define MULTICURVETYPE
Definition: liblwgeom.h:95
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
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
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:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define MULTILINETYPE
Definition: liblwgeom.h:89
#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:91
Here is the call graph for this function:
Here is the caller graph for this function: