Fix bug with reading Set values from Lua scripts. (#6285)

* Fix bug with reading Set values from Lua scripts.

* Add test for foot profile named-road suffixes

Co-authored-by: Michael Bell <michael@mjjbell.com>
This commit is contained in:
Siarhei Fedartsou 2022-07-31 00:14:06 +02:00 committed by GitHub
parent 1a3d0f7c20
commit 204fdaff6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 4 deletions

View File

@ -2,6 +2,8 @@
- Changes from 5.26.0
- API:
- FIXED: Fix inefficient osrm-routed connection handling [#6113](https://github.com/Project-OSRM/osrm-backend/pull/6113)
- Misc:
- FIXED: Fix bug with reading Set values from Lua scripts. [#6285](https://github.com/Project-OSRM/osrm-backend/pull/6285)
- Build:
- CHANGED: Update macOS CI image to macos-11. [#6286](https://github.com/Project-OSRM/osrm-backend/pull/6286)
- CHANGED: Enable even more clang-tidy checks. [#6273](https://github.com/Project-OSRM/osrm-backend/pull/6273)

View File

@ -20,3 +20,20 @@ Feature: Foot - Street names in instructions
When I route I should get
| from | to | route | ref |
| a | c | My Way,, | ,A7,A7 |
Scenario: Foot - Combines named roads with suffix changes
Given the node map
"""
a b c d
"""
And the ways
| nodes | name |
| ab | High Street W |
| bc | High Street E |
| cd | Market Street |
When I route I should get
| from | to | route |
| a | d | High Street W,Market Street,Market Street |

View File

@ -29,7 +29,7 @@ Feature: Foot - Turn restrictions
When I route I should get
| from | to | route |
| s | w | sj,wj,wj |
| s | n | sj,nj,nj |
| s | n | sj,nj |
| s | e | sj,ej,ej |
@only_turning
@ -55,7 +55,7 @@ Feature: Foot - Turn restrictions
When I route I should get
| from | to | route |
| s | w | sj,wj,wj |
| s | n | sj,nj,nj |
| s | n | sj,nj |
| s | e | sj,ej,ej |
@except

View File

@ -939,6 +939,26 @@ Sol2ScriptingEnvironment::GetStringListFromFunction(const std::string &function_
return strings;
}
namespace
{
// string list can be defined either as a Set(see profiles/lua/set.lua) or as a Sequence (see
// profiles/lua/sequence.lua) `Set` is a table with keys that are actual values we are looking for
// and values that always `true`. `Sequence` is a table with keys that are indices and values that
// are actual values we are looking for.
std::string GetSetOrSequenceValue(const std::pair<sol::object, sol::object> &pair)
{
if (pair.second.is<std::string>())
{
return pair.second.as<std::string>();
}
BOOST_ASSERT(pair.first.is<std::string>());
return pair.first.as<std::string>();
}
} // namespace
std::vector<std::string>
Sol2ScriptingEnvironment::GetStringListFromTable(const std::string &table_name)
{
@ -954,7 +974,7 @@ Sol2ScriptingEnvironment::GetStringListFromTable(const std::string &table_name)
{
for (auto &&pair : table)
{
strings.push_back(pair.second.as<std::string>());
strings.emplace_back(GetSetOrSequenceValue(pair));
}
}
return strings;
@ -989,7 +1009,7 @@ Sol2ScriptingEnvironment::GetStringListsFromTable(const std::string &table_name)
std::vector<std::string> inner_vector;
for (const auto &inner_pair : inner_table)
{
inner_vector.push_back(inner_pair.first.as<std::string>());
inner_vector.emplace_back(GetSetOrSequenceValue(inner_pair));
}
string_lists.push_back(std::move(inner_vector));
}