PostGIS  2.4.9dev-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 1189 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().

1190 {
1191  int result = 0;
1192 
1193  /* Null? Zero. */
1194  if( ! geom ) return 0;
1195 
1196  LWDEBUGF(4, "lwgeom_count_vertices got type %s",
1197  lwtype_name(geom->type));
1198 
1199  /* Empty? Zero. */
1200  if( lwgeom_is_empty(geom) ) return 0;
1201 
1202  switch (geom->type)
1203  {
1204  case POINTTYPE:
1205  result = 1;
1206  break;
1207  case TRIANGLETYPE:
1208  case CIRCSTRINGTYPE:
1209  case LINETYPE:
1210  result = lwline_count_vertices((LWLINE *)geom);
1211  break;
1212  case POLYGONTYPE:
1213  result = lwpoly_count_vertices((LWPOLY *)geom);
1214  break;
1215  case COMPOUNDTYPE:
1216  case CURVEPOLYTYPE:
1217  case MULTICURVETYPE:
1218  case MULTISURFACETYPE:
1219  case MULTIPOINTTYPE:
1220  case MULTILINETYPE:
1221  case MULTIPOLYGONTYPE:
1222  case POLYHEDRALSURFACETYPE:
1223  case TINTYPE:
1224  case COLLECTIONTYPE:
1225  result = lwcollection_count_vertices((LWCOLLECTION *)geom);
1226  break;
1227  default:
1228  lwerror("%s: unsupported input geometry type: %s",
1229  __func__, lwtype_name(geom->type));
1230  break;
1231  }
1232  LWDEBUGF(3, "counted %d vertices", result);
1233  return result;
1234 }
#define LINETYPE
Definition: liblwgeom.h:86
int lwcollection_count_vertices(LWCOLLECTION *col)
Definition: lwcollection.c:514
#define MULTICURVETYPE
Definition: liblwgeom.h:95
int lwline_count_vertices(LWLINE *line)
Definition: lwline.c:533
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define TINTYPE
Definition: liblwgeom.h:99
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:1346
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#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
int lwpoly_count_vertices(LWPOLY *poly)
Definition: lwpoly.c:452
#define MULTILINETYPE
Definition: liblwgeom.h:89
#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:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: