17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-03 12:00:22 +01:00

feat(editor): a switch laid into a curve is checked by ST-T1-A6 as it's placed: the radii of its main and diverging tracks at its start and its end shown at it; warnings where the curvature of a track turns from one side to the other within it (KZW II, 9.7 pkt 12), where the diverging track is sharper or the main track bent more than table 11.9 allows the basic switch (the values allowed by way of exception named), where a switch of 1:9.403 or steeper is bent (11.4 pkt 4), where the cant changes within it (11.4 pkt 7), where a cant ramp starts or ends within it or under 6 m off it (9.6 pkt 16-17) and where the cant is over 100 mm (table 9.6); a note on a transition curve, which only an exception allows. The ends of the cant ramps are marked on the curve, and the start of the switch pressed within 3 m of where it starts or ends at an end of a ramp, or keeps the 6 m off it, is drawn there. The warnings stay in the status once it's laid. The checks stand on their own in editor/editorSwitchCurve, with unit tests

This commit is contained in:
maj00r
2026-10-25 00:29:05 +02:00
parent aeef2cebb3
commit ece61056ff
9 changed files with 633 additions and 12 deletions

View File

@@ -0,0 +1,61 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <string>
#include <vector>
// a switch laid into a curve or into a transition curve, as the standard of PKP PLK ST-T1-A6 sees it: the curvatures of its tracks
// (9.7 pkt 12, 11.4, table 11.9) and the cant along it, which is to stay the same over it or be ramped from its ends (9.6 pkt
// 16-17, 11.4 pkt 7, table 9.6)
namespace switch_curve
{
// a point of a track in the plan: how far along it, which way it heads (radians, growing as it turns to the left), its cant (mm)
struct track_point
{
double station{0.0};
double heading{0.0};
double cant{0.0};
};
// the curvature of the track at the station, from its headings a metre either side of it, 1/m positive to the left
double curvature_at(std::vector<track_point> const &Track, double const Station);
// the stations where the cant of the track starts or stops changing: the ends of its cant ramps
std::vector<double> ramp_ends(std::vector<track_point> const &Track);
struct switch_report
{
// at the start and at the end of the switch, 1/m, positive turning the way the line does
double main_start{0.0};
double main_end{0.0};
double branch_start{0.0};
double branch_end{0.0};
// of the main track, mm
double cant_start{0.0};
double cant_end{0.0};
bool curved{false}; // the main track bent
bool transition{false}; // its curvature changing along the switch
std::vector<std::string> notes;
std::vector<std::string> warnings;
};
// Main, Branch: the tracks of the switch from its start, the stations from 0 there; Line: the track it's laid into, From and To the
// stations of the start and the end of the switch along it, From after To where it goes back along the line. Radius and Ratio:
// of the diverging track of the basic switch it's bent from
switch_report check(std::vector<track_point> const &Main, std::vector<track_point> const &Branch, std::vector<track_point> const &Line, double const From, double const To, double const Radius,
double const Ratio);
// the start of a switch Length long, going Direction along the line, drawn to where its start or its end meets an end of a cant ramp,
// or to where it keeps the 6 m off it, when the station pressed is within Reach of that; What receives which of them, empty for none
double snapped_start(std::vector<double> const &Ramps, double const Pressed, double const Length, int const Direction, double const Reach, std::string *What = nullptr);
} // namespace switch_curve