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
+1 -1
View File
@@ -1673,7 +1673,7 @@
"losFrequencyLabel": "Frequency", "losFrequencyLabel": "Frequency",
"losFrequencyInfoTooltip": "View calculation details", "losFrequencyInfoTooltip": "View calculation details",
"losFrequencyDialogTitle": "Radio horizon calculation", "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": { "@losFrequencyDialogDescription": {
"description": "Explain how the calculation uses the baseline frequency and derived k-factor.", "description": "Explain how the calculation uses the baseline frequency and derived k-factor.",
"placeholders": { "placeholders": {
+1 -1
View File
@@ -5043,7 +5043,7 @@ abstract class AppLocalizations {
/// Explain how the calculation uses the baseline frequency and derived k-factor. /// Explain how the calculation uses the baseline frequency and derived k-factor.
/// ///
/// In en, this message translates to: /// 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( String losFrequencyDialogDescription(
double baselineK, double baselineK,
double baselineFreq, double baselineFreq,
+1 -1
View File
@@ -2849,7 +2849,7 @@ class AppLocalizationsEn extends AppLocalizations {
double frequencyMHz, double frequencyMHz,
double kFactor, 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 @override
+8 -6
View File
@@ -1065,13 +1065,15 @@ class _LosProfilePainter extends CustomPainter {
samples.last.terrainMeters, samples.last.terrainMeters,
); );
double distanceForCanvasX(double x) => double distanceForCanvasX(double x) {
((x - horizontalPadding) / chartWidth) * maxDist; final normalized = ((x - horizontalPadding) / chartWidth).clamp(0.0, 1.0);
return normalized * maxDist;
}
double elevationToPixel(double elevation) => double elevationToPixel(double elevation) {
size.height - final normalized = ((elevation - minY) / ySpan).clamp(0.0, 1.0);
verticalPadding - return size.height - verticalPadding - normalized * chartHeight;
((elevation - minY) / ySpan) * chartHeight; }
double extrapolateTerrain(double distance, bool isLeft) { double extrapolateTerrain(double distance, bool isLeft) {
final samplesForSlope = isLeft final samplesForSlope = isLeft