move summaries to car profile, test for references, use boost adaptors
This commit is contained in:
parent
cbb96ce7f4
commit
e4d0d49300
@ -21,6 +21,7 @@
|
|||||||
- Guidance
|
- Guidance
|
||||||
- Handle Access tags for lanes, only considering valid lanes in lane-guidance (think car | car | bike | car)
|
- Handle Access tags for lanes, only considering valid lanes in lane-guidance (think car | car | bike | car)
|
||||||
- Improved the detection of non-noticeable name-changes
|
- Improved the detection of non-noticeable name-changes
|
||||||
|
- Summaries have been improved to consider references as well
|
||||||
- API:
|
- API:
|
||||||
- `annotations=true` now returns the data source id for each segment as `datasources`
|
- `annotations=true` now returns the data source id for each segment as `datasources`
|
||||||
- Reduced semantic of merge to refer only to merges from a lane onto a motorway-like road
|
- Reduced semantic of merge to refer only to merges from a lane onto a motorway-like road
|
||||||
|
94
features/car/summaries.feature
Normal file
94
features/car/summaries.feature
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
@routing @basic @car
|
||||||
|
Feature: Basic Routing
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given the profile "car"
|
||||||
|
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 |
|
||||||
|
|
||||||
|
Scenario: Name Empty
|
||||||
|
Given the node map
|
||||||
|
| a | | b | | | c |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name |
|
||||||
|
| ab | road |
|
||||||
|
| bc | |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | summary |
|
||||||
|
| a,c | road, | road |
|
||||||
|
|
||||||
|
Scenario: Name Empty But Ref
|
||||||
|
Given the node map
|
||||||
|
| a | | b | | | c |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name | ref |
|
||||||
|
| ab | road | |
|
||||||
|
| bc | | 101 |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | summary |
|
||||||
|
| a,c | road, | road,101 |
|
||||||
|
|
||||||
|
Scenario: Only Refs
|
||||||
|
Given the node map
|
||||||
|
| a | | b | | | c |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name | ref |
|
||||||
|
| ab | | 100 |
|
||||||
|
| bc | | 101 |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | summary |
|
||||||
|
| a,c | , | 100,101 |
|
||||||
|
|
||||||
|
Scenario: Single Ref
|
||||||
|
Given the node map
|
||||||
|
| a | | b | | | c |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name | ref |
|
||||||
|
| ab | | |
|
||||||
|
| bc | | 101 |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | summary |
|
||||||
|
| a,c | ,, | 101 |
|
||||||
|
|
||||||
|
Scenario: Nothing
|
||||||
|
Given the node map
|
||||||
|
| a | | b | | | c |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name |
|
||||||
|
| ab | |
|
||||||
|
| bc | |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | summary |
|
||||||
|
| a,c | , | |
|
@ -1,29 +0,0 @@
|
|||||||
@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 |
|
|
@ -19,10 +19,10 @@ Feature: Basic Routing
|
|||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | summary |
|
| from | to | route | summary |
|
||||||
| a | e | ab,bc,cd,de,de | ab, bc |
|
| a | e | ab,bc,cd,de,de | ab,bc |
|
||||||
| e | a | de,cd,bc,ab,ab | de, bc |
|
| e | a | de,cd,bc,ab,ab | de,bc |
|
||||||
| a | b | ab,ab | ab |
|
| a | b | ab,ab | ab |
|
||||||
| b | d | bc,cd,cd | bc, cd |
|
| b | d | bc,cd,cd | bc,cd |
|
||||||
| 1 | c | bc,bc | bc |
|
| 1 | c | bc,bc | bc |
|
||||||
|
|
||||||
@smallest
|
@smallest
|
||||||
@ -41,7 +41,7 @@ Feature: Basic Routing
|
|||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | summary |
|
| from | to | route | summary |
|
||||||
| e | a | de,,bc,ab,ab | de, bc |
|
| e | a | de,,bc,ab,ab | de,bc |
|
||||||
|
|
||||||
@smallest @todo
|
@smallest @todo
|
||||||
Scenario: Summaries when routing on a simple network
|
Scenario: Summaries when routing on a simple network
|
||||||
@ -75,5 +75,5 @@ Feature: Basic Routing
|
|||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | summary |
|
| from | to | route | summary |
|
||||||
| a | 1 | first,first,second,second | first, second |
|
| a | 1 | first,first,second,second | first,second |
|
||||||
|
|
||||||
|
@ -6,7 +6,11 @@
|
|||||||
#include "engine/guidance/route_leg.hpp"
|
#include "engine/guidance/route_leg.hpp"
|
||||||
#include "engine/guidance/route_step.hpp"
|
#include "engine/guidance/route_step.hpp"
|
||||||
#include "engine/internal_route_result.hpp"
|
#include "engine/internal_route_result.hpp"
|
||||||
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
|
#include <boost/range/adaptor/filtered.hpp>
|
||||||
|
#include <boost/range/adaptor/transformed.hpp>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -108,7 +112,7 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const std::vector<PathDa
|
|||||||
});
|
});
|
||||||
|
|
||||||
std::array<std::uint32_t, SegmentNumber> summary;
|
std::array<std::uint32_t, SegmentNumber> summary;
|
||||||
std::fill(summary.begin(), summary.end(), 0);
|
std::fill(summary.begin(), summary.end(), EMPTY_NAMEID);
|
||||||
std::transform(segments.begin(),
|
std::transform(segments.begin(),
|
||||||
segments.end(),
|
segments.end(),
|
||||||
summary.begin(),
|
summary.begin(),
|
||||||
@ -173,21 +177,28 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
|
|||||||
{
|
{
|
||||||
auto summary_array = detail::summarizeRoute<detail::MAX_USED_SEGMENTS>(
|
auto summary_array = detail::summarizeRoute<detail::MAX_USED_SEGMENTS>(
|
||||||
route_data, target_node, target_traversed_in_reverse);
|
route_data, target_node, target_traversed_in_reverse);
|
||||||
if (route_data.empty())
|
|
||||||
summary_array[0] = source_node.name_id;
|
|
||||||
|
|
||||||
BOOST_ASSERT(detail::MAX_USED_SEGMENTS > 0);
|
BOOST_ASSERT(detail::MAX_USED_SEGMENTS > 0);
|
||||||
BOOST_ASSERT(summary_array.begin() != summary_array.end());
|
BOOST_ASSERT(summary_array.begin() != summary_array.end());
|
||||||
std::vector<std::string> summary_names;
|
|
||||||
for (auto nameIt = summary_array.begin(), end = summary_array.end(); nameIt != end; ++nameIt)
|
// transform a name_id into a string containing either the name, or -if the name is empty-
|
||||||
{
|
// the reference.
|
||||||
auto name = facade.GetNameForID(* nameIt);
|
const auto name_id_to_string = [&](const NameID name_id) {
|
||||||
name = name.empty() ? facade.GetRefForID(* nameIt) : name;
|
const auto name = facade.GetNameForID(name_id);
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
summary_names.push_back(name);
|
return name;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto ref = facade.GetRefForID(name_id);
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
BOOST_ASSERT(summary_names.size() =< MAX_USED_SEGMENTS);
|
};
|
||||||
summary = boost::algorithm::join(summary_names, ", ");
|
|
||||||
|
const auto not_empty = [&](const std::string &name) { return !name.empty(); };
|
||||||
|
|
||||||
|
const auto summary_names = summary_array | boost::adaptors::transformed(name_id_to_string) |
|
||||||
|
boost::adaptors::filtered(not_empty);
|
||||||
|
summary = boost::algorithm::join(summary_names, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
return RouteLeg{duration, distance, summary, {}};
|
return RouteLeg{duration, distance, summary, {}};
|
||||||
|
Loading…
Reference in New Issue
Block a user