diff --git a/application/editormodenorms.cpp b/application/editormodenorms.cpp index fc6d717c5..d77b0597e 100644 --- a/application/editormodenorms.cpp +++ b/application/editormodenorms.cpp @@ -212,8 +212,24 @@ void norms_tool::forget(scene::basic_node const *Node) state.selected = -1; for (auto &line : state.lines) std::erase_if(line.entries, [Node](norms_report::entry const &Entry) { return Entry.track == Node; }); - for (auto &line : state.queue) - std::erase_if(line.spans, [Node](norms_report::span const &Span) { return Span.track == Node; }); + // the span whose findings alone are kept moves down by the spans taken out before it; a line whose own span went has nothing left + // to report + auto const gone = [Node](norms_report::span const &Span) { return Span.track == Node; }; + auto line{state.queue.begin()}; + while (line != state.queue.end()) + { + if (line->own >= 0 && line->own < static_cast(line->spans.size())) + { + if (gone(line->spans[line->own])) + { + line = state.queue.erase(line); + continue; + } + line->own -= static_cast(std::count_if(line->spans.begin(), line->spans.begin() + line->own, gone)); + } + std::erase_if(line->spans, gone); + ++line; + } } void norms_tool::render_class() diff --git a/editor/norms/normsEngine.cpp b/editor/norms/normsEngine.cpp index df571a502..f2e2c7eed 100644 --- a/editor/norms/normsEngine.cpp +++ b/editor/norms/normsEngine.cpp @@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/. #include "editor/norms/norms.hpp" #include +#include #include #include @@ -374,15 +375,22 @@ class checker return result; } - // the shortest element between two jumps for them to be taken apart: the longest the profiles of the element between them ask for + // the shortest element between two jumps for them to be taken apart: the longest the profiles of the element between them ask for. + // TSI INF and EN 13803 limit the jump but say nothing of jumps close together, so with only them there the longest any profile + // asks for is taken: otherwise two jumps a metre apart would each pass a limit their sum breaks double intermediate(std::size_t const Index, double const Speed) const { auto const &element{m_line.elements[Index]}; - double result{0.0}; - for (auto const profile : profiles(element)) - if (auto const bound{limits(profile, parameter::intermediate_length, where(element, Speed, 0.0)).block}) - result = std::max(result, bound->value); - return result; + auto const longest = [this, &element, Speed](auto const &Profiles) { + double result{0.0}; + for (auto const profile : Profiles) + if (auto const bound{limits(profile, parameter::intermediate_length, where(element, Speed, 0.0)).block}) + result = std::max(result, bound->value); + return result; + }; + if (auto const own{longest(profiles(element))}; own > 0.0) + return own; + return longest(std::array{profile_id::plk, profile_id::tsi, profile_id::en13803, profile_id::ch}); } // ST-T1-A6 9.11 pkt 8 - 13: the jumps closer than the intermediate length, changing the cant deficiency the same way, are taken diff --git a/tests/unit/data/norms/line_report.txt b/tests/unit/data/norms/line_report.txt index 28b635204..fe0fd0aff 100644 --- a/tests/unit/data/norms/line_report.txt +++ b/tests/unit/data/norms/line_report.txt @@ -34,17 +34,17 @@ Line n01: 988.0 m, 11 elements, 19 findings 828.0 note cant change rate 42 mm/s, PLK recommends at most 35 mm/s (tab. 9.13) [n13] Norms: TSI INF, line 100 km/h, slow trains 60 km/h, mixed traffic, main track, 5 Tg a year, the speed of the tracks where they have one -Line n01: 988.0 m, 11 elements, 3 findings +Line n01: 988.0 m, 11 elements, 4 findings + 478.0 hard limit abrupt change of the cant deficiency 191 mm, TSI INF allows at most 130 mm (4.2.4.4(1)) [n07] 598.0 hard limit break of the grade with no vertical curve, TSI INF asks for a radius of at least 900 m (4.2.3.5(1)) [n10] 648.0 hard limit cant ramp 3.00 mm/m, EN 13803-1 allows at most 2.50 mm/m (5.2.5) [n11] 648.0 hard limit break of the grade with no vertical curve, TSI INF asks for a radius of at least 500 m (4.2.3.5(1)) [n11] Norms: EN 13803, line 100 km/h, slow trains 60 km/h, mixed traffic, main track, 5 Tg a year, the speed of the tracks where they have one -Line n01: 988.0 m, 11 elements, 10 findings +Line n01: 988.0 m, 11 elements, 9 findings 210.0 warning cant deficiency 137 mm, EN 13803 allows at most 130 mm (5.2.3, tab. 1) [n03] 398.0 warning abrupt change of the cant deficiency 106 mm, EN 13803 allows at most 50 mm (EN 13803-2 7.1.3), the limit not confirmed [n06] - 478.0 warning abrupt change of the cant deficiency 106 mm, EN 13803 allows at most 50 mm (EN 13803-2 7.1.3), the limit not confirmed [n07] - 488.0 warning abrupt change of the cant deficiency 85 mm, EN 13803 allows at most 50 mm (EN 13803-2 7.1.3), the limit not confirmed [n08] + 478.0 hard limit abrupt change of the cant deficiency 191 mm, TSI INF allows at most 130 mm (4.2.4.4(1)) [n07] 548.0 warning abrupt change of the cant deficiency 85 mm, EN 13803 allows at most 50 mm (EN 13803-2 7.1.3), the limit not confirmed [n09] 598.0 hard limit break of the grade with no vertical curve, TSI INF asks for a radius of at least 900 m (4.2.3.5(1)) [n10] 648.0 hard limit cant ramp 3.00 mm/m, EN 13803 allows at most 2.50 mm/m (5.2.5) [n11] diff --git a/tests/unit/test_norms_engine.cpp b/tests/unit/test_norms_engine.cpp index 71100e481..fdea9d765 100644 --- a/tests/unit/test_norms_engine.cpp +++ b/tests/unit/test_norms_engine.cpp @@ -237,6 +237,21 @@ TEST_CASE("norms engine: the abrupt changes over a straight shorter than tab. 9. } } +TEST_CASE("norms engine: TSI and EN, which say nothing of jumps close together, take them together over the intermediate length of the other profiles") { + // the reverse curves of the test above, 10 m apart: each jump of 106.2 mm passes the TSI, their 212.4 mm don't + auto const each{11.8 * 60 * 60 / 400.0}; + for (auto const profile : {profile_id::tsi, profile_id::en13803}) { + CAPTURE(static_cast(profile)); + line_builder builder; + builder.straight(100, 60).arc(400, 80, 60).straight(10.0, 60).arc(-400, 80, 60).straight(100, 60); + auto const found{of(evaluate(builder.done(), mixed_main(60), profile), parameter::deficiency_jump)}; + auto const summed{std::ranges::find_if(found, [](norms::finding const &Finding) { return std::abs(Finding.chainage - 180.0) < 1e-6; })}; + REQUIRE(summed != found.end()); + CHECK(summed->value == doctest::Approx(2.0 * each)); + CHECK(summed->length == doctest::Approx(10.0)); + } +} + TEST_CASE("norms engine: the gradient and the rate of change of the cant along a ramp, the rate of change of the deficiency along a transition") { // 100 mm over 50 m at 120 km/h: 2 mm/m, 66.7 mm/s line_builder ramp; diff --git a/tests/unit/test_norms_report.cpp b/tests/unit/test_norms_report.cpp index 1d1aff285..d412ebea4 100644 --- a/tests/unit/test_norms_report.cpp +++ b/tests/unit/test_norms_report.cpp @@ -149,16 +149,15 @@ TEST_CASE("norms report: the cant of a curve laid by the editor leans into it, b } } CHECK(curved > 50); - // so at 80 km/h the arc falls short by 11.8 V^2 / R - 80 mm, not by more + // so at 90 km/h the arc falls short by 11.8 V^2 / R - 80 mm, not by more: 159 mm, past the 110 mm of a finding (at 80 km/h + // the 108.8 mm would make none, and the check would never run) norms_report::options options; - options.line.vmax = 80.0; + options.line.vmax = 90.0; options.track_speeds = false; auto const checked{norms_report::check(spans, options)}; - for (auto const &found : checked.entries) { - if (found.finding.what == norms::parameter::cant_deficiency && found.kind == norms::element_kind::arc) { - CHECK(found.finding.value == doctest::Approx(11.8 * 80 * 80 / 400.0 - 80.0).epsilon(0.02)); - } - } + auto const deficient{std::ranges::find_if(checked.entries, [](auto const &Found) { return Found.finding.what == norms::parameter::cant_deficiency && Found.kind == norms::element_kind::arc; })}; + REQUIRE(deficient != checked.entries.end()); + CHECK(deficient->finding.value == doctest::Approx(11.8 * 90 * 90 / 400.0 - 80.0).epsilon(0.02)); } } }