From 49a1dfff60e3bab95f8a6fcc8d2997776a8cd6b5 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 27 May 2014 12:09:05 +0200 Subject: [PATCH] fix off-by-one issue related to #1020 --- Descriptors/DescriptionFactory.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Descriptors/DescriptionFactory.h b/Descriptors/DescriptionFactory.h index e8b4d650e..ed9d5de46 100644 --- a/Descriptors/DescriptionFactory.h +++ b/Descriptors/DescriptionFactory.h @@ -193,22 +193,21 @@ class DescriptionFactory polyline_generalizer.Run(path_description, zoomLevel); // fix what needs to be fixed else - unsigned necessary_pieces = 0; + unsigned necessary_pieces = 0; // a running index that counts the necessary pieces for (unsigned i = 0; i < path_description.size() - 1 && path_description.size() >= 2; ++i) { if (path_description[i].necessary) { + ++necessary_pieces; 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.GetBearing(path_description[i].location); path_description[i].bearing = angle * 10; - ++necessary_pieces; } } - via_indices.push_back(necessary_pieces); + via_indices.push_back(necessary_pieces+1); BOOST_ASSERT(via_indices.size() >= 2); // BOOST_ASSERT(0 != necessary_pieces || path_description.empty()); return;