mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-06 04:27:29 +00:00
fix(lotw): strip STATE ' // Name' suffix for award stats
LoTW returns STATE as 'CODE // Name' (verified with a real report 2026-09), e.g. 'GD // Guangdong' (China), '34 // Tottori-ken' (Japan), 'CA // California' (US). The award calculator matched on the bare CODE, so every mainland China province (WAPC), all Japan prefectures (WAJA) and US states (WAS) failed — WAPC only showed HK/MO/TW (entity branch, no STATE needed) and WAJA was empty. Normalize STATE once at parse time: strip the ' // Name' suffix so the stored GridQso.state is the clean code consumed by persistence and AwardCalculator. Add a test covering China/Japan/US formats.
This commit is contained in:
1 parent
a64f9c80b9
commit
20143cf096
2 files changed
+30
-3
No files matched your search
+11
-1
@@ -212,7 +212,7 @@ class LoTWRepository : ILoTWRepository {
|
||||
line.startsWith("<CQZ:") ->
|
||||
cqz = adifValue(line).toIntOrNull()
|
||||
line.startsWith("<STATE:") ->
|
||||
state = adifValue(line).trim().ifBlank { null }
|
||||
state = adifValue(line).trim().ifBlank { null }?.let { normalizeState(it) }
|
||||
line.startsWith("<GRIDSQUARE:") || line.startsWith("<VUCC_GRIDS:") -> {
|
||||
// VUCC_GRIDS holds a comma-separated list of grids
|
||||
// ("EN52en,EN53fa"), up to four for contacts spanning
|
||||
@@ -231,6 +231,16 @@ class LoTWRepository : ILoTWRepository {
|
||||
private fun adifValue(line: String): String =
|
||||
line.substringAfter('>').substringBefore("E<").trim()
|
||||
|
||||
/**
|
||||
* LoTW returns STATE as "CODE // NAME" (e.g. "HB // Hubei" for China,
|
||||
* "34 // Tottori-ken" for Japan, "CA // California" for the US). The award
|
||||
* statistics match on the short CODE only (China 2-letter province pinyin,
|
||||
* Japan 2-digit prefecture, US 2-letter state), so strip the " // NAME"
|
||||
* suffix here once, storing the clean code for every downstream consumer
|
||||
* (persistence, AwardCalculator).
|
||||
*/
|
||||
private fun normalizeState(raw: String): String = raw.substringBefore(" // ").trim()
|
||||
|
||||
/** "20260820" + "1130" (or "113000") -> UTC epoch ms; 0 when unparseable. */
|
||||
private fun adifTimestampToEpoch(date: String, time: String): Long = try {
|
||||
val d = date.trim()
|
||||
|
||||
Reference in new issue
Block a user