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

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

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

1295 {
1296  int dim;
1297 
1298  LWDEBUGF(3, "lwgeom_dimensionality got type %s",
1299  lwtype_name(geom->type));
1300 
1301  switch (geom->type)
1302  {
1303  case POINTTYPE:
1304  case MULTIPOINTTYPE:
1305  return 0;
1306  break;
1307  case LINETYPE:
1308  case CIRCSTRINGTYPE:
1309  case MULTILINETYPE:
1310  case COMPOUNDTYPE:
1311  case MULTICURVETYPE:
1312  return 1;
1313  break;
1314  case POLYGONTYPE:
1315  case TRIANGLETYPE:
1316  case CURVEPOLYTYPE:
1317  case MULTIPOLYGONTYPE:
1318  case MULTISURFACETYPE:
1319  return 2;
1320  break;
1321 
1322  case POLYHEDRALSURFACETYPE:
1323  case TINTYPE:
1324  dim = lwgeom_is_closed(geom)?3:2;
1325  return dim;
1326  break;
1327 
1328  case COLLECTIONTYPE:
1329  return lwcollection_dimensionality((LWCOLLECTION *)geom);
1330  break;
1331  default:
1332  lwerror("lwgeom_dimensionality: unsupported input geometry type: %s",
1333  lwtype_name(geom->type));
1334  break;
1335  }
1336  return 0;
1337 }
#define LINETYPE
Definition: liblwgeom.h:61
static int lwcollection_dimensionality(LWCOLLECTION *col)
Definition: lwgeom.c:1281
#define MULTICURVETYPE
Definition: liblwgeom.h:70
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
#define TRIANGLETYPE
Definition: liblwgeom.h:73
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:72
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:903
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
#define TINTYPE
Definition: liblwgeom.h:74
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
#define MULTISURFACETYPE
Definition: liblwgeom.h:71
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
#define MULTILINETYPE
Definition: liblwgeom.h:64
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: