PostGIS  2.2.7dev-r@@SVN_REVISION@@
int lwgeom_dimensionality ( LWGEOM geom)

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

Definition at line 1362 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, and LWGEOM::type.

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

1363 {
1364  int dim;
1365 
1366  LWDEBUGF(3, "lwgeom_dimensionality got type %s",
1367  lwtype_name(geom->type));
1368 
1369  switch (geom->type)
1370  {
1371  case POINTTYPE:
1372  case MULTIPOINTTYPE:
1373  return 0;
1374  break;
1375  case LINETYPE:
1376  case CIRCSTRINGTYPE:
1377  case MULTILINETYPE:
1378  case COMPOUNDTYPE:
1379  case MULTICURVETYPE:
1380  return 1;
1381  break;
1382  case POLYGONTYPE:
1383  case TRIANGLETYPE:
1384  case CURVEPOLYTYPE:
1385  case MULTIPOLYGONTYPE:
1386  case MULTISURFACETYPE:
1387  return 2;
1388  break;
1389 
1390  case POLYHEDRALSURFACETYPE:
1391  case TINTYPE:
1392  dim = lwgeom_is_closed(geom)?3:2;
1393  return dim;
1394  break;
1395 
1396  case COLLECTIONTYPE:
1397  return lwcollection_dimensionality((LWCOLLECTION *)geom);
1398  break;
1399  default:
1400  lwerror("lwgeom_dimensionality: unsupported input geometry type: %s",
1401  lwtype_name(geom->type));
1402  break;
1403  }
1404  return 0;
1405 }
#define LINETYPE
Definition: liblwgeom.h:71
static int lwcollection_dimensionality(LWCOLLECTION *col)
Definition: lwgeom.c:1349
#define MULTICURVETYPE
Definition: liblwgeom.h:80
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
#define TRIANGLETYPE
Definition: liblwgeom.h:83
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:82
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:947
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
#define TINTYPE
Definition: liblwgeom.h:84
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
#define MULTISURFACETYPE
Definition: liblwgeom.h:81
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
#define MULTILINETYPE
Definition: liblwgeom.h:74
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76

Here is the call graph for this function:

Here is the caller graph for this function: