mirror of
				https://git.ianrenton.com/ian/spothole.git
				synced 2025-10-27 16:59:25 +00:00 
			
		
		
		
	Various tweaks including getting GMA SIGs working properly
This commit is contained in:
		| @@ -1,3 +1,4 @@ | ||||
| import logging | ||||
| from datetime import datetime, timedelta | ||||
|  | ||||
| import pytz | ||||
| @@ -27,24 +28,56 @@ class GMA(HTTPProvider): | ||||
|             spot = Spot(source=self.name, | ||||
|                         dx_call=source_spot["ACTIVATOR"].upper(), | ||||
|                         de_call=source_spot["SPOTTER"].upper(), | ||||
|                         freq=float(source_spot["QRG"]) * 1000 if (source_spot["QRG"] != "") else None, # Seen GMA spots with no frequency | ||||
|                         mode=source_spot["MODE"].upper() if "<>" not in source_spot["MODE"] else None, # Filter out some weird mode strings | ||||
|                         freq=float(source_spot["QRG"]) * 1000 if (source_spot["QRG"] != "") else None, | ||||
|                         # Seen GMA spots with no frequency | ||||
|                         mode=source_spot["MODE"].upper() if "<>" not in source_spot["MODE"] else None, | ||||
|                         # Filter out some weird mode strings | ||||
|                         comment=source_spot["TEXT"], | ||||
|                         sig_refs=[source_spot["REF"]], | ||||
|                         sig_refs_names=[source_spot["NAME"]], | ||||
|                         icon="person-hiking", | ||||
|                         time=datetime.strptime(source_spot["DATE"] + source_spot["TIME"], "%Y%m%d%H%M").replace(tzinfo=pytz.UTC), | ||||
|                         latitude=float(source_spot["LAT"]) if (source_spot["LAT"] != "") else None, # Seen GMA spots with no lat/lon | ||||
|                         time=datetime.strptime(source_spot["DATE"] + source_spot["TIME"], "%Y%m%d%H%M").replace( | ||||
|                             tzinfo=pytz.UTC), | ||||
|                         latitude=float(source_spot["LAT"]) if (source_spot["LAT"] != "") else None, | ||||
|                         # Seen GMA spots with no lat/lon | ||||
|                         longitude=float(source_spot["LON"]) if (source_spot["LON"] != "") else None) | ||||
|  | ||||
|             # GMA doesn't give what programme (SIG) the reference is for until we separately look it up. | ||||
|             ref_response = self.REF_INFO_CACHE.get(self.REF_INFO_URL_ROOT + source_spot["REF"], headers=self.HTTP_HEADERS) | ||||
|             ref_response = self.REF_INFO_CACHE.get(self.REF_INFO_URL_ROOT + source_spot["REF"], | ||||
|                                                    headers=self.HTTP_HEADERS) | ||||
|             # Sometimes this is blank, so handle that | ||||
|             if ref_response.text is not None and ref_response.text != "": | ||||
|                 ref_info = ref_response.json() | ||||
|                 spot.sig = ref_info["reftype"] | ||||
|                 # 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 ref_info["reftype"] not in ["POTA", "WWFF"] and (ref_info["reftype"] is not "Summit" or ref_info["sota"] is ""): | ||||
|                     match ref_info["reftype"]: | ||||
|                         case "Summit": | ||||
|                             spot.sig = "GMA" | ||||
|                             spot.icon = "mountain" | ||||
|                         case "IOTA Island": | ||||
|                             spot.sig = "IOTA" | ||||
|                             spot.icon = "umbrella-beach" | ||||
|                         case "Lighthouse (ILLW)": | ||||
|                             spot.sig = "ILLW" | ||||
|                             spot.icon = "tower-observation" | ||||
|                         case "Lighthouse (ARLHS)": | ||||
|                             spot.sig = "ARLHS" | ||||
|                             spot.icon = "tower-observation" | ||||
|                         case "Castle": | ||||
|                             spot.sig = "WCA/COTA" | ||||
|                             spot.icon = "chess-rook" | ||||
|                         case "Mill": | ||||
|                             spot.sig = "MOTA" | ||||
|                             spot.icon = "fan" | ||||
|                         case _: | ||||
|                             logging.warn("GMA spot found with ref type " + ref_info[ | ||||
|                                 "reftype"] + ", developer needs to figure out an icon for this!") | ||||
|                             spot.sig = ref_info["reftype"] | ||||
|                             spot.icon = "person-hiking" | ||||
|  | ||||
|             # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do | ||||
|             # that for us. | ||||
|             new_spots.append(spot) | ||||
|         return new_spots | ||||
|                     # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do | ||||
|                     # that for us. | ||||
|                     new_spots.append(spot) | ||||
|         return new_spots | ||||
|   | ||||
| @@ -54,7 +54,7 @@ class HEMA(HTTPProvider): | ||||
|                                 sig="HEMA", | ||||
|                                 sig_refs=[spot_items[3].upper()], | ||||
|                                 sig_refs_names=[spot_items[4]], | ||||
|                                 icon="person-hiking", | ||||
|                                 icon="mound", | ||||
|                                 time=datetime.strptime(spot_items[0], "%d/%m/%Y %H:%M").replace(tzinfo=pytz.UTC), | ||||
|                                 latitude=float(spot_items[7]), | ||||
|                                 longitude=float(spot_items[8])) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ian Renton
					Ian Renton