17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-02 05:49:13 +01:00

fix(editor): the whole-scenery grade fit takes spans a few metres apart for one bridge, leaves the culverts on the embankment and ends a bridge at a joint by its abutment

Bridged stretches less than 5 m apart are merged into one bridge on its piers, and those shorter than 3 m, a ditch or a
culvert under the embankment, are no bridge. A bridge end within 1 m of a joint of the route or a break of the line moves to
it, so the cut leaves no sliver of a path by the abutment. Against the OpenStreetMap railway bridges the marked share stays
the same (lk91 60 of 66, TG 90 of 104); the places with nothing under them in the map fall from 6 to 4 on lk91 and from 18
to 12 on TG, and the bridge paths shorter than 1 m from 9 to 0 and from 11 to 1.
This commit is contained in:
maj00r
2026-10-22 05:56:05 +02:00
parent 0d9fa6337d
commit 7fb9d2d458
2 changed files with 26 additions and 3 deletions

View File

@@ -1476,7 +1476,18 @@ void editor_mode::profile_apply(bool const Terrain, std::vector<profile::departu
std::vector<std::pair<TTrack *, editor_track::state>> states;
std::vector<TTrack *> created;
auto cuts{profile::breaks(line)};
for (auto const &bridge : Bridges)
// a bridge ends at a joint or a break of the line by its abutment rather than leave a sliver of a path there
double constexpr kBridgeSnap{1.0}; // m
auto joints{cuts};
for (auto const &span : state.route.spans)
joints.insert(joints.end(), {span.from, span.to});
auto bridges{Bridges};
for (auto &bridge : bridges)
for (auto *end : {&bridge.from, &bridge.to})
if (auto const nearest{std::min_element(joints.begin(), joints.end(), [&](double const A, double const B) { return std::abs(A - *end) < std::abs(B - *end); })};
nearest != joints.end() && std::abs(*nearest - *end) <= kBridgeSnap)
*end = *nearest;
for (auto const &bridge : bridges)
cuts.insert(cuts.end(), {bridge.from, bridge.to});
std::sort(cuts.begin(), cuts.end());
auto const gaps{editor_track::apply_profile(
@@ -1486,7 +1497,7 @@ void editor_mode::profile_apply(bool const Terrain, std::vector<profile::departu
std::size_t bridged{0};
for (auto const &span : state.route.spans)
if (span.track->eEnvironment != e_bridge && span.track->eEnvironment != e_tunnel
&& std::any_of(Bridges.begin(), Bridges.end(), [&](profile::departure const &Bridge) { return span.from >= Bridge.from - kBridgeEnd && span.to <= Bridge.to + kBridgeEnd; }))
&& std::any_of(bridges.begin(), bridges.end(), [&](profile::departure const &Bridge) { return span.from >= Bridge.from - kBridgeEnd && span.to <= Bridge.to + kBridgeEnd; }))
{
span.track->eEnvironment = e_bridge;
++bridged;