mnc: int,
gsm_cells: List[Tuple[int, int, int]],
wifi_aps: List[Tuple[str, int]],
-) -> Tuple[float, float]:
+) -> Tuple[float, float, float]:
result = _lookup(mcc, mnc, gsm_cells, wifi_aps)
if "location" in result:
- return result["location"]["lat"], result["location"]["lng"]
+ return (
+ result["location"]["lat"],
+ result["location"]["lng"],
+ result["accuracy"],
+ )
else:
raise ValueError("google geolocation: " + str(result))
def lookup(
mcc: int, mnc: int, gsm_cells: List[Tuple[int, int, int]], __: Any
-) -> Tuple[float, float]:
+) -> Tuple[float, float, float]:
assert ldb is not None
lc = ldb.cursor()
lc.execute("""attach database ":memory:" as mem""")
nsigs = [1 / sig / sumsig for _, _, sig in data]
avlat = sum([lat * nsig for (lat, _, _), nsig in zip(data, nsigs)])
avlon = sum([lon * nsig for (_, lon, _), nsig in zip(data, nsigs)])
- return avlat, avlon
+ return avlat, avlon, 99.9 # TODO estimate accuracy for real
mnc: int,
gsm_cells: List[Tuple[int, int, int]],
wifi_aps: List[Tuple[str, int]],
- ) -> Tuple[float, float]:
+ ) -> Tuple[float, float, float]:
...
zpub.send(Rept(imei=zmsg.imei, payload=rect.json).packed)
elif isinstance(rect, HintReport):
try:
- lat, lon = qry.lookup(
+ lat, lon, acc = qry.lookup(
rect.mcc,
rect.mnc,
rect.gsm_cells,
list((mac, strng) for _, mac, strng in rect.wifi_aps),
)
log.debug(
- "Approximated lat=%s, lon=%s for %s", lat, lon, rect
+ "Approximated lat=%s, lon=%s, acc=%s for %s",
+ lat,
+ lon,
+ acc,
+ rect,
)
if proto_needanswer.get(zmsg.proto, False):
resp = Resp(
rept = CoordReport(
devtime=rect.devtime,
battery_percentage=rect.battery_percentage,
- accuracy=None,
+ accuracy=acc,
altitude=None,
speed=None,
direction=None,