handle empty names in summaries
This commit is contained in:
parent
54aaf574d9
commit
cbb96ce7f4
@ -132,7 +132,7 @@ module.exports = function () {
|
||||
|
||||
this.summary = (instructions) => {
|
||||
if (instructions) {
|
||||
return instructions.legs.map(l => l.summary).join(',');
|
||||
return instructions.legs.map(l => l.summary).join(';');
|
||||
}
|
||||
};
|
||||
|
||||
|
29
features/testbot/summaries.feature
Normal file
29
features/testbot/summaries.feature
Normal file
@ -0,0 +1,29 @@
|
||||
@routing @basic @testbot
|
||||
Feature: Basic Routing
|
||||
|
||||
Background:
|
||||
Given the profile "testbot"
|
||||
Given a grid size of 500 meters
|
||||
|
||||
@smallest
|
||||
Scenario: Summaries when routing on a simple network
|
||||
Given the node map
|
||||
| b | | | f |
|
||||
| | | | |
|
||||
| c | d | | g |
|
||||
| | | | |
|
||||
| a | | e | |
|
||||
|
||||
And the ways
|
||||
| nodes | name |
|
||||
| acb | road |
|
||||
| de | 1 st |
|
||||
| cd | |
|
||||
| dg | blvd |
|
||||
| df | street |
|
||||
|
||||
When I route I should get
|
||||
| waypoints | route | summary |
|
||||
| a,e | road,,1 st,1 st | road, 1 st |
|
||||
| a,d,f | road,,,street,street | road;street |
|
||||
| a,e,f | road,,1 st,1 st,1 st,street,street | road, 1 st;1 st, street |
|
@ -6,6 +6,7 @@
|
||||
#include "engine/guidance/route_leg.hpp"
|
||||
#include "engine/guidance/route_step.hpp"
|
||||
#include "engine/internal_route_result.hpp"
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@ -177,16 +178,16 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
|
||||
|
||||
BOOST_ASSERT(detail::MAX_USED_SEGMENTS > 0);
|
||||
BOOST_ASSERT(summary_array.begin() != summary_array.end());
|
||||
summary = std::accumulate(std::next(summary_array.begin()),
|
||||
summary_array.end(),
|
||||
facade.GetNameForID(summary_array.front()),
|
||||
[&facade](std::string previous, const std::uint32_t name_id) {
|
||||
if (name_id != 0)
|
||||
std::vector<std::string> summary_names;
|
||||
for (auto nameIt = summary_array.begin(), end = summary_array.end(); nameIt != end; ++nameIt)
|
||||
{
|
||||
previous += ", " + facade.GetNameForID(name_id);
|
||||
auto name = facade.GetNameForID(* nameIt);
|
||||
name = name.empty() ? facade.GetRefForID(* nameIt) : name;
|
||||
if (!name.empty())
|
||||
summary_names.push_back(name);
|
||||
}
|
||||
return previous;
|
||||
});
|
||||
BOOST_ASSERT(summary_names.size() =< MAX_USED_SEGMENTS);
|
||||
summary = boost::algorithm::join(summary_names, ", ");
|
||||
}
|
||||
|
||||
return RouteLeg{duration, distance, summary, {}};
|
||||
|
Loading…
Reference in New Issue
Block a user