Skip to content

Commit

Permalink
Add HTTP API routing options, force input level match by default (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohoch authored Mar 8, 2024
1 parent 20e8f98 commit 29453ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
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

0 comments on commit 29453ed

Please sign in to comment.