/*! \brief Call simplification on an iterator pair */ inline void simplify(const R& range, O_IT out, double max_distance) const { PSDS strategy; // Init the output, a vector of references to all points // Note Geometry Algorithms suggest here // http://geometryalgorithms.com/Archive/algorithm_0205/algorithm_0205.htm // to "STAGE 1: Vertex Reduction within max_distance of prior vertex cluster" // However, that is not correct: a vertex within the specified distance might be // excluded here, but might be a better candidate for final inclusion than the point before. std::vector<DP> ref_candidates(boost::begin(range), boost::end(range)); // Include first and last point of line, they are always part of the line int n = 2; ref_candidates.front().included = true; ref_candidates.back().included = true; // Get points, recursively, including them if they are further away than the specified distance typedef typename PSDS::return_type RET; consider(boost::begin(ref_candidates), boost::end(ref_candidates), make_distance_result<RET>(max_distance), n, strategy); // Copy included elements to the output (might be changed using copy_if) for(typename std::vector<DP>::const_iterator it = boost::begin(ref_candidates); it != boost::end(ref_candidates); it++) { if (it->included) { *out = it->p; out++; } } }
inline OutputIterator apply(Range const& range, OutputIterator out, distance_type max_distance) const { #ifdef BOOST_GEOMETRY_DEBUG_DOUGLAS_PEUCKER std::cout << "max distance: " << max_distance << std::endl << std::endl; #endif distance_strategy_type strategy; // Copy coordinates, a vector of references to all points std::vector<dp_point_type> ref_candidates(boost::begin(range), boost::end(range)); // Include first and last point of line, // they are always part of the line int n = 2; ref_candidates.front().included = true; ref_candidates.back().included = true; // Get points, recursively, including them if they are further away // than the specified distance consider(boost::begin(ref_candidates), boost::end(ref_candidates), max_distance, n, strategy); // Copy included elements to the output for(typename std::vector<dp_point_type>::const_iterator it = boost::begin(ref_candidates); it != boost::end(ref_candidates); ++it) { if (it->included) { // copy-coordinates does not work because OutputIterator // does not model Point (??) //geometry::convert(it->p, *out); *out = it->p; out++; } } return out; }
static inline OutputIterator apply(Range const& range, OutputIterator out, double max_distance) { distance_strategy_type strategy; // Copy coordinates, a vector of references to all points std::vector<dp_point_type> ref_candidates(pdalboost::begin(range), pdalboost::end(range)); // Include first and last point of line, // they are always part of the line int n = 2; ref_candidates.front().included = true; ref_candidates.back().included = true; // Get points, recursively, including them if they are further away // than the specified distance typedef typename strategy::distance::services::return_type<distance_strategy_type>::type return_type; consider(pdalboost::begin(ref_candidates), pdalboost::end(ref_candidates), max_distance, n, strategy); // Copy included elements to the output for(typename std::vector<dp_point_type>::const_iterator it = pdalboost::begin(ref_candidates); it != pdalboost::end(ref_candidates); ++it) { if (it->included) { // copy-coordinates does not work because OutputIterator // does not model Point (??) //geometry::convert(it->p, *out); *out = it->p; out++; } } return out; }