ml02_distance_strategy.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  3. // Use, modification and distribution is subject to the Boost Software License,
  4. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Multipolygon DP simplification example from the mailing list discussion
  8. // about the DP algorithm issue:
  9. // http://lists.osgeo.org/pipermail/ggl/2011-September/001533.html
  10. #include <boost/geometry.hpp>
  11. #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
  12. #include <boost/geometry/geometries/point_xy.hpp>
  13. using namespace boost::geometry;
  14. int main()
  15. {
  16. typedef model::d2::point_xy<double> point_xy;
  17. point_xy p1(0.0, 0.0);
  18. point_xy p2(5.0, 0.0);
  19. // 1) This is direct call to Pythagoras algo
  20. typedef strategy::distance::pythagoras<point_xy, point_xy, double> strategy1_type;
  21. strategy1_type strategy1;
  22. strategy1_type ::calculation_type d1 = strategy1.apply(p1, p2);
  23. // 2) This is what is effectively called by simplify
  24. typedef strategy::distance::comparable::pythagoras<point_xy, point_xy, double> strategy2_type;
  25. strategy2_type strategy2;
  26. strategy2_type::calculation_type d2 = strategy2.apply(p1, p2);
  27. return 0;
  28. }