Skip to content

Commit

Permalink
Use maxTravelTime to filter results (#668)
Browse files Browse the repository at this point in the history
* Use 'maxTravelTime' to filter results

* Change unit to minutes

* Fix formatting

* Fix type for MSVC build

* Update nigiri dependency

* Set limit for maximum travel time
  • Loading branch information
MichaelKutzner authored Dec 9, 2024
1 parent e850634 commit f9b0bb8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[nigiri]
[email protected]:motis-project/nigiri.git
branch=master
commit=815bd0c66f7f64aa6edd6011b8e065cc9e1e641b
commit=2cf648ac22315fb6578be3f5d689f4d94e81b457
[cista]
[email protected]:felixguendling/cista.git
branch=master
Expand Down
4 changes: 2 additions & 2 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
782561049874253657
11944721483929486774
cista 847b27100b7e730370b810ce62206a66b0bf2d79
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 930f38eb0365ceb7853273e03da4d9e7787abfb9
Expand Down Expand Up @@ -26,7 +26,7 @@ opentelemetry-cpp 60770dc9dc63e3543fc87d605b2e88fd53d7a414
pugixml 60175e80e2f5e97e027ac78f7e14c5acc009ce50
unordered_dense b33b037377ca966bbdd9cccc3417e46e88f83bfb
wyhash 1e012b57fc2227a9e583a57e2eacb3da99816d99
nigiri 815bd0c66f7f64aa6edd6011b8e065cc9e1e641b
nigiri 2cf648ac22315fb6578be3f5d689f4d94e81b457
conf f9bf4bd83bf55a2170725707e526cbacc45dcc66
expat 636c9861e8e7c119f3626d1e6c260603ab624516
libosmium 6e6d6b3081cc8bdf25dda89730e25c36eb995516
Expand Down
8 changes: 3 additions & 5 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -359,22 +359,20 @@ paths:
schema:
type: integer

- name: maxHours
- name: maxTravelTime
in: query
required: false
description: |
The maximum travel time in hours.
The maximum travel time in minutes.
If not provided, the routing to uses the value
hardcoded in the server which is usually quite high.
*Warning*: Use with care. Setting this too low can lead to
optimal (e.g. the least transfers) journeys not being found.
If this value is too low to reach the destination at all,
it can lead to slow routing performance.
TODO: pass parameter to nigiri
schema:
type: number
type: integer

- name: minTransferTime
in: query
Expand Down
7 changes: 7 additions & 0 deletions src/endpoints/routing.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "motis/endpoints/routing.h"

#include <algorithm>

#include "boost/thread/tss.hpp"

#include "utl/erase_duplicates.h"
Expand Down Expand Up @@ -457,6 +459,11 @@ api::plan_response routing::operator()(boost::urls::url_view const& url) const {
.max_transfers_ = static_cast<std::uint8_t>(
query.maxTransfers_.has_value() ? *query.maxTransfers_
: n::routing::kMaxTransfers),
.max_travel_time_ = query.maxTravelTime_
.and_then([](std::int64_t const dur) {
return std::optional{n::duration_t{dur}};
})
.value_or(kInfinityDuration),
.min_connection_count_ = static_cast<unsigned>(query.numItineraries_),
.extend_interval_earlier_ = start_time.extend_interval_earlier_,
.extend_interval_later_ = start_time.extend_interval_later_,
Expand Down

0 comments on commit f9b0bb8

Please sign in to comment.