PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwcollection_ngeoms()

int lwcollection_ngeoms ( const LWCOLLECTION col)

Definition at line 288 of file lwcollection.c.

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

289 {
290  int i;
291  int ngeoms = 0;
292 
293  if ( ! col )
294  {
295  lwerror("Null input geometry.");
296  return 0;
297  }
298 
299  for ( i = 0; i < col->ngeoms; i++ )
300  {
301  if ( col->geoms[i])
302  {
303  switch (col->geoms[i]->type)
304  {
305  case POINTTYPE:
306  case LINETYPE:
307  case CIRCSTRINGTYPE:
308  case POLYGONTYPE:
309  ngeoms += 1;
310  break;
311  case MULTIPOINTTYPE:
312  case MULTILINETYPE:
313  case MULTICURVETYPE:
314  case MULTIPOLYGONTYPE:
315  ngeoms += col->ngeoms;
316  break;
317  case COLLECTIONTYPE:
318  ngeoms += lwcollection_ngeoms((LWCOLLECTION*)col->geoms[i]);
319  break;
320  }
321  }
322  }
323  return ngeoms;
324 }
#define LINETYPE
Definition: liblwgeom.h:71
#define MULTICURVETYPE
Definition: liblwgeom.h:80
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
int lwcollection_ngeoms(const LWCOLLECTION *col)
Definition: lwcollection.c:288
LWGEOM ** geoms
Definition: liblwgeom.h:493
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
#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
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: