diff --git a/data/activities.py b/data/activities.py index 0e5c7c2..ebf4986 100644 --- a/data/activities.py +++ b/data/activities.py @@ -92,7 +92,7 @@ ACTIVITIES: dict[ActivityName, Activity] = { description="Summits on the Air", sig_type=ActivityType.ADVENTURE, has_refs=True, - refs_globally_unique=False, + refs_globally_unique=True, ref_type=ActivityRefType.SUMMIT, ref_regex=r"[A-Z0-9]{1,3}\/[A-Z]{2}\-\d{3}", comment_names=["SOTA"], diff --git a/data/spot.py b/data/spot.py index ab33d2b..896eb6c 100644 --- a/data/spot.py +++ b/data/spot.py @@ -359,20 +359,20 @@ class Spot: # These are common on cluster spots and can provide grid references in preference to e.g. QRZ lookup, as well as # being the only source we have for propagation mode. Brace for nightmare regex from hell. if self.comment: - grid_mode_grid_match = re.search( + grid_match = re.search( r"\b([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)(?:<([^>]*)>|\(([^)]*)\))([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\b", self.comment, ) - if grid_mode_grid_match: + if grid_match: # regex matches, so extract grids: if not self.de_grid: - self.de_grid = grid_mode_grid_match.group(1).upper() + self.de_grid = grid_match.group(1).upper() if not self.dx_grid: - self.dx_grid = grid_mode_grid_match.group(4).upper() + self.dx_grid = grid_match.group(4).upper() self.dx_location_source = LocationSourceForSpot.GRID # And extract propagation mode (group 2 for <...>, group 3 for (...)): - mode_tag = (grid_mode_grid_match.group(2) or grid_mode_grid_match.group(3) or "").upper() + mode_tag = (grid_match.group(2) or grid_match.group(3) or "").upper() if mode_tag and not self.propagation_mode: if mode_tag in PROPAGATION_MODES: self.propagation_mode = PROPAGATION_MODES[mode_tag] @@ -386,6 +386,17 @@ class Spot: if self.propagation_mode == "Earth-Moon-Earth" and not self.sig: self.sig = ActivityName.EME + # Parse 6-digit grid structures from the comment if the frequency is VHF or above, as it's common to see + # VHF+ operators spotted with their grid + if self.comment and self.freq and self.freq > 30000000: + grid_match = re.search( + r"\b([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\b", + self.comment, + ) + if grid_match and not self.dx_grid: + self.dx_grid = grid_match.group(1).upper() + self.dx_location_source = LocationSourceForSpot.GRID + # Set activities based on the DX callsign suffix if self.dx_call and not self.sig: if self.dx_call.upper().endswith(ActivityName.AERONAUTICAL_MOBILE): @@ -411,17 +422,17 @@ class Spot: # Parse "de_grid -> dx_grid" structures from the comment if self.comment: - grid_mode_grid_match = re.search( + grid_match = re.search( r"\b([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\s*->\s*([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\b", self.comment, ) - if grid_mode_grid_match: + if grid_match: # regex matches, so extract grids: if not self.dx_grid: - self.dx_grid = grid_mode_grid_match.group(1).upper() + self.dx_grid = grid_match.group(1).upper() self.dx_location_source = LocationSourceForSpot.GRID if not self.de_grid: - self.de_grid = grid_mode_grid_match.group(2).upper() + self.de_grid = grid_match.group(2).upper() # DX Grid to lat/lon and vice versa in case one is missing if self.dx_grid and (not self.dx_latitude or not self.dx_longitude): diff --git a/providers/spot/gma.py b/providers/spot/gma.py index 8946221..27dd166 100644 --- a/providers/spot/gma.py +++ b/providers/spot/gma.py @@ -98,24 +98,27 @@ class GMA(HTTPSpotProvider): and ref_response.text != "\n" ): ref_info = ref_response.json() - # If this is POTA, SOTA or WWFF data we already have it through other means, so ignore. POTA and WWFF - # spots come through with reftype=POTA or reftype=WWFF. SOTA is harder to figure out because both SOTA - # and GMA summits come through with reftype=Summit, so we must check for the presence of a "sota" entry - # to determine if it's a SOTA summit. - if ( - spot.sig_refs - and ref_info - and "reftype" in ref_info - and ref_info["reftype"] not in [ActivityName.POTA, ActivityName.WWFF] - and ( - ref_info["reftype"] != "Summit" or "sota" not in ref_info or ref_info["sota"] == "" - ) - ): + if spot.sig_refs and ref_info and "reftype" in ref_info: match ref_info["reftype"]: case "Summit": - spot.sig_refs[0].sig = ActivityName.GMA - spot.sig_refs[0].ref_type = ActivityRefType.SUMMIT - spot.sig = ActivityName.GMA + # Summits are a bit complicated, they can be SOTA or GMA depending on the + # separate "sota" field: + if "sota" in ref_info and ref_info["sota"] != "": + spot.sig_refs[0].sig = ActivityName.SOTA + spot.sig_refs[0].ref_type = ActivityRefType.SUMMIT + spot.sig = ActivityName.SOTA + else: + spot.sig_refs[0].sig = ActivityName.GMA + spot.sig_refs[0].ref_type = ActivityRefType.SUMMIT + spot.sig = ActivityName.GMA + case "POTA": + spot.sig_refs[0].sig = ActivityName.POTA + spot.sig_refs[0].ref_type = ActivityRefType.PARK + spot.sig = ActivityName.POTA + case "WWFF": + spot.sig_refs[0].sig = ActivityName.WWFF + spot.sig_refs[0].ref_type = ActivityRefType.PARK + spot.sig = ActivityName.WWFF case "IOTA Island": spot.sig_refs[0].sig = ActivityName.IOTA spot.sig_refs[0].ref_type = ActivityRefType.ISLAND diff --git a/templates/add_spot.html b/templates/add_spot.html index 9f0f32b..c5446e1 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 7e778dc..f917cd8 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -85,7 +85,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index d21ba65..b5b6843 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index 448d46c..f118e2f 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 %}
diff --git a/templates/conditions.html b/templates/conditions.html index c0415c8..c5ba915 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index 979aef5..3c5c810 100644 --- a/templates/map.html +++ b/templates/map.html @@ -113,8 +113,8 @@ const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; - - + + diff --git a/templates/spots.html b/templates/spots.html index 900c8dc..3c4ae23 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -125,8 +125,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index b965ef5..2e54358 100644 --- a/templates/status.html +++ b/templates/status.html @@ -96,7 +96,7 @@ - +