...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Calculates the number of interior rings of a geometry.
The free function num_interior_rings calculates the number of interior rings of a geometry.
template<typename Geometry> std::size_t num_interior_rings(Geometry const & geometry)
Type |
Concept |
Name |
Description |
---|---|---|---|
Geometry const & |
Any type fulfilling a Geometry Concept |
geometry |
A model of the specified concept |
The calculated number of interior rings
Either
#include <boost/geometry.hpp>
Or
#include <boost/geometry/algorithms/num_interior_rings.hpp>
The function num_interior_ring implements function NumInteriorRing from the OGC Simple Feature Specification.
Note | |
---|---|
Boost.Geometry adds an "s" |
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
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