mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-27 02:19:48 +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:
@@ -2073,10 +2073,22 @@ bool editor_mode::nmt_fit_line(TTrack &Track)
|
||||
// are cut off and set to the bridge, the formation is laid up to it, the ground under it stays as the model has it
|
||||
double constexpr kBridged{1.0}; // m
|
||||
double constexpr kAbutment{100.0}; // per mille
|
||||
// spans a few metres apart are one bridge on its piers; what is shorter than that is a culvert under the embankment
|
||||
double constexpr kPier{5.0}; // m
|
||||
double constexpr kCulvert{3.0}; // m
|
||||
std::vector<double> heights(count);
|
||||
for (std::size_t i = 0; i < count; ++i)
|
||||
heights[i] = profile::elevation(fitted_line, sampled[i]);
|
||||
auto const bridges{profile::bridged(sampled, heights, model, kBridged, kAbutment)};
|
||||
std::vector<profile::departure> bridges;
|
||||
for (auto const &stretch : profile::bridged(sampled, heights, model, kBridged, kAbutment))
|
||||
if (false == bridges.empty() && stretch.from - bridges.back().to < kPier)
|
||||
{
|
||||
bridges.back().to = stretch.to;
|
||||
bridges.back().depth = std::min(bridges.back().depth, stretch.depth);
|
||||
}
|
||||
else
|
||||
bridges.push_back(stretch);
|
||||
bridges.erase(std::remove_if(bridges.begin(), bridges.end(), [&](profile::departure const &Bridge) { return Bridge.to - Bridge.from < kCulvert; }), bridges.end());
|
||||
profile_apply(false, bridges);
|
||||
auto const applied{profile.error.empty()};
|
||||
// where the line parts from the model: under it a gap, a bridge or a viaduct, over it a wall or a structure above the track
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user