correctly detect loss of prefix/suffix
This commit is contained in:
parent
be266c7c2b
commit
f7265892ed
@ -12,6 +12,7 @@
|
|||||||
- Fixed an issue that would result in segfaults for viaroutes with an invalid intermediate segment when u-turns were allowed at the via-location
|
- Fixed an issue that would result in segfaults for viaroutes with an invalid intermediate segment when u-turns were allowed at the via-location
|
||||||
- Invalid only_* restrictions could result in loss of connectivity. As a fallback, we assume all turns allowed when the restriction is not valid
|
- Invalid only_* restrictions could result in loss of connectivity. As a fallback, we assume all turns allowed when the restriction is not valid
|
||||||
- Fixed a bug that could result in an infinite loop when finding information about an upcoming intersection
|
- Fixed a bug that could result in an infinite loop when finding information about an upcoming intersection
|
||||||
|
- Fixed a bug that led to not discovering if a road simply looses a considered prefix
|
||||||
|
|
||||||
# 5.3.0
|
# 5.3.0
|
||||||
Changes from 5.3.0-rc.3
|
Changes from 5.3.0-rc.3
|
||||||
|
@ -3,7 +3,7 @@ Feature: Suppress New Names on dedicated Suffices
|
|||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given the profile "car"
|
Given the profile "car"
|
||||||
Given a grid size of 10 meters
|
Given a grid size of 2000 meters
|
||||||
|
|
||||||
Scenario: Suffix To Suffix
|
Scenario: Suffix To Suffix
|
||||||
Given the node map
|
Given the node map
|
||||||
@ -44,6 +44,19 @@ Feature: Suppress New Names on dedicated Suffices
|
|||||||
| waypoints | route | turns |
|
| waypoints | route | turns |
|
||||||
| a,c | West 42,East 42 | depart,arrive |
|
| a,c | West 42,East 42 | depart,arrive |
|
||||||
|
|
||||||
|
Scenario: Prefix Change ref
|
||||||
|
Given the node map
|
||||||
|
| a | | b | | c |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name |
|
||||||
|
| ab | West 42 |
|
||||||
|
| bc | 42 |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | turns |
|
||||||
|
| a,c | West 42,42 | depart,arrive |
|
||||||
|
|
||||||
Scenario: Prefix Change and Reference
|
Scenario: Prefix Change and Reference
|
||||||
Given the node map
|
Given the node map
|
||||||
| a | | b | | c |
|
| a | | b | | c |
|
||||||
|
@ -205,43 +205,50 @@ inline bool requiresNameAnnounced(const std::string &from,
|
|||||||
const auto name_is_contained =
|
const auto name_is_contained =
|
||||||
boost::starts_with(from_name, to_name) || boost::starts_with(to_name, from_name);
|
boost::starts_with(from_name, to_name) || boost::starts_with(to_name, from_name);
|
||||||
|
|
||||||
const auto checkForPrefixOrSuffixChange =
|
const auto checkForPrefixOrSuffixChange = [](
|
||||||
[](const std::string &first, const std::string &second, const SuffixTable &suffix_table) {
|
const std::string &first, const std::string &second, const SuffixTable &suffix_table) {
|
||||||
|
|
||||||
const auto first_prefix_and_suffixes = getPrefixAndSuffix(first);
|
const auto first_prefix_and_suffixes = getPrefixAndSuffix(first);
|
||||||
const auto second_prefix_and_suffixes = getPrefixAndSuffix(second);
|
const auto second_prefix_and_suffixes = getPrefixAndSuffix(second);
|
||||||
// reverse strings, get suffices and reverse them to get prefixes
|
// reverse strings, get suffices and reverse them to get prefixes
|
||||||
const auto checkTable = [&](const std::string str) {
|
const auto checkTable = [&](const std::string& str) {
|
||||||
return str.empty() || suffix_table.isSuffix(str);
|
return str.empty() || suffix_table.isSuffix(str);
|
||||||
};
|
|
||||||
|
|
||||||
const bool is_prefix_change = [&]() -> bool {
|
|
||||||
if (!checkTable(first_prefix_and_suffixes.first))
|
|
||||||
return false;
|
|
||||||
if (!checkTable(first_prefix_and_suffixes.first))
|
|
||||||
return false;
|
|
||||||
return !first.compare(first_prefix_and_suffixes.first.length(),
|
|
||||||
std::string::npos,
|
|
||||||
second,
|
|
||||||
second_prefix_and_suffixes.first.length(),
|
|
||||||
std::string::npos);
|
|
||||||
}();
|
|
||||||
|
|
||||||
const bool is_suffix_change = [&]() -> bool {
|
|
||||||
if (!checkTable(first_prefix_and_suffixes.second))
|
|
||||||
return false;
|
|
||||||
if (!checkTable(first_prefix_and_suffixes.second))
|
|
||||||
return false;
|
|
||||||
return !first.compare(0,
|
|
||||||
first.length() - first_prefix_and_suffixes.second.length(),
|
|
||||||
second,
|
|
||||||
0,
|
|
||||||
second.length() - second_prefix_and_suffixes.second.length());
|
|
||||||
}();
|
|
||||||
|
|
||||||
return is_prefix_change || is_suffix_change;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const auto getOffset = [](const std::string &str) -> std::size_t {
|
||||||
|
if (str.empty())
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return str.length() + 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
const bool is_prefix_change = [&]() -> bool {
|
||||||
|
if (!checkTable(first_prefix_and_suffixes.first))
|
||||||
|
return false;
|
||||||
|
if (!checkTable(second_prefix_and_suffixes.first))
|
||||||
|
return false;
|
||||||
|
return !first.compare(getOffset(first_prefix_and_suffixes.first),
|
||||||
|
std::string::npos,
|
||||||
|
second,
|
||||||
|
getOffset(second_prefix_and_suffixes.first),
|
||||||
|
std::string::npos);
|
||||||
|
}();
|
||||||
|
|
||||||
|
const bool is_suffix_change = [&]() -> bool {
|
||||||
|
if (!checkTable(first_prefix_and_suffixes.second))
|
||||||
|
return false;
|
||||||
|
if (!checkTable(second_prefix_and_suffixes.second))
|
||||||
|
return false;
|
||||||
|
return !first.compare(0,
|
||||||
|
first.length() - getOffset(first_prefix_and_suffixes.second),
|
||||||
|
second,
|
||||||
|
0,
|
||||||
|
second.length() - getOffset(second_prefix_and_suffixes.second));
|
||||||
|
}();
|
||||||
|
|
||||||
|
return is_prefix_change || is_suffix_change;
|
||||||
|
};
|
||||||
|
|
||||||
const auto is_suffix_change = checkForPrefixOrSuffixChange(from_name, to_name, suffix_table);
|
const auto is_suffix_change = checkForPrefixOrSuffixChange(from_name, to_name, suffix_table);
|
||||||
const auto names_are_equal = from_name == to_name || name_is_contained || is_suffix_change;
|
const auto names_are_equal = from_name == to_name || name_is_contained || is_suffix_change;
|
||||||
const auto name_is_removed = !from_name.empty() && to_name.empty();
|
const auto name_is_removed = !from_name.empty() && to_name.empty();
|
||||||
|
Loading…
Reference in New Issue
Block a user