PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwgeom_count_vertices()

uint32_t lwgeom_count_vertices ( const LWGEOM geom)
extern

Count the total number of vertices in any LWGEOM.

Count the total number of vertices in any LWGEOM.

TODO: Make sure the internal functions don't overflow

Definition at line 1229 of file lwgeom.c.

1230{
1231 int result = 0;
1232
1233 /* Null? Zero. */
1234 if( ! geom ) return 0;
1235
1236 LWDEBUGF(4, "lwgeom_count_vertices got type %s",
1237 lwtype_name(geom->type));
1238
1239 /* Empty? Zero. */
1240 if( lwgeom_is_empty(geom) ) return 0;
1241
1242 switch (geom->type)
1243 {
1244 case POINTTYPE:
1245 result = 1;
1246 break;
1247 case TRIANGLETYPE:
1248 case CIRCSTRINGTYPE:
1249 case LINETYPE:
1250 result = lwline_count_vertices((LWLINE *)geom);
1251 break;
1252 case POLYGONTYPE:
1253 result = lwpoly_count_vertices((LWPOLY *)geom);
1254 break;
1255 case COMPOUNDTYPE:
1256 case CURVEPOLYTYPE:
1257 case MULTICURVETYPE:
1258 case MULTISURFACETYPE:
1259 case MULTIPOINTTYPE:
1260 case MULTILINETYPE:
1261 case MULTIPOLYGONTYPE:
1263 case TINTYPE:
1264 case COLLECTIONTYPE:
1265 result = lwcollection_count_vertices((LWCOLLECTION *)geom);
1266 break;
1267 default:
1268 lwerror("%s: unsupported input geometry type: %s",
1269 __func__, lwtype_name(geom->type));
1270 break;
1271 }
1272 LWDEBUGF(3, "counted %d vertices", result);
1273 return result;
1274}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#define COLLECTIONTYPE
Definition liblwgeom.h:122
#define COMPOUNDTYPE
Definition liblwgeom.h:124
#define CURVEPOLYTYPE
Definition liblwgeom.h:125
#define MULTILINETYPE
Definition liblwgeom.h:120
#define MULTISURFACETYPE
Definition liblwgeom.h:127
#define LINETYPE
Definition liblwgeom.h:117
#define MULTIPOINTTYPE
Definition liblwgeom.h:119
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:116
#define TINTYPE
Definition liblwgeom.h:130
#define MULTIPOLYGONTYPE
Definition liblwgeom.h:121
#define POLYGONTYPE
Definition liblwgeom.h:118
#define POLYHEDRALSURFACETYPE
Definition liblwgeom.h:128
#define CIRCSTRINGTYPE
Definition liblwgeom.h:123
#define MULTICURVETYPE
Definition liblwgeom.h:126
#define TRIANGLETYPE
Definition liblwgeom.h:129
uint32_t lwpoly_count_vertices(LWPOLY *poly)
Definition lwpoly.c:418
uint32_t lwcollection_count_vertices(LWCOLLECTION *col)
uint32_t lwline_count_vertices(LWLINE *line)
Definition lwline.c:502
#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:193
uint8_t type
Definition liblwgeom.h:448

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_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: