]> www.average.org Git - loctrkd.git/blobdiff - gps303/googlemaps.py
Multiprotocol support in zmq messages and storage
[loctrkd.git] / gps303 / googlemaps.py
index bb19a64578a071958bc0fe577a7a4fcec48d0236..dac607959b6e102579dc66030275aec8e8e4f0f9 100644 (file)
@@ -1,17 +1,27 @@
 import googlemaps as gmaps
-from sqlite3 import connect
+from typing import Any, Dict, List, Tuple
 
 gclient = None
 
 
-def init(conf):
+def init(conf: Dict[str, Any]) -> None:
     global gclient
     with open(conf["googlemaps"]["accesstoken"], encoding="ascii") as fl:
         token = fl.read().rstrip()
     gclient = gmaps.Client(key=token)
 
 
-def lookup(mcc, mnc, gsm_cells, wifi_aps):
+def shut() -> None:
+    return
+
+
+def lookup(
+    mcc: int,
+    mnc: int,
+    gsm_cells: List[Tuple[int, int, int]],
+    wifi_aps: List[Tuple[str, int]],
+) -> Tuple[float, float]:
+    assert gclient is not None
     kwargs = {
         "home_mobile_country_code": mcc,
         "home_mobile_network_code": mnc,
@@ -39,6 +49,7 @@ def lookup(mcc, mnc, gsm_cells, wifi_aps):
 
 if __name__.endswith("__main__"):
     from datetime import datetime, timezone
+    from sqlite3 import connect
     import sys
     from .gps303proto import *
 
@@ -47,7 +58,7 @@ if __name__.endswith("__main__"):
     c.execute(
         """select tstamp, packet from events
             where proto in (?, ?)""",
-        (WIFI_POSITIONING.PROTO, WIFI_OFFLINE_POSITIONING.PROTO),
+        (proto_name(WIFI_POSITIONING), proto_name(WIFI_OFFLINE_POSITIONING)),
     )
     init({"googlemaps": {"accesstoken": sys.argv[2]}})
     count = 0