PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lwcollection_ngeoms ( const LWCOLLECTION col)

Definition at line 278 of file lwcollection.c.

References CIRCSTRINGTYPE, COLLECTIONTYPE, LWCOLLECTION::geoms, LINETYPE, lwerror(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, LWCOLLECTION::ngeoms, POINTTYPE, POLYGONTYPE, and LWGEOM::type.

279 {
280  int i;
281  int ngeoms = 0;
282 
283  if ( ! col )
284  {
285  lwerror("Null input geometry.");
286  return 0;
287  }
288 
289  for ( i = 0; i < col->ngeoms; i++ )
290  {
291  if ( col->geoms[i])
292  {
293  switch (col->geoms[i]->type)
294  {
295  case POINTTYPE:
296  case LINETYPE:
297  case CIRCSTRINGTYPE:
298  case POLYGONTYPE:
299  ngeoms += 1;
300  break;
301  case MULTIPOINTTYPE:
302  case MULTILINETYPE:
303  case MULTICURVETYPE:
304  case MULTIPOLYGONTYPE:
305  ngeoms += col->ngeoms;
306  break;
307  case COLLECTIONTYPE:
308  ngeoms += lwcollection_ngeoms((LWCOLLECTION*)col->geoms[i]);
309  break;
310  }
311  }
312  }
313  return ngeoms;
314 }
#define LINETYPE
Definition: liblwgeom.h:61
#define MULTICURVETYPE
Definition: liblwgeom.h:70
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
int lwcollection_ngeoms(const LWCOLLECTION *col)
Definition: lwcollection.c:278
LWGEOM ** geoms
Definition: liblwgeom.h:465
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
#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 COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function: