Skip to content

Commit

Permalink
factor to inflate the duration of the fastest direct connection found (
Browse files Browse the repository at this point in the history
  • Loading branch information
mority authored Feb 20, 2025
1 parent fb604ba commit cb852dc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/motis/endpoints/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ struct routing {
nigiri::unixtime_t start_time,
bool wheelchair,
std::chrono::seconds max,
double max_matching_distance) const;
double max_matching_distance,
double fastest_direct_factor) const;

config const& config_;
osr::ways const* w_;
Expand Down
12 changes: 12 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,18 @@ paths:
default: 1800
minimum: 0

- name: fastestDirectFactor
in: query
required: false
description: |
Optional. Experimental. Default is `1.0`.
Factor with which the duration of the fastest direct connection is multiplied.
Values > 1.0 allow connections that are slower than the fastest direct connection to be found.
schema:
type: number
default: 1.0
minimum: 0

- name: timeout
in: query
required: false
Expand Down
10 changes: 7 additions & 3 deletions src/endpoints/routing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ std::pair<std::vector<api::Itinerary>, n::duration_t> routing::route_direct(
n::unixtime_t const start_time,
bool wheelchair,
std::chrono::seconds max,
double const max_matching_distance) const {
double const max_matching_distance,
double const fastest_direct_factor) const {
if (!w_ || !l_) {
return {};
}
Expand Down Expand Up @@ -326,7 +327,10 @@ std::pair<std::vector<api::Itinerary>, n::duration_t> routing::route_direct(
}
}
}
return {itineraries, fastest_direct};
return {itineraries, fastest_direct != kInfinityDuration
? std::chrono::round<n::duration_t>(
fastest_direct * fastest_direct_factor)
: fastest_direct};
}

using stats_map_t = std::map<std::string, std::uint64_t>;
Expand Down Expand Up @@ -456,7 +460,7 @@ api::plan_response routing::operator()(boost::urls::url_view const& url) const {
query.pedestrianProfile_ ==
api::PedestrianProfileEnum::WHEELCHAIR,
std::chrono::seconds{query.maxDirectTime_},
query.maxMatchingDistance_)
query.maxMatchingDistance_, query.fastestDirectFactor_)
: std::pair{std::vector<api::Itinerary>{}, kInfinityDuration};
UTL_STOP_TIMING(direct);

Expand Down
3 changes: 2 additions & 1 deletion src/odm/meta_router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ n::duration_t init_direct(std::vector<direct_ride>& direct_rides,
e, gbfs, from_p, to_p, {api::ModeEnum::CAR}, std::nullopt, std::nullopt,
std::nullopt, intvl.from_,
query.pedestrianProfile_ == api::PedestrianProfileEnum::WHEELCHAIR,
std::chrono::seconds{query.maxDirectTime_}, query.maxMatchingDistance_);
std::chrono::seconds{query.maxDirectTime_}, query.maxMatchingDistance_,
query.fastestDirectFactor_);
direct_rides.clear();
if (query.arriveBy_) {
for (auto arr =
Expand Down

0 comments on commit cb852dc

Please sign in to comment.