diff --git a/core/constants.py b/core/constants.py index 6c57950..acadaad 100644 --- a/core/constants.py +++ b/core/constants.py @@ -253,10 +253,10 @@ SIGS = [ description="Diploma Municipios de España", sig_type=SIGType.REGIONAL, ref_type=SIGRefType.TOWN, - ref_regex=r"\d{4,5}", + ref_regex=r"DME[\- ]\d{3,5}", icon="fa-building", region_flag="🇪🇸", - refs_globally_unique=False, + refs_globally_unique=True, ), SIG( name="FEA", diff --git a/core/sig_lookup_helper.py b/core/sig_lookup_helper.py index e5fc5be..92ca542 100644 --- a/core/sig_lookup_helper.py +++ b/core/sig_lookup_helper.py @@ -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 diff --git a/providers/sigrefdata/dme.py b/providers/sigrefdata/dme.py index c46b1bc..315061b 100644 --- a/providers/sigrefdata/dme.py +++ b/providers/sigrefdata/dme.py @@ -23,7 +23,11 @@ class DME(LocalFileSIGRefDataProvider): new_data = [] with open(path, encoding="latin-1") as _f: for row in csv.DictReader(_f, delimiter=";"): - ref_id = row["COD_INE"][:5] + # Store reference IDs with the "DME-" prefix rather than just the number. This will prevent Spothole + # from agressively thinking every number in a spot comment is DME after it's seen "DME" once. The only + # numbers that count are straight after "DME " or "DME-". The dash versus space is normalised in + # sig_lookup_helper.py. + ref_id = "DME-" + row["COD_INE"][:5] latitude = ( float(row["LATITUD_ETRS89_REGCAN95"].replace(",", ".")) if row.get("LATITUD_ETRS89_REGCAN95") diff --git a/templates/add_spot.html b/templates/add_spot.html index d3ca997..c9a69b6 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -77,7 +77,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 704537b..78f0126 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -81,7 +81,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 6610b7b..86e9496 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index c60fa1c..b213f7d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -16,10 +16,10 @@ window.fetchEventSource = fetchEventSource; - - - - + + + + {% end %} {% block body %}