Boost C++ Libraries

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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

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.hpp>`

Or

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

Conformance

The function num_interior_ring implements function NumInteriorRing from the OGC Simple Feature Specification.

Note Boost.Geometry adds an "s"
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/geometries/multi_polygon.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
```
 Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam Wulkiewicz, Oracle and/or its affiliates Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)