PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwcollection_ngeoms()

int lwcollection_ngeoms ( const LWCOLLECTION col)

Definition at line 301 of file lwcollection.c.

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

302 {
303  int i;
304  int ngeoms = 0;
305 
306  if ( ! col )
307  {
308  lwerror("Null input geometry.");
309  return 0;
310  }
311 
312  for ( i = 0; i < col->ngeoms; i++ )
313  {
314  if ( col->geoms[i])
315  {
316  switch (col->geoms[i]->type)
317  {
318  case POINTTYPE:
319  case LINETYPE:
320  case CIRCSTRINGTYPE:
321  case POLYGONTYPE:
322  ngeoms += 1;
323  break;
324  case MULTIPOINTTYPE:
325  case MULTILINETYPE:
326  case MULTICURVETYPE:
327  case MULTIPOLYGONTYPE:
328  ngeoms += col->ngeoms;
329  break;
330  case COLLECTIONTYPE:
331  ngeoms += lwcollection_ngeoms((LWCOLLECTION*)col->geoms[i]);
332  break;
333  }
334  }
335  }
336  return ngeoms;
337 }
#define LINETYPE
Definition: liblwgeom.h:85
#define MULTICURVETYPE
Definition: liblwgeom.h:94
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
int lwcollection_ngeoms(const LWCOLLECTION *col)
Definition: lwcollection.c:301
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:102
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function: