Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTP API routing options, force input level match by default #69

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/ppr/backend/requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ppr/common/location.h"
#include "ppr/routing/input_location.h"
#include "ppr/routing/routing_options.h"
#include "ppr/routing/search_profile.h"

namespace ppr::backend {
Expand All @@ -12,6 +13,9 @@ struct route_request {
ppr::routing::input_location start_;
ppr::routing::input_location destination_;
ppr::routing::search_profile profile_;

routing::routing_options options_;

bool include_infos_{};
bool include_full_path_{};
bool include_steps_{};
Expand Down
2 changes: 1 addition & 1 deletion include/ppr/routing/routing_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct routing_options {
bool allow_expansion_{true};
bool allow_osm_id_expansion_{true};

bool force_level_match_{false};
bool force_level_match_{true};
double level_dist_penalty_{50 * 50};

unsigned initial_max_pt_query_{10};
Expand Down
15 changes: 14 additions & 1 deletion src/backend/http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,25 @@ rapidjson::Document parse_json(std::string const& s) {
route_request parse_route_request(web_server::http_req_t const& req) {
route_request r{};
auto doc = parse_json(req.body());

get_input_location(r.start_, doc, "start");
get_input_location(r.destination_, doc, "destination");
get_profile(r.profile_, doc, "profile");

get_bool(r.options_.force_level_match_, doc, "force_level_match");
get_double(r.options_.level_dist_penalty_, doc, "level_dist_penalty");
get_int(r.options_.initial_max_pt_query_, doc, "initial_max_pt_query");
get_int(r.options_.initial_max_pt_count_, doc, "initial_max_pt_count");
get_int(r.options_.expanded_max_pt_query_, doc, "expanded_max_pt_query");
get_int(r.options_.expanded_max_pt_count_, doc, "expanded_max_pt_count");

get_bool(r.include_infos_, doc, "include_infos");
get_bool(r.include_full_path_, doc, "include_full_path");
get_bool(r.include_steps_, doc, "include_steps");
get_bool(r.include_steps_path_, doc, "include_steps_path");
get_bool(r.include_edges_, doc, "include_edges");
get_bool(r.include_statistics_, doc, "include_statistics");

return r;
}

Expand Down Expand Up @@ -120,7 +130,10 @@ struct http_server::impl {
}

auto const rq =
ppr::routing::routing_query{r.start_, {r.destination_}, r.profile_};
ppr::routing::routing_query{.start_ = r.start_,
.destinations_ = {r.destination_},
.profile_ = r.profile_,
.opt_ = r.options_};
auto const result = find_routes_v2(graph_, rq);
auto const& stats = result.stats_;

Expand Down