diff --git a/base/module/src/dispatcher.cc b/base/module/src/dispatcher.cc index 775859702..0e464498e 100644 --- a/base/module/src/dispatcher.cc +++ b/base/module/src/dispatcher.cc @@ -138,9 +138,6 @@ msg_ptr dispatcher::api_desc(int const id) const { } void dispatcher::handle_no_target(msg_ptr const& msg, callback const& cb) { - LOG(logging::warn) << "target \"" - << msg->get()->destination()->target()->str() - << "\" not found"; if (queue_no_target_msgs_) { no_target_msg_queue_.emplace(msg, cb); } else { diff --git a/modules/intermodal/include/motis/intermodal/direct_connections.h b/modules/intermodal/include/motis/intermodal/direct_connections.h index f7e32bf97..147e5a9a8 100644 --- a/modules/intermodal/include/motis/intermodal/direct_connections.h +++ b/modules/intermodal/include/motis/intermodal/direct_connections.h @@ -26,8 +26,7 @@ struct direct_connection { std::vector get_direct_connections( query_start const& q_start, query_dest const& q_dest, - IntermodalRoutingRequest const* req, ppr_profiles const& profiles, - bool const ppr_fallback); + IntermodalRoutingRequest const* req, ppr_profiles const& profiles); std::size_t remove_dominated_journeys( std::vector& journeys, diff --git a/modules/intermodal/include/motis/intermodal/intermodal.h b/modules/intermodal/include/motis/intermodal/intermodal.h index d0675f671..773041d1b 100644 --- a/modules/intermodal/include/motis/intermodal/intermodal.h +++ b/modules/intermodal/include/motis/intermodal/intermodal.h @@ -26,7 +26,6 @@ struct intermodal : public motis::module::module { std::string router_{"routing"}; bool revise_{false}; - bool ppr_fallback_{false}; ppr_profiles ppr_profiles_; }; diff --git a/modules/intermodal/include/motis/intermodal/mumo_edge.h b/modules/intermodal/include/motis/intermodal/mumo_edge.h index 4a1d48151..05820d2ef 100644 --- a/modules/intermodal/include/motis/intermodal/mumo_edge.h +++ b/modules/intermodal/include/motis/intermodal/mumo_edge.h @@ -64,10 +64,10 @@ using mumo_stats_appender_fun = std::function; void make_starts(IntermodalRoutingRequest const*, geo::latlng const&, appender_fun const&, mumo_stats_appender_fun const&, - ppr_profiles const&, bool ppr_fallback); + ppr_profiles const&); void make_dests(IntermodalRoutingRequest const*, geo::latlng const&, appender_fun const&, mumo_stats_appender_fun const&, - ppr_profiles const&, bool ppr_fallback); + ppr_profiles const&); void remove_intersection(std::vector& starts, std::vector& destinations, diff --git a/modules/intermodal/src/direct_connections.cc b/modules/intermodal/src/direct_connections.cc index d8da37b94..55c4ed309 100644 --- a/modules/intermodal/src/direct_connections.cc +++ b/modules/intermodal/src/direct_connections.cc @@ -188,8 +188,7 @@ msg_ptr make_direct_osrm_request(geo::latlng const& start, std::vector get_direct_connections( query_start const& q_start, query_dest const& q_dest, - IntermodalRoutingRequest const* req, ppr_profiles const& profiles, - bool const ppr_fallback) { + IntermodalRoutingRequest const* req, ppr_profiles const& profiles) { auto direct = std::vector{}; auto const beeline = distance(q_start.pos_, q_dest.pos_); @@ -199,35 +198,18 @@ std::vector get_direct_connections( auto const ppr_settings = get_direct_ppr_settings(req, profiles); if (ppr_settings.max_duration_ > 0 && beeline <= ppr_settings.max_distance_) { futures.emplace_back(spawn_job_void([&]() { - try { - auto const ppr_msg = - motis_call(make_direct_ppr_request( - q_start.pos_, q_dest.pos_, ppr_settings.profile_, - ppr_settings.max_duration_, req->search_dir())) - ->val(); - auto const ppr_resp = motis_content(FootRoutingResponse, ppr_msg); - auto const routes = ppr_resp->routes(); - - if (routes->size() == 1) { - std::lock_guard guard{direct_mutex}; - for (auto const& route : *routes->Get(0)->routes()) { - direct.emplace_back(mumo_type::FOOT, route->duration(), - route->accessibility()); - } - } else if (ppr_fallback) { - std::lock_guard guard{direct_mutex}; - auto const duration = - (beeline / profiles.get_walking_speed(ppr_settings.profile_)) / - 60.0F * 1.5F; - direct.emplace_back(mumo_type::FOOT, duration, 0); - } - } catch (std::exception const& /* module not found */) { - if (ppr_fallback) { - std::lock_guard guard{direct_mutex}; - auto const duration = - (beeline / profiles.get_walking_speed(ppr_settings.profile_)) / - 60.0F * 1.5F; - direct.emplace_back(mumo_type::FOOT, duration, 0); + auto const ppr_msg = + motis_call(make_direct_ppr_request( + q_start.pos_, q_dest.pos_, ppr_settings.profile_, + ppr_settings.max_duration_, req->search_dir())) + ->val(); + auto const ppr_resp = motis_content(FootRoutingResponse, ppr_msg); + auto const routes = ppr_resp->routes(); + if (routes->size() == 1) { + std::lock_guard guard{direct_mutex}; + for (auto const& route : *routes->Get(0)->routes()) { + direct.emplace_back(mumo_type::FOOT, route->duration(), + route->accessibility()); } } })); diff --git a/modules/intermodal/src/intermodal.cc b/modules/intermodal/src/intermodal.cc index 7c13542d1..5ab7049d3 100644 --- a/modules/intermodal/src/intermodal.cc +++ b/modules/intermodal/src/intermodal.cc @@ -38,9 +38,6 @@ namespace motis::intermodal { intermodal::intermodal() : module("Intermodal Options", "intermodal") { param(router_, "router", "routing module"); param(revise_, "revise", "revise connections"); - param(ppr_fallback_, "ppr_fallback", - "use direct line as fallback if ppr is not available or results are " - "empty (useful if ppr doesn't cover the whole timetable area)"); } intermodal::~intermodal() = default; @@ -205,12 +202,14 @@ void apply_parking_patches(journey& j, std::vector& patches) { } } -msg_ptr postprocess_response( - msg_ptr const& response_msg, query_start const& q_start, - query_dest const& q_dest, IntermodalRoutingRequest const* req, - std::vector const& edge_mapping, statistics& stats, - bool const revise, std::vector const& mumo_stats, - ppr_profiles const& profiles, bool const ppr_fallback) { +msg_ptr postprocess_response(msg_ptr const& response_msg, + query_start const& q_start, + query_dest const& q_dest, + IntermodalRoutingRequest const* req, + std::vector const& edge_mapping, + statistics& stats, bool const revise, + std::vector const& mumo_stats, + ppr_profiles const& profiles) { auto const dir = req->search_dir(); auto routing_response = motis_content(RoutingResponse, response_msg); auto journeys = message_to_journeys(routing_response); @@ -260,8 +259,7 @@ msg_ptr postprocess_response( } MOTIS_START_TIMING(direct_connection_timing); - auto const direct = - get_direct_connections(q_start, q_dest, req, profiles, ppr_fallback); + auto const direct = get_direct_connections(q_start, q_dest, req, profiles); stats.dominated_by_direct_connection_ = remove_dominated_journeys(journeys, direct); add_direct_connections(journeys, direct, q_start, q_dest, req); @@ -366,7 +364,7 @@ msg_ptr intermodal::route(msg_ptr const& msg) { req, start.pos_, std::bind(appender, std::ref(deps), // NOLINT STATION_START, _1, start.pos_, _2, _3, _4, _5, _6), - mumo_stats_appender, ppr_profiles_, ppr_fallback_); + mumo_stats_appender, ppr_profiles_); })); } if (dest.is_intermodal_) { @@ -374,7 +372,7 @@ msg_ptr intermodal::route(msg_ptr const& msg) { make_dests(req, dest.pos_, std::bind(appender, std::ref(arrs), // NOLINT _1, STATION_END, _2, dest.pos_, _3, _4, _5, _6), - mumo_stats_appender, ppr_profiles_, ppr_fallback_); + mumo_stats_appender, ppr_profiles_); })); } } else { @@ -384,7 +382,7 @@ msg_ptr intermodal::route(msg_ptr const& msg) { req, start.pos_, std::bind(appender, std::ref(deps), // NOLINT _1, STATION_START, _2, start.pos_, _3, _4, _5, _6), - mumo_stats_appender, ppr_profiles_, ppr_fallback_); + mumo_stats_appender, ppr_profiles_); })); } if (dest.is_intermodal_) { @@ -392,7 +390,7 @@ msg_ptr intermodal::route(msg_ptr const& msg) { make_dests(req, dest.pos_, std::bind(appender, std::ref(arrs), // NOLINT STATION_END, _1, dest.pos_, _2, _3, _4, _5, _6), - mumo_stats_appender, ppr_profiles_, ppr_fallback_); + mumo_stats_appender, ppr_profiles_); })); } } @@ -435,8 +433,7 @@ msg_ptr intermodal::route(msg_ptr const& msg) { stats.routing_duration_ = static_cast(MOTIS_TIMING_MS(routing_timing)); return postprocess_response(resp, start, dest, req, edge_mapping, stats, - revise_, mumo_stats, ppr_profiles_, - ppr_fallback_); + revise_, mumo_stats, ppr_profiles_); } } // namespace motis::intermodal diff --git a/modules/intermodal/src/mumo_edge.cc b/modules/intermodal/src/mumo_edge.cc index 18a7e41a6..bb8f852a5 100644 --- a/modules/intermodal/src/mumo_edge.cc +++ b/modules/intermodal/src/mumo_edge.cc @@ -103,7 +103,7 @@ msg_ptr make_ppr_request(latlng const& pos, void ppr_edges(latlng const& pos, SearchOptions const* search_options, Direction direction, appender_fun const& appender, - ppr_profiles const& profiles, bool const ppr_fallback) { + ppr_profiles const& profiles) { auto const max_dur = search_options->duration_limit(); if (max_dur == 0) { return; @@ -114,46 +114,21 @@ void ppr_edges(latlng const& pos, SearchOptions const* search_options, auto const geo_resp = motis_content(LookupGeoStationResponse, geo_msg); auto const stations = geo_resp->stations(); - auto const make_direct_edges_fallback = [&]() { - for (auto const& s : *stations) { - auto const station_pos = to_latlng(s->pos()); - auto const duration = - (distance(station_pos, pos) / - profiles.get_walking_speed(search_options->profile()->str())) / - 60.0F * 1.5F; - if (duration <= search_options->duration_limit()) { - appender(s->id()->str(), station_pos, duration, 0, mumo_type::FOOT, 0); - } - } - }; - - try { - auto const ppr_msg = - motis_call(make_ppr_request(pos, stations, search_options, direction)) - ->val(); - auto const ppr_resp = motis_content(FootRoutingResponse, ppr_msg); - - auto const routes = ppr_resp->routes(); - if (ppr_fallback && routes->size() == 0U) { - make_direct_edges_fallback(); - return; - } - - assert(routes->size() <= stations->size()); - for (auto i = 0U; i < routes->size(); ++i) { - auto const dest_routes = routes->Get(i); - auto const dest_id = stations->Get(i)->id()->str(); - auto const dest_pos = to_latlng(stations->Get(i)->pos()); - for (auto const& route : *dest_routes->routes()) { - appender(dest_id, dest_pos, route->duration(), route->accessibility(), - mumo_type::FOOT, 0); - } - } - } catch (std::exception const& /* probably module not found */) { - if (!ppr_fallback) { - throw; + auto const ppr_msg = + motis_call(make_ppr_request(pos, stations, search_options, direction)) + ->val(); + auto const ppr_resp = motis_content(FootRoutingResponse, ppr_msg); + + auto const routes = ppr_resp->routes(); + assert(routes->size() <= stations->size()); + for (auto i = 0U; i < routes->size(); ++i) { + auto const dest_routes = routes->Get(i); + auto const dest_id = stations->Get(i)->id()->str(); + auto const dest_pos = to_latlng(stations->Get(i)->pos()); + for (auto const& route : *dest_routes->routes()) { + appender(dest_id, dest_pos, route->duration(), route->accessibility(), + mumo_type::FOOT, 0); } - make_direct_edges_fallback(); } } @@ -200,7 +175,7 @@ void make_edges(Vector> const* modes, latlng const& pos, Direction const osrm_direction, appender_fun const& appender, mumo_stats_appender_fun const& mumo_stats_appender, std::string const& mumo_stats_prefix, - ppr_profiles const& profiles, bool const ppr_fallback) { + ppr_profiles const& profiles) { for (auto const& wrapper : *modes) { switch (wrapper->mode_type()) { case Mode_Foot: { @@ -233,8 +208,7 @@ void make_edges(Vector> const* modes, latlng const& pos, case Mode_FootPPR: { auto const options = reinterpret_cast(wrapper->mode())->search_options(); - ppr_edges(pos, options, osrm_direction, appender, profiles, - ppr_fallback); + ppr_edges(pos, options, osrm_direction, appender, profiles); break; } @@ -254,17 +228,17 @@ void make_edges(Vector> const* modes, latlng const& pos, void make_starts(IntermodalRoutingRequest const* req, latlng const& pos, appender_fun const& appender, mumo_stats_appender_fun const& mumo_stats_appender, - ppr_profiles const& profiles, bool const ppr_fallback) { + ppr_profiles const& profiles) { make_edges(req->start_modes(), pos, Direction_Forward, appender, - mumo_stats_appender, "intermodal.start.", profiles, ppr_fallback); + mumo_stats_appender, "intermodal.start.", profiles); } void make_dests(IntermodalRoutingRequest const* req, latlng const& pos, appender_fun const& appender, mumo_stats_appender_fun const& mumo_stats_appender, - ppr_profiles const& profiles, bool const ppr_fallback) { + ppr_profiles const& profiles) { make_edges(req->destination_modes(), pos, Direction_Backward, appender, - mumo_stats_appender, "intermodal.dest.", profiles, ppr_fallback); + mumo_stats_appender, "intermodal.dest.", profiles); } void remove_intersection(std::vector& starts,