PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwcollection_ngeoms()

int lwcollection_ngeoms ( const LWCOLLECTION col)

Definition at line 302 of file lwcollection.c.

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

303 {
304  int i;
305  int ngeoms = 0;
306 
307  if ( ! col )
308  {
309  lwerror("Null input geometry.");
310  return 0;
311  }
312 
313  for ( i = 0; i < col->ngeoms; i++ )
314  {
315  if ( col->geoms[i])
316  {
317  switch (col->geoms[i]->type)
318  {
319  case POINTTYPE:
320  case LINETYPE:
321  case CIRCSTRINGTYPE:
322  case POLYGONTYPE:
323  ngeoms += 1;
324  break;
325  case MULTIPOINTTYPE:
326  case MULTILINETYPE:
327  case MULTICURVETYPE:
328  case MULTIPOLYGONTYPE:
329  ngeoms += col->ngeoms;
330  break;
331  case COLLECTIONTYPE:
332  ngeoms += lwcollection_ngeoms((LWCOLLECTION*)col->geoms[i]);
333  break;
334  }
335  }
336  }
337  return ngeoms;
338 }
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTICURVETYPE
Definition: liblwgeom.h:95
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
int lwcollection_ngeoms(const LWCOLLECTION *col)
Definition: lwcollection.c:302
LWGEOM ** geoms
Definition: liblwgeom.h:509
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define MULTILINETYPE
Definition: liblwgeom.h:89
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function: