PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwcollection_ngeoms()

int lwcollection_ngeoms ( const LWCOLLECTION col)

Definition at line 318 of file lwcollection.c.

319 {
320  uint32_t i;
321  int ngeoms = 0;
322 
323  if ( ! col )
324  {
325  lwerror("Null input geometry.");
326  return 0;
327  }
328 
329  for ( i = 0; i < col->ngeoms; i++ )
330  {
331  if ( col->geoms[i])
332  {
333  switch (col->geoms[i]->type)
334  {
335  case POINTTYPE:
336  case LINETYPE:
337  case CIRCSTRINGTYPE:
338  case POLYGONTYPE:
339  ngeoms += 1;
340  break;
341  case MULTIPOINTTYPE:
342  case MULTILINETYPE:
343  case MULTICURVETYPE:
344  case MULTIPOLYGONTYPE:
345  ngeoms += col->ngeoms;
346  break;
347  case COLLECTIONTYPE:
348  ngeoms += lwcollection_ngeoms((LWCOLLECTION*)col->geoms[i]);
349  break;
350  }
351  }
352  }
353  return ngeoms;
354 }
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define MULTICURVETYPE
Definition: liblwgeom.h:95
int lwcollection_ngeoms(const LWCOLLECTION *col)
Definition: lwcollection.c:318
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
uint32_t ngeoms
Definition: liblwgeom.h:510
LWGEOM ** geoms
Definition: liblwgeom.h:512
uint8_t type
Definition: liblwgeom.h:399
unsigned int uint32_t
Definition: uthash.h:78

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

Referenced by lwcollection_ngeoms().

Here is the call graph for this function:
Here is the caller graph for this function: