simplify_douglas_peucker.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 1995, 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 1995 Maarten Hilferink, Amsterdam, the Netherlands
  4. // This file was modified by Oracle on 2015-2021.
  5. // Modifications copyright (c) 2015-2021, Oracle and/or its affiliates.
  6. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  10. // Use, modification and distribution is subject to the Boost Software License,
  11. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_STRATEGY_AGNOSTIC_SIMPLIFY_DOUGLAS_PEUCKER_HPP
  14. #define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_SIMPLIFY_DOUGLAS_PEUCKER_HPP
  15. #include <boost/geometry/strategies/distance.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. namespace strategy { namespace simplify
  19. {
  20. // NOTE: Left here for backward compatibility.
  21. /*!
  22. \brief Implements the simplify algorithm.
  23. \ingroup strategies
  24. \details The douglas_peucker strategy simplifies a linestring, ring or
  25. vector of points using the well-known Douglas-Peucker algorithm.
  26. \tparam Point the point type
  27. \tparam PointDistanceStrategy point-segment distance strategy to be used
  28. \note This strategy uses itself a point-segment-distance strategy which
  29. can be specified
  30. \author Barend and Maarten, 1995/1996
  31. \author Barend, revised for Generic Geometry Library, 2008
  32. */
  33. /*
  34. For the algorithm, see for example:
  35. - http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
  36. - http://www2.dcs.hull.ac.uk/CISRG/projects/Royal-Inst/demos/dp.html
  37. */
  38. template
  39. <
  40. typename Point,
  41. typename PointDistanceStrategy
  42. >
  43. class douglas_peucker
  44. {
  45. public :
  46. typedef PointDistanceStrategy distance_strategy_type;
  47. typedef typename strategy::distance::services::return_type
  48. <
  49. distance_strategy_type,
  50. Point, Point
  51. >::type distance_type;
  52. template <typename Range, typename OutputIterator>
  53. static inline OutputIterator apply(Range const& ,
  54. OutputIterator out,
  55. distance_type const& )
  56. {
  57. return out;
  58. }
  59. };
  60. }} // namespace strategy::simplify
  61. }} // namespace boost::geometry
  62. #endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_SIMPLIFY_DOUGLAS_PEUCKER_HPP