# Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world.

#### num_interior_rings

Calculates the number of interior rings of a geometry.

###### Description

The free function num_interior_rings calculates the number of interior rings of a geometry.

###### Synopsis

template<typename Geometry>
std::size_t num_interior_rings(Geometry const & geometry)

###### Parameters

Type

Concept

Name

Description

Geometry const &

Any type fulfilling a Geometry Concept

geometry

A model of the specified concept

###### Returns

The calculated number of interior rings

Either

#include <boost/geometry/geometry.hpp>

Or

#include <boost/geometry/algorithms/num_interior_rings.hpp>

###### Behavior

Case

Behavior

Polygon

Returns the number of its interior rings

Multi Polygon

Returns the number of the interior rings of all polygons

Other geometries

Returns 0

Constant

###### Examples

Get the number of interior rings in a multi-polygon

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>

int main()
{
boost::geometry::model::multi_polygon
<
boost::geometry::model::polygon
<
boost::geometry::model::d2::point_xy<double>
>
> mp;
boost::geometry::read_wkt("MULTIPOLYGON(((0 0,0 10,10 0,0 0),(1 1,1 9,9 1,1 1)),((10 10,10 7,7 10,10 10)))", mp);
std::cout << "Number of interior rings: " << boost::geometry::num_interior_rings(mp) << std::endl;

return 0;
}

Output:

Number of interior rings: 1