- Fingerprint (associated with one location) contains multiple measurements
- One measurement contains multiple WIFI readings (bssid, rssi).
- For given a current measurement (call it cur). Program calculates the distance of all previous measurements to cur. It output a hashmap<string, List<Integer>>, string is the location name, and List includes the distances to cur, from all measurements in this location.
- Then it averages the hashmap, returning hashmap<string, int> this is the average distance for all locations to cur.
- It creates a location helper class, which contains string (location name), and int (average distance), then put it in a TreeSet. So all locations is sorted according to average distance.
- Algorithm is, if the closest locations (first in TreeSet), the distance is within 5. We use the first distance; Otherwise, we output the first three locations, and do a weighted average to find the averaged location.
suppose L1 (x1, y1, d1), L2 (x2, y2, d2), L3 (x3, y3, d3).
x = x1 * (d2+d3)/(d1+d2+d3) + x2 * (d1+d3)/(d1+d2+d3) + x3 * (d1+d2)/(d1+d2+d3)
网友评论