PostGIS  3.4.0dev-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 1246 of file lwgeom.c.

1247 {
1248  int result = 0;
1249 
1250  /* Null? Zero. */
1251  if( ! geom ) return 0;
1252 
1253  LWDEBUGF(4, "lwgeom_count_vertices got type %s",
1254  lwtype_name(geom->type));
1255 
1256  /* Empty? Zero. */
1257  if( lwgeom_is_empty(geom) ) return 0;
1258 
1259  switch (geom->type)
1260  {
1261  case POINTTYPE:
1262  result = 1;
1263  break;
1264  case TRIANGLETYPE:
1265  case CIRCSTRINGTYPE:
1266  case LINETYPE:
1267  result = lwline_count_vertices((const LWLINE *)geom);
1268  break;
1269  case POLYGONTYPE:
1270  result = lwpoly_count_vertices((const LWPOLY *)geom);
1271  break;
1272  case COMPOUNDTYPE:
1273  case CURVEPOLYTYPE:
1274  case MULTICURVETYPE:
1275  case MULTISURFACETYPE:
1276  case MULTIPOINTTYPE:
1277  case MULTILINETYPE:
1278  case MULTIPOLYGONTYPE:
1279  case POLYHEDRALSURFACETYPE:
1280  case TINTYPE:
1281  case COLLECTIONTYPE:
1283  break;
1284  default:
1285  lwerror("%s: unsupported input geometry type: %s",
1286  __func__, lwtype_name(geom->type));
1287  break;
1288  }
1289  LWDEBUGF(3, "counted %d vertices", result);
1290  return result;
1291 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
#define COLLECTIONTYPE
Definition: liblwgeom.h:108
#define COMPOUNDTYPE
Definition: liblwgeom.h:110
#define CURVEPOLYTYPE
Definition: liblwgeom.h:111
#define MULTILINETYPE
Definition: liblwgeom.h:106
#define MULTISURFACETYPE
Definition: liblwgeom.h:113
#define LINETYPE
Definition: liblwgeom.h:103
#define MULTIPOINTTYPE
Definition: liblwgeom.h:105
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:102
#define TINTYPE
Definition: liblwgeom.h:116
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:107
#define POLYGONTYPE
Definition: liblwgeom.h:104
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:114
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:109
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
#define MULTICURVETYPE
Definition: liblwgeom.h:112
#define TRIANGLETYPE
Definition: liblwgeom.h:115
uint32_t lwline_count_vertices(const LWLINE *line)
Definition: lwline.c:505
uint32_t lwpoly_count_vertices(const LWPOLY *poly)
Definition: lwpoly.c:418
uint32_t lwcollection_count_vertices(const LWCOLLECTION *col)
Definition: lwcollection.c:500
#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
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:203
uint8_t type
Definition: liblwgeom.h:462

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, 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(), RASTER_InterpolateRaster(), test_lwcurve_linearize(), test_lwgeom_count_vertices(), test_lwpoly_construct_circle(), test_misc_count_vertices(), test_on_gser2_lwgeom_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: