@Override
    public Position locate(MacRssiPair[] data) {
        double x = 0.0;
        double y = 0.0;
        int total = 0;

        for (MacRssiPair pair1:data) {
            for (MacRssiPair pair2:data) {
                if (pair2 == pair1 || !pair1.isOnMap() || !pair2.isOnMap()) {
                    continue;
                }
                double d = pair1.distanceTo(pair2);
                double r1 = pair1.getDistance();
                double r2 = pair2.getDistance();
                double factor = r1 / (r1 + r2);
                total += 1;
                x += pair1.getX() + (pair2.getX() - pair1.getX()) * factor;
                y += pair2.getY() + (pair2.getY() - pair1.getY()) * factor;
            }
        }

        System.out.println(total + " Samples");

        if(total == 0) {
            for(MacRssiPair pair : data) {
                if(pair.isOnMap()) {
                    lastPos = new Position(pair.getX(), pair.getY());
                    return lastPos;
                }
            }

            return lastPos;
        }

        lastPos = new Position(x / total, y / total);
        return lastPos;
    }