use irange based for loop in DouglasPeucker run
This commit is contained in:
parent
fee83fee40
commit
bc9f5189a5
@ -25,17 +25,20 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <osrm/Coordinate.h>
|
|
||||||
|
|
||||||
#include "DouglasPeucker.h"
|
#include "DouglasPeucker.h"
|
||||||
|
|
||||||
|
#include "../DataStructures/Range.h"
|
||||||
#include "../DataStructures/SegmentInformation.h"
|
#include "../DataStructures/SegmentInformation.h"
|
||||||
|
|
||||||
|
#include <osrm/Coordinate.h>
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace {
|
||||||
struct CoordinatePairCalculator
|
struct CoordinatePairCalculator
|
||||||
{
|
{
|
||||||
CoordinatePairCalculator() = delete;
|
CoordinatePairCalculator() = delete;
|
||||||
@ -77,6 +80,7 @@ struct CoordinatePairCalculator
|
|||||||
float second_lat;
|
float second_lat;
|
||||||
float second_lon;
|
float second_lon;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
DouglasPeucker::DouglasPeucker()
|
DouglasPeucker::DouglasPeucker()
|
||||||
: douglas_peucker_thresholds({512440, // z0
|
: douglas_peucker_thresholds({512440, // z0
|
||||||
@ -149,13 +153,13 @@ void DouglasPeucker::Run(std::vector<SegmentInformation> &input_geometry, const
|
|||||||
|
|
||||||
int max_int_distance = 0;
|
int max_int_distance = 0;
|
||||||
unsigned farthest_entry_index = pair.second;
|
unsigned farthest_entry_index = pair.second;
|
||||||
const CoordinatePairCalculator DistCalc(input_geometry[pair.first].location,
|
const CoordinatePairCalculator dist_calc(input_geometry[pair.first].location,
|
||||||
input_geometry[pair.second].location);
|
input_geometry[pair.second].location);
|
||||||
|
|
||||||
// sweep over range to find the maximum
|
// sweep over range to find the maximum
|
||||||
for (unsigned i = pair.first + 1; i < pair.second; ++i)
|
for (const auto i : osrm::irange(pair.first + 1, pair.second))
|
||||||
{
|
{
|
||||||
const int distance = DistCalc(input_geometry[i].location);
|
const int distance = dist_calc(input_geometry[i].location);
|
||||||
// found new feasible maximum?
|
// found new feasible maximum?
|
||||||
if (distance > max_int_distance && distance > douglas_peucker_thresholds[zoom_level])
|
if (distance > max_int_distance && distance > douglas_peucker_thresholds[zoom_level])
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user