-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Open
Labels
Description
Issue
MAX_EXCLUDABLE_CLASSES is set 8, and then the number of exclusion sets is checked with excludable_classes.size() > MAX_EXCLUDABLE_CLASSES to raise error.
But when we try de define 8 exclusion classes, the last one is not usable at runtime. The API return for this last exclusion {"message":"Exclude flag combination is not supported.","code":"InvalidValue"}
Steps to reproduce
By setting 8 excludables set in the car profile.
diff --git a/profiles/car.lua b/profiles/car.lua
index 35b4178d9..68ade0023 100644
--- a/profiles/car.lua
+++ b/profiles/car.lua
@@ -116,14 +116,19 @@ function setup()
},
classes = Sequence {
- 'toll', 'motorway', 'ferry', 'restricted', 'tunnel'
+ '0', '1', '2', '3', '4', '5', '6', '7'
},
-- classes to support for exclude flags
excludable = Sequence {
- Set {'toll'},
- Set {'motorway'},
- Set {'ferry'}
+ Set {'0'},
+ Set {'1'},
+ Set {'2'},
+ Set {'3'},
+ Set {'4'},
+ Set {'5'},
+ Set {'6'},
+ Set {'7'},
},
avoid = Set {With this profile the extract works fine (with more excludables, it raises an error).
The last exclution set doest not works.
$ for i in 0 1 2 3 4 5 6 7; do echo $i; curl "http://localhost:5000/route/v1/driving/1.5330380201339724,42.55796045336781;1.532946825027466,42.557834008579746?overview=false&exclude=${i}"; echo; done
0
{"code":"Ok","routes":[{"legs":[{"steps":[],"weight":3.8e-127,"summary":"","duration":3.8,"distance":15.8}],"weight_name":"routability","weight":3.8e-127,"duration":3.8,"distance":15.8}],"waypoints":[{"hint":"Hw4AgCAOAIAaAAAACwAAAEMAAAB_AAAAqMguQctBlEBRc-BBZJtUQhoAAAALAAAAQwAAAH8AAAAXAAAAbGQXAAhiiQJuZBcACGKJAgYATwEAAAAA","location":[1.533036,42.55796],"name":"Carrer del Turer","distance":0.1642014105},{"hint":"Hw4AgCAOAIAMAAAADAAAACsAAACkAAAAwFilQMd-mkC5fZBB5GqJQgwAAAAMAAAAKwAAAKQAAAAXAAAAJmQXAIRhiQITZBcAimGJAgQAbwEAAAAA","location":[1.532966,42.557828],"name":"Carrer del Turer","distance":1.69633755}]}
1
{"code":"Ok","routes":[{"legs":[{"steps":[],"weight":3.8e-127,"summary":"","duration":3.8,"distance":15.8}],"weight_name":"routability","weight":3.8e-127,"duration":3.8,"distance":15.8}],"waypoints":[{"hint":"Hw4AgCAOAIAaAAAACwAAAEMAAAB_AAAAqMguQctBlEBRc-BBZJtUQhoAAAALAAAAQwAAAH8AAAAXAAAAbGQXAAhiiQJuZBcACGKJAgYATwEAAAAA","location":[1.533036,42.55796],"name":"Carrer del Turer","distance":0.1642014105},{"hint":"Hw4AgCAOAIAMAAAADAAAACsAAACkAAAAwFilQMd-mkC5fZBB5GqJQgwAAAAMAAAAKwAAAKQAAAAXAAAAJmQXAIRhiQITZBcAimGJAgQAbwEAAAAA","location":[1.532966,42.557828],"name":"Carrer del Turer","distance":1.69633755}]}
2
{"code":"Ok","routes":[{"legs":[{"steps":[],"weight":3.8e-127,"summary":"","duration":3.8,"distance":15.8}],"weight_name":"routability","weight":3.8e-127,"duration":3.8,"distance":15.8}],"waypoints":[{"hint":"Hw4AgCAOAIAaAAAACwAAAEMAAAB_AAAAqMguQctBlEBRc-BBZJtUQhoAAAALAAAAQwAAAH8AAAAXAAAAbGQXAAhiiQJuZBcACGKJAgYATwEAAAAA","location":[1.533036,42.55796],"name":"Carrer del Turer","distance":0.1642014105},{"hint":"Hw4AgCAOAIAMAAAADAAAACsAAACkAAAAwFilQMd-mkC5fZBB5GqJQgwAAAAMAAAAKwAAAKQAAAAXAAAAJmQXAIRhiQITZBcAimGJAgQAbwEAAAAA","location":[1.532966,42.557828],"name":"Carrer del Turer","distance":1.69633755}]}
3
{"code":"Ok","routes":[{"legs":[{"steps":[],"weight":3.8e-127,"summary":"","duration":3.8,"distance":15.8}],"weight_name":"routability","weight":3.8e-127,"duration":3.8,"distance":15.8}],"waypoints":[{"hint":"Hw4AgCAOAIAaAAAACwAAAEMAAAB_AAAAqMguQctBlEBRc-BBZJtUQhoAAAALAAAAQwAAAH8AAAAXAAAAbGQXAAhiiQJuZBcACGKJAgYATwEAAAAA","location":[1.533036,42.55796],"name":"Carrer del Turer","distance":0.1642014105},{"hint":"Hw4AgCAOAIAMAAAADAAAACsAAACkAAAAwFilQMd-mkC5fZBB5GqJQgwAAAAMAAAAKwAAAKQAAAAXAAAAJmQXAIRhiQITZBcAimGJAgQAbwEAAAAA","location":[1.532966,42.557828],"name":"Carrer del Turer","distance":1.69633755}]}
4
{"code":"Ok","routes":[{"legs":[{"steps":[],"weight":3.8e-127,"summary":"","duration":3.8,"distance":15.8}],"weight_name":"routability","weight":3.8e-127,"duration":3.8,"distance":15.8}],"waypoints":[{"hint":"Hw4AgCAOAIAaAAAACwAAAEMAAAB_AAAAqMguQctBlEBRc-BBZJtUQhoAAAALAAAAQwAAAH8AAAAXAAAAbGQXAAhiiQJuZBcACGKJAgYATwEAAAAA","location":[1.533036,42.55796],"name":"Carrer del Turer","distance":0.1642014105},{"hint":"Hw4AgCAOAIAMAAAADAAAACsAAACkAAAAwFilQMd-mkC5fZBB5GqJQgwAAAAMAAAAKwAAAKQAAAAXAAAAJmQXAIRhiQITZBcAimGJAgQAbwEAAAAA","location":[1.532966,42.557828],"name":"Carrer del Turer","distance":1.69633755}]}
5
{"code":"Ok","routes":[{"legs":[{"steps":[],"weight":3.8e-127,"summary":"","duration":3.8,"distance":15.8}],"weight_name":"routability","weight":3.8e-127,"duration":3.8,"distance":15.8}],"waypoints":[{"hint":"Hw4AgCAOAIAaAAAACwAAAEMAAAB_AAAAqMguQctBlEBRc-BBZJtUQhoAAAALAAAAQwAAAH8AAAAXAAAAbGQXAAhiiQJuZBcACGKJAgYATwEAAAAA","location":[1.533036,42.55796],"name":"Carrer del Turer","distance":0.1642014105},{"hint":"Hw4AgCAOAIAMAAAADAAAACsAAACkAAAAwFilQMd-mkC5fZBB5GqJQgwAAAAMAAAAKwAAAKQAAAAXAAAAJmQXAIRhiQITZBcAimGJAgQAbwEAAAAA","location":[1.532966,42.557828],"name":"Carrer del Turer","distance":1.69633755}]}
6
{"code":"Ok","routes":[{"legs":[{"steps":[],"weight":3.8e-127,"summary":"","duration":3.8,"distance":15.8}],"weight_name":"routability","weight":3.8e-127,"duration":3.8,"distance":15.8}],"waypoints":[{"hint":"Hw4AgCAOAIAaAAAACwAAAEMAAAB_AAAAqMguQctBlEBRc-BBZJtUQhoAAAALAAAAQwAAAH8AAAAXAAAAbGQXAAhiiQJuZBcACGKJAgYATwEAAAAA","location":[1.533036,42.55796],"name":"Carrer del Turer","distance":0.1642014105},{"hint":"Hw4AgCAOAIAMAAAADAAAACsAAACkAAAAwFilQMd-mkC5fZBB5GqJQgwAAAAMAAAAKwAAAKQAAAAXAAAAJmQXAIRhiQITZBcAimGJAgQAbwEAAAAA","location":[1.532966,42.557828],"name":"Carrer del Turer","distance":1.69633755}]}
7
{"message":"Exclude flag combination is not supported.","code":"InvalidValue"}
Fix
class_data.hpp
using ClassData = std::uint8_t;
constexpr ClassData INAVLID_CLASS_DATA = std::numeric_limits<ClassData>::max();
static const std::uint8_t MAX_CLASS_INDEX = 8 - 1;
static const std::uint8_t MAX_EXCLUDABLE_CLASSES = 8;extractor.cpp
if (excludable_classes.size() > MAX_EXCLUDABLE_CLASSES)
{
throw util::exception("Only " + std::to_string(MAX_EXCLUDABLE_CLASSES) +
" excludable combinations allowed.");
}
// The exclude index 0 is reserve for not excludeing anything
profile_properties.SetExcludableClasses(0, 0);
std::size_t combination_index = 1;
for (const auto &combination : excludable_classes)As 0 index and mask are for no exclusion (right?), it looks like to me only 7 excludate sets should be allowed. And so the fix could be
diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp
index 435a0e481..0d52715ac 100644
--- a/src/extractor/extractor.cpp
+++ b/src/extractor/extractor.cpp
@@ -114,9 +114,9 @@ void SetExcludableClasses(const ExtractorCallbacks::ClassesMap &classes_map,
const std::vector<std::vector<std::string>> &excludable_classes,
ProfileProperties &profile_properties)
{
- if (excludable_classes.size() > MAX_EXCLUDABLE_CLASSES)
+ if (excludable_classes.size() > MAX_CLASS_INDEX)
{
- throw util::exception("Only " + std::to_string(MAX_EXCLUDABLE_CLASSES) +
+ throw util::exception("Only " + std::to_string(MAX_CLASS_INDEX) +
" excludable combinations allowed.");
}