Skip to content

Commit

Permalink
separate require bike transport request flag (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling authored Nov 1, 2024
1 parent 48ff42a commit cc32e20
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[osr]
[email protected]:motis-project/osr.git
branch=master
commit=d7aacbe419824dcac29d3e9b016385c05d08bb91
commit=6c7f593aa694700a39084cfda8552422aa2c05d2
[utl]
[email protected]:motis-project/utl.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 @@
14838580964254850101
7997122102643462416
cista 5b6808fd7d7a7c1c7e4cb152b563dbf71e3efba4
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 73549ebca677fe6214202a1ab580362b4f80e653
Expand Down Expand Up @@ -39,7 +39,7 @@ sol2 40c7cbc7c5cfed1e8c7f1bbe6fcbe23d7a67fc75
variant 5aa73631dc969087c77433a5cdef246303051f69
tiles 6b6dc45bc904966640c7207ab91950848a8b3f6c
rtree.c 6ed73a7dc4f1184f2b5b2acd8ac1c2b28a273057
osr d7aacbe419824dcac29d3e9b016385c05d08bb91
osr 6c7f593aa694700a39084cfda8552422aa2c05d2
yaml-cpp 1d8ca1f35eb3a9c9142462b28282a848e5d29a91
reflect-cpp c54fe66de4650b60c23aadd4a06d9db4ffeda22f
FTXUI dd6a5d371fd7a3e2937bb579955003c54b727233
Expand Down
19 changes: 13 additions & 6 deletions exe/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ int main(int ac, char** av) {
" static timetables.\n"
" This enables transit routing");

auto const help = [&]() {
std::cout << "MOTIS " << MOTIS_VERSION << "\n\n"
<< "Usage:\n"
" - simple: motis [PATHS...]\n"
" - import: motis import [-c config.yml] [-d data_dir]\n"
" - server: motis server [-d data_dir]\n\n"
<< desc << "\n";
};

enum mode { kImport, kServer, kSimple } mode = kSimple;
if (ac > 1) {
auto const cmd = std::string_view{av[1]};
Expand All @@ -70,6 +79,9 @@ int main(int ac, char** av) {
++av;
break;
}
} else {
help();
return 1;
}

auto pos = po::positional_options_description{}.add("paths", -1);
Expand All @@ -82,12 +94,7 @@ int main(int ac, char** av) {
std::cout << MOTIS_VERSION << "\n";
return 0;
} else if (vm.count("help")) {
std::cout << "MOTIS " << MOTIS_VERSION << "\n\n"
<< "Usage:\n"
" - simple: motis [PATHS...]\n"
" - import: motis import [-c config.yml] [-d data_dir]\n"
" - server: motis server [-d data_dir]\n\n"
<< desc << "\n";
help();
return 0;
}

Expand Down
13 changes: 11 additions & 2 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,17 @@ paths:
default: 7200
minium: 0

- name: requireBikeTransport
in: query
required: false
schema:
type: boolean
default: false
description: |
Optional. Default is `false`.
If set to `true`, all used transit trips are required to allow bike carriage.
- name: maxPreTransitTime
in: query
required: false
Expand Down Expand Up @@ -858,12 +869,10 @@ components:
description: |
- `NORMAL` - latitude / longitude coordinate or address
- `BIKESHARE` - bike sharing station
- `BIKEPARK` - bike parking
- `TRANSIT` - transit stop
enum:
- NORMAL
- BIKESHARE
- BIKEPARK
- TRANSIT

Place:
Expand Down
7 changes: 1 addition & 6 deletions src/endpoints/routing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ std::vector<n::routing::offset> station_start(n::location_idx_t const l) {
return {{l, n::duration_t{0U}, 0U}};
}

bool require_bike_transport(std::vector<api::ModeEnum> const& mode) {
return utl::any_of(
mode, [](api::ModeEnum const m) { return m == api::ModeEnum::BIKE; });
}

td_offsets_t routing::get_td_offsets(elevators const& e,
osr::location const& pos,
osr::direction const dir,
Expand Down Expand Up @@ -465,7 +460,7 @@ api::plan_response routing::operator()(boost::urls::url_view const& url) const {
.extend_interval_later_ = start_time.extend_interval_later_,
.prf_idx_ = static_cast<n::profile_idx_t>(query.wheelchair_ ? 2U : 1U),
.allowed_claszes_ = to_clasz_mask(modes),
.require_bike_transport_ = require_bike_transport(modes),
.require_bike_transport_ = query.requireBikeTransport_,
.fastest_direct_ = fastest_direct == kInfinityDuration
? std::nullopt
: std::optional{fastest_direct}};
Expand Down

0 comments on commit cc32e20

Please sign in to comment.