doxygen_3.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. OBSOLETE
  2. // Boost.Geometry (aka GGL, Generic Geometry Library)
  3. //
  4. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  5. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  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
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // Doxygen Examples, for e.g. email formal review
  11. #include <boost/foreach.hpp>
  12. #include <boost/geometry/geometry.hpp>
  13. void example_distance()
  14. {
  15. int a[2] = {1,2};
  16. int b[2] = {3,4};
  17. double d = boost::geometry::distance(a, b);
  18. std::cout << d << std::endl;
  19. }
  20. void example_length1()
  21. {
  22. std::vector<boost::tuple<double, double, double> > line;
  23. line.push_back(boost::make_tuple(1, 2, 3));
  24. line.push_back(boost::make_tuple(4, 5, 6));
  25. line.push_back(boost::make_tuple(7, 8, 9));
  26. double length = boost::geometry::length(line);
  27. std::cout << length << std::endl;
  28. }
  29. void example_length2()
  30. {
  31. std::vector<boost::tuple<double, double> > line;
  32. line.push_back(boost::make_tuple(1.1, 2.2));
  33. line.push_back(boost::make_tuple(3.3, 4.4));
  34. line.push_back(boost::make_tuple(5.5, 6.6));
  35. std::cout << boost::geometry::length(
  36. std::make_pair(boost::begin(line), boost::end(line) + -1)
  37. )
  38. << std::endl;
  39. }
  40. void example_less()
  41. {
  42. typedef boost::tuple<double, double> P;
  43. std::vector<P> line;
  44. line.push_back(boost::make_tuple(8.1, 1.9));
  45. line.push_back(boost::make_tuple(4.2, 7.5));
  46. line.push_back(boost::make_tuple(2.3, 3.6));
  47. std::sort(line.begin(), line.end(), boost::geometry::less<P>());
  48. // Display ordered points
  49. BOOST_FOREACH(P const& p, line)
  50. {
  51. std::cout << boost::geometry::dsv(p) << std::endl;
  52. }
  53. }
  54. int main(void)
  55. {
  56. example_distance();
  57. example_length1();
  58. example_length2();
  59. example_less();
  60. return 0;
  61. }