From cc32e20edccea339fd09f08b90781731773b090a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Fri, 1 Nov 2024 01:14:09 +0100 Subject: [PATCH] separate require bike transport request flag (#636) --- .pkg | 2 +- .pkg.lock | 4 ++-- exe/main.cc | 19 +++++++++++++------ openapi.yaml | 13 +++++++++++-- src/endpoints/routing.cc | 7 +------ 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.pkg b/.pkg index 5d8ed9340..ffdc71550 100644 --- a/.pkg +++ b/.pkg @@ -9,7 +9,7 @@ [osr] url=git@github.com:motis-project/osr.git branch=master - commit=d7aacbe419824dcac29d3e9b016385c05d08bb91 + commit=6c7f593aa694700a39084cfda8552422aa2c05d2 [utl] url=git@github.com:motis-project/utl.git branch=master diff --git a/.pkg.lock b/.pkg.lock index e99681856..41248823f 100644 --- a/.pkg.lock +++ b/.pkg.lock @@ -1,4 +1,4 @@ -14838580964254850101 +7997122102643462416 cista 5b6808fd7d7a7c1c7e4cb152b563dbf71e3efba4 zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3 boost 73549ebca677fe6214202a1ab580362b4f80e653 @@ -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 diff --git a/exe/main.cc b/exe/main.cc index e52b5894c..2bcfc45c5 100644 --- a/exe/main.cc +++ b/exe/main.cc @@ -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]}; @@ -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); @@ -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; } diff --git a/openapi.yaml b/openapi.yaml index 1fd2cb471..fb4f742d9 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -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 @@ -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: diff --git a/src/endpoints/routing.cc b/src/endpoints/routing.cc index b9b847cc4..bf41fa813 100644 --- a/src/endpoints/routing.cc +++ b/src/endpoints/routing.cc @@ -73,11 +73,6 @@ std::vector station_start(n::location_idx_t const l) { return {{l, n::duration_t{0U}, 0U}}; } -bool require_bike_transport(std::vector 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, @@ -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(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}};