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

http://hadesmem.googlecode.com/ · 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. // Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //[num_geometries
  8. //` Get the number of geometries making up a multi-geometry
  9. #include <iostream>
  10. #include <boost/geometry.hpp>
  11. #include <boost/geometry/geometries/point_xy.hpp>
  12. #include <boost/geometry/geometries/polygon.hpp>
  13. #include <boost/geometry/multi/geometries/multi_polygon.hpp>
  14. #include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
  15. int main()
  16. {
  17. boost::geometry::model::multi_polygon
  18. <
  19. boost::geometry::model::polygon
  20. <
  21. boost::geometry::model::d2::point_xy<double>
  22. >
  23. > mp;
  24. 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);
  25. std::cout << "Number of geometries: " << boost::geometry::num_geometries(mp) << std::endl;
  26. return 0;
  27. }
  28. //]
  29. //[num_geometries_output
  30. /*`
  31. Output:
  32. [pre
  33. Number of geometries: 2
  34. ]
  35. */
  36. //]