PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lwgeom_count_vertices ( const LWGEOM geom)

Count the total number of vertices in any LWGEOM.

Count the total number of vertices in any LWGEOM.

Definition at line 1072 of file lwgeom.c.

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LINETYPE, lwcollection_count_vertices(), LWDEBUGF, lwerror(), lwgeom_is_empty(), lwline_count_vertices(), lwpoly_count_vertices(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, result, TINTYPE, TRIANGLETYPE, and LWGEOM::type.

Referenced by lwcollection_count_vertices(), LWGEOM_npoints(), LWGEOM_numpoints_linestring(), test_lwgeom_count_vertices(), test_misc_count_vertices(), test_on_gser_lwgeom_count_vertices(), and wkt_parser_curvepolygon_add_ring().

1073 {
1074  int result = 0;
1075 
1076  /* Null? Zero. */
1077  if( ! geom ) return 0;
1078 
1079  LWDEBUGF(4, "lwgeom_count_vertices got type %s",
1080  lwtype_name(geom->type));
1081 
1082  /* Empty? Zero. */
1083  if( lwgeom_is_empty(geom) ) return 0;
1084 
1085  switch (geom->type)
1086  {
1087  case POINTTYPE:
1088  result = 1;
1089  break;
1090  case TRIANGLETYPE:
1091  case CIRCSTRINGTYPE:
1092  case LINETYPE:
1093  result = lwline_count_vertices((LWLINE *)geom);
1094  break;
1095  case POLYGONTYPE:
1096  result = lwpoly_count_vertices((LWPOLY *)geom);
1097  break;
1098  case COMPOUNDTYPE:
1099  case CURVEPOLYTYPE:
1100  case MULTICURVETYPE:
1101  case MULTISURFACETYPE:
1102  case MULTIPOINTTYPE:
1103  case MULTILINETYPE:
1104  case MULTIPOLYGONTYPE:
1105  case POLYHEDRALSURFACETYPE:
1106  case TINTYPE:
1107  case COLLECTIONTYPE:
1108  result = lwcollection_count_vertices((LWCOLLECTION *)geom);
1109  break;
1110  default:
1111  lwerror("lwgeom_count_vertices: unsupported input geometry type: %s",
1112  lwtype_name(geom->type));
1113  break;
1114  }
1115  LWDEBUGF(3, "counted %d vertices", result);
1116  return result;
1117 }
#define LINETYPE
Definition: liblwgeom.h:61
int lwcollection_count_vertices(LWCOLLECTION *col)
Definition: lwcollection.c:484
#define MULTICURVETYPE
Definition: liblwgeom.h:70
int lwline_count_vertices(LWLINE *line)
Definition: lwline.c:472
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
#define TRIANGLETYPE
Definition: liblwgeom.h:73
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:72
char ** result
Definition: liblwgeom.h:218
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
#define TINTYPE
Definition: liblwgeom.h:74
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1229
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
#define MULTISURFACETYPE
Definition: liblwgeom.h:71
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
int lwpoly_count_vertices(LWPOLY *poly)
Definition: lwpoly.c:334
#define MULTILINETYPE
Definition: liblwgeom.h:64
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: