PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwgeom_count_vertices()

int lwgeom_count_vertices ( const LWGEOM geom)

Count points in an LWGEOM.

Count the total number of vertices in any LWGEOM.

Definition at line 1140 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, TINTYPE, TRIANGLETYPE, LWGEOM::type, and LWCOLLECTION::type.

Referenced by _lwt_toposnap(), lwcollection_count_vertices(), lwcompound_get_lwpoint(), lwgeom_needs_bbox(), LWGEOM_npoints(), LWGEOM_numpoints_linestring(), lwgeom_subdivide_recursive(), test_lwgeom_count_vertices(), test_misc_count_vertices(), test_on_gser_lwgeom_count_vertices(), and wkt_parser_curvepolygon_add_ring().

1141 {
1142  int result = 0;
1143 
1144  /* Null? Zero. */
1145  if( ! geom ) return 0;
1146 
1147  LWDEBUGF(4, "lwgeom_count_vertices got type %s",
1148  lwtype_name(geom->type));
1149 
1150  /* Empty? Zero. */
1151  if( lwgeom_is_empty(geom) ) return 0;
1152 
1153  switch (geom->type)
1154  {
1155  case POINTTYPE:
1156  result = 1;
1157  break;
1158  case TRIANGLETYPE:
1159  case CIRCSTRINGTYPE:
1160  case LINETYPE:
1161  result = lwline_count_vertices((LWLINE *)geom);
1162  break;
1163  case POLYGONTYPE:
1164  result = lwpoly_count_vertices((LWPOLY *)geom);
1165  break;
1166  case COMPOUNDTYPE:
1167  case CURVEPOLYTYPE:
1168  case MULTICURVETYPE:
1169  case MULTISURFACETYPE:
1170  case MULTIPOINTTYPE:
1171  case MULTILINETYPE:
1172  case MULTIPOLYGONTYPE:
1173  case POLYHEDRALSURFACETYPE:
1174  case TINTYPE:
1175  case COLLECTIONTYPE:
1176  result = lwcollection_count_vertices((LWCOLLECTION *)geom);
1177  break;
1178  default:
1179  lwerror("%s: unsupported input geometry type: %s",
1180  __func__, lwtype_name(geom->type));
1181  break;
1182  }
1183  LWDEBUGF(3, "counted %d vertices", result);
1184  return result;
1185 }
#define LINETYPE
Definition: liblwgeom.h:71
int lwcollection_count_vertices(LWCOLLECTION *col)
Definition: lwcollection.c:494
#define MULTICURVETYPE
Definition: liblwgeom.h:80
int lwline_count_vertices(LWLINE *line)
Definition: lwline.c:504
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
#define TRIANGLETYPE
Definition: liblwgeom.h:83
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:82
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
#define TINTYPE
Definition: liblwgeom.h:84
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:1297
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
#define MULTISURFACETYPE
Definition: liblwgeom.h:81
#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
int lwpoly_count_vertices(LWPOLY *poly)
Definition: lwpoly.c:339
#define MULTILINETYPE
Definition: liblwgeom.h:74
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
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:
Here is the caller graph for this function: