/Src/Dependencies/Boost/libs/geometry/doc/src/examples/geometries/register/multi_linestring.cpp

http://hadesmem.googlecode.com/ · C++ · 51 lines · 19 code · 13 blank · 19 comment · 0 complexity · a0877a5fae8b25d420077386d6746781 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. //[register_multi_linestring
  8. //` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING
  9. #include <iostream>
  10. #include <boost/geometry.hpp>
  11. #include <boost/geometry/geometries/linestring.hpp>
  12. #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
  13. #include <boost/geometry/multi/geometries/register/multi_linestring.hpp>
  14. typedef boost::geometry::model::linestring
  15. <
  16. boost::tuple<float, float>
  17. > linestring_type;
  18. BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
  19. BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING(std::deque<linestring_type>)
  20. int main()
  21. {
  22. // Normal usage of std::
  23. std::deque<linestring_type> lines(2);
  24. boost::geometry::read_wkt("LINESTRING(0 0,1 1)", lines[0]);
  25. boost::geometry::read_wkt("LINESTRING(2 2,3 3)", lines[1]);
  26. // Usage of Boost.Geometry
  27. std::cout << "LENGTH: " << boost::geometry::length(lines) << std::endl;
  28. return 0;
  29. }
  30. //]
  31. //[register_multi_linestring_output
  32. /*`
  33. Output:
  34. [pre
  35. LENGTH: 2.82843
  36. ]
  37. */
  38. //]