handle short summaries correctly
This commit is contained in:
parent
bdc66049a5
commit
58d6e8f4d0
@ -12,6 +12,9 @@
|
|||||||
- Infrastructure
|
- Infrastructure
|
||||||
- BREAKING: Changed the on-disk encoding of the StaticRTree to reduce ramIndex file size. This breaks the **data format**
|
- BREAKING: Changed the on-disk encoding of the StaticRTree to reduce ramIndex file size. This breaks the **data format**
|
||||||
|
|
||||||
|
- Bugfixes
|
||||||
|
- fixed broken summaries for very short routes
|
||||||
|
|
||||||
# 5.2.0 RC1
|
# 5.2.0 RC1
|
||||||
Changes from 5.1.0
|
Changes from 5.1.0
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ Feature: Basic Routing
|
|||||||
@smallest
|
@smallest
|
||||||
Scenario: Checking
|
Scenario: Checking
|
||||||
Given the node map
|
Given the node map
|
||||||
| a | b | | c | d | e |
|
| a | b | 1 | c | d | e |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes |
|
| nodes |
|
||||||
@ -22,6 +22,7 @@ Feature: Basic Routing
|
|||||||
| 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 |
|
||||||
|
|
||||||
@smallest
|
@smallest
|
||||||
Scenario: Check handling empty values
|
Scenario: Check handling empty values
|
||||||
|
@ -35,7 +35,9 @@ struct NamedSegment
|
|||||||
|
|
||||||
template <std::size_t SegmentNumber>
|
template <std::size_t SegmentNumber>
|
||||||
|
|
||||||
std::array<std::uint32_t, SegmentNumber> summarizeRoute(const std::vector<PathData> &route_data)
|
std::array<std::uint32_t, SegmentNumber> summarizeRoute(const std::vector<PathData> &route_data,
|
||||||
|
const PhantomNode &target_node,
|
||||||
|
const bool target_traversed_in_reverse)
|
||||||
{
|
{
|
||||||
// merges segments with same name id
|
// merges segments with same name id
|
||||||
const auto collapse_segments = [](std::vector<NamedSegment> &segments) {
|
const auto collapse_segments = [](std::vector<NamedSegment> &segments) {
|
||||||
@ -71,6 +73,10 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const std::vector<PathDa
|
|||||||
route_data.begin(), route_data.end(), segments.begin(), [&index](const PathData &point) {
|
route_data.begin(), route_data.end(), segments.begin(), [&index](const PathData &point) {
|
||||||
return NamedSegment{point.duration_until_turn, index++, point.name_id};
|
return NamedSegment{point.duration_until_turn, index++, point.name_id};
|
||||||
});
|
});
|
||||||
|
const auto target_duration =
|
||||||
|
target_traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight;
|
||||||
|
if (target_duration > 1)
|
||||||
|
segments.push_back({target_duration, index++, target_node.name_id});
|
||||||
// this makes sure that the segment with the lowest position comes first
|
// this makes sure that the segment with the lowest position comes first
|
||||||
std::sort(
|
std::sort(
|
||||||
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
|
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
|
||||||
@ -86,6 +92,7 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const std::vector<PathDa
|
|||||||
});
|
});
|
||||||
segments.resize(new_end - segments.begin());
|
segments.resize(new_end - segments.begin());
|
||||||
|
|
||||||
|
|
||||||
// sort descending
|
// sort descending
|
||||||
std::sort(
|
std::sort(
|
||||||
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
|
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
|
||||||
@ -164,7 +171,10 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
|
|||||||
std::string summary;
|
std::string summary;
|
||||||
if (needs_summary)
|
if (needs_summary)
|
||||||
{
|
{
|
||||||
auto summary_array = detail::summarizeRoute<detail::MAX_USED_SEGMENTS>(route_data);
|
auto summary_array = detail::summarizeRoute<detail::MAX_USED_SEGMENTS>(
|
||||||
|
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());
|
||||||
|
Loading…
Reference in New Issue
Block a user