fix: clamp los profile bounds

This commit is contained in:
just_stuff_tm 2026-02-23 18:12:04 -05:00
parent ea2f35ec2e
commit 74e29a6c0f
4 changed files with 11 additions and 9 deletions

View file

@ -1673,7 +1673,7 @@
"losFrequencyLabel": "Frequency",
"losFrequencyInfoTooltip": "View calculation details",
"losFrequencyDialogTitle": "Radio horizon calculation",
"losFrequencyDialogDescription": "Starting from k={baselineK} at {baselineFreq} MHz, the calculation multiplies 0.15 × (frequency {baselineFreq}) / {baselineFreq} to reach k approx {kFactor} for the current {frequencyMHz} MHz band, which defines the curved radio horizon cap.",
"losFrequencyDialogDescription": "Starting from k={baselineK} at {baselineFreq} MHz, the calculation adjusts the k-factor for the current {frequencyMHz} MHz band, which defines the curved radio horizon cap.",
"@losFrequencyDialogDescription": {
"description": "Explain how the calculation uses the baseline frequency and derived k-factor.",
"placeholders": {

View file

@ -5043,7 +5043,7 @@ abstract class AppLocalizations {
/// Explain how the calculation uses the baseline frequency and derived k-factor.
///
/// In en, this message translates to:
/// **'Starting from k={baselineK} at {baselineFreq} MHz, the calculation multiplies 0.15 × (frequency {baselineFreq}) / {baselineFreq} to reach k approx {kFactor} for the current {frequencyMHz} MHz band, which defines the curved radio horizon cap.'**
/// **'Starting from k={baselineK} at {baselineFreq} MHz, the calculation adjusts the k-factor for the current {frequencyMHz} MHz band, which defines the curved radio horizon cap.'**
String losFrequencyDialogDescription(
double baselineK,
double baselineFreq,

View file

@ -2849,7 +2849,7 @@ class AppLocalizationsEn extends AppLocalizations {
double frequencyMHz,
double kFactor,
) {
return 'Starting from k=$baselineK at $baselineFreq MHz, the calculation multiplies 0.15 × (frequency $baselineFreq) / $baselineFreq to reach k approx $kFactor for the current $frequencyMHz MHz band, which defines the curved radio horizon cap.';
return 'Starting from k=$baselineK at $baselineFreq MHz, the calculation adjusts the k-factor for the current $frequencyMHz MHz band, which defines the curved radio horizon cap.';
}
@override

View file

@ -1065,13 +1065,15 @@ class _LosProfilePainter extends CustomPainter {
samples.last.terrainMeters,
);
double distanceForCanvasX(double x) =>
((x - horizontalPadding) / chartWidth) * maxDist;
double distanceForCanvasX(double x) {
final normalized = ((x - horizontalPadding) / chartWidth).clamp(0.0, 1.0);
return normalized * maxDist;
}
double elevationToPixel(double elevation) =>
size.height -
verticalPadding -
((elevation - minY) / ySpan) * chartHeight;
double elevationToPixel(double elevation) {
final normalized = ((elevation - minY) / ySpan).clamp(0.0, 1.0);
return size.height - verticalPadding - normalized * chartHeight;
}
double extrapolateTerrain(double distance, bool isLeft) {
final samplesForSlope = isLeft