Keep the band when the frequency is past the edge

Contest operating goes outside the band edges. Someone answers a CQ at 14352, or
a radio reports a frequency a few hundred hertz off, and Bands.ForFrequency
returned null: the contact scored nothing, missed the per-band dupe check and
exported with no band.

N1MM buckets a frequency by its whole megahertz — its BandFor divides the
kilohertz by 1000 and switches on the result, with 1 and 2 both 160M, 3 and 4
both 80M, 28 and 29 both 10M — and never looks at a band edge. Same rule here,
except that the real edges are checked first: 2190M and 630M are both under
1 MHz and share the bucket, so nothing else can tell them apart. A frequency
under 1 MHz that misses both edge ranges still has no band, as it does in N1MM.

The bandmap clamped its slice to the band edges, so a radio past the edge left
the receiver bar off the top of the scale. The slice now stretches to wherever
the radio is.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 23:01:39 +00:00
parent d375d86466
commit e6d0b58305
4 changed files with 65 additions and 6 deletions

View File

@@ -18,6 +18,30 @@ public class BandsTests
public void FrequencyOutsideEveryAllocationHasNoBand() =>
Assert.Null(Bands.ForFrequency(Frequency.FromKilohertz(12000)));
/// N1MM buckets by whole megahertz, so a contact made past the edge keeps
/// its band instead of losing it.
[Theory]
[InlineData(14400, "20M")]
[InlineData(7305, "40M")]
[InlineData(1999.9, "160M")]
[InlineData(4100, "80M")]
[InlineData(29800, "10M")]
[InlineData(21500, "15M")]
public void FrequencyPastTheBandEdgeStillCountsAsThatBand(double kilohertz, string expected) =>
Assert.Equal(expected, Bands.ForFrequency(Frequency.FromKilohertz(kilohertz))?.Name);
/// Below 1 MHz every band shares the same megahertz, so only the real edges
/// decide.
[Theory]
[InlineData(137, "2190M")]
[InlineData(475, "630M")]
public void TheLowFrequencyBandsGoByTheirEdges(double kilohertz, string expected) =>
Assert.Equal(expected, Bands.ForFrequency(Frequency.FromKilohertz(kilohertz))?.Name);
[Fact]
public void BroadcastFrequenciesBelowOneMegahertzHaveNoBand() =>
Assert.Null(Bands.ForFrequency(Frequency.FromKilohertz(900)));
[Fact]
public void BandEdgesAreIncluded()
{