From fa114575f357fe13b8712d6e75aae9330efb3a95 Mon Sep 17 00:00:00 2001 From: mority Date: Wed, 28 Aug 2024 18:08:22 +0200 Subject: [PATCH 01/27] bug fix: merge trip active days, early bail out similar location sequence --- src/loader/merge_duplicates.cc | 45 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/loader/merge_duplicates.cc b/src/loader/merge_duplicates.cc index 46ea49c0..3f4c2471 100644 --- a/src/loader/merge_duplicates.cc +++ b/src/loader/merge_duplicates.cc @@ -39,21 +39,31 @@ bool merge(timetable& tt, return false; } - if ((bf_a & bf_b) == bf_a) { - tt.transport_traffic_days_[b] = bitfield_idx_t{0U}; // disable trip 'b' - - for (auto const merged_trips_idx_b : tt.transport_to_trip_section_[b]) { - for (auto const b_trp : tt.merged_trips_[merged_trips_idx_b]) { - for (auto& [t, range] : tt.trip_transport_ranges_[b_trp]) { - if (t == b) { - t = a; // replace b with a in b's trip transport ranges + auto const merge_and_nullify = [&tt](transport_idx_t const x, + transport_idx_t const y) { + tt.transport_traffic_days_[x] = bitfield_idx_t{0U}; // disable trip 'b' + + for (auto const merged_trips_idx_a : tt.transport_to_trip_section_[x]) { + for (auto const a_trp : tt.merged_trips_[merged_trips_idx_a]) { + for (auto& [t, range] : tt.trip_transport_ranges_[a_trp]) { + if (t == x) { + t = y; // replace b with x in b's trip transport ranges } } } } + }; + + auto const is_superset = [](bitfield const& x, bitfield const& y) { + return (x & y) == x; + }; + + if (is_superset(bf_b, bf_a)) { + merge_and_nullify(a, b); + } else if (is_superset(bf_a, bf_b)) { + merge_and_nullify(b, a); } else { - tt.transport_traffic_days_[a] = tt.register_bitfield(bf_a | bf_b); - tt.transport_traffic_days_[b] = tt.register_bitfield(bf_b & ~bf_a); + tt.transport_traffic_days_[a] = tt.register_bitfield(bf_a & ~(bf_a & bf_b)); hash_set b_trips; for (auto const merged_trips_idx_b : tt.transport_to_trip_section_[b]) { @@ -100,11 +110,16 @@ unsigned find_duplicates(timetable& tt, continue; } - for (auto const [x, y] : utl::zip(a_loc_seq, b_loc_seq)) { - if (!matches.contains(make_match_pair(stop{x}.location_idx(), - stop{y}.location_idx()))) { - continue; - } + auto const station_sequence_matches = [&]() { + return utl::all_of(utl::zip(a_loc_seq, b_loc_seq), [&](auto&& pair) { + auto const [x, y] = pair; + return matches.contains( + make_match_pair(stop{x}.location_idx(), stop{y}.location_idx())); + }); + }; + + if (!station_sequence_matches()) { + continue; } auto const a_transport_range = tt.route_transport_ranges_[a_route]; From c853bb67ed1cb3f98303fa1ec31c3b68075507b0 Mon Sep 17 00:00:00 2001 From: mority Date: Thu, 29 Aug 2024 17:44:40 +0200 Subject: [PATCH 02/27] wip --- include/nigiri/loader/build_footpaths.h | 3 +- include/nigiri/loader/init_finish.h | 3 +- include/nigiri/loader/link_nearby_stations.h | 3 +- include/nigiri/loader/merge_duplicates.h | 4 +- src/loader/build_footpaths.cc | 12 +- src/loader/init_finish.cc | 6 +- src/loader/link_nearby_stations.cc | 29 +++- test/loader/merge_duplicates_test.cc | 170 +++++++++++++++++++ 8 files changed, 215 insertions(+), 15 deletions(-) create mode 100644 test/loader/merge_duplicates_test.cc diff --git a/include/nigiri/loader/build_footpaths.h b/include/nigiri/loader/build_footpaths.h index eefde79d..4089cf79 100644 --- a/include/nigiri/loader/build_footpaths.h +++ b/include/nigiri/loader/build_footpaths.h @@ -6,7 +6,8 @@ namespace nigiri::loader { void build_footpaths(timetable& tt, bool adjust_footpaths, - bool merge_duplicates, + bool merge_dupes_intra_src, + bool merge_dupes_inter_src, std::uint16_t max_footpath_length); } // namespace nigiri::loader diff --git a/include/nigiri/loader/init_finish.h b/include/nigiri/loader/init_finish.h index ae4cf2a2..f0fabfeb 100644 --- a/include/nigiri/loader/init_finish.h +++ b/include/nigiri/loader/init_finish.h @@ -12,7 +12,8 @@ namespace nigiri::loader { void register_special_stations(timetable&); void finalize(timetable&, bool adjust_footpaths = false, - bool merge_duplicates = false, + bool merge_dupes_intra_src = false, + bool merge_dupes_inter_src = false, std::uint16_t max_footpath_length = std::numeric_limits::max()); diff --git a/include/nigiri/loader/link_nearby_stations.h b/include/nigiri/loader/link_nearby_stations.h index 0dcfb8a3..1af4a28f 100644 --- a/include/nigiri/loader/link_nearby_stations.h +++ b/include/nigiri/loader/link_nearby_stations.h @@ -6,6 +6,7 @@ struct timetable; namespace nigiri::loader { -match_set_t link_nearby_stations(timetable&, bool const store_matches); +template +match_set_t link_nearby_stations(timetable&); } // namespace nigiri::loader \ No newline at end of file diff --git a/include/nigiri/loader/merge_duplicates.h b/include/nigiri/loader/merge_duplicates.h index 044c5b19..c2546769 100644 --- a/include/nigiri/loader/merge_duplicates.h +++ b/include/nigiri/loader/merge_duplicates.h @@ -10,7 +10,7 @@ using match_set_t = hash_set>; unsigned find_duplicates(timetable& tt, match_set_t const& matches, - location_idx_t const a, - location_idx_t const b); + location_idx_t a, + location_idx_t b); } // namespace nigiri::loader \ No newline at end of file diff --git a/src/loader/build_footpaths.cc b/src/loader/build_footpaths.cc index da769046..58239d8a 100644 --- a/src/loader/build_footpaths.cc +++ b/src/loader/build_footpaths.cc @@ -407,11 +407,17 @@ void write_footpaths(timetable& tt) { void build_footpaths(timetable& tt, bool const adjust_footpaths, - bool const merge_duplicates, + bool const merge_dupes_intra_src, + bool const merge_dupes_inter_src, std::uint16_t const max_footpath_length) { add_links_to_and_between_children(tt); - auto const matches = link_nearby_stations(tt, merge_duplicates); - if (merge_duplicates) { + auto const matches = + merge_dupes_intra_src && merge_dupes_inter_src + ? link_nearby_stations(tt) + : merge_dupes_intra_src ? link_nearby_stations(tt) + : merge_dupes_inter_src ? link_nearby_stations(tt) + : link_nearby_stations(tt); + if (merge_dupes_intra_src || merge_dupes_inter_src) { for (auto const& [a, b] : matches) { find_duplicates(tt, matches, a, b); } diff --git a/src/loader/init_finish.cc b/src/loader/init_finish.cc index a32a27fe..27aeb76e 100644 --- a/src/loader/init_finish.cc +++ b/src/loader/init_finish.cc @@ -28,7 +28,8 @@ void register_special_stations(timetable& tt) { void finalize(timetable& tt, bool const adjust_footpaths, - bool const merge_duplicates, + bool const merge_dupes_intra_src, + bool const merge_dupes_inter_src, std::uint16_t const max_footpath_length) { tt.location_routes_.resize(tt.n_locations()); @@ -47,7 +48,8 @@ void finalize(timetable& tt, tt.trip_id_strings_[b.first].view()); }); } - build_footpaths(tt, adjust_footpaths, merge_duplicates, max_footpath_length); + build_footpaths(tt, adjust_footpaths, merge_dupes_intra_src, + merge_dupes_inter_src, max_footpath_length); build_lb_graph(tt); build_lb_graph(tt); } diff --git a/src/loader/link_nearby_stations.cc b/src/loader/link_nearby_stations.cc index 187ecd0c..766497b1 100644 --- a/src/loader/link_nearby_stations.cc +++ b/src/loader/link_nearby_stations.cc @@ -8,13 +8,17 @@ namespace nigiri::loader { -match_set_t link_nearby_stations(timetable& tt, bool const store_matches) { +template +match_set_t link_nearby_stations(timetable& tt) { constexpr auto const kLinkNearbyMaxDistance = 300; // [m]; auto const locations_rtree = geo::make_point_rtree(tt.locations_.coordinates_); auto matches = match_set_t{}; + if constexpr (!MatchIntraSrc && !MatchInterSrc) { + return matches; + } for (auto l_from_idx = location_idx_t{0U}; l_from_idx != tt.locations_.src_.size(); ++l_from_idx) { auto const from_pos = tt.locations_.coordinates_[l_from_idx]; @@ -35,11 +39,21 @@ match_set_t link_nearby_stations(timetable& tt, bool const store_matches) { } auto const to_src = tt.locations_.src_[l_to_idx]; - auto const to_pos = tt.locations_.coordinates_[l_to_idx]; - if (to_src == source_idx_t::invalid() /* no dummy stations */ - || from_src == to_src /* don't short-circuit */) { + if (to_src == source_idx_t::invalid() /* no dummy stations */) { continue; } + if constexpr (!MatchIntraSrc) { + if (to_src == from_src) { + continue; + } + } + if constexpr (!MatchInterSrc) { + if (to_src != from_src) { + continue; + } + } + + auto const to_pos = tt.locations_.coordinates_[l_to_idx]; auto const from_transfer_time = duration_t{tt.locations_.transfer_time_[l_from_idx]}; @@ -56,7 +70,7 @@ match_set_t link_nearby_stations(timetable& tt, bool const store_matches) { l_from_idx, duration); tt.locations_.equivalences_[l_from_idx].emplace_back(l_to_idx); - if (store_matches) { + if constexpr (MatchIntraSrc || MatchInterSrc) { matches.emplace(make_match_pair(l_from_idx, l_to_idx)); } } @@ -65,4 +79,9 @@ match_set_t link_nearby_stations(timetable& tt, bool const store_matches) { return matches; } +template match_set_t link_nearby_stations(timetable&); +template match_set_t link_nearby_stations(timetable&); +template match_set_t link_nearby_stations(timetable&); +template match_set_t link_nearby_stations(timetable&); + } // namespace nigiri::loader \ No newline at end of file diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc new file mode 100644 index 00000000..35f5dba4 --- /dev/null +++ b/test/loader/merge_duplicates_test.cc @@ -0,0 +1,170 @@ +#include "gtest/gtest.h" + +#include "utl/enumerate.h" + +#include "nigiri/loader/dir.h" +#include "nigiri/loader/gtfs/files.h" +#include "nigiri/loader/gtfs/load_timetable.h" +#include "nigiri/loader/init_finish.h" +#include "nigiri/timetable.h" + +using namespace nigiri; +using namespace nigiri::loader; +using namespace nigiri::loader::gtfs; +using namespace date; + +namespace { + +mem_dir rbo500_files() { + return mem_dir::read(R"__( +# trips.txt +"route_id","service_id","trip_id","trip_headsign","trip_short_name","direction_id","block_id","shape_id","wheelchair_accessible","bikes_allowed" +"de:vvo:27-500_3",1171,2593445697,"Hoyerswerda Bahnhof","",0,,50181,0,0 +"de:von:27-500_3",1171,2593399070,"Hoyerswerda Bahnhof","",0,,89021,0,0 + +# routes.txt +"route_id","agency_id","route_short_name","route_long_name","route_type","route_color","route_text_color","route_desc" +"de:vvo:27-500_3",8197,"500","",3,"","","" +"de:von:27-500_3",7874,"500","",3,"","","" + +# agency.txt +"agency_id","agency_name","agency_url","agency_timezone","agency_lang","agency_phone" +8197,"RBO-Busverkehr","https://www.delfi.de","Europe/Berlin","","" +7874,"RBO-Bus","https://www.delfi.de","Europe/Berlin","","" + +# stop_times.txt +"trip_id","arrival_time","departure_time","stop_id","stop_sequence","pickup_type","drop_off_type","stop_headsign" +2593445697,9:23:00,9:23:00,"de:14625:7501:0:7",0,0,0,"" +2593445697,9:24:00,9:24:00,"de:14625:7500:3:1",1,0,0,"" +2593445697,9:27:00,9:27:00,"de:14625:7502:0:1",2,0,0,"" +2593445697,9:29:00,9:29:00,"de:14625:7507:0:1",3,0,0,"" +2593445697,9:31:00,9:31:00,"de:14625:7578:0:1",4,0,0,"" +2593445697,9:33:00,9:33:00,"de:14625:7577:0:1",5,0,0,"" +2593445697,9:36:00,9:36:00,"de:14625:7652:0:1",6,0,0,"" +2593445697,9:38:00,9:38:00,"de:14625:7661:0:1",7,0,0,"" +2593445697,9:40:00,9:40:00,"de:14625:7770:0:1",8,0,0,"" +2593445697,9:42:00,9:42:00,"de:14625:7685:0:1",9,0,0,"" +2593445697,9:45:00,9:45:00,"de:14625:7687:0:1",10,0,0,"" +2593445697,9:46:00,9:46:00,"de:14625:7689:0:1",11,0,0,"" +2593445697,9:48:00,9:48:00,"de:14625:7692:0:1",12,0,0,"" +2593445697,9:51:00,9:51:00,"de:14625:7733:0:1",13,0,0,"" +2593445697,9:54:00,9:54:00,"de:14625:7720:0:1",14,0,0,"" +2593445697,9:55:00,9:55:00,"de:14625:7721:0:1",15,0,0,"" +2593445697,9:58:00,9:58:00,"de:14625:6969:1:1",16,0,0,"" +2593445697,10:01:00,10:01:00,"de:14625:6967:1:1",17,0,0,"" +2593445697,10:06:00,10:06:00,"de:14625:6954:1:1",18,0,0,"" +2593445697,10:12:00,10:12:00,"de:14625:8063:0:1",19,0,0,"" +2593445697,10:16:00,10:16:00,"de:14625:8044:0:1",20,0,0,"" +2593445697,10:18:00,10:18:00,"de:14625:8041:1:1",21,0,0,"" +2593445697,10:20:00,10:20:00,"de:14625:8010:1:2",22,0,0,"" +2593445697,10:23:00,10:23:00,"de:14625:8000:3:3",23,0,0,"" +2593399070,9:23:00,9:23:00,"de:14625:7501:0:7_G",0,0,0,"" +2593399070,9:24:00,9:24:00,"de:14625:7500:3:1",1,0,0,"" +2593399070,9:27:00,9:27:00,"de:14625:7502:0:1_G",2,0,0,"" +2593399070,9:29:00,9:29:00,"de:14625:7507:0:1_G",3,0,0,"" +2593399070,9:31:00,9:31:00,"de:14625:7578:0:1_G",4,0,0,"" +2593399070,9:33:00,9:33:00,"de:14625:7577:0:1_G",5,0,0,"" +2593399070,9:36:00,9:36:00,"de:14625:7652:0:1_G",6,0,0,"" +2593399070,9:38:00,9:38:00,"de:14625:7661:0:3",7,0,0,"" +2593399070,9:40:00,9:40:00,"de:14625:7770:0:1_G",8,0,0,"" +2593399070,9:42:00,9:42:00,"de:14625:7685:0:1_G",9,0,0,"" +2593399070,9:45:00,9:45:00,"de:14625:7687:0:1_G",10,0,0,"" +2593399070,9:46:00,9:46:00,"de:14625:7689:0:1_G",11,0,0,"" +2593399070,9:48:00,9:48:00,"de:14625:7692:0:1_G",12,0,0,"" +2593399070,9:51:00,9:51:00,"de:14625:7733:0:1",13,0,0,"" +2593399070,9:54:00,9:54:00,"de:14625:7720:0:1_G",14,0,0,"" +2593399070,9:55:00,9:55:00,"de:14625:7721:0:1_G",15,0,0,"" +2593399070,9:58:00,9:58:00,"de:14625:6969:1:1",16,0,0,"" +2593399070,10:01:00,10:01:00,"de:14625:6967:1:1",17,0,0,"" +2593399070,10:06:00,10:06:00,"de:14625:6954:1:1_G",18,0,0,"" +2593399070,10:12:00,10:12:00,"de:14625:8063:0:1_G",19,0,0,"" +2593399070,10:16:00,10:16:00,"de:14625:8044:0:1",20,0,0,"" +2593399070,10:18:00,10:18:00,"de:14625:8041:0:1",21,0,0,"" +2593399070,10:20:00,10:20:00,"de:14625:8010:1:2",22,0,0,"" +2593399070,10:23:00,10:23:00,"de:14625:8000:3:3",23,0,0,"" + +# stops.txt +"stop_id","stop_code","stop_name","stop_desc","stop_lat","stop_lon","location_type","parent_station","wheelchair_boarding","platform_code","level_id" +"de:14625:8000:3:3","","Hoyerswerda Bahnhof","Bus","51.433460000000","14.231371000000",0,,0,"3","2" +"de:14625:8010:1:2","","Hoyerswerda Behördenpark","Haltestelle","51.435196000000","14.245690000000",0,,0,"2","2" +"de:14625:8041:1:1","","Hoyersw. Albert-Einstein-Str.",,"51.438769000000","14.255931000000",0,,0,"","" +"de:14625:8044:0:1","","Hoyerswerda Lausitzer Platz","Hoyerswerda Lausitzer Platz","51.438909000000","14.262749000000",0,,0,"1","2" +"de:14625:8063:0:1","","Hoyerswerda Straße E",,"51.430979000000","14.285477000000",0,,0,"","" +"de:14625:6967:1:1","","Groß Särchen Cafe","Haltestelle","51.365574000000","14.310145000000",0,,0,"1","2" +"de:14625:7721:0:1","","Caminau Kaolinwerk",,"51.337281000000","14.342223000000",0,,0,"","" +"de:14625:6954:1:1","","Maukendorf, B96",,"51.396982000000","14.294828000000",0,,0,"","" +"de:14625:7577:0:1","","Bautzen Hoyerswerdaer Straße",,"51.196612000000","14.409462000000",0,,0,"","" +"de:14625:7689:0:1","","Neudorf (b Neschwitz) B96",,"51.275680000000","14.339798000000",0,,0,"","" +"de:14625:7770:0:1","","Schwarzadler",,"51.236410000000","14.370826000000",0,,0,"","" +"de:14625:6969:1:1","","Wartha (b Königswartha) B 96","Haltestelle","51.350478000000","14.326431000000",0,,0,"1","2" +"de:14625:7685:0:1","","Luga (b Neschwitz) B 96",,"51.247304000000","14.357117000000",0,,0,"","" +"de:14625:7661:0:1","","Cölln Goldene Höhe",,"51.223349000000","14.388262000000",0,,0,"","" +"de:14625:7578:0:1","","Bautzen Abzw Seidau",,"51.191849000000","14.412400000000",0,,0,"","" +"de:14625:7502:0:1","","Bautzen Lauengraben",,"51.179670000000","14.425210000000",0,,0,"","" +"de:14625:7652:0:1","","Kleinwelka Gasthof",,"51.213283000000","14.392942000000",0,,0,"","" +"de:14625:7500:3:1","","Bautzen Bahnhof","Bus","51.173723000000","14.429764000000",0,,0,"1","2" +"de:14625:7501:0:7","","Bautzen August-Bebel-Pl (ZOB)",,"51.177395000000","14.433501000000",0,,0,"","" +"de:14625:7507:0:1","","Bautzen Fiedlerstraße",,"51.181241000000","14.414960000000",0,,0,"","" +"de:14625:7733:0:1","","Königswartha Kirchplatz","Königswartha Kirchplatz","51.309930000000","14.328767000000",0,,0,"1","2" +"de:14625:7692:0:1","","Zescha B 96",,"51.293148000000","14.327994000000",0,,0,"","" +"de:14625:7687:0:1","","Holscha B 96",,"51.266817000000","14.344775000000",0,,0,"","" +"de:14625:7720:0:1","","Caminau Dorf",,"51.328065000000","14.341298000000",0,,0,"","" +"de:14625:8063:0:1_G","","Hoyerswerda Straße E",,"51.430979000000","14.285477000000",0,,0,"","" +"de:14625:6954:1:1_G","","Maukendorf, B96",,"51.396982000000","14.294828000000",0,,0,"","" +"de:14625:7689:0:1_G","","Neudorf (b Neschwitz) B96",,"51.275579000000","14.339825000000",0,,0,"","" +"de:14625:7501:0:7_G","","Bautzen August-Bebel-Pl (ZOB)",,"51.177395000000","14.433501000000",0,,0,"","" +"de:14625:7692:0:1_G","","Zescha B 96",,"51.293098000000","14.328012000000",0,,0,"","" +"de:14625:7685:0:1_G","","Luga (b Neschwitz) B 96",,"51.247191000000","14.357171000000",0,,0,"","" +"de:14625:7770:0:1_G","","Schwarzadler",,"51.236348000000","14.370835000000",0,,0,"","" +"de:14625:7720:0:1_G","","Caminau Dorf",,"51.327913000000","14.341181000000",0,,0,"","" +"de:14625:7502:0:1_G","","Bautzen Lauengraben",,"51.179602000000","14.424958000000",0,,0,"","" +"de:14625:7661:0:3","","Cölln Goldene Höhe",,"51.224749000000","14.386394000000",0,,0,"","" +"de:14625:7577:0:1_G","","Bautzen Hoyerswerdaer Straße",,"51.196443000000","14.409480000000",0,,0,"","" +"de:14625:7578:0:1_G","","Bautzen Abzw Seidau",,"51.191781000000","14.412436000000",0,,0,"","" +"de:14625:7721:0:1_G","","Caminau Kaolinwerk",,"51.337202000000","14.342205000000",0,,0,"","" +"de:14625:7507:0:1_G","","Bautzen Fiedlerstraße",,"51.181100000000","14.415014000000",0,,0,"","" +"de:14625:7652:0:1_G","","Kleinwelka Gasthof",,"51.213204000000","14.392987000000",0,,0,"","" +"de:14625:8041:0:1","","Hoyersw. Albert-Einstein-Str.",,"51.438769000000","14.255931000000",0,,0,"","" +"de:14625:7687:0:1_G","","Holscha B 96",,"51.266778000000","14.344802000000",0,,0,"","" + +# calendar.txt +"service_id","monday","tuesday","wednesday","thursday","friday","saturday","sunday","start_date","end_date" +1171,1,1,1,1,1,0,0,20240805,20241214 + +# calendar_dates.txt +"service_id","date","exception_type" +1171,20240805,2 +1171,20240812,2 +1171,20240806,2 +1171,20240813,2 +1171,20240807,2 +1171,20241120,2 +1171,20240808,2 +1171,20241003,2 +1171,20241031,2 +1171,20240809,2 + +)__"); +} + +} // namespace + +TEST(loader, merge_intra_src) { + auto tt = timetable{}; + + tt.date_range_ = {date::sys_days{2024_y / August / 5}, + date::sys_days{2024_y / December / 14}}; + register_special_stations(tt); + load_timetable({}, source_idx_t{0}, rbo500_files(), tt); + finalize(tt, false, true, false); + + for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { + for (auto b = transport_idx_t{0U}; b != tt.next_transport_idx(); ++b) { + if (a != b) { + EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] & + tt.bitfields_[tt.transport_traffic_days_[b]], + tt.bitfields_[bitfield_idx_t{0U}]); + } + } + } +} \ No newline at end of file From 6a6be8e292da0a40563ece88c893951f40d9d718 Mon Sep 17 00:00:00 2001 From: mority Date: Fri, 30 Aug 2024 12:01:58 +0200 Subject: [PATCH 03/27] wip --- include/nigiri/loader/loader_interface.h | 3 ++- src/loader/load.cc | 6 +++--- test/loader/merge_duplicates_test.cc | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/nigiri/loader/loader_interface.h b/include/nigiri/loader/loader_interface.h index 7abdf9d8..2b9b7eb7 100644 --- a/include/nigiri/loader/loader_interface.h +++ b/include/nigiri/loader/loader_interface.h @@ -20,7 +20,8 @@ struct loader_config { // finalize options bool adjust_footpaths_{true}; - bool merge_duplicates_{true}; + bool merge_dupes_intra_src{true}; + bool merge_dupes_inter_src{true}; std::uint16_t max_footpath_length_{20}; }; diff --git a/src/loader/load.cc b/src/loader/load.cc index fce14ed4..b3ab9d08 100644 --- a/src/loader/load.cc +++ b/src/loader/load.cc @@ -1,6 +1,6 @@ #include "nigiri/loader/load.h" -#include +// #include #include "utl/enumerate.h" @@ -50,8 +50,8 @@ timetable load(std::vector const& paths, } } - finalize(tt, c.adjust_footpaths_, c.merge_duplicates_, - c.max_footpath_length_); + finalize(tt, c.adjust_footpaths_, c.merge_dupes_intra_src, + c.merge_dupes_inter_src, c.max_footpath_length_); return tt; } diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc index 35f5dba4..e2759302 100644 --- a/test/loader/merge_duplicates_test.cc +++ b/test/loader/merge_duplicates_test.cc @@ -161,9 +161,10 @@ TEST(loader, merge_intra_src) { for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { for (auto b = transport_idx_t{0U}; b != tt.next_transport_idx(); ++b) { if (a != b) { - EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] & - tt.bitfields_[tt.transport_traffic_days_[b]], - tt.bitfields_[bitfield_idx_t{0U}]); + // EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] + // & + // tt.bitfields_[tt.transport_traffic_days_[b]], + // tt.bitfields_[bitfield_idx_t{0U}]); } } } From daed28b567e6676e12b65fe8c393a2b7db79df28 Mon Sep 17 00:00:00 2001 From: mority Date: Fri, 30 Aug 2024 12:32:17 +0200 Subject: [PATCH 04/27] wip --- exe/import.cc | 11 ++++++++--- include/nigiri/loader/loader_interface.h | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/exe/import.cc b/exe/import.cc index eb0d05e9..3811a585 100644 --- a/exe/import.cc +++ b/exe/import.cc @@ -60,9 +60,14 @@ int main(int ac, char** av) { ("link_stop_distance", bpo::value(&c.link_stop_distance_)->default_value(c.link_stop_distance_), "the maximum distance at which stops in proximity will be linked") // - ("merge_duplicates", - bpo::value(&c.merge_duplicates_)->default_value(c.merge_duplicates_), - "merge duplicates") // + ("merge_dupes_intra_source", + bpo::value(&c.merge_dupes_intra_src_) + ->default_value(c.merge_dupes_intra_src_), + "merge duplicates within a source") // + ("merge_dupes_inter_source", + bpo::value(&c.merge_dupes_inter_src_) + ->default_value(c.merge_dupes_inter_src_), + "merge duplicates between different sources") // ("adjust_footpaths", bpo::value(&c.adjust_footpaths_)->default_value(c.adjust_footpaths_), "adjust footpath lengths") // diff --git a/include/nigiri/loader/loader_interface.h b/include/nigiri/loader/loader_interface.h index 2b9b7eb7..d5271240 100644 --- a/include/nigiri/loader/loader_interface.h +++ b/include/nigiri/loader/loader_interface.h @@ -20,8 +20,8 @@ struct loader_config { // finalize options bool adjust_footpaths_{true}; - bool merge_dupes_intra_src{true}; - bool merge_dupes_inter_src{true}; + bool merge_dupes_intra_src_{true}; + bool merge_dupes_inter_src_{true}; std::uint16_t max_footpath_length_{20}; }; From ec755a37e9091482e1de72775961c5d13042f19f Mon Sep 17 00:00:00 2001 From: mority Date: Fri, 30 Aug 2024 12:34:03 +0200 Subject: [PATCH 05/27] wip --- src/loader/load.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/loader/load.cc b/src/loader/load.cc index b3ab9d08..556d7567 100644 --- a/src/loader/load.cc +++ b/src/loader/load.cc @@ -50,8 +50,8 @@ timetable load(std::vector const& paths, } } - finalize(tt, c.adjust_footpaths_, c.merge_dupes_intra_src, - c.merge_dupes_inter_src, c.max_footpath_length_); + finalize(tt, c.adjust_footpaths_, c.merge_dupes_intra_src_, + c.merge_dupes_inter_src_, c.max_footpath_length_); return tt; } From c7351f317de4948af23ffc04f9c2b6b14f3ae372 Mon Sep 17 00:00:00 2001 From: mority Date: Fri, 30 Aug 2024 15:50:43 +0200 Subject: [PATCH 06/27] reflexivity --- src/loader/merge_duplicates.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/loader/merge_duplicates.cc b/src/loader/merge_duplicates.cc index 3f4c2471..7b1ffb97 100644 --- a/src/loader/merge_duplicates.cc +++ b/src/loader/merge_duplicates.cc @@ -113,8 +113,8 @@ unsigned find_duplicates(timetable& tt, auto const station_sequence_matches = [&]() { return utl::all_of(utl::zip(a_loc_seq, b_loc_seq), [&](auto&& pair) { auto const [x, y] = pair; - return matches.contains( - make_match_pair(stop{x}.location_idx(), stop{y}.location_idx())); + return x == y || matches.contains(make_match_pair( + stop{x}.location_idx(), stop{y}.location_idx())); }); }; From bd2f569ca6bc769839ec5af958b810569f211afa Mon Sep 17 00:00:00 2001 From: mority Date: Fri, 30 Aug 2024 15:51:48 +0200 Subject: [PATCH 07/27] intra-source merge test case --- test/loader/merge_duplicates_test.cc | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc index e2759302..5e613376 100644 --- a/test/loader/merge_duplicates_test.cc +++ b/test/loader/merge_duplicates_test.cc @@ -161,11 +161,30 @@ TEST(loader, merge_intra_src) { for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { for (auto b = transport_idx_t{0U}; b != tt.next_transport_idx(); ++b) { if (a != b) { - // EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] - // & - // tt.bitfields_[tt.transport_traffic_days_[b]], - // tt.bitfields_[bitfield_idx_t{0U}]); + EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] & + tt.bitfields_[tt.transport_traffic_days_[b]], + tt.bitfields_[bitfield_idx_t{0U}]); } } } + + auto tt_contains_2593445697 = false; + auto tt_contains_2593399070 = false; + for (auto i = trip_id_idx_t{0U}; i != tt.trip_id_strings_.size(); ++i) { + if (tt.trip_id_strings_[i].view() == "2593445697") { + tt_contains_2593445697 = true; + } + if (tt.trip_id_strings_[i].view() == "2593399070") { + tt_contains_2593399070 = true; + } + } + EXPECT_TRUE(tt_contains_2593445697); + EXPECT_TRUE(tt_contains_2593399070); + + for (auto [tr_range_a, tr_range_b] : + utl::zip(tt.trip_transport_ranges_[trip_idx_t{0U}], + tt.trip_transport_ranges_[trip_idx_t{1U}])) { + EXPECT_EQ(tr_range_a.first, tr_range_b.first); + EXPECT_EQ(tr_range_a.second, tr_range_b.second); + } } \ No newline at end of file From f1f48affd0b4ca54c47977a851ccb93fd697d25f Mon Sep 17 00:00:00 2001 From: mority Date: Fri, 30 Aug 2024 16:24:41 +0200 Subject: [PATCH 08/27] inter-source merge test case --- test/loader/merge_duplicates_test.cc | 193 +++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc index 5e613376..98040d4e 100644 --- a/test/loader/merge_duplicates_test.cc +++ b/test/loader/merge_duplicates_test.cc @@ -181,6 +181,199 @@ TEST(loader, merge_intra_src) { EXPECT_TRUE(tt_contains_2593445697); EXPECT_TRUE(tt_contains_2593399070); + for (auto [tr_range_a, tr_range_b] : + utl::zip(tt.trip_transport_ranges_[trip_idx_t{0U}], + tt.trip_transport_ranges_[trip_idx_t{1U}])) { + EXPECT_EQ(tr_range_a.first, tr_range_b.first); + EXPECT_EQ(tr_range_a.second, tr_range_b.second); + } +} + +namespace { + +mem_dir line1_2593432458_files() { + return mem_dir::read(R"__( +# trips.txt +"route_id","service_id","trip_id","trip_headsign","trip_short_name","direction_id","block_id","shape_id","wheelchair_accessible","bikes_allowed" +"de:vvo:28-1_3",1194,2593432458,"Hoyerswerda Bahnhof","",0,,49500,0,0 + +# routes.txt +"route_id","agency_id","route_short_name","route_long_name","route_type","route_color","route_text_color","route_desc" +"de:vvo:28-1_3",8198,"1 (Hoyerswerda)","",3,"","","" + +# agency.txt +"agency_id","agency_name","agency_url","agency_timezone","agency_lang","agency_phone" +8198,"VGH Busverkehr","https://www.delfi.de","Europe/Berlin","","" + +# stop_times.txt +"trip_id","arrival_time","departure_time","stop_id","stop_sequence","pickup_type","drop_off_type","stop_headsign" +2593432458,12:56:00,12:56:00,"de:14625:8090:0:1",0,0,0,"" +2593432458,12:58:00,12:58:00,"de:14625:8089:0:1",1,0,0,"" +2593432458,12:59:00,12:59:00,"de:14625:8088:1:1",2,0,0,"" +2593432458,13:01:00,13:01:00,"de:14625:8087:1:1",3,0,0,"" +2593432458,13:02:00,13:02:00,"de:14625:8086:1:1",4,0,0,"" +2593432458,13:04:00,13:04:00,"de:14625:8077:0:1",5,0,0,"" +2593432458,13:06:00,13:06:00,"de:14625:8075:0:1",6,0,0,"" +2593432458,13:08:00,13:08:00,"de:14625:8091:0:1",7,0,0,"" +2593432458,13:10:00,13:12:00,"de:14625:8044:0:3",8,0,0,"" +2593432458,13:14:00,13:14:00,"de:14625:8041:1:1",9,0,0,"" +2593432458,13:16:00,13:16:00,"de:14625:8040:0:2",10,0,0,"" +2593432458,13:17:00,13:17:00,"de:14625:8021:0:1",11,0,0,"" +2593432458,13:18:00,13:18:00,"de:14625:8023:0:1",12,0,0,"" +2593432458,13:20:00,13:20:00,"de:14625:8022:0:1",13,0,0,"" +2593432458,13:21:00,13:21:00,"de:14625:8020:0:1",14,0,0,"" +2593432458,13:22:00,13:22:00,"de:14625:8000:3:1",15,0,0,"" + +# stops.txt +"stop_id","stop_code","stop_name","stop_desc","stop_lat","stop_lon","location_type","parent_station","wheelchair_boarding","platform_code","level_id" +"de:14625:8000:3:1","","Hoyerswerda Bahnhof","Bus","51.433343000000","14.231317000000",0,,0,"1","2" +"de:14625:8020:0:1","","Hoyerswerda Am Bahnhofsvorpl.",,"51.435051000000","14.232809000000",0,,0,"","" +"de:14625:8022:0:1","","Hoyerswerda Heinrich-Heine-Str",,"51.435566000000","14.238675000000",0,,0,"","" +"de:14625:8023:0:1","","HY Lessinghaus",,"51.436501000000","14.244963000000",0,,0,"","" +"de:14625:8021:0:1","","Hoyerswerda Zoo",,"51.439480000000","14.247496000000",0,,0,"","" +"de:14625:8040:0:2","","Hoyerswerda Am Elsterbogen","Hoyerswerda Am Elsterbogen","51.439637000000","14.251044000000",0,,0,"2","2" +"de:14625:8087:1:1","","Hoyerswerda Cottbuser Tor","Haltestelle","51.453175000000","14.267726000000",0,,0,"1","2" +"de:14625:8089:0:1","","Hoyerswerda Mittelweg",,"51.456679000000","14.261824000000",0,,0,"","" +"de:14625:8041:1:1","","Hoyersw. Albert-Einstein-Str.",,"51.438769000000","14.255931000000",0,,0,"","" +"de:14625:8091:0:1","","Hoyerswerda E.-Weinert-Straße",,"51.438892000000","14.268984000000",0,,0,"","" +"de:14625:8044:0:3","","Hoyerswerda Lausitzer Platz","Hoyerswerda Lausitzer Platz","51.438724000000","14.262983000000",0,,0,"3","2" +"de:14625:8075:0:1","","Hoyersw. von-Stauffenberg-Str.",,"51.443613000000","14.269109000000",0,,0,"","" +"de:14625:8077:0:1","","Hoyerswerda Kühnichter Heide",,"51.447487000000","14.267834000000",0,,0,"","" +"de:14625:8086:1:1","","Hoyerswerda Thomas-Müntzer-Str",,"51.449878000000","14.271831000000",0,,0,"","" +"de:14625:8088:1:1","","Hoyerswerda Käthe-Kollwitz-Str","Haltestelle","51.454977000000","14.263872000000",0,,0,"1","2" +"de:14625:8090:0:1","","Hoyerswerda Am Speicher",,"51.457177000000","14.267205000000",0,,0,"","" + +# calendar.txt +"service_id","monday","tuesday","wednesday","thursday","friday","saturday","sunday","start_date","end_date" +1194,1,1,1,1,1,1,0,20240805,20241214 + +# calendar_dates.txt +"service_id","date","exception_type" +1194,20240805,2 +1194,20240812,2 +1194,20240806,2 +1194,20240813,2 +1194,20240807,2 +1194,20241120,2 +1194,20240808,2 +1194,20241003,2 +1194,20241031,2 +1194,20240809,2 +1194,20240810,2 + +)__"); +} + +mem_dir line1_2593402613_files() { + return mem_dir::read(R"__( +# trips.txt +"route_id","service_id","trip_id","trip_headsign","trip_short_name","direction_id","block_id","shape_id","wheelchair_accessible","bikes_allowed" +"de:vvo:28-1_D_3",1194,2593402613,"Hoyerswerda Bahnhof","",0,,89918,0,0 + +# routes.txt +"route_id","agency_id","route_short_name","route_long_name","route_type","route_color","route_text_color","route_desc" +"de:vvo:28-1_D_3",14223,"1","",3,"","","" + +# agency.txt +"agency_id","agency_name","agency_url","agency_timezone","agency_lang","agency_phone" +14223,"VGH-Verkehrsgesellschaft Hoyerswerda","https://www.delfi.de","Europe/Berlin","","" + +# stop_times.txt +"trip_id","arrival_time","departure_time","stop_id","stop_sequence","pickup_type","drop_off_type","stop_headsign" +2593402613,12:56:00,12:56:00,"de:14625:8090:0:1_G",0,0,0,"" +2593402613,12:58:00,12:58:00,"de:14625:8089:0:1_G",1,0,0,"" +2593402613,12:59:00,12:59:00,"de:14625:8088:1:1",2,0,0,"" +2593402613,13:01:00,13:01:00,"de:14625:8087:1:1",3,0,0,"" +2593402613,13:03:00,13:03:00,"de:14625:8086:0:1",4,0,0,"" +2593402613,13:04:00,13:04:00,"de:14625:8077:0:1_G",5,0,0,"" +2593402613,13:06:00,13:06:00,"de:14625:8075:0:1_G",6,0,0,"" +2593402613,13:08:00,13:08:00,"de:14625:8091:0:1_G",7,0,0,"" +2593402613,13:10:00,13:12:00,"de:14625:8044:0:3",8,0,0,"" +2593402613,13:14:00,13:14:00,"de:14625:8041:0:1",9,0,0,"" +2593402613,13:16:00,13:16:00,"de:14625:8040:0:1",10,0,0,"" +2593402613,13:17:00,13:17:00,"de:14625:8021:0:1_G",11,0,0,"" +2593402613,13:18:00,13:18:00,"de:14625:8023:0:1_G",12,0,0,"" +2593402613,13:20:00,13:20:00,"de:14625:8022:0:1_G",13,0,0,"" +2593402613,13:21:00,13:21:00,"de:14625:8020:0:1_G",14,0,0,"" +2593402613,13:22:00,13:22:00,"de:14625:8000:3:1",15,0,0,"" + +# stops.txt +"stop_id","stop_code","stop_name","stop_desc","stop_lat","stop_lon","location_type","parent_station","wheelchair_boarding","platform_code","level_id" +"de:14625:8000:3:1","","Hoyerswerda Bahnhof","Bus","51.433343000000","14.231317000000",0,,0,"1","2" +"de:14625:8020:0:1_G","","Hoyerswerda Am Bahnhofsvorpl.",,"51.435084000000","14.232755000000",0,,0,"","" +"de:14625:8023:0:1_G","","HY Lessinghaus",,"51.436501000000","14.244954000000",0,,0,"","" +"de:14625:8021:0:1_G","","Hoyerswerda Zoo",,"51.439480000000","14.247496000000",0,,0,"","" +"de:14625:8091:0:1_G","","Hoyerswerda E.-Weinert-Straße",,"51.438892000000","14.268984000000",0,,0,"","" +"de:14625:8077:0:1_G","","Hoyerswerda Kühnichter Heide",,"51.447481000000","14.267834000000",0,,0,"","" +"de:14625:8040:0:1","","Hoyerswerda Am Elsterbogen","Hoyerswerda Am Elsterbogen","51.439816000000","14.250425000000",0,,0,"1","2" +"de:14625:8022:0:1_G","","Hoyerswerda Heinrich-Heine-Str",,"51.435583000000","14.238693000000",0,,0,"","" +"de:14625:8090:0:1_G","","Hoyerswerda Am Speicher",,"51.457177000000","14.267205000000",0,,0,"","" +"de:14625:8044:0:3","","Hoyerswerda Lausitzer Platz","Hoyerswerda Lausitzer Platz","51.438724000000","14.262983000000",0,,0,"3","2" +"de:14625:8075:0:1_G","","Hoyersw. von-Stauffenberg-Str.",,"51.443613000000","14.269109000000",0,,0,"","" +"de:14625:8041:0:1","","Hoyersw. Albert-Einstein-Str.",,"51.438769000000","14.255931000000",0,,0,"","" +"de:14625:8087:1:1","","Hoyerswerda Cottbuser Tor","Haltestelle","51.453175000000","14.267726000000",0,,0,"1","2" +"de:14625:8086:0:1","","Hoyerswerda Thomas-Müntzer-Str",,"51.449878000000","14.271831000000",0,,0,"","" +"de:14625:8088:1:1","","Hoyerswerda Käthe-Kollwitz-Str","Haltestelle","51.454977000000","14.263872000000",0,,0,"1","2" +"de:14625:8089:0:1_G","","Hoyerswerda Mittelweg",,"51.456701000000","14.261788000000",0,,0,"","" + +# calendar.txt +"service_id","monday","tuesday","wednesday","thursday","friday","saturday","sunday","start_date","end_date" +1194,1,1,1,1,1,1,0,20240805,20241214 + +# calendar_dates.txt +"service_id","date","exception_type" +1194,20240805,2 +1194,20240812,2 +1194,20240806,2 +1194,20240813,2 +1194,20240807,2 +1194,20241120,2 +1194,20240808,2 +1194,20241003,2 +1194,20241031,2 +1194,20240809,2 +1194,20240810,2 + +)__"); +} + +} // namespace + +TEST(loader, merge_inter_src) { + auto tt = timetable{}; + + tt.date_range_ = {date::sys_days{2024_y / August / 5}, + date::sys_days{2024_y / December / 14}}; + register_special_stations(tt); + load_timetable({}, source_idx_t{0}, line1_2593432458_files(), tt); + load_timetable({}, source_idx_t{1}, line1_2593402613_files(), tt); + finalize(tt, false, false, true); + + std::cout << tt << "\n"; + + for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { + for (auto b = transport_idx_t{0U}; b != tt.next_transport_idx(); ++b) { + if (a != b) { + EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] & + tt.bitfields_[tt.transport_traffic_days_[b]], + tt.bitfields_[bitfield_idx_t{0U}]); + } + } + } + + auto tt_contains_2593432458 = false; + auto tt_contains_2593402613 = false; + for (auto i = trip_id_idx_t{0U}; i != tt.trip_id_strings_.size(); ++i) { + if (tt.trip_id_strings_[i].view() == "2593432458") { + tt_contains_2593432458 = true; + } + if (tt.trip_id_strings_[i].view() == "2593402613") { + tt_contains_2593402613 = true; + } + } + EXPECT_TRUE(tt_contains_2593432458); + EXPECT_TRUE(tt_contains_2593402613); + for (auto [tr_range_a, tr_range_b] : utl::zip(tt.trip_transport_ranges_[trip_idx_t{0U}], tt.trip_transport_ranges_[trip_idx_t{1U}])) { From 9de77c45fdc15c4d85fc8222c9ce26bcdc3c96a7 Mon Sep 17 00:00:00 2001 From: mority Date: Mon, 2 Sep 2024 14:13:22 +0200 Subject: [PATCH 09/27] reflexive matching --- src/loader/build_footpaths.cc | 3 + test/loader/merge_duplicates_test.cc | 160 +++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) diff --git a/src/loader/build_footpaths.cc b/src/loader/build_footpaths.cc index 58239d8a..d6d9e5ad 100644 --- a/src/loader/build_footpaths.cc +++ b/src/loader/build_footpaths.cc @@ -421,6 +421,9 @@ void build_footpaths(timetable& tt, for (auto const& [a, b] : matches) { find_duplicates(tt, matches, a, b); } + for (auto l = location_idx_t{0U}; l != tt.n_locations(); ++l) { + find_duplicates(tt, matches, l, l); + } } connect_components(tt, max_footpath_length, adjust_footpaths); sort_footpaths(tt); diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc index 98040d4e..b9493f8c 100644 --- a/test/loader/merge_duplicates_test.cc +++ b/test/loader/merge_duplicates_test.cc @@ -380,4 +380,164 @@ TEST(loader, merge_inter_src) { EXPECT_EQ(tr_range_a.first, tr_range_b.first); EXPECT_EQ(tr_range_a.second, tr_range_b.second); } +} + +namespace { + +mem_dir bus500_files() { + return mem_dir::read(R"__( +# trips.txt +"route_id","service_id","trip_id","trip_headsign","trip_short_name","direction_id","block_id","shape_id","wheelchair_accessible","bikes_allowed" +"de:vvo:27-500_3",1171,2593445670,"Bautzen Bahnhof","",1,,50186,0,0 +"de:von:27-500_3",1171,2593399038,"Bautzen Bahnhof","",1,,89025,0,0 + +# routes.txt +"route_id","agency_id","route_short_name","route_long_name","route_type","route_color","route_text_color","route_desc" +"de:vvo:27-500_3",8197,"500","",3,"","","" +"de:von:27-500_3",7874,"500","",3,"","","" + +# agency.txt +"agency_id","agency_name","agency_url","agency_timezone","agency_lang","agency_phone" +8197,"RBO-Busverkehr","https://www.delfi.de","Europe/Berlin","","" +7874,"RBO-Bus","https://www.delfi.de","Europe/Berlin","","" + +# stop_times.txt +"trip_id","arrival_time","departure_time","stop_id","stop_sequence","pickup_type","drop_off_type","stop_headsign" +2593445670,12:32:00,12:32:00,"de:14625:8000:3:3",0,0,0,"" +2593445670,12:34:00,12:34:00,"de:14625:8010:1:1",1,0,0,"" +2593445670,12:36:00,12:36:00,"de:14625:8041:1:2",2,0,0,"" +2593445670,12:38:00,12:38:00,"de:14625:8044:0:8",3,0,0,"" +2593445670,12:42:00,12:42:00,"de:14625:8063:0:2",4,0,0,"" +2593445670,12:48:00,12:48:00,"de:14625:6954:1:2",5,0,0,"" +2593445670,12:53:00,12:53:00,"de:14625:6967:1:2",6,0,0,"" +2593445670,12:56:00,12:56:00,"de:14625:6969:1:2",7,0,0,"" +2593445670,12:58:00,12:58:00,"de:14625:7721:0:2",8,0,0,"" +2593445670,13:00:00,13:00:00,"de:14625:7720:0:2",9,0,0,"" +2593445670,13:03:00,13:03:00,"de:14625:7733:0:2",10,0,0,"" +2593445670,13:05:00,13:05:00,"de:14625:7692:0:2",11,0,0,"" +2593445670,13:07:00,13:07:00,"de:14625:7689:0:2",12,0,0,"" +2593445670,13:08:00,13:08:00,"de:14625:7687:0:2",13,0,0,"" +2593445670,13:11:00,13:11:00,"de:14625:7685:0:2",14,0,0,"" +2593445670,13:13:00,13:13:00,"de:14625:7770:0:2",15,0,0,"" +2593445670,13:15:00,13:15:00,"de:14625:7661:0:2",16,0,0,"" +2593445670,13:17:00,13:17:00,"de:14625:7652:0:2",17,0,0,"" +2593445670,13:19:00,13:19:00,"de:14625:7577:0:2",18,0,0,"" +2593445670,13:20:00,13:20:00,"de:14625:7578:0:2",19,0,0,"" +2593445670,13:23:00,13:23:00,"de:14625:7507:0:2",20,0,0,"" +2593445670,13:26:00,13:26:00,"de:14625:7502:0:2",21,0,0,"" +2593445670,13:28:00,13:28:00,"de:14625:7555:0:2",22,0,0,"" +2593445670,13:30:00,13:30:00,"de:14625:7501:0:9",23,0,0,"" +2593445670,13:31:00,13:31:00,"de:14625:7500:3:1",24,0,0,"" +2593399038,12:32:00,12:32:00,"de:14625:8000:3:3",0,0,0,"" +2593399038,12:34:00,12:34:00,"de:14625:8010:1:1",1,0,0,"" +2593399038,12:36:00,12:36:00,"de:14625:8041:0:2",2,0,0,"" +2593399038,12:38:00,12:38:00,"de:14625:8044:0:8",3,0,0,"" +2593399038,12:42:00,12:42:00,"de:14625:8063:0:2_G",4,0,0,"" +2593399038,12:48:00,12:48:00,"de:14625:6954:1:2_G",5,0,0,"" +2593399038,12:53:00,12:53:00,"de:14625:6967:1:2",6,0,0,"" +2593399038,12:56:00,12:56:00,"de:14625:6969:1:2",7,0,0,"" +2593399038,12:58:00,12:58:00,"de:14625:7721:0:2_G",8,0,0,"" +2593399038,13:00:00,13:00:00,"de:14625:7720:0:2_G",9,0,0,"" +2593399038,13:03:00,13:03:00,"de:14625:7733:0:2",10,0,0,"" +2593399038,13:05:00,13:05:00,"de:14625:7692:0:2_G",11,0,0,"" +2593399038,13:07:00,13:07:00,"de:14625:7689:0:2_G",12,0,0,"" +2593399038,13:08:00,13:08:00,"de:14625:7687:0:2_G",13,0,0,"" +2593399038,13:11:00,13:11:00,"de:14625:7685:0:2_G",14,0,0,"" +2593399038,13:13:00,13:13:00,"de:14625:7770:0:2_G",15,0,0,"" +2593399038,13:15:00,13:15:00,"de:14625:7661:0:4",16,0,0,"" +2593399038,13:17:00,13:17:00,"de:14625:7652:0:2_G",17,0,0,"" +2593399038,13:19:00,13:19:00,"de:14625:7577:0:2_G",18,0,0,"" +2593399038,13:20:00,13:20:00,"de:14625:7578:0:2_G",19,0,0,"" +2593399038,13:23:00,13:23:00,"de:14625:7507:0:2_G",20,0,0,"" +2593399038,13:26:00,13:26:00,"de:14625:7502:0:2_G",21,0,0,"" +2593399038,13:28:00,13:28:00,"de:14625:7555:0:2_G",22,0,0,"" +2593399038,13:30:00,13:30:00,"de:14625:7501:0:9_G",23,0,0,"" +2593399038,13:31:00,13:31:00,"de:14625:7500:3:1",24,0,0,"" + +# stops.txt +"stop_id","stop_code","stop_name","stop_desc","stop_lat","stop_lon","location_type","parent_station","wheelchair_boarding","platform_code","level_id" +"de:14625:7500:3:1","","Bautzen Bahnhof","Bus","51.173723000000","14.429764000000",0,,0,"1","2" +"de:14625:7501:0:9","","Bautzen August-Bebel-Pl (ZOB)",,"51.177017000000","14.433968000000",0,,0,"","" +"de:14625:7507:0:2","","Bautzen Fiedlerstraße",,"51.180633000000","14.415202000000",0,,0,"","" +"de:14625:7577:0:2","","Bautzen Hoyerswerdaer Straße",,"51.196189000000","14.409480000000",0,,0,"","" +"de:14625:7652:0:2","","Kleinwelka Gasthof",,"51.212827000000","14.393418000000",0,,0,"","" +"de:14625:7661:0:2","","Cölln Goldene Höhe",,"51.223225000000","14.388289000000",0,,0,"","" +"de:14625:7770:0:2","","Schwarzadler",,"51.235145000000","14.372020000000",0,,0,"","" +"de:14625:7555:0:2","","Bautzen Taucherstraße/Friedhof",,"51.180492000000","14.437436000000",0,,0,"","" +"de:14625:7502:0:2","","Bautzen Lauengraben",,"51.179698000000","14.425955000000",0,,0,"","" +"de:14625:7685:0:2","","Luga (b Neschwitz) B 96",,"51.247967000000","14.356273000000",0,,0,"","" +"de:14625:7687:0:2","","Holscha B 96",,"51.266941000000","14.344837000000",0,,0,"","" +"de:14625:7689:0:2","","Neudorf (b Neschwitz) B96",,"51.275427000000","14.339807000000",0,,0,"","" +"de:14625:7733:0:2","","Königswartha Kirchplatz","Königswartha Kirchplatz","51.309672000000","14.328452000000",0,,0,"2","2" +"de:14625:8041:1:2","","Hoyersw. Albert-Einstein-Str.",,"51.438741000000","14.256093000000",0,,0,"","" +"de:14625:8010:1:1","","Hoyerswerda Behördenpark","Haltestelle","51.435135000000","14.246202000000",0,,0,"1","2" +"de:14625:6969:1:2","","Wartha (b Königswartha) B 96","Haltestelle","51.350254000000","14.326395000000",0,,0,"2","2" +"de:14625:7578:0:2","","Bautzen Abzw Seidau",,"51.192108000000","14.411555000000",0,,0,"","" +"de:14625:7721:0:2","","Caminau Kaolinwerk",,"51.336983000000","14.342116000000",0,,0,"","" +"de:14625:6954:1:2","","Maukendorf, B96",,"51.396848000000","14.294685000000",0,,0,"","" +"de:14625:7720:0:2","","Caminau Dorf",,"51.327851000000","14.341118000000",0,,0,"","" +"de:14625:6967:1:2","","Groß Särchen Cafe","Haltestelle","51.365288000000","14.310243000000",0,,0,"2","2" +"de:14625:8063:0:2","","Hoyerswerda Straße E",,"51.430806000000","14.285944000000",0,,0,"","" +"de:14625:8044:0:8","","Hoyerswerda Lausitzer Platz","Hoyerswerda Lausitzer Platz","51.438416000000","14.263486000000",0,,0,"8","2" +"de:14625:7692:0:2","","Zescha B 96",,"51.292294000000","14.328138000000",0,,0,"","" +"de:14625:8000:3:3","","Hoyerswerda Bahnhof","Bus","51.433460000000","14.231371000000",0,,0,"3","2" +"de:14625:7501:0:9_G","","Bautzen August-Bebel-Pl (ZOB)",,"51.177006000000","14.433986000000",0,,0,"","" +"de:14625:7507:0:2_G","","Bautzen Fiedlerstraße",,"51.180734000000","14.415077000000",0,,0,"","" +"de:14625:7577:0:2_G","","Bautzen Hoyerswerdaer Straße",,"51.196330000000","14.409372000000",0,,0,"","" +"de:14625:7652:0:2_G","","Kleinwelka Gasthof",,"51.212832000000","14.393337000000",0,,0,"","" +"de:14625:7661:0:4","","Cölln Goldene Höhe",,"51.223630000000","14.387202000000",0,,0,"","" +"de:14625:8041:0:2","","Hoyersw. Albert-Einstein-Str.",,"51.438696000000","14.256057000000",0,,0,"","" +"de:14625:6954:1:2_G","","Maukendorf, B96",,"51.396848000000","14.294685000000",0,,0,"","" +"de:14625:7685:0:2_G","","Luga (b Neschwitz) B 96",,"51.248051000000","14.356183000000",0,,0,"","" +"de:14625:7502:0:2_G","","Bautzen Lauengraben",,"51.179692000000","14.425848000000",0,,0,"","" +"de:14625:7687:0:2_G","","Holscha B 96",,"51.266963000000","14.344748000000",0,,0,"","" +"de:14625:7689:0:2_G","","Neudorf (b Neschwitz) B96",,"51.275545000000","14.339726000000",0,,0,"","" +"de:14625:7578:0:2_G","","Bautzen Abzw Seidau",,"51.192114000000","14.411474000000",0,,0,"","" +"de:14625:7692:0:2_G","","Zescha B 96",,"51.292396000000","14.328066000000",0,,0,"","" +"de:14625:7721:0:2_G","","Caminau Kaolinwerk",,"51.337006000000","14.342080000000",0,,0,"","" +"de:14625:7770:0:2_G","","Schwarzadler",,"51.235207000000","14.371913000000",0,,0,"","" +"de:14625:7720:0:2_G","","Caminau Dorf",,"51.327896000000","14.341029000000",0,,0,"","" +"de:14625:7555:0:2_G","","Bautzen Taucherstraße/Friedhof",,"51.180503000000","14.437472000000",0,,0,"","" +"de:14625:8063:0:2_G","","Hoyerswerda Straße E",,"51.430806000000","14.285944000000",0,,0,"","" + +# calendar.txt +"service_id","monday","tuesday","wednesday","thursday","friday","saturday","sunday","start_date","end_date" +1171,1,1,1,1,1,0,0,20240805,20241214 + +# calendar_dates.txt +"service_id","date","exception_type" +1171,20240805,2 +1171,20240812,2 +1171,20240806,2 +1171,20240813,2 +1171,20240807,2 +1171,20241120,2 +1171,20240808,2 +1171,20241003,2 +1171,20241031,2 +1171,20240809,2 + +)__"); +} + +} // namespace + +TEST(loader, merge_reflexive_matching) { + timetable tt; + register_special_stations(tt); + tt.date_range_ = {date::sys_days{2024_y / August / 1}, + date::sys_days{2024_y / September / 30}}; + auto const src_idx = source_idx_t{0}; + load_timetable({}, src_idx, bus500_files(), tt); + finalize(tt, false, true, false); + + for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { + for (auto b = transport_idx_t{0U}; b != tt.next_transport_idx(); ++b) { + if (a != b) { + EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] & + tt.bitfields_[tt.transport_traffic_days_[b]], + tt.bitfields_[bitfield_idx_t{0U}]); + } + } + } } \ No newline at end of file From c6171e2a11987c8ab2abb344a07662f5ddfb051e Mon Sep 17 00:00:00 2001 From: mority Date: Mon, 2 Sep 2024 18:01:41 +0200 Subject: [PATCH 10/27] no reflexive merging --- src/loader/merge_duplicates.cc | 9 +++++++ test/loader/merge_duplicates_test.cc | 40 ++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/loader/merge_duplicates.cc b/src/loader/merge_duplicates.cc index 7b1ffb97..2330437d 100644 --- a/src/loader/merge_duplicates.cc +++ b/src/loader/merge_duplicates.cc @@ -33,6 +33,10 @@ bool merge(timetable& tt, stop_idx_t const size, transport_idx_t const a, transport_idx_t const b) { + if (a == b) { + return true; + } + auto const bf_a = tt.bitfields_[tt.transport_traffic_days_[a]]; auto const bf_b = tt.bitfields_[tt.transport_traffic_days_[b]]; if ((bf_a & bf_b).none()) { @@ -127,6 +131,11 @@ unsigned find_duplicates(timetable& tt, auto a_t = begin(a_transport_range), b_t = begin(b_transport_range); while (a_t != end(a_transport_range) && b_t != end(b_transport_range)) { + if (*a_t == *b_t) { + ++a_t; + ++b_t; + } + auto const time_a = tt.event_mam(a_route, *a_t, 0U, event_type::kDep); auto const time_b = tt.event_mam(b_route, *b_t, 0U, event_type::kDep); diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc index b9493f8c..73ef1c48 100644 --- a/test/loader/merge_duplicates_test.cc +++ b/test/loader/merge_duplicates_test.cc @@ -15,7 +15,7 @@ using namespace date; namespace { -mem_dir rbo500_files() { +mem_dir rbo500_a_files() { return mem_dir::read(R"__( # trips.txt "route_id","service_id","trip_id","trip_headsign","trip_short_name","direction_id","block_id","shape_id","wheelchair_accessible","bikes_allowed" @@ -155,7 +155,7 @@ TEST(loader, merge_intra_src) { tt.date_range_ = {date::sys_days{2024_y / August / 5}, date::sys_days{2024_y / December / 14}}; register_special_stations(tt); - load_timetable({}, source_idx_t{0}, rbo500_files(), tt); + load_timetable({}, source_idx_t{0}, rbo500_a_files(), tt); finalize(tt, false, true, false); for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { @@ -186,6 +186,8 @@ TEST(loader, merge_intra_src) { tt.trip_transport_ranges_[trip_idx_t{1U}])) { EXPECT_EQ(tr_range_a.first, tr_range_b.first); EXPECT_EQ(tr_range_a.second, tr_range_b.second); + EXPECT_NE(tt.bitfields_[tt.transport_traffic_days_[tr_range_a.first]], + tt.bitfields_[bitfield_idx_t{0U}]); } } @@ -349,8 +351,6 @@ TEST(loader, merge_inter_src) { load_timetable({}, source_idx_t{1}, line1_2593402613_files(), tt); finalize(tt, false, false, true); - std::cout << tt << "\n"; - for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { for (auto b = transport_idx_t{0U}; b != tt.next_transport_idx(); ++b) { if (a != b) { @@ -379,12 +379,14 @@ TEST(loader, merge_inter_src) { tt.trip_transport_ranges_[trip_idx_t{1U}])) { EXPECT_EQ(tr_range_a.first, tr_range_b.first); EXPECT_EQ(tr_range_a.second, tr_range_b.second); + EXPECT_NE(tt.bitfields_[tt.transport_traffic_days_[tr_range_a.first]], + tt.bitfields_[bitfield_idx_t{0U}]); } } namespace { -mem_dir bus500_files() { +mem_dir rbo500_b_files() { return mem_dir::read(R"__( # trips.txt "route_id","service_id","trip_id","trip_headsign","trip_short_name","direction_id","block_id","shape_id","wheelchair_accessible","bikes_allowed" @@ -525,10 +527,10 @@ mem_dir bus500_files() { TEST(loader, merge_reflexive_matching) { timetable tt; register_special_stations(tt); - tt.date_range_ = {date::sys_days{2024_y / August / 1}, - date::sys_days{2024_y / September / 30}}; + tt.date_range_ = {date::sys_days{2024_y / August / 5}, + date::sys_days{2024_y / December / 14}}; auto const src_idx = source_idx_t{0}; - load_timetable({}, src_idx, bus500_files(), tt); + load_timetable({}, src_idx, rbo500_b_files(), tt); finalize(tt, false, true, false); for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { @@ -540,4 +542,26 @@ TEST(loader, merge_reflexive_matching) { } } } + + auto tt_contains_2593445670 = false; + auto tt_contains_2593399038 = false; + for (auto i = trip_id_idx_t{0U}; i != tt.trip_id_strings_.size(); ++i) { + if (tt.trip_id_strings_[i].view() == "2593445670") { + tt_contains_2593445670 = true; + } + if (tt.trip_id_strings_[i].view() == "2593399038") { + tt_contains_2593399038 = true; + } + } + EXPECT_TRUE(tt_contains_2593445670); + EXPECT_TRUE(tt_contains_2593399038); + + for (auto [tr_range_a, tr_range_b] : + utl::zip(tt.trip_transport_ranges_[trip_idx_t{0U}], + tt.trip_transport_ranges_[trip_idx_t{1U}])) { + EXPECT_EQ(tr_range_a.first, tr_range_b.first); + EXPECT_EQ(tr_range_a.second, tr_range_b.second); + EXPECT_NE(tt.bitfields_[tt.transport_traffic_days_[tr_range_a.first]], + tt.bitfields_[bitfield_idx_t{0U}]); + } } \ No newline at end of file From cd99baa29999564803158cdb4901d5cb0f644939 Mon Sep 17 00:00:00 2001 From: mority Date: Mon, 2 Sep 2024 19:01:06 +0200 Subject: [PATCH 11/27] no reflexive merging --- src/loader/merge_duplicates.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/loader/merge_duplicates.cc b/src/loader/merge_duplicates.cc index 2330437d..28abbb2b 100644 --- a/src/loader/merge_duplicates.cc +++ b/src/loader/merge_duplicates.cc @@ -134,6 +134,7 @@ unsigned find_duplicates(timetable& tt, if (*a_t == *b_t) { ++a_t; ++b_t; + continue; } auto const time_a = tt.event_mam(a_route, *a_t, 0U, event_type::kDep); From 36ac65811453c9f3fc0471a1702a6a471fd215e9 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:01:36 +0200 Subject: [PATCH 12/27] rm unused import --- src/loader/load.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/loader/load.cc b/src/loader/load.cc index 556d7567..7ed3d4cf 100644 --- a/src/loader/load.cc +++ b/src/loader/load.cc @@ -1,7 +1,5 @@ #include "nigiri/loader/load.h" -// #include - #include "utl/enumerate.h" #include "nigiri/loader/dir.h" From 3d138d93501e1353f9518f0ef4daf346c8e8d436 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:09:53 +0200 Subject: [PATCH 13/27] removes matches data structure --- include/nigiri/loader/link_nearby_stations.h | 3 +- src/loader/link_nearby_stations.cc | 35 +++----------------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/include/nigiri/loader/link_nearby_stations.h b/include/nigiri/loader/link_nearby_stations.h index 1af4a28f..5563ec09 100644 --- a/include/nigiri/loader/link_nearby_stations.h +++ b/include/nigiri/loader/link_nearby_stations.h @@ -6,7 +6,6 @@ struct timetable; namespace nigiri::loader { -template -match_set_t link_nearby_stations(timetable&); +void link_nearby_stations(timetable&); } // namespace nigiri::loader \ No newline at end of file diff --git a/src/loader/link_nearby_stations.cc b/src/loader/link_nearby_stations.cc index 766497b1..ff407d6b 100644 --- a/src/loader/link_nearby_stations.cc +++ b/src/loader/link_nearby_stations.cc @@ -8,17 +8,12 @@ namespace nigiri::loader { -template -match_set_t link_nearby_stations(timetable& tt) { +void link_nearby_stations(timetable& tt) { constexpr auto const kLinkNearbyMaxDistance = 300; // [m]; auto const locations_rtree = geo::make_point_rtree(tt.locations_.coordinates_); - auto matches = match_set_t{}; - if constexpr (!MatchIntraSrc && !MatchInterSrc) { - return matches; - } for (auto l_from_idx = location_idx_t{0U}; l_from_idx != tt.locations_.src_.size(); ++l_from_idx) { auto const from_pos = tt.locations_.coordinates_[l_from_idx]; @@ -39,21 +34,10 @@ match_set_t link_nearby_stations(timetable& tt) { } auto const to_src = tt.locations_.src_[l_to_idx]; - if (to_src == source_idx_t::invalid() /* no dummy stations */) { - continue; - } - if constexpr (!MatchIntraSrc) { - if (to_src == from_src) { - continue; - } - } - if constexpr (!MatchInterSrc) { - if (to_src != from_src) { - continue; - } - } - auto const to_pos = tt.locations_.coordinates_[l_to_idx]; + if (to_src == source_idx_t::invalid()) { + continue; /* no dummy stations */ + } auto const from_transfer_time = duration_t{tt.locations_.transfer_time_[l_from_idx]}; @@ -69,19 +53,8 @@ match_set_t link_nearby_stations(timetable& tt) { tt.locations_.preprocessing_footpaths_in_[l_to_idx].emplace_back( l_from_idx, duration); tt.locations_.equivalences_[l_from_idx].emplace_back(l_to_idx); - - if constexpr (MatchIntraSrc || MatchInterSrc) { - matches.emplace(make_match_pair(l_from_idx, l_to_idx)); - } } } - - return matches; } -template match_set_t link_nearby_stations(timetable&); -template match_set_t link_nearby_stations(timetable&); -template match_set_t link_nearby_stations(timetable&); -template match_set_t link_nearby_stations(timetable&); - } // namespace nigiri::loader \ No newline at end of file From 00654a1bb4534ac7e28589bdb20207f59acc72ef Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:15:38 +0200 Subject: [PATCH 14/27] removes matches data structure --- src/loader/link_nearby_stations.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/loader/link_nearby_stations.cc b/src/loader/link_nearby_stations.cc index ff407d6b..3c7f1293 100644 --- a/src/loader/link_nearby_stations.cc +++ b/src/loader/link_nearby_stations.cc @@ -35,8 +35,9 @@ void link_nearby_stations(timetable& tt) { auto const to_src = tt.locations_.src_[l_to_idx]; auto const to_pos = tt.locations_.coordinates_[l_to_idx]; - if (to_src == source_idx_t::invalid()) { - continue; /* no dummy stations */ + if (to_src == source_idx_t::invalid() /* no dummy stations */ + || from_src == to_src /* don't short-circuit */) { + continue; } auto const from_transfer_time = From e5d0bdfb4d4f69751d4e466512b6a900e48b0812 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:32:13 +0200 Subject: [PATCH 15/27] gets rid of templated link_nearby_stations --- src/loader/build_footpaths.cc | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/loader/build_footpaths.cc b/src/loader/build_footpaths.cc index d6d9e5ad..bdb9fdc2 100644 --- a/src/loader/build_footpaths.cc +++ b/src/loader/build_footpaths.cc @@ -411,18 +411,23 @@ void build_footpaths(timetable& tt, bool const merge_dupes_inter_src, std::uint16_t const max_footpath_length) { add_links_to_and_between_children(tt); - auto const matches = - merge_dupes_intra_src && merge_dupes_inter_src - ? link_nearby_stations(tt) - : merge_dupes_intra_src ? link_nearby_stations(tt) - : merge_dupes_inter_src ? link_nearby_stations(tt) - : link_nearby_stations(tt); + link_nearby_stations(tt); if (merge_dupes_intra_src || merge_dupes_inter_src) { - for (auto const& [a, b] : matches) { - find_duplicates(tt, matches, a, b); - } for (auto l = location_idx_t{0U}; l != tt.n_locations(); ++l) { - find_duplicates(tt, matches, l, l); + if (tt.locations_.src_[l] == source_idx_t{source_idx_t::invalid()}) { + continue; + } + for (auto e : tt.locations_.equivalences_[l]) { + if (tt.locations_.src_[e] == source_idx_t{source_idx_t::invalid()} || + (!merge_dupes_intra_src && + tt.locations_.src_[l] == tt.locations_.src_[e]) || + (!merge_dupes_inter_src && + tt.locations_.src_[l] != tt.locations_.src_[e])) { + continue; + } + + find_duplicates(tt, l, e); + } } } connect_components(tt, max_footpath_length, adjust_footpaths); From b7aa232d1353dafeea03c6deadebebfbe494b8ff Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:33:26 +0200 Subject: [PATCH 16/27] assert a != b when merging transports --- src/loader/merge_duplicates.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/loader/merge_duplicates.cc b/src/loader/merge_duplicates.cc index 28abbb2b..481a1dac 100644 --- a/src/loader/merge_duplicates.cc +++ b/src/loader/merge_duplicates.cc @@ -33,9 +33,7 @@ bool merge(timetable& tt, stop_idx_t const size, transport_idx_t const a, transport_idx_t const b) { - if (a == b) { - return true; - } + assert(a != b); auto const bf_a = tt.bitfields_[tt.transport_traffic_days_[a]]; auto const bf_b = tt.bitfields_[tt.transport_traffic_days_[b]]; From 6bf6e55de48236cc244ee3bd2e64415114fa1da5 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:45:12 +0200 Subject: [PATCH 17/27] removes matches data structure --- include/nigiri/loader/merge_duplicates.h | 7 +------ src/loader/merge_duplicates.cc | 5 ++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/include/nigiri/loader/merge_duplicates.h b/include/nigiri/loader/merge_duplicates.h index c2546769..ddd9028e 100644 --- a/include/nigiri/loader/merge_duplicates.h +++ b/include/nigiri/loader/merge_duplicates.h @@ -6,11 +6,6 @@ struct timetable; namespace nigiri::loader { -using match_set_t = hash_set>; - -unsigned find_duplicates(timetable& tt, - match_set_t const& matches, - location_idx_t a, - location_idx_t b); +unsigned find_duplicates(timetable& tt, location_idx_t a, location_idx_t b); } // namespace nigiri::loader \ No newline at end of file diff --git a/src/loader/merge_duplicates.cc b/src/loader/merge_duplicates.cc index 481a1dac..255b7b4b 100644 --- a/src/loader/merge_duplicates.cc +++ b/src/loader/merge_duplicates.cc @@ -88,7 +88,6 @@ bool merge(timetable& tt, } unsigned find_duplicates(timetable& tt, - match_set_t const& matches, location_idx_t const a, location_idx_t const b) { auto merged = 0U; @@ -115,8 +114,8 @@ unsigned find_duplicates(timetable& tt, auto const station_sequence_matches = [&]() { return utl::all_of(utl::zip(a_loc_seq, b_loc_seq), [&](auto&& pair) { auto const [x, y] = pair; - return x == y || matches.contains(make_match_pair( - stop{x}.location_idx(), stop{y}.location_idx())); + return matches(tt, routing::location_match_mode::kEquivalent, + stop{x}.location_idx(), stop{y}.location_idx()); }); }; From 4793e7fd50bee33ff65860130848575611f72303 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:45:44 +0200 Subject: [PATCH 18/27] fix var names and comments --- src/loader/merge_duplicates.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/loader/merge_duplicates.cc b/src/loader/merge_duplicates.cc index 255b7b4b..8a01c6a5 100644 --- a/src/loader/merge_duplicates.cc +++ b/src/loader/merge_duplicates.cc @@ -43,13 +43,13 @@ bool merge(timetable& tt, auto const merge_and_nullify = [&tt](transport_idx_t const x, transport_idx_t const y) { - tt.transport_traffic_days_[x] = bitfield_idx_t{0U}; // disable trip 'b' + tt.transport_traffic_days_[x] = bitfield_idx_t{0U}; // disable transport x - for (auto const merged_trips_idx_a : tt.transport_to_trip_section_[x]) { - for (auto const a_trp : tt.merged_trips_[merged_trips_idx_a]) { - for (auto& [t, range] : tt.trip_transport_ranges_[a_trp]) { + for (auto const merged_trips_idx_x : tt.transport_to_trip_section_[x]) { + for (auto const x_trp : tt.merged_trips_[merged_trips_idx_x]) { + for (auto& [t, range] : tt.trip_transport_ranges_[x_trp]) { if (t == x) { - t = y; // replace b with x in b's trip transport ranges + t = y; // replace x with y in x's trip transport ranges } } } From c3005ac6477f084d55137322aa48b26839f35805 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:46:28 +0200 Subject: [PATCH 19/27] use matches function from for_each_meta.h to compare locations for equivalence --- src/loader/merge_duplicates.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader/merge_duplicates.cc b/src/loader/merge_duplicates.cc index 8a01c6a5..ac2e78f1 100644 --- a/src/loader/merge_duplicates.cc +++ b/src/loader/merge_duplicates.cc @@ -1,6 +1,6 @@ #include "nigiri/loader/merge_duplicates.h" -#include "nigiri/loader/match_set.h" +#include "nigiri/routing/for_each_meta.h" #include "nigiri/timetable.h" namespace nigiri::loader { From e8ae6bd59bde36760d0f67829ead8732ce34fab4 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:46:41 +0200 Subject: [PATCH 20/27] remove matches data structure --- include/nigiri/loader/match_set.h | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 include/nigiri/loader/match_set.h diff --git a/include/nigiri/loader/match_set.h b/include/nigiri/loader/match_set.h deleted file mode 100644 index 0d378724..00000000 --- a/include/nigiri/loader/match_set.h +++ /dev/null @@ -1,12 +0,0 @@ -#include "nigiri/types.h" - -namespace nigiri::loader { - -using match_set_t = hash_set>; - -inline pair make_match_pair( - location_idx_t const a, location_idx_t const b) { - return {std::min(a, b), std::max(a, b)}; -} - -} // namespace nigiri::loader \ No newline at end of file From e1540fe134517775fbd1334da6f0920125304a93 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:46:46 +0200 Subject: [PATCH 21/27] remove matches data structure --- include/nigiri/loader/link_nearby_stations.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/nigiri/loader/link_nearby_stations.h b/include/nigiri/loader/link_nearby_stations.h index 5563ec09..a6666cd2 100644 --- a/include/nigiri/loader/link_nearby_stations.h +++ b/include/nigiri/loader/link_nearby_stations.h @@ -1,5 +1,3 @@ -#include "nigiri/loader/match_set.h" - namespace nigiri { struct timetable; } From 308fbf8fae544eb6c51ea6ffb4918761ea295049 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 12:52:28 +0200 Subject: [PATCH 22/27] check bitfield == 0 with none() --- test/loader/merge_duplicates_test.cc | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc index 73ef1c48..a1c523ec 100644 --- a/test/loader/merge_duplicates_test.cc +++ b/test/loader/merge_duplicates_test.cc @@ -156,14 +156,18 @@ TEST(loader, merge_intra_src) { date::sys_days{2024_y / December / 14}}; register_special_stations(tt); load_timetable({}, source_idx_t{0}, rbo500_a_files(), tt); + + ASSERT_TRUE(!tt.bitfields_.empty() && + tt.bitfields_[bitfield_idx_t{0U}].none()); + finalize(tt, false, true, false); for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { for (auto b = transport_idx_t{0U}; b != tt.next_transport_idx(); ++b) { if (a != b) { - EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] & - tt.bitfields_[tt.transport_traffic_days_[b]], - tt.bitfields_[bitfield_idx_t{0U}]); + EXPECT_TRUE((tt.bitfields_[tt.transport_traffic_days_[a]] & + tt.bitfields_[tt.transport_traffic_days_[b]]) + .none()); } } } @@ -349,14 +353,18 @@ TEST(loader, merge_inter_src) { register_special_stations(tt); load_timetable({}, source_idx_t{0}, line1_2593432458_files(), tt); load_timetable({}, source_idx_t{1}, line1_2593402613_files(), tt); + + ASSERT_TRUE(!tt.bitfields_.empty() && + tt.bitfields_[bitfield_idx_t{0U}].none()); + finalize(tt, false, false, true); for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { for (auto b = transport_idx_t{0U}; b != tt.next_transport_idx(); ++b) { if (a != b) { - EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] & - tt.bitfields_[tt.transport_traffic_days_[b]], - tt.bitfields_[bitfield_idx_t{0U}]); + EXPECT_TRUE((tt.bitfields_[tt.transport_traffic_days_[a]] & + tt.bitfields_[tt.transport_traffic_days_[b]]) + .none()); } } } @@ -531,14 +539,18 @@ TEST(loader, merge_reflexive_matching) { date::sys_days{2024_y / December / 14}}; auto const src_idx = source_idx_t{0}; load_timetable({}, src_idx, rbo500_b_files(), tt); + + ASSERT_TRUE(!tt.bitfields_.empty() && + tt.bitfields_[bitfield_idx_t{0U}].none()); + finalize(tt, false, true, false); for (auto a = transport_idx_t{0U}; a != tt.next_transport_idx(); ++a) { for (auto b = transport_idx_t{0U}; b != tt.next_transport_idx(); ++b) { if (a != b) { - EXPECT_EQ(tt.bitfields_[tt.transport_traffic_days_[a]] & - tt.bitfields_[tt.transport_traffic_days_[b]], - tt.bitfields_[bitfield_idx_t{0U}]); + EXPECT_TRUE((tt.bitfields_[tt.transport_traffic_days_[a]] & + tt.bitfields_[tt.transport_traffic_days_[b]]) + .none()); } } } From 511604f422f7e52162dc4741c872a672b1f0aea5 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 14:38:04 +0200 Subject: [PATCH 23/27] rm unused import --- test/loader/merge_duplicates_test.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc index a1c523ec..cabe561c 100644 --- a/test/loader/merge_duplicates_test.cc +++ b/test/loader/merge_duplicates_test.cc @@ -1,7 +1,5 @@ #include "gtest/gtest.h" -#include "utl/enumerate.h" - #include "nigiri/loader/dir.h" #include "nigiri/loader/gtfs/files.h" #include "nigiri/loader/gtfs/load_timetable.h" From 07cd5b8d3792d52d51c8d6b8389408de00c73dae Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 14:39:02 +0200 Subject: [PATCH 24/27] check if trip descriptor can be resolved after merge --- test/loader/merge_duplicates_test.cc | 87 ++++++++++++++++------------ 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc index cabe561c..f80e666d 100644 --- a/test/loader/merge_duplicates_test.cc +++ b/test/loader/merge_duplicates_test.cc @@ -4,6 +4,7 @@ #include "nigiri/loader/gtfs/files.h" #include "nigiri/loader/gtfs/load_timetable.h" #include "nigiri/loader/init_finish.h" +#include "nigiri/rt/gtfsrt_resolve_run.h" #include "nigiri/timetable.h" using namespace nigiri; @@ -11,6 +12,14 @@ using namespace nigiri::loader; using namespace nigiri::loader::gtfs; using namespace date; +auto resolve(date::sys_days d, + timetable const& tt, + source_idx_t const src, + transit_realtime::TripDescriptor const& td) { + rt_timetable rtt; + return rt::gtfsrt_resolve_run(d, tt, rtt, src, td); +} + namespace { mem_dir rbo500_a_files() { @@ -170,18 +179,20 @@ TEST(loader, merge_intra_src) { } } - auto tt_contains_2593445697 = false; - auto tt_contains_2593399070 = false; - for (auto i = trip_id_idx_t{0U}; i != tt.trip_id_strings_.size(); ++i) { - if (tt.trip_id_strings_[i].view() == "2593445697") { - tt_contains_2593445697 = true; - } - if (tt.trip_id_strings_[i].view() == "2593399070") { - tt_contains_2593399070 = true; - } - } - EXPECT_TRUE(tt_contains_2593445697); - EXPECT_TRUE(tt_contains_2593399070); + auto td = transit_realtime::TripDescriptor(); + + *td.mutable_trip_id() = "2593445697"; + auto const [r0, t0] = + resolve(date::sys_days{2024_y / September / 3}, tt, source_idx_t{0}, td); + ASSERT_TRUE(r0.valid()); + + *td.mutable_trip_id() = "2593399070"; + auto const [r1, t1] = + resolve(date::sys_days{2024_y / September / 3}, tt, source_idx_t{0}, td); + ASSERT_TRUE(r1.valid()); + + EXPECT_EQ(r0.t_, r1.t_); + EXPECT_NE(t0, t1); for (auto [tr_range_a, tr_range_b] : utl::zip(tt.trip_transport_ranges_[trip_idx_t{0U}], @@ -367,18 +378,20 @@ TEST(loader, merge_inter_src) { } } - auto tt_contains_2593432458 = false; - auto tt_contains_2593402613 = false; - for (auto i = trip_id_idx_t{0U}; i != tt.trip_id_strings_.size(); ++i) { - if (tt.trip_id_strings_[i].view() == "2593432458") { - tt_contains_2593432458 = true; - } - if (tt.trip_id_strings_[i].view() == "2593402613") { - tt_contains_2593402613 = true; - } - } - EXPECT_TRUE(tt_contains_2593432458); - EXPECT_TRUE(tt_contains_2593402613); + auto td = transit_realtime::TripDescriptor(); + + *td.mutable_trip_id() = "2593432458"; + auto const [r0, t0] = + resolve(date::sys_days{2024_y / September / 3}, tt, source_idx_t{0}, td); + ASSERT_TRUE(r0.valid()); + + *td.mutable_trip_id() = "2593402613"; + auto const [r1, t1] = + resolve(date::sys_days{2024_y / September / 3}, tt, source_idx_t{1}, td); + ASSERT_TRUE(r1.valid()); + + EXPECT_EQ(r0.t_, r1.t_); + EXPECT_NE(t0, t1); for (auto [tr_range_a, tr_range_b] : utl::zip(tt.trip_transport_ranges_[trip_idx_t{0U}], @@ -553,18 +566,20 @@ TEST(loader, merge_reflexive_matching) { } } - auto tt_contains_2593445670 = false; - auto tt_contains_2593399038 = false; - for (auto i = trip_id_idx_t{0U}; i != tt.trip_id_strings_.size(); ++i) { - if (tt.trip_id_strings_[i].view() == "2593445670") { - tt_contains_2593445670 = true; - } - if (tt.trip_id_strings_[i].view() == "2593399038") { - tt_contains_2593399038 = true; - } - } - EXPECT_TRUE(tt_contains_2593445670); - EXPECT_TRUE(tt_contains_2593399038); + auto td = transit_realtime::TripDescriptor(); + + *td.mutable_trip_id() = "2593445670"; + auto const [r0, t0] = + resolve(date::sys_days{2024_y / September / 3}, tt, source_idx_t{0}, td); + ASSERT_TRUE(r0.valid()); + + *td.mutable_trip_id() = "2593399038"; + auto const [r1, t1] = + resolve(date::sys_days{2024_y / September / 3}, tt, source_idx_t{0}, td); + ASSERT_TRUE(r1.valid()); + + EXPECT_EQ(r0.t_, r1.t_); + EXPECT_NE(t0, t1); for (auto [tr_range_a, tr_range_b] : utl::zip(tt.trip_transport_ranges_[trip_idx_t{0U}], From b216d70b90c4f22a48b8722cb4919a00e5ee6ba0 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 14:39:36 +0200 Subject: [PATCH 25/27] use none() to check if bitfield == 0 --- test/loader/merge_duplicates_test.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/loader/merge_duplicates_test.cc b/test/loader/merge_duplicates_test.cc index f80e666d..b982ef29 100644 --- a/test/loader/merge_duplicates_test.cc +++ b/test/loader/merge_duplicates_test.cc @@ -199,8 +199,8 @@ TEST(loader, merge_intra_src) { tt.trip_transport_ranges_[trip_idx_t{1U}])) { EXPECT_EQ(tr_range_a.first, tr_range_b.first); EXPECT_EQ(tr_range_a.second, tr_range_b.second); - EXPECT_NE(tt.bitfields_[tt.transport_traffic_days_[tr_range_a.first]], - tt.bitfields_[bitfield_idx_t{0U}]); + EXPECT_FALSE( + tt.bitfields_[tt.transport_traffic_days_[tr_range_a.first]].none()); } } @@ -398,8 +398,8 @@ TEST(loader, merge_inter_src) { tt.trip_transport_ranges_[trip_idx_t{1U}])) { EXPECT_EQ(tr_range_a.first, tr_range_b.first); EXPECT_EQ(tr_range_a.second, tr_range_b.second); - EXPECT_NE(tt.bitfields_[tt.transport_traffic_days_[tr_range_a.first]], - tt.bitfields_[bitfield_idx_t{0U}]); + EXPECT_FALSE( + tt.bitfields_[tt.transport_traffic_days_[tr_range_a.first]].none()); } } @@ -586,7 +586,7 @@ TEST(loader, merge_reflexive_matching) { tt.trip_transport_ranges_[trip_idx_t{1U}])) { EXPECT_EQ(tr_range_a.first, tr_range_b.first); EXPECT_EQ(tr_range_a.second, tr_range_b.second); - EXPECT_NE(tt.bitfields_[tt.transport_traffic_days_[tr_range_a.first]], - tt.bitfields_[bitfield_idx_t{0U}]); + EXPECT_FALSE( + tt.bitfields_[tt.transport_traffic_days_[tr_range_a.first]].none()); } } \ No newline at end of file From 876feb4be3783d3c06c40b5c84bc786804104975 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 16:23:34 +0200 Subject: [PATCH 26/27] moves for_each_meta.h and location_match_mode.h to top level --- include/nigiri/{routing => }/for_each_meta.h | 2 +- .../{routing => }/location_match_mode.h | 0 .../query_generator/generator_settings.h | 2 +- include/nigiri/routing/query.h | 2 +- include/nigiri/routing/sanitize_via_stops.h | 2 +- include/nigiri/routing/search.h | 44 +++++++++---------- src/loader/merge_duplicates.cc | 2 +- src/query_generator/generator.cc | 2 +- src/routing/dijkstra.cc | 2 +- src/routing/get_fastest_direct.cc | 2 +- src/routing/raptor/optimize_footpaths.cc | 2 +- src/routing/raptor/reconstruct.cc | 2 +- src/routing/start_times.cc | 2 +- 13 files changed, 33 insertions(+), 33 deletions(-) rename include/nigiri/{routing => }/for_each_meta.h (97%) rename include/nigiri/{routing => }/location_match_mode.h (100%) diff --git a/include/nigiri/routing/for_each_meta.h b/include/nigiri/for_each_meta.h similarity index 97% rename from include/nigiri/routing/for_each_meta.h rename to include/nigiri/for_each_meta.h index 9486d089..3622f7de 100644 --- a/include/nigiri/routing/for_each_meta.h +++ b/include/nigiri/for_each_meta.h @@ -1,6 +1,6 @@ #pragma once -#include "nigiri/routing/location_match_mode.h" +#include "nigiri/location_match_mode.h" #include "nigiri/timetable.h" namespace nigiri::routing { diff --git a/include/nigiri/routing/location_match_mode.h b/include/nigiri/location_match_mode.h similarity index 100% rename from include/nigiri/routing/location_match_mode.h rename to include/nigiri/location_match_mode.h diff --git a/include/nigiri/query_generator/generator_settings.h b/include/nigiri/query_generator/generator_settings.h index 77c8493e..6403ef3e 100644 --- a/include/nigiri/query_generator/generator_settings.h +++ b/include/nigiri/query_generator/generator_settings.h @@ -2,10 +2,10 @@ #include "geo/box.h" +#include "nigiri/location_match_mode.h" #include "nigiri/query_generator/transport_mode.h" #include "nigiri/routing/clasz_mask.h" #include "nigiri/routing/limits.h" -#include "nigiri/routing/location_match_mode.h" #include "nigiri/routing/transfer_time_settings.h" #include "nigiri/timetable.h" diff --git a/include/nigiri/routing/query.h b/include/nigiri/routing/query.h index c634482e..2a1f5e7d 100644 --- a/include/nigiri/routing/query.h +++ b/include/nigiri/routing/query.h @@ -7,9 +7,9 @@ #include "nigiri/common/interval.h" #include "nigiri/footpath.h" +#include "nigiri/location_match_mode.h" #include "nigiri/routing/clasz_mask.h" #include "nigiri/routing/limits.h" -#include "nigiri/routing/location_match_mode.h" #include "nigiri/routing/transfer_time_settings.h" #include "nigiri/td_footpath.h" #include "nigiri/types.h" diff --git a/include/nigiri/routing/sanitize_via_stops.h b/include/nigiri/routing/sanitize_via_stops.h index abe8cdcc..9e0dce64 100644 --- a/include/nigiri/routing/sanitize_via_stops.h +++ b/include/nigiri/routing/sanitize_via_stops.h @@ -1,6 +1,6 @@ #pragma once -#include "nigiri/routing/for_each_meta.h" +#include "nigiri/for_each_meta.h" #include "nigiri/routing/query.h" #include "nigiri/timetable.h" diff --git a/include/nigiri/routing/search.h b/include/nigiri/routing/search.h index dcd5bdf4..8a8d0270 100644 --- a/include/nigiri/routing/search.h +++ b/include/nigiri/routing/search.h @@ -6,9 +6,9 @@ #include "utl/timing.h" #include "utl/to_vec.h" +#include "nigiri/for_each_meta.h" #include "nigiri/logging.h" #include "nigiri/routing/dijkstra.h" -#include "nigiri/routing/for_each_meta.h" #include "nigiri/routing/get_fastest_direct.h" #include "nigiri/routing/interval_estimate.h" #include "nigiri/routing/journey.h" @@ -147,13 +147,13 @@ struct search { state_{s}, q_{std::move(q)}, search_interval_{std::visit( - utl::overloaded{ - [](interval const start_interval) { - return start_interval; - }, - [](unixtime_t const start_time) { - return interval{start_time, start_time}; - }}, + utl::overloaded{[](interval const start_interval) { + return start_interval; + }, + [](unixtime_t const start_time) { + return interval{start_time, + start_time}; + }}, q_.start_time_)}, fastest_direct_{get_fastest_direct(tt_, q_, SearchDir)}, algo_{init(q_.allowed_claszes_, @@ -209,13 +209,13 @@ struct search { "timeout_reached={}\n", is_ontrip(), q_.extend_interval_earlier_, q_.extend_interval_later_, std::visit( - utl::overloaded{ - [](interval const& start_interval) { - return start_interval; - }, - [](unixtime_t const start_time) { - return interval{start_time, start_time}; - }}, + utl::overloaded{[](interval const& start_interval) { + return start_interval; + }, + [](unixtime_t const start_time) { + return interval{start_time, + start_time}; + }}, q_.start_time_), search_interval_, tt_.external_interval(), n_results_in_interval(), is_timeout_reached()); @@ -227,13 +227,13 @@ struct search { "number_of_results_in_interval={}\n", q_.extend_interval_earlier_, q_.extend_interval_later_, std::visit( - utl::overloaded{ - [](interval const& start_interval) { - return start_interval; - }, - [](unixtime_t const start_time) { - return interval{start_time, start_time}; - }}, + utl::overloaded{[](interval const& start_interval) { + return start_interval; + }, + [](unixtime_t const start_time) { + return interval{start_time, + start_time}; + }}, q_.start_time_), search_interval_, tt_.external_interval(), n_results_in_interval()); } diff --git a/src/loader/merge_duplicates.cc b/src/loader/merge_duplicates.cc index ac2e78f1..476c9c9d 100644 --- a/src/loader/merge_duplicates.cc +++ b/src/loader/merge_duplicates.cc @@ -1,6 +1,6 @@ #include "nigiri/loader/merge_duplicates.h" -#include "nigiri/routing/for_each_meta.h" +#include "nigiri/for_each_meta.h" #include "nigiri/timetable.h" namespace nigiri::loader { diff --git a/src/query_generator/generator.cc b/src/query_generator/generator.cc index 4c954c21..9b975953 100644 --- a/src/query_generator/generator.cc +++ b/src/query_generator/generator.cc @@ -1,7 +1,7 @@ #include "nigiri/query_generator/generator.h" +#include "nigiri/location_match_mode.h" #include "nigiri/logging.h" -#include "nigiri/routing/location_match_mode.h" #include "nigiri/routing/ontrip_train.h" #include "nigiri/special_stations.h" #include "nigiri/timetable.h" diff --git a/src/routing/dijkstra.cc b/src/routing/dijkstra.cc index bd63ca62..9a5b6bcb 100644 --- a/src/routing/dijkstra.cc +++ b/src/routing/dijkstra.cc @@ -6,7 +6,7 @@ #include "nigiri/common/dial.h" #include "nigiri/footpath.h" -#include "nigiri/routing/for_each_meta.h" +#include "nigiri/for_each_meta.h" #include "nigiri/routing/limits.h" #include "nigiri/routing/query.h" diff --git a/src/routing/get_fastest_direct.cc b/src/routing/get_fastest_direct.cc index 39c2957a..9e957520 100644 --- a/src/routing/get_fastest_direct.cc +++ b/src/routing/get_fastest_direct.cc @@ -3,8 +3,8 @@ #include "utl/get_or_create.h" #include "nigiri/common/dial.h" +#include "nigiri/for_each_meta.h" #include "nigiri/routing/dijkstra.h" -#include "nigiri/routing/for_each_meta.h" #include "nigiri/special_stations.h" namespace nigiri::routing { diff --git a/src/routing/raptor/optimize_footpaths.cc b/src/routing/raptor/optimize_footpaths.cc index e6267a22..5d4b8ab8 100644 --- a/src/routing/raptor/optimize_footpaths.cc +++ b/src/routing/raptor/optimize_footpaths.cc @@ -2,7 +2,7 @@ #include "utl/overloaded.h" -#include "nigiri/routing/for_each_meta.h" +#include "nigiri/for_each_meta.h" #include "nigiri/routing/journey.h" #include "nigiri/rt/frun.h" #include "nigiri/rt/rt_timetable.h" diff --git a/src/routing/raptor/reconstruct.cc b/src/routing/raptor/reconstruct.cc index aa61c14a..7c2086bf 100644 --- a/src/routing/raptor/reconstruct.cc +++ b/src/routing/raptor/reconstruct.cc @@ -8,7 +8,7 @@ #include "utl/overloaded.h" #include "nigiri/common/delta_t.h" -#include "nigiri/routing/for_each_meta.h" +#include "nigiri/for_each_meta.h" #include "nigiri/routing/journey.h" #include "nigiri/routing/raptor/raptor_state.h" #include "nigiri/rt/frun.h" diff --git a/src/routing/start_times.cc b/src/routing/start_times.cc index 7f924bbc..95af2f1b 100644 --- a/src/routing/start_times.cc +++ b/src/routing/start_times.cc @@ -1,6 +1,6 @@ #include "nigiri/routing/start_times.h" -#include "nigiri/routing/for_each_meta.h" +#include "nigiri/for_each_meta.h" #include "nigiri/rt/rt_timetable.h" #include "nigiri/special_stations.h" #include "utl/enumerate.h" From 18de1caf474af401a1c5f7c94c0e44b96dec14a0 Mon Sep 17 00:00:00 2001 From: mority Date: Tue, 3 Sep 2024 16:43:32 +0200 Subject: [PATCH 27/27] clang-format-17 --- include/nigiri/routing/search.h | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/include/nigiri/routing/search.h b/include/nigiri/routing/search.h index 8a8d0270..e9cd023b 100644 --- a/include/nigiri/routing/search.h +++ b/include/nigiri/routing/search.h @@ -147,13 +147,13 @@ struct search { state_{s}, q_{std::move(q)}, search_interval_{std::visit( - utl::overloaded{[](interval const start_interval) { - return start_interval; - }, - [](unixtime_t const start_time) { - return interval{start_time, - start_time}; - }}, + utl::overloaded{ + [](interval const start_interval) { + return start_interval; + }, + [](unixtime_t const start_time) { + return interval{start_time, start_time}; + }}, q_.start_time_)}, fastest_direct_{get_fastest_direct(tt_, q_, SearchDir)}, algo_{init(q_.allowed_claszes_, @@ -209,13 +209,13 @@ struct search { "timeout_reached={}\n", is_ontrip(), q_.extend_interval_earlier_, q_.extend_interval_later_, std::visit( - utl::overloaded{[](interval const& start_interval) { - return start_interval; - }, - [](unixtime_t const start_time) { - return interval{start_time, - start_time}; - }}, + utl::overloaded{ + [](interval const& start_interval) { + return start_interval; + }, + [](unixtime_t const start_time) { + return interval{start_time, start_time}; + }}, q_.start_time_), search_interval_, tt_.external_interval(), n_results_in_interval(), is_timeout_reached()); @@ -227,13 +227,13 @@ struct search { "number_of_results_in_interval={}\n", q_.extend_interval_earlier_, q_.extend_interval_later_, std::visit( - utl::overloaded{[](interval const& start_interval) { - return start_interval; - }, - [](unixtime_t const start_time) { - return interval{start_time, - start_time}; - }}, + utl::overloaded{ + [](interval const& start_interval) { + return start_interval; + }, + [](unixtime_t const start_time) { + return interval{start_time, start_time}; + }}, q_.start_time_), search_interval_, tt_.external_interval(), n_results_in_interval()); }