Fix some dodgy handling of DME references

This commit is contained in:
Ian Renton
2026-09-05 09:57:05 +01:00
parent 3e4327ec0c
commit df724409a5
11 changed files with 28 additions and 20 deletions
+6 -2
View File
@@ -1,4 +1,5 @@
import logging
import re
from pyhamtools.locator import latlong_to_locator, locator_to_latlong
@@ -41,9 +42,12 @@ def get_sig_ref_info(sig_name, ref_id):
### FUDGES ###
#
# DME fudge. Our database has leading zeros padding to 5 digits which is the expected format, but not all
# activators add leading zeros.
# activators add leading zeros. We also need to normalise "DME 01234" to "DME-01234" to match what's in our
# database.
if sig_name.upper() == "DME":
ref_id = ref_id.zfill(5)
match = re.match(r"DME[\- ]\d{3,5}", ref_id, re.IGNORECASE)
number = match.group(1)
return f"DME-{number.zfill(5)}"
# DTMBA spotters sometimes include spaces and dashes, our regex allows them but they must be removed here so we
# can look up against the official list which doesn't have them