move distance calculations to float
This commit is contained in:
parent
df978345d7
commit
4b5f744c6f
@ -104,17 +104,17 @@ void DouglasPeucker::Run(std::vector<SegmentInformation> &input_geometry, const
|
|||||||
BOOST_ASSERT_MSG(input_geometry[pair.second].necessary, "right border must be necessary");
|
BOOST_ASSERT_MSG(input_geometry[pair.second].necessary, "right border must be necessary");
|
||||||
BOOST_ASSERT_MSG(pair.second < input_geometry.size(), "right border outside of geometry");
|
BOOST_ASSERT_MSG(pair.second < input_geometry.size(), "right border outside of geometry");
|
||||||
BOOST_ASSERT_MSG(pair.first < pair.second, "left border on the wrong side");
|
BOOST_ASSERT_MSG(pair.first < pair.second, "left border on the wrong side");
|
||||||
double max_distance = std::numeric_limits<double>::min();
|
float max_distance = std::numeric_limits<float>::min();
|
||||||
|
|
||||||
unsigned farthest_element_index = pair.second;
|
unsigned farthest_element_index = pair.second;
|
||||||
// find index idx of element with max_distance
|
// find index idx of element with max_distance
|
||||||
for (unsigned i = pair.first + 1; i < pair.second; ++i)
|
for (unsigned i = pair.first + 1; i < pair.second; ++i)
|
||||||
{
|
{
|
||||||
const double temp_dist = FixedPointCoordinate::ComputePerpendicularDistance(
|
const float temp_dist = FixedPointCoordinate::ComputePerpendicularDistance(
|
||||||
input_geometry[i].location,
|
input_geometry[i].location,
|
||||||
input_geometry[pair.first].location,
|
input_geometry[pair.first].location,
|
||||||
input_geometry[pair.second].location);
|
input_geometry[pair.second].location);
|
||||||
const double distance = std::abs(temp_dist);
|
const float distance = std::abs(temp_dist);
|
||||||
if (distance > douglas_peucker_thresholds[zoom_level] && distance > max_distance)
|
if (distance > douglas_peucker_thresholds[zoom_level] && distance > max_distance)
|
||||||
{
|
{
|
||||||
farthest_element_index = i;
|
farthest_element_index = i;
|
||||||
|
@ -44,16 +44,12 @@ struct SegmentInformation;
|
|||||||
class DouglasPeucker
|
class DouglasPeucker
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<double> douglas_peucker_thresholds;
|
std::vector<float> douglas_peucker_thresholds;
|
||||||
|
|
||||||
typedef std::pair<unsigned, unsigned> GeometryRange;
|
typedef std::pair<unsigned, unsigned> GeometryRange;
|
||||||
// Stack to simulate the recursion
|
// Stack to simulate the recursion
|
||||||
std::stack<GeometryRange> recursion_stack;
|
std::stack<GeometryRange> recursion_stack;
|
||||||
|
|
||||||
double ComputeDistance(const FixedPointCoordinate &point,
|
|
||||||
const FixedPointCoordinate &segA,
|
|
||||||
const FixedPointCoordinate &segB) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DouglasPeucker();
|
DouglasPeucker();
|
||||||
void Run(std::vector<SegmentInformation> &input_geometry, const unsigned zoom_level);
|
void Run(std::vector<SegmentInformation> &input_geometry, const unsigned zoom_level);
|
||||||
|
Loading…
Reference in New Issue
Block a user