/Src/Dependencies/Boost/libs/geometry/doc/src/examples/algorithms/num_geometries.cpp

C++ | 47 lines | 19 code | 11 blank | 17 comment | 0 complexity | 4dd6c5f052ed8dc12524a0987b9de0fd MD5 | raw file
``` 1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// QuickBook Example
3
4// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
5
6// Use, modification and distribution is subject to the Boost Software License,
7// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9
10//[num_geometries
11//` Get the number of geometries making up a multi-geometry
12
13#include <iostream>
14
15#include <boost/geometry.hpp>
16#include <boost/geometry/geometries/point_xy.hpp>
17#include <boost/geometry/geometries/polygon.hpp>
18#include <boost/geometry/multi/geometries/multi_polygon.hpp>
19#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
20
21
22int main()
23{
24    boost::geometry::model::multi_polygon
25        <
26            boost::geometry::model::polygon
27                <
28                    boost::geometry::model::d2::point_xy<double>
29                >
30        > mp;
31    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);
32    std::cout << "Number of geometries: " << boost::geometry::num_geometries(mp) << std::endl;
33
34    return 0;
35}
36
37//]
38
39
40//[num_geometries_output
41/*`
42Output:
43[pre
44 Number of geometries: 2
45]
46*/
47//]
```