From b384340cbb40ea20a8b156d80e04b794371ba765 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Mon, 5 Jan 2015 12:57:34 +0100 Subject: [PATCH] Revert "remove remnants of hinting mechanism" This reverts commit 7de428233eb4e4e4bd585d810fc212cd89267264. --- Include/osrm/RouteParameters.h | 4 +++- data_structures/route_parameters.cpp | 14 +++++++------- plugins/hello_world.hpp | 12 ++++++++++++ tools/simpleclient.cpp | 2 ++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Include/osrm/RouteParameters.h b/Include/osrm/RouteParameters.h index 9eb1ccc08..fd570a1ef 100644 --- a/Include/osrm/RouteParameters.h +++ b/Include/osrm/RouteParameters.h @@ -40,7 +40,7 @@ struct RouteParameters RouteParameters(); void setZoomLevel(const short level); - + void setNumberOfResults(const short number); void setAlternateRouteFlag(const bool flag); @@ -78,11 +78,13 @@ struct RouteParameters bool compression; bool deprecatedAPI; bool uturn_default; + unsigned check_sum; short num_results; std::string service; std::string output_format; std::string jsonp_parameter; std::string language; + std::vector hints; std::vector uturns; std::vector coordinates; }; diff --git a/data_structures/route_parameters.cpp b/data_structures/route_parameters.cpp index 08aad949d..1019a9149 100644 --- a/data_structures/route_parameters.cpp +++ b/data_structures/route_parameters.cpp @@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. RouteParameters::RouteParameters() : zoom_level(18), print_instructions(false), alternate_route(true), geometry(true), - compression(true), deprecatedAPI(false), uturn_default(false), num_results(1) + compression(true), deprecatedAPI(false), uturn_default(false), check_sum(-1), num_results(1) { } @@ -77,7 +77,7 @@ void RouteParameters::setAllUTurns(const bool flag) void RouteParameters::setDeprecatedAPIFlag(const std::string &) { deprecatedAPI = true; } -void RouteParameters::setChecksum(const unsigned sum) { } +void RouteParameters::setChecksum(const unsigned sum) { check_sum = sum; } void RouteParameters::setInstructionFlag(const bool flag) { print_instructions = flag; } @@ -92,11 +92,11 @@ void RouteParameters::setJSONpParameter(const std::string ¶meter) void RouteParameters::addHint(const std::string &hint) { - // hints.resize(coordinates.size()); - // if (!hints.empty()) - // { - // hints.back() = hint; - // } + hints.resize(coordinates.size()); + if (!hints.empty()) + { + hints.back() = hint; + } } void RouteParameters::setLanguage(const std::string &language_string) diff --git a/plugins/hello_world.hpp b/plugins/hello_world.hpp index c6cc1aed3..c8b07b081 100644 --- a/plugins/hello_world.hpp +++ b/plugins/hello_world.hpp @@ -57,6 +57,8 @@ class HelloWorldPlugin final : public BasePlugin temp_string = cast::integral_to_string(routeParameters.zoom_level); json_result.values["zoom_level"] = temp_string; + temp_string = cast::integral_to_string(routeParameters.check_sum); + json_result.values["check_sum"] = temp_string; json_result.values["instructions"] = (routeParameters.print_instructions ? "yes" : "no"); json_result.values["geometry"] = (routeParameters.geometry ? "yes" : "no"); json_result.values["compression"] = (routeParameters.compression ? "yes" : "no"); @@ -84,6 +86,16 @@ class HelloWorldPlugin final : public BasePlugin ++counter; } json_result.values["locations"] = json_locations; + json_result.values["hint_count"] = routeParameters.hints.size(); + + JSON::Array json_hints; + counter = 0; + for (const std::string ¤t_hint : routeParameters.hints) + { + json_hints.values.push_back(current_hint); + ++counter; + } + json_result.values["hints"] = json_hints; JSON::render(reply.content, json_result); } diff --git a/tools/simpleclient.cpp b/tools/simpleclient.cpp index e328b4cc9..b6714566a 100644 --- a/tools/simpleclient.cpp +++ b/tools/simpleclient.cpp @@ -90,10 +90,12 @@ int main(int argc, const char *argv[]) route_parameters.alternate_route = true; // get an alternate route, too route_parameters.geometry = true; // retrieve geometry of route route_parameters.compression = true; // polyline encoding + route_parameters.check_sum = UINT_MAX; // see wiki route_parameters.service = "viaroute"; // that's routing route_parameters.output_format = "json"; route_parameters.jsonp_parameter = ""; // set for jsonp wrapping route_parameters.language = ""; // unused atm + // route_parameters.hints.push_back(); // see wiki, saves I/O if done properly // start_coordinate route_parameters.coordinates.emplace_back(52.519930 * COORDINATE_PRECISION,