PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_count_vertices()

uint32_t lwgeom_count_vertices ( const LWGEOM geom)

Count points in an LWGEOM.

Count the total number of vertices in any LWGEOM.

TODO: Make sure the internal functions don't overflow

Definition at line 1235 of file lwgeom.c.

1236 {
1237  int result = 0;
1238 
1239  /* Null? Zero. */
1240  if( ! geom ) return 0;
1241 
1242  LWDEBUGF(4, "lwgeom_count_vertices got type %s",
1243  lwtype_name(geom->type));
1244 
1245  /* Empty? Zero. */
1246  if( lwgeom_is_empty(geom) ) return 0;
1247 
1248  switch (geom->type)
1249  {
1250  case POINTTYPE:
1251  result = 1;
1252  break;
1253  case TRIANGLETYPE:
1254  case CIRCSTRINGTYPE:
1255  case LINETYPE:
1256  result = lwline_count_vertices((LWLINE *)geom);
1257  break;
1258  case POLYGONTYPE:
1259  result = lwpoly_count_vertices((LWPOLY *)geom);
1260  break;
1261  case COMPOUNDTYPE:
1262  case CURVEPOLYTYPE:
1263  case MULTICURVETYPE:
1264  case MULTISURFACETYPE:
1265  case MULTIPOINTTYPE:
1266  case MULTILINETYPE:
1267  case MULTIPOLYGONTYPE:
1268  case POLYHEDRALSURFACETYPE:
1269  case TINTYPE:
1270  case COLLECTIONTYPE:
1271  result = lwcollection_count_vertices((LWCOLLECTION *)geom);
1272  break;
1273  default:
1274  lwerror("%s: unsupported input geometry type: %s",
1275  __func__, lwtype_name(geom->type));
1276  break;
1277  }
1278  LWDEBUGF(3, "counted %d vertices", result);
1279  return result;
1280 }
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#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 TINTYPE
Definition: liblwgeom.h:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define MULTICURVETYPE
Definition: liblwgeom.h:95
#define TRIANGLETYPE
Definition: liblwgeom.h:98
uint32_t lwpoly_count_vertices(LWPOLY *poly)
Definition: lwpoly.c:425
uint32_t lwcollection_count_vertices(LWCOLLECTION *col)
Definition: lwcollection.c:521
uint32_t lwline_count_vertices(LWLINE *line)
Definition: lwline.c:519
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:1393
#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
uint8_t type
Definition: liblwgeom.h:399

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 LWLINE::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().

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