-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * clang-tidy * clang-format * clang-format * wip * wip * direction_id matching * direction_id matching * wip * wip * direction_id matching * wip * wip * wip * wip * wip * clang-format-17 * wip * wip * wip * wip * select all IstFahrt nodes in update messages, regardless of where they are located * skip updates without stops, only log them * skip updates without stops, only log them * minimized timetables for case studies of unmatchable runs * redirected update event output to file, adds test case for matching prevented by line name * allow reference time differences of 1 minute * use postfix matching for line names * candidate struct to improve readability, discard subsequent matches if stop_idx is lower than the first matching stop_idx * smd712 test case * rbo920 test case * maintain mapping vdv run id -> rt::run * import run.h * removes early termination when searching run * removes early termination when searching run * fix vdv run id parsing * no result if there are multiple matches * require at least half of the stops to match * use matching ratio as tie breaker * comment for test case ovo65 * rbo707 test case, requires iterating routes at equivalent stations to pass * iterate routes at equivalent locations * fix macos ci * fix macos ci * clang-tidy * clang-tidy * clang-format-17 * tolerate time discrepancies of up to 5 minutes between GTFS reference timetable and VDV update messages * vgm 456 test case * aggregate time error at matching stops * allow time discrepancies of up to 10 min * rvs347 & rbo512 test cases * use total length of route as tiebreaker * fix stats * vgm418 test case * reverse iteration * monotonize rt times after vdv update * vgm418: check for monotone rt times after update * msvc fix: split update_vgm418 * optional debug logging * optional debug logging * wip * rvs360 testcase * scoring with quadratic error, refactoring * early bailout if local_score < 0 * variable naming convention * cleanup * clang-format-17 * only count first update for unmatchable run in stats * rm parameter name in declaration * moves implementation of updater and vdv_stop to source file * cleanup * change name of limits for backward iteration * const vdv_ev * dbg output macro without std format * remove time_since_epoch * remove string append * reverse iterator * fix import * rm vdv update exe * fix reverse iterator * fix reverse iterator * fix dbg output, single update event function, fix monotonize * rm unused import * clang-tidy * mam_dist * descriptive test case names * second return value signals if and in which direction midnight is traversed * test cases with time discrepancies that traverse midnight * handle time discrepancies that traverse midnight when matching * switch off debug logging by default * mam_dist descriptive types * mam_dist comment * rm empty line * rm empty line * parse_time function, tests for behavior on invalid input * parse_time exception handling * parse_time exception handling * import sstream * param name * format * refactor * fwd declare pugixml structs * refactor * fix msvc ci * rm pugi linkage * class fwd declarations for pugi --------- Co-authored-by: Felix Gündling <[email protected]>
- Loading branch information
1 parent
471d09f
commit fc462d3
Showing
16 changed files
with
5,633 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,7 @@ | |
[email protected]:motis-project/opentelemetry-cpp.git | ||
branch=main | ||
commit=ec4aef6b17b697052edef5417825ad71947b2ed1 | ||
[pugixml] | ||
[email protected]:motis-project/pugixml.git | ||
branch=master | ||
commit=60175e80e2f5e97e027ac78f7e14c5acc009ce50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <utility> | ||
|
||
#include "nigiri/types.h" | ||
|
||
namespace nigiri { | ||
|
||
/* | ||
* Computes the minimal distance between two minutes after midnight values | ||
* within [0, 1440[, i.e., if the shorter distance between the two values spans | ||
* midnight that distance is returned | ||
* the first value of the returned pair contains the absolute distance between | ||
* the two values | ||
* the second value of the returned pair signals if and in which direction | ||
* midnight is passed: | ||
* -1: [actual -- midnight -- expected] | ||
* 0: [actual -- expected] / [expected -- actual] | ||
* +1: [expected -- midnight -- actual] | ||
*/ | ||
std::pair<i32_minutes, date::days> mam_dist(i32_minutes expected, | ||
i32_minutes actual); | ||
|
||
} // namespace nigiri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include "nigiri/types.h" | ||
|
||
namespace nigiri { | ||
|
||
unixtime_t parse_time(std::string const&); | ||
|
||
} // namespace nigiri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#pragma once | ||
|
||
#include "nigiri/rt/run.h" | ||
#include "nigiri/types.h" | ||
|
||
namespace pugi { | ||
class xml_document; | ||
class xml_node; | ||
} // namespace pugi | ||
|
||
namespace nigiri { | ||
struct rt_timetable; | ||
struct timetable; | ||
} // namespace nigiri | ||
|
||
namespace nigiri::rt::vdv { | ||
|
||
struct statistics { | ||
friend std::ostream& operator<<(std::ostream&, statistics const&); | ||
friend statistics& operator+=(statistics&, statistics const&); | ||
|
||
std::uint32_t unsupported_additional_runs_{0U}; | ||
std::uint32_t unsupported_cancelled_runs_{0U}; | ||
std::uint32_t total_stops_{0U}; | ||
std::uint32_t resolved_stops_{0U}; | ||
std::uint32_t unknown_stops_{0U}; | ||
std::uint32_t unsupported_additional_stops_{0U}; | ||
std::uint32_t total_runs_{0U}; | ||
std::uint32_t no_transport_found_at_stop_{0U}; | ||
std::uint32_t search_on_incomplete_{0U}; | ||
std::uint32_t found_runs_{0U}; | ||
std::uint32_t multiple_matches_{0U}; | ||
std::uint32_t matched_runs_{0U}; | ||
std::uint32_t unmatchable_runs_{0U}; | ||
std::uint32_t runs_without_stops_{0U}; | ||
std::uint32_t skipped_vdv_stops_{0U}; | ||
std::uint32_t excess_vdv_stops_{0U}; | ||
std::uint32_t updated_events_{0U}; | ||
std::uint32_t propagated_delays_{0U}; | ||
}; | ||
|
||
struct updater { | ||
static constexpr auto const kExactMatchScore = 1000; | ||
static constexpr auto const kAllowedTimeDiscrepancy = []() { | ||
auto error = 0; | ||
while (kExactMatchScore - error * error > 0) { | ||
++error; | ||
} | ||
return error - 1; | ||
}(); // minutes | ||
|
||
updater(timetable const&, source_idx_t); | ||
|
||
void reset_vdv_run_ids_(); | ||
|
||
statistics const& get_stats() const; | ||
|
||
void update(rt_timetable&, pugi::xml_document const&); | ||
|
||
private: | ||
static std::optional<unixtime_t> get_opt_time(pugi::xml_node const&, | ||
char const*); | ||
|
||
struct vdv_stop { | ||
explicit vdv_stop(location_idx_t, std::string_view id, pugi::xml_node); | ||
|
||
std::optional<std::pair<unixtime_t, event_type>> get_event( | ||
event_type et) const; | ||
|
||
location_idx_t l_; | ||
std::string_view id_; | ||
std::optional<unixtime_t> dep_, arr_, rt_dep_, rt_arr_; | ||
}; | ||
|
||
vector<vdv_stop> resolve_stops(pugi::xml_node vdv_run); | ||
|
||
std::optional<rt::run> find_run(std::string_view vdv_run_id, | ||
vector<vdv_stop> const&, | ||
bool is_complete_run); | ||
|
||
void update_run(rt_timetable&, | ||
run&, | ||
vector<vdv_stop> const&, | ||
bool is_complete_run); | ||
|
||
void process_vdv_run(rt_timetable&, pugi::xml_node vdv_run); | ||
|
||
timetable const& tt_; | ||
source_idx_t src_idx_; | ||
statistics stats_{}; | ||
hash_map<std::string, run> vdv_nigiri_{}; | ||
}; | ||
|
||
} // namespace nigiri::rt::vdv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "nigiri/common/mam_dist.h" | ||
|
||
#include <cassert> | ||
#include <cstdlib> | ||
|
||
namespace nigiri { | ||
|
||
std::pair<i32_minutes, date::days> mam_dist(i32_minutes const expected, | ||
i32_minutes const actual) { | ||
assert(i32_minutes{0} <= expected && expected < i32_minutes{1440}); | ||
assert(i32_minutes{0} <= actual && actual < i32_minutes{1440}); | ||
|
||
auto const diff = (expected - actual).count(); | ||
auto const abs = std::abs(diff); | ||
|
||
if (abs > 1440 / 2) { | ||
return {i32_minutes{1440 - abs}, date::days{diff < 0 ? -1 : +1}}; | ||
} else { | ||
return {i32_minutes{abs}, date::days{0}}; | ||
} | ||
} | ||
|
||
} // namespace nigiri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "nigiri/common/parse_time.h" | ||
|
||
#include <sstream> | ||
|
||
namespace nigiri { | ||
|
||
unixtime_t parse_time(std::string const& str) { | ||
unixtime_t parsed; | ||
auto ss = std::stringstream{str}; | ||
ss.exceptions(std::ios::badbit | std::ios::failbit | std::ios::eofbit); | ||
ss >> date::parse("%FT%T", parsed); | ||
return parsed; | ||
} | ||
|
||
} // namespace nigiri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.