replace for loop with hand-rolled pair-wise traverse of container with call to for_each_pair; fix target type of cast
This commit is contained in:
parent
ccd803416e
commit
1c12b468a8
@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "../data_structures/coordinate_calculation.hpp"
|
#include "../data_structures/coordinate_calculation.hpp"
|
||||||
#include "../data_structures/internal_route_result.hpp"
|
#include "../data_structures/internal_route_result.hpp"
|
||||||
#include "../data_structures/turn_instructions.hpp"
|
#include "../data_structures/turn_instructions.hpp"
|
||||||
|
#include "../Util/container.hpp"
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
DescriptionFactory::DescriptionFactory() : entire_length(0) { via_indices.push_back(0); }
|
DescriptionFactory::DescriptionFactory() : entire_length(0) { via_indices.push_back(0); }
|
||||||
@ -216,23 +217,27 @@ void DescriptionFactory::Run(const unsigned zoom_level)
|
|||||||
polyline_generalizer.Run(path_description.begin(), path_description.end(), zoom_level);
|
polyline_generalizer.Run(path_description.begin(), path_description.end(), zoom_level);
|
||||||
|
|
||||||
// fix what needs to be fixed else
|
// fix what needs to be fixed else
|
||||||
unsigned necessary_pieces = 0; // a running index that counts the necessary pieces
|
unsigned necessary_segments = 0; // a running index that counts the necessary pieces
|
||||||
for (unsigned i = 0; i < path_description.size() - 1 && path_description.size() >= 2; ++i)
|
osrm::for_each_pair(
|
||||||
|
path_description, [&](SegmentInformation &first, const SegmentInformation &second)
|
||||||
{
|
{
|
||||||
if (path_description[i].necessary)
|
if (!first.necessary)
|
||||||
{
|
{
|
||||||
++necessary_pieces;
|
return;
|
||||||
if (path_description[i].is_via_location)
|
|
||||||
{ // mark the end of a leg
|
|
||||||
via_indices.push_back(necessary_pieces);
|
|
||||||
}
|
}
|
||||||
const double angle =
|
|
||||||
path_description[i + 1].location.bearing(path_description[i].location);
|
++necessary_segments;
|
||||||
path_description[i].bearing = static_cast<unsigned>(angle * 10);
|
|
||||||
|
if (first.is_via_location)
|
||||||
|
{ // mark the end of a leg (of several segments)
|
||||||
|
via_indices.push_back(necessary_segments);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
via_indices.push_back(necessary_pieces + 1);
|
const double angle = coordinate_calculation::bearing(first.location, second.location);
|
||||||
|
first.bearing = static_cast<short>(angle * 10);
|
||||||
|
});
|
||||||
|
|
||||||
|
via_indices.push_back(necessary_segments + 1);
|
||||||
BOOST_ASSERT(via_indices.size() >= 2);
|
BOOST_ASSERT(via_indices.size() >= 2);
|
||||||
// BOOST_ASSERT(0 != necessary_pieces || path_description.empty());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user