leg-aware capacity and wagon sharing

This commit is contained in:
Marshal
2026-07-30 19:08:06 +00:00
parent acef6870e9
commit f891f6abe2
7 changed files with 113 additions and 25 deletions

View File

@@ -1103,19 +1103,31 @@ export default function TrainScheduleV2DetailPage() {
},
{
label: "Wagons / load",
// Gross: cargo load + the tare of every wagon in the consist — the
// weight the locomotive actually hauls.
value: `${schedule.trainSet?.wagonCount ?? displayWagonPlan.length} · ${
Math.round(
((schedule.trainSet?.totalWeightTons ?? 0) +
(schedule.trainSet?.wagons ?? []).reduce(
(sum, w) => sum + (Number(w.tareWeightTons) || 0),
0,
)) *
100,
) / 100
}T`,
hint: "gross · wagon tare + cargo",
// Gross: cargo load + wagon tare — the weight the locomotives
// actually haul. Heaviest corridor edge when the server sends it;
// plain consist sums over-report a multi-stop train (cross-leg
// wagon sharing counts one physical wagon as several slots).
value: (() => {
const heaviest = schedule.trainSet?.heaviestLeg;
const wagonCount =
heaviest?.loadedWagonCount ??
schedule.trainSet?.wagonCount ??
displayWagonPlan.length;
const grossTons =
heaviest?.grossWeightTons ??
Math.round(
((schedule.trainSet?.totalWeightTons ?? 0) +
(schedule.trainSet?.wagons ?? []).reduce(
(sum, w) => sum + (Number(w.tareWeightTons) || 0),
0,
)) *
100,
) / 100;
return `${wagonCount} · ${grossTons}T`;
})(),
hint: schedule.trainSet?.heaviestLeg
? "heaviest leg · wagon tare + cargo"
: "gross · wagon tare + cargo",
icon: Weight,
},
{