From cb212a7315bb2986728408c87361dacce59a239d Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Thu, 17 Mar 2016 13:52:45 +0100 Subject: [PATCH] Makes table plugin adhere to v5 spec for limit violations, fixes #2100 --- src/engine/plugins/table.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/engine/plugins/table.cpp b/src/engine/plugins/table.cpp index 2d13e1051..27e310054 100644 --- a/src/engine/plugins/table.cpp +++ b/src/engine/plugins/table.cpp @@ -44,17 +44,18 @@ Status TablePlugin::HandleRequest(const api::TableParameters ¶ms, util::json result); } + // Empty sources or destinations means the user wants all of them included, respectively + // The ManyToMany routing algorithm we dispatch to below already handles this perfectly. + const auto num_sources = + params.sources.empty() ? params.coordinates.size() : params.sources.size(); + const auto num_destinations = + params.destinations.empty() ? params.coordinates.size() : params.destinations.size(); + if (max_locations_distance_table > 0 && - (params.sources.size() * params.destinations.size() > + ((num_sources * num_destinations) > static_cast(max_locations_distance_table * max_locations_distance_table))) { - return Error( - "InvalidOptions", - "Number of entries " + - std::to_string(params.sources.size() * params.destinations.size()) + - " is higher than current maximum (" + - std::to_string(max_locations_distance_table * max_locations_distance_table) + ")", - result); + return Error("TooBig", "Too many table coordinates", result); } auto snapped_phantoms = SnapPhantomNodes(GetPhantomNodes(params));