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

Definition at line 304 of file lwcollection.c.

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

305 {
306  uint32_t i;
307  int ngeoms = 0;
308 
309  if ( ! col )
310  {
311  lwerror("Null input geometry.");
312  return 0;
313  }
314 
315  for ( i = 0; i < col->ngeoms; i++ )
316  {
317  if ( col->geoms[i])
318  {
319  switch (col->geoms[i]->type)
320  {
321  case POINTTYPE:
322  case LINETYPE:
323  case CIRCSTRINGTYPE:
324  case POLYGONTYPE:
325  ngeoms += 1;
326  break;
327  case MULTIPOINTTYPE:
328  case MULTILINETYPE:
329  case MULTICURVETYPE:
330  case MULTIPOLYGONTYPE:
331  ngeoms += col->ngeoms;
332  break;
333  case COLLECTIONTYPE:
334  ngeoms += lwcollection_ngeoms((LWCOLLECTION*)col->geoms[i]);
335  break;
336  }
337  }
338  }
339  return ngeoms;
340 }
#define LINETYPE
Definition: liblwgeom.h:85
#define MULTICURVETYPE
Definition: liblwgeom.h:94
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
uint32_t ngeoms
Definition: liblwgeom.h:506
unsigned int uint32_t
Definition: uthash.h:78
int lwcollection_ngeoms(const LWCOLLECTION *col)
Definition: lwcollection.c:304
LWGEOM ** geoms
Definition: liblwgeom.h:508
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
#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
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:90

Here is the call graph for this function: