simplify.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_SIMPLIFY_HPP
  11. #define BOOST_GEOMETRY_MULTI_ALGORITHMS_SIMPLIFY_HPP
  12. #include <boost/range.hpp>
  13. #include <boost/geometry/core/mutable_range.hpp>
  14. #include <boost/geometry/multi/core/tags.hpp>
  15. #include <boost/geometry/multi/geometries/concepts/check.hpp>
  16. #include <boost/geometry/multi/algorithms/clear.hpp>
  17. #include <boost/geometry/algorithms/simplify.hpp>
  18. namespace boost { namespace geometry
  19. {
  20. #ifndef DOXYGEN_NO_DETAIL
  21. namespace detail { namespace simplify
  22. {
  23. template<typename Policy>
  24. struct simplify_multi
  25. {
  26. template <typename MultiGeometry, typename Strategy>
  27. static inline void apply(MultiGeometry const& multi, MultiGeometry& out,
  28. double max_distance, Strategy const& strategy)
  29. {
  30. traits::resize<MultiGeometry>::apply(out, boost::size(multi));
  31. typename boost::range_iterator<MultiGeometry>::type it_out
  32. = boost::begin(out);
  33. for (typename boost::range_iterator<MultiGeometry const>::type it_in
  34. = boost::begin(multi);
  35. it_in != boost::end(multi);
  36. ++it_in, ++it_out)
  37. {
  38. Policy::apply(*it_in, *it_out, max_distance, strategy);
  39. }
  40. }
  41. };
  42. }} // namespace detail::simplify
  43. #endif // DOXYGEN_NO_DETAIL
  44. #ifndef DOXYGEN_NO_DISPATCH
  45. namespace dispatch
  46. {
  47. template <typename MultiPoint>
  48. struct simplify<MultiPoint, multi_point_tag>
  49. : detail::simplify::simplify_copy
  50. {};
  51. template <typename MultiLinestring>
  52. struct simplify<MultiLinestring, multi_linestring_tag>
  53. : detail::simplify::simplify_multi<detail::simplify::simplify_range<2> >
  54. {};
  55. template <typename MultiPolygon>
  56. struct simplify<MultiPolygon, multi_polygon_tag>
  57. : detail::simplify::simplify_multi<detail::simplify::simplify_polygon>
  58. {};
  59. } // namespace dispatch
  60. #endif // DOXYGEN_NO_DISPATCH
  61. }} // namespace boost::geometry
  62. #endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_SIMPLIFY_HPP