locator: Improve single wifi accuracy calculations
This commit is contained in:
@@ -237,8 +237,8 @@ def aggregate_mac_position(networks, minimum_accuracy):
|
||||
net = networks[0]
|
||||
lat = float(net["lat"])
|
||||
lon = float(net["lon"])
|
||||
signal = min(net["signalStrength"], WIFI_MAX_SIGNAL)
|
||||
ratio = 1.0 - abs(signal - WIFI_MIN_SIGNAL) / abs(WIFI_MIN_SIGNAL)
|
||||
sig = min(net["signalStrength"], WIFI_MAX_SIGNAL)
|
||||
ratio = 1.0 - abs(sig - WIFI_MIN_SIGNAL) / (WIFI_MAX_SIGNAL - WIFI_MIN_SIGNAL)
|
||||
accuracy = max(min(net["radius"] * ratio, WIFI_MAX_ACCURACY),
|
||||
minimum_accuracy)
|
||||
return lat, lon, accuracy
|
||||
|
@@ -6,7 +6,10 @@ from ..constants import (
|
||||
CELL_DEFAULT_RADIUS,
|
||||
CELL_MIN_SIGNAL,
|
||||
WIFI_DEFAULT_SIGNAL,
|
||||
WIFI_MIN_RADIUS,
|
||||
WIFI_MAX_ACCURACY,
|
||||
WIFI_MAX_SIGNAL,
|
||||
WIFI_MIN_ACCURACY,
|
||||
WIFI_MIN_SIGNAL,
|
||||
)
|
||||
from ..utils import mcc_mnc_to_opc
|
||||
|
||||
@@ -31,7 +34,11 @@ class SingleWifiLocatorBase(LocatorBase):
|
||||
if wifi is not None:
|
||||
log.debug(f'Got result from {mac=}')
|
||||
latlon = wifi.get('latlon')
|
||||
accuracy = max(WIFI_MIN_RADIUS, 100.0 - signalstrength) # FIXME:improve
|
||||
sig = min(signalstrength, WIFI_MAX_SIGNAL)
|
||||
ratio = 1.0 - ((sig - WIFI_MIN_SIGNAL)
|
||||
/ (WIFI_MAX_SIGNAL - WIFI_MIN_SIGNAL))
|
||||
accuracy = max(min(wifi['radius'] * ratio, WIFI_MAX_ACCURACY),
|
||||
WIFI_MIN_ACCURACY)
|
||||
break
|
||||
|
||||
return latlon, accuracy
|
||||
|
Reference in New Issue
Block a user