168 lines
3.7 KiB
C++
168 lines
3.7 KiB
C++
#include "referencepoint.hh"
|
|
|
|
|
|
using namespace std ;
|
|
|
|
|
|
|
|
/*** Constructeurs ***/
|
|
|
|
|
|
ReferencePoint::~ReferencePoint()
|
|
{
|
|
measurements.clear() ;
|
|
}
|
|
|
|
|
|
|
|
// float ReferencePoint::getSsSquareDistance(const vector<CalibrationMeasurement> &m) const
|
|
// {
|
|
// unsigned int i, j;
|
|
// float ret = 0;
|
|
// bool found;
|
|
// vector<CalibrationMeasurement> ref_m = measurements;
|
|
// vector<CalibrationMeasurement> test_m = m;
|
|
// CalibrationMeasurement new_meas;
|
|
|
|
// new_meas.addSsValue(-95);
|
|
|
|
// /* Complete measurement vector with unexisting ap (from ref point) */
|
|
// for (i = 0 ; i < ref_m.size() ; i++)
|
|
// {
|
|
// found = false;
|
|
// for (j = 0 ; j < test_m.size() && !found ; j++)
|
|
// if (test_m[j].getMacAddr() == ref_m[i].getMacAddr())
|
|
// found = true;
|
|
// if (!found)
|
|
// {
|
|
// new_meas.setMacAddr(measurements[i].getMacAddr());
|
|
// test_m.push_back(new_meas);
|
|
// }
|
|
// }
|
|
|
|
// /* Now, complete ref. point meas. */
|
|
// for (i = 0 ; i < test_m.size() ; i++)
|
|
// {
|
|
// found = false;
|
|
// for (j = 0 ; j < ref_m.size() && !found ; j++)
|
|
// if (test_m[i].getMacAddr() == ref_m[j].getMacAddr())
|
|
// found = true;
|
|
// if (!found)
|
|
// {
|
|
// new_meas.setMacAddr(test_m[i].getMacAddr());
|
|
// ref_m.push_back(new_meas);
|
|
// }
|
|
// }
|
|
|
|
// /* Now, compute SS distance */
|
|
// for (i = 0 ; i < test_m.size() ; i++)
|
|
// {
|
|
// j = 0;
|
|
// found = false;
|
|
// while ((j < ref_m.size())&&(found == false))
|
|
// {
|
|
// if (ref_m[j].getMacAddr() == test_m[i].getMacAddr())
|
|
// {
|
|
// found = true;
|
|
// ret += ref_m[j].getSsSquareDistance(test_m[i].getAverage());
|
|
// }
|
|
// j++;
|
|
// }
|
|
// }
|
|
|
|
// ref_m.clear();
|
|
// test_m.clear();
|
|
|
|
// return ret;
|
|
// }
|
|
|
|
|
|
// void ReferencePoint::addMeasurement(const string &mac_a, const int &value)
|
|
// {
|
|
// unsigned int i;
|
|
// CalibrationMeasurement m;
|
|
// bool inserted = false;
|
|
|
|
// for (i = 0 ; i < measurements.size() ; i++)
|
|
// if (measurements[i].getMacAddr() == mac_a)
|
|
// {
|
|
// measurements[i].addSsValue(value);
|
|
// inserted = true;
|
|
// break;
|
|
// }
|
|
// if (inserted == false)
|
|
// {
|
|
// m.setMacAddr(mac_a);
|
|
// m.addSsValue(value);
|
|
// measurements.push_back(m);
|
|
// }
|
|
// }
|
|
|
|
|
|
// bool ReferencePoint::getPowerForAp(const string &ap_mac, float *p) const
|
|
// {
|
|
// unsigned int i;
|
|
// string str = ap_mac;
|
|
// string macLowerCase;
|
|
|
|
// //Pour convertir les majuscules en miniscules
|
|
// const int length = str.length();
|
|
// for (int j=0; j < length; ++j)
|
|
// str[j] = tolower(str[j]);
|
|
|
|
// for (i = 0 ; i < measurements.size() ; i++)
|
|
// if (measurements[i].getMacAddr() == str)
|
|
// {
|
|
// *p = measurements[i].getAverage();
|
|
// return true;
|
|
// }
|
|
|
|
// return false;
|
|
// }
|
|
|
|
|
|
|
|
/*** Opérateurs ***/
|
|
|
|
|
|
ReferencePoint ReferencePoint::operator=(const ReferencePoint &rp)
|
|
{
|
|
if (this == &rp)
|
|
return *this ;
|
|
|
|
this->Point3D::operator=(rp) ;
|
|
measurements = rp.measurements ;
|
|
|
|
return *this ;
|
|
}
|
|
|
|
|
|
bool ReferencePoint::operator==(const ReferencePoint &rp) const
|
|
{
|
|
if (this == &rp)
|
|
return true ;
|
|
|
|
return
|
|
this->Point3D::operator==(rp) &&
|
|
measurements == rp.measurements ;
|
|
}
|
|
|
|
|
|
|
|
ostream &operator<<(ostream &os, const ReferencePoint &rp)
|
|
{
|
|
// Coordinates
|
|
os << (Point3D) rp << endl ;
|
|
|
|
// List of measurements
|
|
if (rp.measurements.size() == 0)
|
|
os << "No measurement." << endl ;
|
|
else
|
|
for (vector<CalibrationMeasurement*>::const_iterator
|
|
i = rp.measurements.begin() ;
|
|
i != rp.measurements.end() ; i++)
|
|
os << endl << *i ;
|
|
|
|
return os ;
|
|
}
|