Display track radius in track hover info

This commit is contained in:
dominik-korsa 2025-07-19 15:48:36 +02:00
parent fe17f058bb
commit ff3baa3c26
No known key found for this signature in database
GPG Key ID: 5A24D76EE0A30974

View File

@ -21,6 +21,7 @@ export default function TrackHoverInfoPopup(props) {
<InfoPopupItem value={track['electrificationStatus']} label="Electrification" options={{translationConstKey: 'electrification'}} />
<InfoPopupItem value={track['source']} label="Type" options={{translationConstKey: 'source'}} />
<InfoPopupSwitchItems track={track} />
<InfoPopupShapeItems track={track} />
</tbody>
</table>
</div>
@ -37,6 +38,13 @@ function InfoPopupSwitchItems(props) {
</>
}
function InfoPopupShapeItems(props) {
const { track } = props;
if (track.type !== 'StandardTrack' || track.r === 0) return null;
return <InfoPopupItem value={Math.abs(track.r)} label="Radius" options={{suffix: ' m', precision: 0}} />
}
function processItemValue(value, options) {
const { translationConstKey, join, subOptions, suffix } = options || {};
@ -48,6 +56,10 @@ function processItemValue(value, options) {
return TrackHoverInfoConsts[translationConstKey]?.[value] || value;
}
if (typeof value === 'number' && 'precision' in options) {
value = value.toFixed(options.precision);
}
if (value === undefined || value === null || value === '') {
return "N/A";
}