PostGIS  2.3.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 1153 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_calculate_mbc(), lwgeom_needs_bbox(), LWGEOM_npoints(), LWGEOM_numpoints_linestring(), LWGEOM_pointn_linestring(), lwgeom_subdivide_recursive(), lwgeom_voronoi_diagram(), test_lwgeom_count_vertices(), test_lwpoly_construct_circle(), test_misc_count_vertices(), test_on_gser_lwgeom_count_vertices(), test_point_count(), and wkt_parser_curvepolygon_add_ring().

1154 {
1155  int result = 0;
1156 
1157  /* Null? Zero. */
1158  if( ! geom ) return 0;
1159 
1160  LWDEBUGF(4, "lwgeom_count_vertices got type %s",
1161  lwtype_name(geom->type));
1162 
1163  /* Empty? Zero. */
1164  if( lwgeom_is_empty(geom) ) return 0;
1165 
1166  switch (geom->type)
1167  {
1168  case POINTTYPE:
1169  result = 1;
1170  break;
1171  case TRIANGLETYPE:
1172  case CIRCSTRINGTYPE:
1173  case LINETYPE:
1174  result = lwline_count_vertices((LWLINE *)geom);
1175  break;
1176  case POLYGONTYPE:
1177  result = lwpoly_count_vertices((LWPOLY *)geom);
1178  break;
1179  case COMPOUNDTYPE:
1180  case CURVEPOLYTYPE:
1181  case MULTICURVETYPE:
1182  case MULTISURFACETYPE:
1183  case MULTIPOINTTYPE:
1184  case MULTILINETYPE:
1185  case MULTIPOLYGONTYPE:
1186  case POLYHEDRALSURFACETYPE:
1187  case TINTYPE:
1188  case COLLECTIONTYPE:
1189  result = lwcollection_count_vertices((LWCOLLECTION *)geom);
1190  break;
1191  default:
1192  lwerror("%s: unsupported input geometry type: %s",
1193  __func__, lwtype_name(geom->type));
1194  break;
1195  }
1196  LWDEBUGF(3, "counted %d vertices", result);
1197  return result;
1198 }
#define LINETYPE
Definition: liblwgeom.h:85
int lwcollection_count_vertices(LWCOLLECTION *col)
Definition: lwcollection.c:507
#define MULTICURVETYPE
Definition: liblwgeom.h:94
int lwline_count_vertices(LWLINE *line)
Definition: lwline.c:533
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
#define MULTIPOINTTYPE
Definition: liblwgeom.h:87
#define TRIANGLETYPE
Definition: liblwgeom.h:97
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:96
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
#define TINTYPE
Definition: liblwgeom.h:98
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:1310
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:395
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
int lwpoly_count_vertices(LWPOLY *poly)
Definition: lwpoly.c:412
#define MULTILINETYPE
Definition: liblwgeom.h:88
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function:
Here is the caller graph for this function: