[Positioning] Reindent with astyle 1.24
This commit is contained in:
parent
3b6eb55e38
commit
d35e0dd5e5
|
@ -27,22 +27,22 @@ AccessPoint::AccessPoint(const AccessPoint &ap)
|
|||
|
||||
|
||||
bool AccessPoint::operator==(const AccessPoint &ap)const
|
||||
{
|
||||
if (ap_addr == ap.ap_addr)
|
||||
return true;
|
||||
{
|
||||
if (ap_addr == ap.ap_addr)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool AccessPoint::operator!=(const AccessPoint &ap)const
|
||||
{
|
||||
if (ap_addr != ap.ap_addr)
|
||||
return true;
|
||||
{
|
||||
if (ap_addr != ap.ap_addr)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,79 +16,79 @@ using std::string;
|
|||
#define AP_DEFAULT_OUTPUT_POWER 20 // Another good value, eq. to 100mW
|
||||
|
||||
class AccessPoint
|
||||
{
|
||||
protected:
|
||||
Point coordinates;
|
||||
string ap_addr;
|
||||
float friis_index;
|
||||
unsigned int freq;
|
||||
float antenna_gain;
|
||||
float output_power;
|
||||
|
||||
public:
|
||||
AccessPoint(const string &addr = AP_DEFAULT_ADDR, const float &fidx = AP_DEFAULT_FRIIS_INDEX, const Point &coords = Point(), const unsigned int &f = AP_DEFAULT_FREQ, const float &antg = AP_DEFAULT_ANTENNA_GAIN, const float &outp = AP_DEFAULT_OUTPUT_POWER);
|
||||
AccessPoint(const AccessPoint &ap);
|
||||
~AccessPoint() {};
|
||||
|
||||
string getApAddr()const
|
||||
{
|
||||
protected:
|
||||
Point coordinates;
|
||||
string ap_addr;
|
||||
float friis_index;
|
||||
unsigned int freq;
|
||||
float antenna_gain;
|
||||
float output_power;
|
||||
|
||||
public:
|
||||
AccessPoint(const string &addr = AP_DEFAULT_ADDR, const float &fidx = AP_DEFAULT_FRIIS_INDEX, const Point &coords = Point(), const unsigned int &f = AP_DEFAULT_FREQ, const float &antg = AP_DEFAULT_ANTENNA_GAIN, const float &outp = AP_DEFAULT_OUTPUT_POWER);
|
||||
AccessPoint(const AccessPoint &ap);
|
||||
~AccessPoint() {};
|
||||
|
||||
string getApAddr()const
|
||||
{
|
||||
return ap_addr;
|
||||
};
|
||||
float getFriisIndex()const
|
||||
{
|
||||
return friis_index;
|
||||
};
|
||||
Point getCoordinates()const
|
||||
{
|
||||
return coordinates;
|
||||
};
|
||||
float getAntennaGain()const
|
||||
{
|
||||
return antenna_gain;
|
||||
};
|
||||
unsigned int getFrequency()const
|
||||
{
|
||||
return freq;
|
||||
};
|
||||
float getOutputPower()const
|
||||
{
|
||||
return output_power;
|
||||
};
|
||||
|
||||
void setApAddr(const string &addr)
|
||||
{
|
||||
ap_addr = addr;
|
||||
};
|
||||
void setFriisIndex(const float &fidx)
|
||||
{
|
||||
friis_index = fidx;
|
||||
};
|
||||
void setCoordinates(const Point &apc)
|
||||
{
|
||||
coordinates = apc;
|
||||
};
|
||||
void setCoordinates(const float &x, const float &y, const float &z)
|
||||
{
|
||||
Point apc(x, y, z);
|
||||
coordinates = apc;
|
||||
};
|
||||
void setFrequency(const unsigned int &f)
|
||||
{
|
||||
freq = f;
|
||||
};
|
||||
void setAntennaGain(const float &antg)
|
||||
{
|
||||
antenna_gain = antg;
|
||||
};
|
||||
void setOutputPower(const float &outp)
|
||||
{
|
||||
output_power = outp;
|
||||
};
|
||||
|
||||
bool operator==(const AccessPoint &ap)const;
|
||||
bool operator!=(const AccessPoint &ap)const;
|
||||
AccessPoint operator=(const AccessPoint &ap);
|
||||
friend ostream &operator<<(ostream &os, const AccessPoint &ap);
|
||||
return ap_addr;
|
||||
};
|
||||
float getFriisIndex()const
|
||||
{
|
||||
return friis_index;
|
||||
};
|
||||
Point getCoordinates()const
|
||||
{
|
||||
return coordinates;
|
||||
};
|
||||
float getAntennaGain()const
|
||||
{
|
||||
return antenna_gain;
|
||||
};
|
||||
unsigned int getFrequency()const
|
||||
{
|
||||
return freq;
|
||||
};
|
||||
float getOutputPower()const
|
||||
{
|
||||
return output_power;
|
||||
};
|
||||
|
||||
void setApAddr(const string &addr)
|
||||
{
|
||||
ap_addr = addr;
|
||||
};
|
||||
void setFriisIndex(const float &fidx)
|
||||
{
|
||||
friis_index = fidx;
|
||||
};
|
||||
void setCoordinates(const Point &apc)
|
||||
{
|
||||
coordinates = apc;
|
||||
};
|
||||
void setCoordinates(const float &x, const float &y, const float &z)
|
||||
{
|
||||
Point apc(x, y, z);
|
||||
coordinates = apc;
|
||||
};
|
||||
void setFrequency(const unsigned int &f)
|
||||
{
|
||||
freq = f;
|
||||
};
|
||||
void setAntennaGain(const float &antg)
|
||||
{
|
||||
antenna_gain = antg;
|
||||
};
|
||||
void setOutputPower(const float &outp)
|
||||
{
|
||||
output_power = outp;
|
||||
};
|
||||
|
||||
bool operator==(const AccessPoint &ap)const;
|
||||
bool operator!=(const AccessPoint &ap)const;
|
||||
AccessPoint operator=(const AccessPoint &ap);
|
||||
friend ostream &operator<<(ostream &os, const AccessPoint &ap);
|
||||
};
|
||||
|
||||
#endif // _ACCESSPOINT_HH_
|
||||
|
|
|
@ -70,35 +70,35 @@ Area::Area(const Area &a)
|
|||
|
||||
|
||||
bool Area::containsPoint(const Point &p)const
|
||||
{
|
||||
if (p.getX() >= x_min &&
|
||||
p.getX() <= x_max &&
|
||||
p.getY() >= y_min &&
|
||||
p.getY() <= y_max &&
|
||||
p.getZ() >= z_min &&
|
||||
p.getZ() <= z_max
|
||||
)
|
||||
return true;
|
||||
{
|
||||
if (p.getX() >= x_min &&
|
||||
p.getX() <= x_max &&
|
||||
p.getY() >= y_min &&
|
||||
p.getY() <= y_max &&
|
||||
p.getZ() >= z_min &&
|
||||
p.getZ() <= z_max
|
||||
)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Area::operator==(const Area &a)const
|
||||
{
|
||||
if (area_name == a.area_name &&
|
||||
x_min == a.x_min &&
|
||||
x_max == a.x_max &&
|
||||
y_min == a.y_min &&
|
||||
y_max == a.y_max &&
|
||||
z_min == a.z_min &&
|
||||
z_max == a.z_max
|
||||
)
|
||||
return true ;
|
||||
{
|
||||
if (area_name == a.area_name &&
|
||||
x_min == a.x_min &&
|
||||
x_max == a.x_max &&
|
||||
y_min == a.y_min &&
|
||||
y_max == a.y_max &&
|
||||
z_min == a.z_min &&
|
||||
z_max == a.z_max
|
||||
)
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,83 +9,83 @@ using namespace std;
|
|||
using std::string;
|
||||
|
||||
class Area
|
||||
{
|
||||
protected:
|
||||
string area_name;
|
||||
float x_min;
|
||||
float x_max;
|
||||
float y_min;
|
||||
float y_max;
|
||||
float z_min;
|
||||
float z_max;
|
||||
|
||||
public:
|
||||
Area(const string &_name = "No name", const float &_x1 = 0, const float &_x2 = 0, const float &_y1 = 0, const float &_y2 = 0, const float &_z1 = 0, const float &_z2 = 0) ;
|
||||
Area(const Area &a) ;
|
||||
~Area() {};
|
||||
|
||||
bool containsPoint(const Point &p)const ;
|
||||
|
||||
string getName()const
|
||||
{
|
||||
protected:
|
||||
string area_name;
|
||||
float x_min;
|
||||
float x_max;
|
||||
float y_min;
|
||||
float y_max;
|
||||
float z_min;
|
||||
float z_max;
|
||||
return area_name ;
|
||||
} ;
|
||||
float getXmin()const
|
||||
{
|
||||
return x_min;
|
||||
} ;
|
||||
float getXmax()const
|
||||
{
|
||||
return x_max;
|
||||
} ;
|
||||
float getYmin()const
|
||||
{
|
||||
return y_min;
|
||||
} ;
|
||||
float getYmax()const
|
||||
{
|
||||
return y_max;
|
||||
} ;
|
||||
float getZmin()const
|
||||
{
|
||||
return z_min;
|
||||
} ;
|
||||
float getZmax()const
|
||||
{
|
||||
return z_max;
|
||||
} ;
|
||||
|
||||
public:
|
||||
Area(const string &_name = "No name", const float &_x1 = 0, const float &_x2 = 0, const float &_y1 = 0, const float &_y2 = 0, const float &_z1 = 0, const float &_z2 = 0) ;
|
||||
Area(const Area &a) ;
|
||||
~Area() {};
|
||||
void setName(const string &_name)
|
||||
{
|
||||
area_name = _name ;
|
||||
} ;
|
||||
void setXmin(const float &v)
|
||||
{
|
||||
x_min = v;
|
||||
} ;
|
||||
void setXmax(const float &v)
|
||||
{
|
||||
x_max = v;
|
||||
} ;
|
||||
void setYmin(const float &v)
|
||||
{
|
||||
y_min = v;
|
||||
} ;
|
||||
void setYmax(const float &v)
|
||||
{
|
||||
y_max = v;
|
||||
} ;
|
||||
void setZmin(const float &v)
|
||||
{
|
||||
z_min = v;
|
||||
} ;
|
||||
void setZmax(const float &v)
|
||||
{
|
||||
z_max = v;
|
||||
} ;
|
||||
|
||||
bool containsPoint(const Point &p)const ;
|
||||
|
||||
string getName()const
|
||||
{
|
||||
return area_name ;
|
||||
} ;
|
||||
float getXmin()const
|
||||
{
|
||||
return x_min;
|
||||
} ;
|
||||
float getXmax()const
|
||||
{
|
||||
return x_max;
|
||||
} ;
|
||||
float getYmin()const
|
||||
{
|
||||
return y_min;
|
||||
} ;
|
||||
float getYmax()const
|
||||
{
|
||||
return y_max;
|
||||
} ;
|
||||
float getZmin()const
|
||||
{
|
||||
return z_min;
|
||||
} ;
|
||||
float getZmax()const
|
||||
{
|
||||
return z_max;
|
||||
} ;
|
||||
|
||||
void setName(const string &_name)
|
||||
{
|
||||
area_name = _name ;
|
||||
} ;
|
||||
void setXmin(const float &v)
|
||||
{
|
||||
x_min = v;
|
||||
} ;
|
||||
void setXmax(const float &v)
|
||||
{
|
||||
x_max = v;
|
||||
} ;
|
||||
void setYmin(const float &v)
|
||||
{
|
||||
y_min = v;
|
||||
} ;
|
||||
void setYmax(const float &v)
|
||||
{
|
||||
y_max = v;
|
||||
} ;
|
||||
void setZmin(const float &v)
|
||||
{
|
||||
z_min = v;
|
||||
} ;
|
||||
void setZmax(const float &v)
|
||||
{
|
||||
z_max = v;
|
||||
} ;
|
||||
|
||||
bool operator==(const Area &a)const ;
|
||||
friend ostream &operator<<(ostream &os, const Area &a) ;
|
||||
};
|
||||
bool operator==(const Area &a)const ;
|
||||
friend ostream &operator<<(ostream &os, const Area &a) ;
|
||||
};
|
||||
|
||||
#endif // _AREA_HH_
|
||||
|
|
|
@ -132,21 +132,21 @@ bool ClientInfo::operator==(const ClientInfo &c)
|
|||
|
||||
|
||||
void ClientInfo::print_viterbi_V() const
|
||||
{
|
||||
{
|
||||
#ifdef DEBUG_T
|
||||
cout << "//--> ClientInfo::print_viterbi_V()" << endl ;
|
||||
fflush(stdout) ;
|
||||
cout << "//--> ClientInfo::print_viterbi_V()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
for (float_index n=0 ; n < viterbi_V.shape()[0] ; n++)
|
||||
{
|
||||
for (float_index k=0 ; k < viterbi_V.shape()[1] ; k++)
|
||||
cout << "[" << viterbi_V[n][k] << "]" ;
|
||||
cout << endl ;
|
||||
}
|
||||
for (float_index n=0 ; n < viterbi_V.shape()[0] ; n++)
|
||||
{
|
||||
for (float_index k=0 ; k < viterbi_V.shape()[1] ; k++)
|
||||
cout << "[" << viterbi_V[n][k] << "]" ;
|
||||
cout << endl ;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_T
|
||||
cout << "//<-- ClientInfo::print_viterbi_V()" << endl ;
|
||||
fflush(stdout) ;
|
||||
cout << "//<-- ClientInfo::print_viterbi_V()" << endl ;
|
||||
fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,51 +20,51 @@ using namespace std;
|
|||
#define VITERBI_K 8
|
||||
|
||||
class ClientInfo
|
||||
{
|
||||
public :
|
||||
typedef boost::multi_array<float, 2> float_array ; // On utilise boost::multi_array pour viterbi_V.
|
||||
typedef float_array::index float_index ;
|
||||
|
||||
protected:
|
||||
string client_ip;
|
||||
float antenna_gain;
|
||||
int client_listen_port;
|
||||
vector<Point> viterbi_Ecurrent; // Last vector
|
||||
vector<Point> viterbi_Eprevious; // Previous vector
|
||||
// float viterbi_distances[5];
|
||||
float_array viterbi_V ;
|
||||
unsigned int viterbi_iteration ; // Nombre d'ensembles d'historique qu'on a déjà passés
|
||||
|
||||
public:
|
||||
ClientInfo(const string &ip = CLIENT_DEFAULT_IP, const int &port = CLIENT_DEFAULT_PORT, const float &antg = CLIENT_DEFAULT_ANTENNA_GAIN);
|
||||
ClientInfo(const ClientInfo &c) ;
|
||||
~ClientInfo();
|
||||
|
||||
ClientInfo operator=(const ClientInfo &c) ;
|
||||
bool operator==(const ClientInfo &c) ;
|
||||
|
||||
float getAntennaGain()const
|
||||
{
|
||||
public :
|
||||
typedef boost::multi_array<float, 2> float_array ; // On utilise boost::multi_array pour viterbi_V.
|
||||
typedef float_array::index float_index ;
|
||||
return antenna_gain;
|
||||
} ;
|
||||
vector<Point>& getRef_viterbi_Ecurrent()
|
||||
{
|
||||
return viterbi_Ecurrent;
|
||||
} ;
|
||||
vector<Point>& getRef_viterbi_Eprevious()
|
||||
{
|
||||
return viterbi_Eprevious;
|
||||
} ;
|
||||
unsigned int& getRef_viterbi_iteration()
|
||||
{
|
||||
return viterbi_iteration ;
|
||||
} ;
|
||||
float_array& getRef_viterbi_V()
|
||||
{
|
||||
return viterbi_V;
|
||||
} ;
|
||||
|
||||
protected:
|
||||
string client_ip;
|
||||
float antenna_gain;
|
||||
int client_listen_port;
|
||||
vector<Point> viterbi_Ecurrent; // Last vector
|
||||
vector<Point> viterbi_Eprevious; // Previous vector
|
||||
// float viterbi_distances[5];
|
||||
float_array viterbi_V ;
|
||||
unsigned int viterbi_iteration ; // Nombre d'ensembles d'historique qu'on a déjà passés
|
||||
|
||||
public:
|
||||
ClientInfo(const string &ip = CLIENT_DEFAULT_IP, const int &port = CLIENT_DEFAULT_PORT, const float &antg = CLIENT_DEFAULT_ANTENNA_GAIN);
|
||||
ClientInfo(const ClientInfo &c) ;
|
||||
~ClientInfo();
|
||||
|
||||
ClientInfo operator=(const ClientInfo &c) ;
|
||||
bool operator==(const ClientInfo &c) ;
|
||||
|
||||
float getAntennaGain()const
|
||||
{
|
||||
return antenna_gain;
|
||||
} ;
|
||||
vector<Point>& getRef_viterbi_Ecurrent()
|
||||
{
|
||||
return viterbi_Ecurrent;
|
||||
} ;
|
||||
vector<Point>& getRef_viterbi_Eprevious()
|
||||
{
|
||||
return viterbi_Eprevious;
|
||||
} ;
|
||||
unsigned int& getRef_viterbi_iteration()
|
||||
{
|
||||
return viterbi_iteration ;
|
||||
} ;
|
||||
float_array& getRef_viterbi_V()
|
||||
{
|
||||
return viterbi_V;
|
||||
} ;
|
||||
|
||||
void print_viterbi_V() const ;
|
||||
};
|
||||
void print_viterbi_V() const ;
|
||||
};
|
||||
|
||||
#endif // _CLIENTINFO_HH_
|
||||
|
|
|
@ -43,17 +43,17 @@
|
|||
#define MINMAX_Z_STOP 6
|
||||
|
||||
typedef struct _couple_info
|
||||
{
|
||||
unsigned char ap_mac_addr_bytes[6]; // Adresse MAC de l'AP
|
||||
int antenna_signal_dbm; // Puissance du signal reçu par l'AP
|
||||
} couple_info;
|
||||
{
|
||||
unsigned char ap_mac_addr_bytes[6]; // Adresse MAC de l'AP
|
||||
int antenna_signal_dbm; // Puissance du signal reçu par l'AP
|
||||
} couple_info;
|
||||
|
||||
typedef struct _request
|
||||
{
|
||||
unsigned char mobile_mac_addr_bytes[6]; //Adresse MAC du mobile
|
||||
struct timeval request_time; // Date sur le client
|
||||
int nb_couples; // Nombre couples (MAC AP;Puissance)
|
||||
} request;
|
||||
{
|
||||
unsigned char mobile_mac_addr_bytes[6]; //Adresse MAC du mobile
|
||||
struct timeval request_time; // Date sur le client
|
||||
int nb_couples; // Nombre couples (MAC AP;Puissance)
|
||||
} request;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ void Measurement::addSsValue(const int &ssv)
|
|||
}
|
||||
|
||||
float Measurement::getSsSquareDistance(const float &ss)const
|
||||
{
|
||||
return ((ss - average_ss) * (ss - average_ss));
|
||||
}
|
||||
{
|
||||
return ((ss - average_ss) * (ss - average_ss));
|
||||
}
|
||||
|
||||
ostream &operator<<(ostream &os, const Measurement &m)
|
||||
{
|
||||
|
|
|
@ -10,47 +10,47 @@ using namespace std;
|
|||
using std::string;
|
||||
|
||||
class Measurement
|
||||
{
|
||||
protected:
|
||||
string mac_addr;
|
||||
float average_ss;
|
||||
vector<int> ss_list;
|
||||
{
|
||||
protected:
|
||||
string mac_addr;
|
||||
float average_ss;
|
||||
vector<int> ss_list;
|
||||
|
||||
public:
|
||||
Measurement(const string &ma = "ff:ff:ff:ff:ff:ff", const float &avg = 0, const vector<int> &ssl = vector<int>())
|
||||
{
|
||||
mac_addr = ma;
|
||||
average_ss = avg, ss_list = ssl;
|
||||
};
|
||||
Measurement(const Measurement &m)
|
||||
{
|
||||
mac_addr = m.mac_addr;
|
||||
average_ss = m.average_ss;
|
||||
ss_list = m.ss_list;
|
||||
};
|
||||
~Measurement()
|
||||
{
|
||||
ss_list.clear();
|
||||
};
|
||||
vector<int> getSsList()const
|
||||
{
|
||||
return ss_list;
|
||||
};
|
||||
float getAverage()const
|
||||
{
|
||||
return average_ss;
|
||||
};
|
||||
string getMacAddr()const
|
||||
{
|
||||
return mac_addr;
|
||||
};
|
||||
void addSsValue(const int &ssv);
|
||||
void setMacAddr(const string &ma)
|
||||
{
|
||||
mac_addr = ma;
|
||||
};
|
||||
float getSsSquareDistance(const float &ss)const;
|
||||
friend ostream &operator<<(ostream &os, const Measurement &m);
|
||||
public:
|
||||
Measurement(const string &ma = "ff:ff:ff:ff:ff:ff", const float &avg = 0, const vector<int> &ssl = vector<int>())
|
||||
{
|
||||
mac_addr = ma;
|
||||
average_ss = avg, ss_list = ssl;
|
||||
};
|
||||
Measurement(const Measurement &m)
|
||||
{
|
||||
mac_addr = m.mac_addr;
|
||||
average_ss = m.average_ss;
|
||||
ss_list = m.ss_list;
|
||||
};
|
||||
~Measurement()
|
||||
{
|
||||
ss_list.clear();
|
||||
};
|
||||
vector<int> getSsList()const
|
||||
{
|
||||
return ss_list;
|
||||
};
|
||||
float getAverage()const
|
||||
{
|
||||
return average_ss;
|
||||
};
|
||||
string getMacAddr()const
|
||||
{
|
||||
return mac_addr;
|
||||
};
|
||||
void addSsValue(const int &ssv);
|
||||
void setMacAddr(const string &ma)
|
||||
{
|
||||
mac_addr = ma;
|
||||
};
|
||||
float getSsSquareDistance(const float &ss)const;
|
||||
friend ostream &operator<<(ostream &os, const Measurement &m);
|
||||
};
|
||||
|
||||
#endif // _MEASUREMENT_HH_
|
||||
|
|
|
@ -17,22 +17,22 @@ Point Point::operator=(const Point &p)
|
|||
|
||||
|
||||
bool Point::operator<(const Point &p) const
|
||||
{
|
||||
if (x < p.x)
|
||||
return true ;
|
||||
if (x > p.x)
|
||||
return false ;
|
||||
|
||||
if (y < p.y)
|
||||
return true ;
|
||||
if (y > p.y)
|
||||
return false ;
|
||||
|
||||
if (z < p.z)
|
||||
return true ;
|
||||
|
||||
{
|
||||
if (x < p.x)
|
||||
return true ;
|
||||
if (x > p.x)
|
||||
return false ;
|
||||
}
|
||||
|
||||
if (y < p.y)
|
||||
return true ;
|
||||
if (y > p.y)
|
||||
return false ;
|
||||
|
||||
if (z < p.z)
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,99 +7,99 @@
|
|||
using namespace std;
|
||||
|
||||
class Point
|
||||
{
|
||||
protected:
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
|
||||
public:
|
||||
Point(const float &_x = 0, const float &_y = 0, const float &_z = 0)
|
||||
{
|
||||
protected:
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z;
|
||||
} ;
|
||||
Point(const Point &p)
|
||||
{
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
z = p.z;
|
||||
} ;
|
||||
Point(const float c[3])
|
||||
{
|
||||
x = c[0] ;
|
||||
y = c[1] ;
|
||||
z = c[2] ;
|
||||
} ;
|
||||
~Point() {};
|
||||
|
||||
public:
|
||||
Point(const float &_x = 0, const float &_y = 0, const float &_z = 0)
|
||||
{
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z;
|
||||
} ;
|
||||
Point(const Point &p)
|
||||
{
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
z = p.z;
|
||||
} ;
|
||||
Point(const float c[3])
|
||||
{
|
||||
x = c[0] ;
|
||||
y = c[1] ;
|
||||
z = c[2] ;
|
||||
} ;
|
||||
~Point() {};
|
||||
|
||||
float getX()const
|
||||
{
|
||||
return x;
|
||||
};
|
||||
float getY()const
|
||||
{
|
||||
return y;
|
||||
};
|
||||
float getZ()const
|
||||
{
|
||||
return z;
|
||||
};
|
||||
|
||||
void setX(const float &_x)
|
||||
{
|
||||
x = _x;
|
||||
};
|
||||
void setY(const float &_y)
|
||||
{
|
||||
y = _y;
|
||||
};
|
||||
void setZ(const float &_z)
|
||||
{
|
||||
z = _z;
|
||||
};
|
||||
|
||||
float squareDistance(const Point &p)const
|
||||
{
|
||||
return ((x-p.x)*(x-p.x))+((y-p.y)*(y-p.y))+((z-p.z)*(z-p.z));
|
||||
};
|
||||
float squareDistance(const float &mx, const float &my, const float &mz)const
|
||||
{
|
||||
return ((x-mx)*(x-mx))+((y-my)*(y-my))+((z-mz)*(z-mz));
|
||||
};
|
||||
float distance(const Point &p)const
|
||||
{
|
||||
return sqrt(((x-p.x)*(x-p.x))+((y-p.y)*(y-p.y))+((z-p.z)*(z-p.z)));
|
||||
};
|
||||
float distance(const float &mx, const float &my, const float &mz)const
|
||||
{
|
||||
return sqrt(((x-mx)*(x-mx))+((y-my)*(y-my))+((z-mz)*(z-mz)));
|
||||
};
|
||||
|
||||
Point operator=(const Point &p) ;
|
||||
bool operator==(const Point &p) const
|
||||
{
|
||||
return ((x == p.x) && (y == p.y) && (z == p.z)) ;
|
||||
} ;
|
||||
bool operator!=(const Point &p) const
|
||||
{
|
||||
return !(*this == p) ;
|
||||
} ;
|
||||
bool operator<(const Point &p) const ;
|
||||
bool operator>(const Point &p) const
|
||||
{
|
||||
return (p < *this) ;
|
||||
} ;
|
||||
bool operator<=(const Point &p) const
|
||||
{
|
||||
return (*this < p || *this == p) ;
|
||||
} ;
|
||||
bool operator>=(const Point &p) const
|
||||
{
|
||||
return (p <= *this) ;
|
||||
} ;
|
||||
friend ostream &operator<<(ostream & os, const Point &p);
|
||||
float getX()const
|
||||
{
|
||||
return x;
|
||||
};
|
||||
float getY()const
|
||||
{
|
||||
return y;
|
||||
};
|
||||
float getZ()const
|
||||
{
|
||||
return z;
|
||||
};
|
||||
|
||||
void setX(const float &_x)
|
||||
{
|
||||
x = _x;
|
||||
};
|
||||
void setY(const float &_y)
|
||||
{
|
||||
y = _y;
|
||||
};
|
||||
void setZ(const float &_z)
|
||||
{
|
||||
z = _z;
|
||||
};
|
||||
|
||||
float squareDistance(const Point &p)const
|
||||
{
|
||||
return ((x-p.x)*(x-p.x))+((y-p.y)*(y-p.y))+((z-p.z)*(z-p.z));
|
||||
};
|
||||
float squareDistance(const float &mx, const float &my, const float &mz)const
|
||||
{
|
||||
return ((x-mx)*(x-mx))+((y-my)*(y-my))+((z-mz)*(z-mz));
|
||||
};
|
||||
float distance(const Point &p)const
|
||||
{
|
||||
return sqrt(((x-p.x)*(x-p.x))+((y-p.y)*(y-p.y))+((z-p.z)*(z-p.z)));
|
||||
};
|
||||
float distance(const float &mx, const float &my, const float &mz)const
|
||||
{
|
||||
return sqrt(((x-mx)*(x-mx))+((y-my)*(y-my))+((z-mz)*(z-mz)));
|
||||
};
|
||||
|
||||
Point operator=(const Point &p) ;
|
||||
bool operator==(const Point &p) const
|
||||
{
|
||||
return ((x == p.x) && (y == p.y) && (z == p.z)) ;
|
||||
} ;
|
||||
bool operator!=(const Point &p) const
|
||||
{
|
||||
return !(*this == p) ;
|
||||
} ;
|
||||
bool operator<(const Point &p) const ;
|
||||
bool operator>(const Point &p) const
|
||||
{
|
||||
return (p < *this) ;
|
||||
} ;
|
||||
bool operator<=(const Point &p) const
|
||||
{
|
||||
return (*this < p || *this == p) ;
|
||||
} ;
|
||||
bool operator>=(const Point &p) const
|
||||
{
|
||||
return (p <= *this) ;
|
||||
} ;
|
||||
friend ostream &operator<<(ostream & os, const Point &p);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -647,70 +647,70 @@ bool Positioning::checkTopology()
|
|||
}
|
||||
|
||||
inline bool Positioning::pointExists(const float &x, const float &y, const float &z) const
|
||||
{
|
||||
return pointExists(reference_point_list, Point(x, y, z));
|
||||
}
|
||||
{
|
||||
return pointExists(reference_point_list, Point(x, y, z));
|
||||
}
|
||||
|
||||
inline bool Positioning::pointExists(const Point &p) const
|
||||
{
|
||||
return pointExists(reference_point_list, p);
|
||||
}
|
||||
{
|
||||
return pointExists(reference_point_list, p);
|
||||
}
|
||||
|
||||
inline bool Positioning::pointExists(const vector<ReferencePoint> &point_list, const float &x, const float &y, const float &z) const
|
||||
{
|
||||
return pointExists(point_list, Point(x, y, z));
|
||||
}
|
||||
{
|
||||
return pointExists(point_list, Point(x, y, z));
|
||||
}
|
||||
|
||||
inline bool Positioning::pointExists(const vector<ReferencePoint> &point_list, const Point &p) const
|
||||
{
|
||||
return (pointIndex(point_list, p) != -1);
|
||||
}
|
||||
{
|
||||
return (pointIndex(point_list, p) != -1);
|
||||
}
|
||||
|
||||
inline int Positioning::pointIndex(const Point &p) const
|
||||
{
|
||||
return (unsigned int) pointIndex(reference_point_list, p);
|
||||
}
|
||||
{
|
||||
return (unsigned int) pointIndex(reference_point_list, p);
|
||||
}
|
||||
|
||||
inline int Positioning::pointIndex(const vector<ReferencePoint> &point_list, const float &x, const float &y, const float &z) const
|
||||
{
|
||||
return (unsigned int) pointIndex(point_list, Point(x, y, z)) ;
|
||||
}
|
||||
{
|
||||
return (unsigned int) pointIndex(point_list, Point(x, y, z)) ;
|
||||
}
|
||||
|
||||
inline int Positioning::pointIndex(const vector<ReferencePoint> &point_list, const Point &p) const
|
||||
{
|
||||
unsigned int i;
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0 ; i < point_list.size() ; i++)
|
||||
if (p == point_list[i].getCoordinates())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
for (i = 0 ; i < point_list.size() ; i++)
|
||||
if (p == point_list[i].getCoordinates())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Retourne la position du Point "p" dans le tableau à une dimension "point_tab" de taille "size", ou -1 en cas d'échec. */
|
||||
inline int Positioning::pointIndex(const Point *point_tab, unsigned int &size, const Point &p) const
|
||||
{
|
||||
for (unsigned int i = 0 ; i < size ; i++)
|
||||
if (point_tab[i] == p)
|
||||
return i;
|
||||
{
|
||||
for (unsigned int i = 0 ; i < size ; i++)
|
||||
if (point_tab[i] == p)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Retourne la position du Point "p" dans le vector "point_list", ou -1 en cas d'échec. */
|
||||
inline int Positioning::pointIndex(const vector<Point> &point_list, const Point &p) const
|
||||
{
|
||||
{
|
||||
|
||||
for (unsigned int i = 0 ; i < point_list.size() ; i++)
|
||||
if (point_list[i] == p)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
for (unsigned int i = 0 ; i < point_list.size() ; i++)
|
||||
if (point_list[i] == p)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Positioning::printReferencePointList()
|
||||
{
|
||||
|
@ -724,10 +724,10 @@ void Positioning::printPointList(vector<ReferencePoint> &point_list)
|
|||
}
|
||||
|
||||
void Positioning::printAccessPointList() const
|
||||
{
|
||||
for (unsigned int i = 0; i < access_point_list.size(); i++)
|
||||
cout << access_point_list[i] << endl;
|
||||
}
|
||||
{
|
||||
for (unsigned int i = 0; i < access_point_list.size(); i++)
|
||||
cout << access_point_list[i] << endl;
|
||||
}
|
||||
|
||||
void Positioning::printAreatList()
|
||||
{
|
||||
|
|
|
@ -9,65 +9,65 @@
|
|||
#include "libowlps-positioning.hh"
|
||||
|
||||
class Positioning
|
||||
{
|
||||
private:
|
||||
vector<ReferencePoint> reference_point_list; // Liste des points de référence (calibration).
|
||||
float** reference_point_matrix; // Matrice des distances entre les points de référence.
|
||||
vector<AccessPoint> access_point_list; // Liste des AP connus.
|
||||
vector<Point> waypoint_list; // Liste des points de passage entre les zones.
|
||||
float** waypoint_matrix; // Matrice des distances entre les points de passage.
|
||||
map<string, Area> area_list ; // Liste des zones homogènes (pièces).
|
||||
|
||||
public :
|
||||
Positioning() {};
|
||||
~Positioning() {};
|
||||
|
||||
void makeReferencePointListFromFile(const string &filename, const bool);
|
||||
void makeApListFromFile(const string &filename);
|
||||
void makeTopologyFromFile(const string &filename);
|
||||
void makeWaypointListFromFile(const string &filename);
|
||||
|
||||
void makeReferencePointListFromDb(PGconn*, const bool);
|
||||
void makeApListFromDb(PGconn*);
|
||||
void makeTopologyFromDb(PGconn*);
|
||||
void makeWaypointListFromDb(PGconn*);
|
||||
|
||||
void makeWaypointMatrix(set<Point>);
|
||||
|
||||
map<string, Area> inWhichAreas(const Point &p);
|
||||
bool inTheSameArea(const Point &p1, const Point &p2);
|
||||
float distanceTopology(const Point &p1, const Point &p2);
|
||||
vector<Point> areaConnection(const Area &z1, const Area &z2);
|
||||
vector<Point> areaConnection(const Area &z);
|
||||
|
||||
void makeReferencePointDistances();
|
||||
bool checkTopology();
|
||||
|
||||
bool pointExists(const float &x, const float &y, const float &z)const;
|
||||
bool pointExists(const Point &p)const;
|
||||
bool pointExists(const vector<ReferencePoint> &point_list, const float &x, const float &y, const float &z) const ;
|
||||
bool pointExists(const vector<ReferencePoint> &point_list, const Point &p) const ;
|
||||
|
||||
int pointIndex(const float &x, const float &y, const float &z) const;
|
||||
int pointIndex(const Point &p) const;
|
||||
int pointIndex(const vector<ReferencePoint> &point_list, const float &x, const float &y, const float &z) const ;
|
||||
int pointIndex(const vector<ReferencePoint> &point_list, const Point &p) const ;
|
||||
int pointIndex(const Point *tab, unsigned int &size, const Point &p) const ;
|
||||
int pointIndex(const vector<Point> &point_list, const Point &p) const ;
|
||||
|
||||
vector<AccessPoint> getAccessPointList() const
|
||||
{
|
||||
private:
|
||||
vector<ReferencePoint> reference_point_list; // Liste des points de référence (calibration).
|
||||
float** reference_point_matrix; // Matrice des distances entre les points de référence.
|
||||
vector<AccessPoint> access_point_list; // Liste des AP connus.
|
||||
vector<Point> waypoint_list; // Liste des points de passage entre les zones.
|
||||
float** waypoint_matrix; // Matrice des distances entre les points de passage.
|
||||
map<string, Area> area_list ; // Liste des zones homogènes (pièces).
|
||||
|
||||
public :
|
||||
Positioning() {};
|
||||
~Positioning() {};
|
||||
|
||||
void makeReferencePointListFromFile(const string &filename, const bool);
|
||||
void makeApListFromFile(const string &filename);
|
||||
void makeTopologyFromFile(const string &filename);
|
||||
void makeWaypointListFromFile(const string &filename);
|
||||
|
||||
void makeReferencePointListFromDb(PGconn*, const bool);
|
||||
void makeApListFromDb(PGconn*);
|
||||
void makeTopologyFromDb(PGconn*);
|
||||
void makeWaypointListFromDb(PGconn*);
|
||||
|
||||
void makeWaypointMatrix(set<Point>);
|
||||
|
||||
map<string, Area> inWhichAreas(const Point &p);
|
||||
bool inTheSameArea(const Point &p1, const Point &p2);
|
||||
float distanceTopology(const Point &p1, const Point &p2);
|
||||
vector<Point> areaConnection(const Area &z1, const Area &z2);
|
||||
vector<Point> areaConnection(const Area &z);
|
||||
|
||||
void makeReferencePointDistances();
|
||||
bool checkTopology();
|
||||
|
||||
bool pointExists(const float &x, const float &y, const float &z)const;
|
||||
bool pointExists(const Point &p)const;
|
||||
bool pointExists(const vector<ReferencePoint> &point_list, const float &x, const float &y, const float &z) const ;
|
||||
bool pointExists(const vector<ReferencePoint> &point_list, const Point &p) const ;
|
||||
|
||||
int pointIndex(const float &x, const float &y, const float &z) const;
|
||||
int pointIndex(const Point &p) const;
|
||||
int pointIndex(const vector<ReferencePoint> &point_list, const float &x, const float &y, const float &z) const ;
|
||||
int pointIndex(const vector<ReferencePoint> &point_list, const Point &p) const ;
|
||||
int pointIndex(const Point *tab, unsigned int &size, const Point &p) const ;
|
||||
int pointIndex(const vector<Point> &point_list, const Point &p) const ;
|
||||
|
||||
vector<AccessPoint> getAccessPointList() const
|
||||
{
|
||||
return access_point_list;
|
||||
};
|
||||
vector<ReferencePoint> getReferencePointList() const
|
||||
{
|
||||
return reference_point_list;
|
||||
};
|
||||
|
||||
void printReferencePointList();
|
||||
void printPointList(vector<ReferencePoint> &point_list);
|
||||
void printAccessPointList() const;
|
||||
void printAreatList();
|
||||
return access_point_list;
|
||||
};
|
||||
vector<ReferencePoint> getReferencePointList() const
|
||||
{
|
||||
return reference_point_list;
|
||||
};
|
||||
|
||||
void printReferencePointList();
|
||||
void printPointList(vector<ReferencePoint> &point_list);
|
||||
void printAccessPointList() const;
|
||||
void printAreatList();
|
||||
};
|
||||
|
||||
#endif // _POSITIONING_HH_
|
||||
|
|
|
@ -3,65 +3,65 @@
|
|||
|
||||
|
||||
float ReferencePoint::getSsSquareDistance(const vector<Measurement> &m)const
|
||||
{
|
||||
unsigned int i, j;
|
||||
float ret = 0;
|
||||
bool found;
|
||||
vector<Measurement> ref_m = measurement_list;
|
||||
vector<Measurement> test_m = m;
|
||||
Measurement new_meas;
|
||||
{
|
||||
unsigned int i, j;
|
||||
float ret = 0;
|
||||
bool found;
|
||||
vector<Measurement> ref_m = measurement_list;
|
||||
vector<Measurement> test_m = m;
|
||||
Measurement new_meas;
|
||||
|
||||
new_meas.addSsValue(-95);
|
||||
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(measurement_list[i].getMacAddr());
|
||||
test_m.push_back(new_meas);
|
||||
}
|
||||
}
|
||||
/* 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(measurement_list[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, 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++;
|
||||
}
|
||||
}
|
||||
/* 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();
|
||||
ref_m.clear();
|
||||
test_m.clear();
|
||||
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -89,25 +89,25 @@ void ReferencePoint::addMeasurement(const string &mac_a, const int &value)
|
|||
|
||||
|
||||
bool ReferencePoint::getPowerForAp(const string &ap_mac, float *p)const
|
||||
{
|
||||
unsigned int i;
|
||||
string str = ap_mac;
|
||||
string macLowerCase;
|
||||
{
|
||||
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]);
|
||||
//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 < measurement_list.size() ; i++)
|
||||
if (measurement_list[i].getMacAddr() == str)
|
||||
{
|
||||
*p = measurement_list[i].getAverage();
|
||||
return true;
|
||||
}
|
||||
for (i = 0 ; i < measurement_list.size() ; i++)
|
||||
if (measurement_list[i].getMacAddr() == str)
|
||||
{
|
||||
*p = measurement_list[i].getAverage();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -141,6 +141,6 @@ ostream &operator<<(ostream &os, ReferencePoint &rp)
|
|||
|
||||
/* Opérateur de cast en Point */
|
||||
ReferencePoint::operator Point() const
|
||||
{
|
||||
return coordinates ;
|
||||
}
|
||||
{
|
||||
return coordinates ;
|
||||
}
|
||||
|
|
|
@ -10,52 +10,52 @@
|
|||
using namespace std;
|
||||
|
||||
class ReferencePoint
|
||||
{
|
||||
protected:
|
||||
Point coordinates;
|
||||
vector<Measurement> measurement_list;
|
||||
|
||||
public:
|
||||
ReferencePoint(const float &x = 0, const float &y = 0, const float &z = 0)
|
||||
{
|
||||
protected:
|
||||
Point coordinates;
|
||||
vector<Measurement> measurement_list;
|
||||
|
||||
public:
|
||||
ReferencePoint(const float &x = 0, const float &y = 0, const float &z = 0)
|
||||
{
|
||||
coordinates.setX(x);
|
||||
coordinates.setY(y);
|
||||
coordinates.setZ(z);
|
||||
};
|
||||
ReferencePoint(const ReferencePoint &rp)
|
||||
{
|
||||
coordinates = rp.coordinates;
|
||||
measurement_list = rp.measurement_list;
|
||||
};
|
||||
ReferencePoint(const Point &c)
|
||||
{
|
||||
coordinates = c;
|
||||
};
|
||||
~ReferencePoint()
|
||||
{
|
||||
measurement_list.clear();
|
||||
};
|
||||
|
||||
float getSsSquareDistance(const vector<Measurement> &m)const;
|
||||
Point getCoordinates()const
|
||||
{
|
||||
return coordinates;
|
||||
};
|
||||
void addMeasurement(const string &mac_a, const int &value);
|
||||
|
||||
void setCoordinates(const Point &p)
|
||||
{
|
||||
coordinates = p;
|
||||
};
|
||||
vector<Measurement> getMeasurementList() const
|
||||
{
|
||||
return measurement_list;
|
||||
} ;
|
||||
bool getPowerForAp(const string &ap_mac, float *p) const ;
|
||||
|
||||
ReferencePoint operator=(const ReferencePoint &rp);
|
||||
operator Point() const ;
|
||||
friend ostream &operator<<(ostream &os, ReferencePoint &rp);
|
||||
coordinates.setX(x);
|
||||
coordinates.setY(y);
|
||||
coordinates.setZ(z);
|
||||
};
|
||||
ReferencePoint(const ReferencePoint &rp)
|
||||
{
|
||||
coordinates = rp.coordinates;
|
||||
measurement_list = rp.measurement_list;
|
||||
};
|
||||
ReferencePoint(const Point &c)
|
||||
{
|
||||
coordinates = c;
|
||||
};
|
||||
~ReferencePoint()
|
||||
{
|
||||
measurement_list.clear();
|
||||
};
|
||||
|
||||
float getSsSquareDistance(const vector<Measurement> &m)const;
|
||||
Point getCoordinates()const
|
||||
{
|
||||
return coordinates;
|
||||
};
|
||||
void addMeasurement(const string &mac_a, const int &value);
|
||||
|
||||
void setCoordinates(const Point &p)
|
||||
{
|
||||
coordinates = p;
|
||||
};
|
||||
vector<Measurement> getMeasurementList() const
|
||||
{
|
||||
return measurement_list;
|
||||
} ;
|
||||
bool getPowerForAp(const string &ap_mac, float *p) const ;
|
||||
|
||||
ReferencePoint operator=(const ReferencePoint &rp);
|
||||
operator Point() const ;
|
||||
friend ostream &operator<<(ostream &os, ReferencePoint &rp);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,37 +17,37 @@
|
|||
#include "libowlps-positioning.hh"
|
||||
|
||||
class Server
|
||||
{
|
||||
|
||||
private:
|
||||
request att_request;
|
||||
vector<couple_info> recv_info;
|
||||
|
||||
int listen_port;
|
||||
int mobile_port;
|
||||
int listen_socket;
|
||||
|
||||
PGconn *conn;
|
||||
|
||||
Positioning pos;
|
||||
|
||||
public:
|
||||
Server(int port, int mport)
|
||||
{
|
||||
|
||||
private:
|
||||
request att_request;
|
||||
vector<couple_info> recv_info;
|
||||
|
||||
int listen_port;
|
||||
int mobile_port;
|
||||
int listen_socket;
|
||||
|
||||
PGconn *conn;
|
||||
|
||||
Positioning pos;
|
||||
|
||||
public:
|
||||
Server(int port, int mport)
|
||||
{
|
||||
listen_port = port;
|
||||
mobile_port = mport;
|
||||
};
|
||||
~Server()
|
||||
{
|
||||
close(listen_socket);
|
||||
PQfinish(conn);
|
||||
};
|
||||
|
||||
int start();
|
||||
int init(const boost::program_options::variables_map);
|
||||
void treatment();
|
||||
void createResult(Point, int, string);
|
||||
void sendToClient(Point, char *);
|
||||
listen_port = port;
|
||||
mobile_port = mport;
|
||||
};
|
||||
~Server()
|
||||
{
|
||||
close(listen_socket);
|
||||
PQfinish(conn);
|
||||
};
|
||||
|
||||
int start();
|
||||
int init(const boost::program_options::variables_map);
|
||||
void treatment();
|
||||
void createResult(Point, int, string);
|
||||
void sendToClient(Point, char *);
|
||||
};
|
||||
|
||||
#endif // _SERVER_HH_
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
#include "treatment.hh"
|
||||
|
||||
bool Treatment::apExists(const string &ap_addr)const
|
||||
{
|
||||
{
|
||||
|
||||
string str;
|
||||
string str;
|
||||
|
||||
for (unsigned int i = 0 ; i < access_point_list.size() ; i++)
|
||||
{
|
||||
str = access_point_list[i].getApAddr() ;
|
||||
const int length = str.length() ;
|
||||
for (int j = 0 ; j < length ; ++j)
|
||||
str[j] = tolower(str[j]) ;
|
||||
if (str == ap_addr)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0 ; i < access_point_list.size() ; i++)
|
||||
{
|
||||
str = access_point_list[i].getApAddr() ;
|
||||
const int length = str.length() ;
|
||||
for (int j = 0 ; j < length ; ++j)
|
||||
str[j] = tolower(str[j]) ;
|
||||
if (str == ap_addr)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
unsigned int Treatment::apIndex(const string &ap_addr)const
|
||||
{
|
||||
unsigned int i;
|
||||
string str;
|
||||
{
|
||||
unsigned int i;
|
||||
string str;
|
||||
|
||||
for (i = 0 ; i < access_point_list.size() ; i++)
|
||||
{
|
||||
str = access_point_list[i].getApAddr() ;
|
||||
const int length = str.length() ;
|
||||
for (int j = 0 ; j < length ; ++j)
|
||||
str[j] = tolower(str[j]) ;
|
||||
if (str == ap_addr)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
for (i = 0 ; i < access_point_list.size() ; i++)
|
||||
{
|
||||
str = access_point_list[i].getApAddr() ;
|
||||
const int length = str.length() ;
|
||||
for (int j = 0 ; j < length ; ++j)
|
||||
str[j] = tolower(str[j]) ;
|
||||
if (str == ap_addr)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 0; // Should never happen
|
||||
}
|
||||
return 0; // Should never happen
|
||||
}
|
||||
|
||||
void Treatment::makeMeasurementList(vector<couple_info> recv_info)
|
||||
{
|
||||
|
@ -76,167 +76,111 @@ void Treatment::makeMeasurementList(vector<couple_info> recv_info)
|
|||
}
|
||||
|
||||
vector<Point> Treatment::getkClosestInSs(const unsigned int &k, const Point *point_ignored)const
|
||||
{
|
||||
{
|
||||
|
||||
unsigned int i, j, min_idx;
|
||||
vector<float> distances_vector;
|
||||
vector<Point> points_vector;
|
||||
Point tmp_pt;
|
||||
float tmp_distance = 0, dist_max = 10000000, tmp_min;
|
||||
unsigned int i, j, min_idx;
|
||||
vector<float> distances_vector;
|
||||
vector<Point> points_vector;
|
||||
Point tmp_pt;
|
||||
float tmp_distance = 0, dist_max = 10000000, tmp_min;
|
||||
|
||||
for (i = 0 ; i < reference_point_list.size() ; i++)
|
||||
if (point_ignored == NULL || (reference_point_list[i].getCoordinates() != *point_ignored))
|
||||
{
|
||||
tmp_distance = reference_point_list[i].getSsSquareDistance(m);
|
||||
|
||||
/* if not k points, add it */
|
||||
if (distances_vector.size() < k)
|
||||
{
|
||||
distances_vector.push_back(tmp_distance);
|
||||
points_vector.push_back(reference_point_list[i].getCoordinates());
|
||||
dist_max = (dist_max < tmp_distance) ? tmp_distance : dist_max;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if tmp_dst < dist_max, should add it and remove previous greatest dist. */
|
||||
if (dist_max > tmp_distance)
|
||||
{
|
||||
/* remove old max */
|
||||
for (j = 0 ; j < distances_vector.size() ; j++)
|
||||
if (distances_vector[j] == dist_max)
|
||||
{
|
||||
distances_vector[j] = tmp_distance;
|
||||
points_vector[j] = reference_point_list[i].getCoordinates();
|
||||
break;
|
||||
}
|
||||
/* Now seek the new max. distance */
|
||||
dist_max = distances_vector[0];
|
||||
for (j = 1 ; j < distances_vector.size() ; j++)
|
||||
if (distances_vector[j] > dist_max)
|
||||
dist_max = distances_vector[j];
|
||||
}
|
||||
/* Else nothing needs to be done */
|
||||
}
|
||||
}
|
||||
|
||||
/* Sorts the vector */
|
||||
for (i = 0 ; i < distances_vector.size() - 1 ; i++)
|
||||
for (i = 0 ; i < reference_point_list.size() ; i++)
|
||||
if (point_ignored == NULL || (reference_point_list[i].getCoordinates() != *point_ignored))
|
||||
{
|
||||
tmp_min = distances_vector[i];
|
||||
min_idx = i;
|
||||
for (j = i+1 ; j < distances_vector.size() ; j++)
|
||||
if (tmp_min > distances_vector[j])
|
||||
{
|
||||
tmp_min = distances_vector[j];
|
||||
min_idx = j;
|
||||
}
|
||||
tmp_distance = reference_point_list[i].getSsSquareDistance(m);
|
||||
|
||||
if (min_idx != i)
|
||||
/* if not k points, add it */
|
||||
if (distances_vector.size() < k)
|
||||
{
|
||||
/* Swap points */
|
||||
tmp_pt = points_vector[i];
|
||||
points_vector[i] = points_vector[min_idx];
|
||||
points_vector[min_idx] = tmp_pt;
|
||||
|
||||
/* Swap distances */
|
||||
distances_vector[min_idx] = distances_vector[i];
|
||||
distances_vector[i] = tmp_min;
|
||||
distances_vector.push_back(tmp_distance);
|
||||
points_vector.push_back(reference_point_list[i].getCoordinates());
|
||||
dist_max = (dist_max < tmp_distance) ? tmp_distance : dist_max;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if tmp_dst < dist_max, should add it and remove previous greatest dist. */
|
||||
if (dist_max > tmp_distance)
|
||||
{
|
||||
/* remove old max */
|
||||
for (j = 0 ; j < distances_vector.size() ; j++)
|
||||
if (distances_vector[j] == dist_max)
|
||||
{
|
||||
distances_vector[j] = tmp_distance;
|
||||
points_vector[j] = reference_point_list[i].getCoordinates();
|
||||
break;
|
||||
}
|
||||
/* Now seek the new max. distance */
|
||||
dist_max = distances_vector[0];
|
||||
for (j = 1 ; j < distances_vector.size() ; j++)
|
||||
if (distances_vector[j] > dist_max)
|
||||
dist_max = distances_vector[j];
|
||||
}
|
||||
/* Else nothing needs to be done */
|
||||
}
|
||||
}
|
||||
|
||||
return points_vector;
|
||||
}
|
||||
/* Sorts the vector */
|
||||
for (i = 0 ; i < distances_vector.size() - 1 ; i++)
|
||||
{
|
||||
tmp_min = distances_vector[i];
|
||||
min_idx = i;
|
||||
for (j = i+1 ; j < distances_vector.size() ; j++)
|
||||
if (tmp_min > distances_vector[j])
|
||||
{
|
||||
tmp_min = distances_vector[j];
|
||||
min_idx = j;
|
||||
}
|
||||
|
||||
if (min_idx != i)
|
||||
{
|
||||
/* Swap points */
|
||||
tmp_pt = points_vector[i];
|
||||
points_vector[i] = points_vector[min_idx];
|
||||
points_vector[min_idx] = tmp_pt;
|
||||
|
||||
/* Swap distances */
|
||||
distances_vector[min_idx] = distances_vector[i];
|
||||
distances_vector[i] = tmp_min;
|
||||
}
|
||||
}
|
||||
|
||||
return points_vector;
|
||||
}
|
||||
|
||||
Point Treatment::fbcm(const int &client_idx)const
|
||||
{
|
||||
{
|
||||
|
||||
Point ret(0, 0, 0);
|
||||
vector<string> addr;
|
||||
vector<float> dist_vect;
|
||||
vector<Point> centres;
|
||||
unsigned int i, ap_idx;
|
||||
float constant_term, minmax_res, minmax_max;
|
||||
float x = MINMAX_X_START, y = MINMAX_Y_START, z = MINMAX_Z_START;
|
||||
Point ret(0, 0, 0);
|
||||
vector<string> addr;
|
||||
vector<float> dist_vect;
|
||||
vector<Point> centres;
|
||||
unsigned int i, ap_idx;
|
||||
float constant_term, minmax_res, minmax_max;
|
||||
float x = MINMAX_X_START, y = MINMAX_Y_START, z = MINMAX_Z_START;
|
||||
|
||||
i = 0;
|
||||
//cout << "FBCM: ";
|
||||
for (i = 0 ; i < m.size() ; i++)
|
||||
if (apExists(m[i].getMacAddr()))
|
||||
{
|
||||
ap_idx = apIndex(m[i].getMacAddr());
|
||||
//cout << "AP idx: " << ap_idx << " ";
|
||||
centres.push_back(access_point_list[ap_idx].getCoordinates());
|
||||
addr.push_back(m[i].getMacAddr());
|
||||
constant_term = access_point_list[ap_idx].getOutputPower() + access_point_list[ap_idx].getAntennaGain() + 2;
|
||||
constant_term += 20 * log10((300000000.0 / (float) access_point_list[ap_idx].getFrequency()) / (4*M_PI));
|
||||
//end of expr. should be: client_list[client_idx].getAntennaGain() instead of 2.
|
||||
//cout << "20log(" << (300000000.0 / (float) access_point_list[ap_idx].getFrequency()) / (4*M_PI) << ") = ";
|
||||
//cout << constant_term << " ";
|
||||
dist_vect.push_back(pow(10, (constant_term - m[i].getAverage()) / (10 * access_point_list[ap_idx].getFriisIndex())));
|
||||
//cout << endl;
|
||||
}
|
||||
|
||||
/* Then: min-max */
|
||||
minmax_res = 1000000;
|
||||
for (x = MINMAX_X_START ; x < MINMAX_X_STOP ; x += MINMAX_STEP)
|
||||
for (y = MINMAX_Y_START ; y < MINMAX_Y_STOP ; y += MINMAX_STEP)
|
||||
for (z = MINMAX_Z_START ; z <= MINMAX_Z_STOP ; z += MINMAX_STEP)
|
||||
{
|
||||
minmax_max = 0;
|
||||
for (i = 0 ; i < centres.size() ; i++)
|
||||
if (abs(centres[i].distance(x, y, z) - dist_vect[i]) > minmax_max)
|
||||
minmax_max = abs(centres[i].distance(x, y, z) - dist_vect[i]) ;
|
||||
if (minmax_max < minmax_res)
|
||||
{
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.setZ(z);
|
||||
minmax_res = minmax_max;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear all vectors */
|
||||
addr.clear();
|
||||
dist_vect.clear();
|
||||
centres.clear();
|
||||
|
||||
/* Return position */
|
||||
return ret;
|
||||
}
|
||||
|
||||
Point Treatment::fbcm_friis(const vector<float> friis_idx_list, const float &z)const
|
||||
{
|
||||
|
||||
Point ret(0, 0, 0);
|
||||
vector<float> dist_vect;
|
||||
vector<Point> centres;
|
||||
unsigned int i, ap_idx;
|
||||
float constant_term, minmax_res, minmax_max;
|
||||
float x = MINMAX_X_START, y = MINMAX_Y_START ;
|
||||
vector<Measurement> vm = m; //Used when filtering 3 strongest APs
|
||||
vector<float> friis_idx = friis_idx_list; //Used when filtering 3 strongest APs
|
||||
|
||||
i = 0;
|
||||
for (i = 0 ; i < vm.size() ; i++)
|
||||
i = 0;
|
||||
//cout << "FBCM: ";
|
||||
for (i = 0 ; i < m.size() ; i++)
|
||||
if (apExists(m[i].getMacAddr()))
|
||||
{
|
||||
if (apExists(vm[i].getMacAddr()))
|
||||
{
|
||||
ap_idx = apIndex(vm[i].getMacAddr());
|
||||
constant_term = access_point_list[ap_idx].getOutputPower() + access_point_list[ap_idx].getAntennaGain() + 2;
|
||||
constant_term += 20 * log10((300000000.0 / (float) access_point_list[ap_idx].getFrequency()) / (4*M_PI));
|
||||
if (friis_idx[i] != -1)
|
||||
{
|
||||
centres.push_back(access_point_list[ap_idx].getCoordinates());
|
||||
dist_vect.push_back(pow(10, (constant_term - vm[i].getAverage()) / (10 * friis_idx[i])));
|
||||
}
|
||||
}
|
||||
ap_idx = apIndex(m[i].getMacAddr());
|
||||
//cout << "AP idx: " << ap_idx << " ";
|
||||
centres.push_back(access_point_list[ap_idx].getCoordinates());
|
||||
addr.push_back(m[i].getMacAddr());
|
||||
constant_term = access_point_list[ap_idx].getOutputPower() + access_point_list[ap_idx].getAntennaGain() + 2;
|
||||
constant_term += 20 * log10((300000000.0 / (float) access_point_list[ap_idx].getFrequency()) / (4*M_PI));
|
||||
//end of expr. should be: client_list[client_idx].getAntennaGain() instead of 2.
|
||||
//cout << "20log(" << (300000000.0 / (float) access_point_list[ap_idx].getFrequency()) / (4*M_PI) << ") = ";
|
||||
//cout << constant_term << " ";
|
||||
dist_vect.push_back(pow(10, (constant_term - m[i].getAverage()) / (10 * access_point_list[ap_idx].getFriisIndex())));
|
||||
//cout << endl;
|
||||
}
|
||||
|
||||
|
||||
/* Then: min-max */
|
||||
minmax_res = 1000000;
|
||||
for (x = MINMAX_X_START ; x < MINMAX_X_STOP ; x += MINMAX_STEP)
|
||||
for (y = MINMAX_Y_START ; y < MINMAX_Y_STOP ; y += MINMAX_STEP)
|
||||
/* Then: min-max */
|
||||
minmax_res = 1000000;
|
||||
for (x = MINMAX_X_START ; x < MINMAX_X_STOP ; x += MINMAX_STEP)
|
||||
for (y = MINMAX_Y_START ; y < MINMAX_Y_STOP ; y += MINMAX_STEP)
|
||||
for (z = MINMAX_Z_START ; z <= MINMAX_Z_STOP ; z += MINMAX_STEP)
|
||||
{
|
||||
minmax_max = 0;
|
||||
for (i = 0 ; i < centres.size() ; i++)
|
||||
|
@ -251,65 +195,121 @@ Point Treatment::fbcm_friis(const vector<float> friis_idx_list, const float &z)c
|
|||
}
|
||||
}
|
||||
|
||||
/* Clear all vectors */
|
||||
dist_vect.clear();
|
||||
centres.clear();
|
||||
/* Clear all vectors */
|
||||
addr.clear();
|
||||
dist_vect.clear();
|
||||
centres.clear();
|
||||
|
||||
/* Return position */
|
||||
return ret;
|
||||
}
|
||||
/* Return position */
|
||||
return ret;
|
||||
}
|
||||
|
||||
Point Treatment::fbcm_friis(const vector<float> friis_idx_list, const float &z)const
|
||||
{
|
||||
|
||||
Point ret(0, 0, 0);
|
||||
vector<float> dist_vect;
|
||||
vector<Point> centres;
|
||||
unsigned int i, ap_idx;
|
||||
float constant_term, minmax_res, minmax_max;
|
||||
float x = MINMAX_X_START, y = MINMAX_Y_START ;
|
||||
vector<Measurement> vm = m; //Used when filtering 3 strongest APs
|
||||
vector<float> friis_idx = friis_idx_list; //Used when filtering 3 strongest APs
|
||||
|
||||
i = 0;
|
||||
for (i = 0 ; i < vm.size() ; i++)
|
||||
{
|
||||
if (apExists(vm[i].getMacAddr()))
|
||||
{
|
||||
ap_idx = apIndex(vm[i].getMacAddr());
|
||||
constant_term = access_point_list[ap_idx].getOutputPower() + access_point_list[ap_idx].getAntennaGain() + 2;
|
||||
constant_term += 20 * log10((300000000.0 / (float) access_point_list[ap_idx].getFrequency()) / (4*M_PI));
|
||||
if (friis_idx[i] != -1)
|
||||
{
|
||||
centres.push_back(access_point_list[ap_idx].getCoordinates());
|
||||
dist_vect.push_back(pow(10, (constant_term - vm[i].getAverage()) / (10 * friis_idx[i])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Then: min-max */
|
||||
minmax_res = 1000000;
|
||||
for (x = MINMAX_X_START ; x < MINMAX_X_STOP ; x += MINMAX_STEP)
|
||||
for (y = MINMAX_Y_START ; y < MINMAX_Y_STOP ; y += MINMAX_STEP)
|
||||
{
|
||||
minmax_max = 0;
|
||||
for (i = 0 ; i < centres.size() ; i++)
|
||||
if (abs(centres[i].distance(x, y, z) - dist_vect[i]) > minmax_max)
|
||||
minmax_max = abs(centres[i].distance(x, y, z) - dist_vect[i]) ;
|
||||
if (minmax_max < minmax_res)
|
||||
{
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.setZ(z);
|
||||
minmax_res = minmax_max;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear all vectors */
|
||||
dist_vect.clear();
|
||||
centres.clear();
|
||||
|
||||
/* Return position */
|
||||
return ret;
|
||||
}
|
||||
|
||||
Point Treatment::interlink(const int &client_idx) const
|
||||
{
|
||||
{
|
||||
|
||||
Point ret(0, 0, 0);
|
||||
vector<string> addr;
|
||||
vector<float> dist_vect;
|
||||
vector<Point> centres;
|
||||
unsigned int i, ap_idx;
|
||||
float constant_term, minmax_res, minmax_max;
|
||||
float x = MINMAX_X_START, y = MINMAX_Y_START, z = MINMAX_Z_START;
|
||||
Point ret(0, 0, 0);
|
||||
vector<string> addr;
|
||||
vector<float> dist_vect;
|
||||
vector<Point> centres;
|
||||
unsigned int i, ap_idx;
|
||||
float constant_term, minmax_res, minmax_max;
|
||||
float x = MINMAX_X_START, y = MINMAX_Y_START, z = MINMAX_Z_START;
|
||||
|
||||
i = 0;
|
||||
for (i = 0 ; i < m.size() ; i++)
|
||||
if (apExists(m[i].getMacAddr()))
|
||||
i = 0;
|
||||
for (i = 0 ; i < m.size() ; i++)
|
||||
if (apExists(m[i].getMacAddr()))
|
||||
{
|
||||
ap_idx = apIndex(m[i].getMacAddr());
|
||||
centres.push_back(access_point_list[ap_idx].getCoordinates());
|
||||
addr.push_back(m[i].getMacAddr());
|
||||
constant_term = access_point_list[ap_idx].getOutputPower() + access_point_list[ap_idx].getAntennaGain();
|
||||
constant_term += 20 * log10((300000000.0 / (float) access_point_list[ap_idx].getFrequency()) / (4*M_PI)) + 2;
|
||||
//end of expr. should be: client_list[client_idx].getAntennaGain() instead of 2.
|
||||
dist_vect.push_back(pow(10, (constant_term - m[i].getAverage()) / 35));
|
||||
}
|
||||
|
||||
/* Then: min-max */
|
||||
minmax_res = 1000000;
|
||||
for (x = MINMAX_X_START ; x < MINMAX_X_STOP ; x += MINMAX_STEP)
|
||||
for (y = MINMAX_Y_START ; y < MINMAX_Y_STOP ; y += MINMAX_STEP)
|
||||
for (z = MINMAX_Z_START ; z < MINMAX_Z_STOP ; z += MINMAX_STEP)
|
||||
{
|
||||
ap_idx = apIndex(m[i].getMacAddr());
|
||||
centres.push_back(access_point_list[ap_idx].getCoordinates());
|
||||
addr.push_back(m[i].getMacAddr());
|
||||
constant_term = access_point_list[ap_idx].getOutputPower() + access_point_list[ap_idx].getAntennaGain();
|
||||
constant_term += 20 * log10((300000000.0 / (float) access_point_list[ap_idx].getFrequency()) / (4*M_PI)) + 2;
|
||||
//end of expr. should be: client_list[client_idx].getAntennaGain() instead of 2.
|
||||
dist_vect.push_back(pow(10, (constant_term - m[i].getAverage()) / 35));
|
||||
minmax_max = 0;
|
||||
for (i = 0 ; i < centres.size() ; i++)
|
||||
if (abs(centres[i].distance(x, y, z) - dist_vect[i]) > minmax_max)
|
||||
minmax_max = abs(centres[i].distance(x, y, z) - dist_vect[i]);
|
||||
if (minmax_max < minmax_res)
|
||||
{
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.setZ(z);
|
||||
minmax_res = minmax_max;
|
||||
}
|
||||
}
|
||||
|
||||
/* Then: min-max */
|
||||
minmax_res = 1000000;
|
||||
for (x = MINMAX_X_START ; x < MINMAX_X_STOP ; x += MINMAX_STEP)
|
||||
for (y = MINMAX_Y_START ; y < MINMAX_Y_STOP ; y += MINMAX_STEP)
|
||||
for (z = MINMAX_Z_START ; z < MINMAX_Z_STOP ; z += MINMAX_STEP)
|
||||
{
|
||||
minmax_max = 0;
|
||||
for (i = 0 ; i < centres.size() ; i++)
|
||||
if (abs(centres[i].distance(x, y, z) - dist_vect[i]) > minmax_max)
|
||||
minmax_max = abs(centres[i].distance(x, y, z) - dist_vect[i]);
|
||||
if (minmax_max < minmax_res)
|
||||
{
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.setZ(z);
|
||||
minmax_res = minmax_max;
|
||||
}
|
||||
}
|
||||
/* Clear all vectors */
|
||||
addr.clear();
|
||||
dist_vect.clear();
|
||||
centres.clear();
|
||||
|
||||
/* Clear all vectors */
|
||||
addr.clear();
|
||||
dist_vect.clear();
|
||||
centres.clear();
|
||||
|
||||
/* Return position */
|
||||
return ret;
|
||||
}
|
||||
/* Return position */
|
||||
return ret;
|
||||
}
|
||||
|
||||
vector<float> Treatment::computeFriisFromRefList(const Point &p)
|
||||
{
|
||||
|
@ -358,59 +358,59 @@ vector<float> Treatment::computeFriisFromRefList(const Point &p)
|
|||
}
|
||||
|
||||
Point Treatment::getkWeightedInSs(const unsigned int &k, const Point *point_ignored)const
|
||||
{
|
||||
{
|
||||
|
||||
unsigned int i, j;
|
||||
vector<float> distances_vector;
|
||||
vector<Point> points_vector;
|
||||
float tmp_distance = 0, dist_max = 10000000;
|
||||
Point ret;
|
||||
float total = 0, x = 0, y = 0, z = 0;
|
||||
unsigned int i, j;
|
||||
vector<float> distances_vector;
|
||||
vector<Point> points_vector;
|
||||
float tmp_distance = 0, dist_max = 10000000;
|
||||
Point ret;
|
||||
float total = 0, x = 0, y = 0, z = 0;
|
||||
|
||||
for (i = 0 ; i < reference_point_list.size() ; i++)
|
||||
if (point_ignored == NULL || (reference_point_list[i].getCoordinates() != *point_ignored))
|
||||
{
|
||||
tmp_distance = reference_point_list[i].getSsSquareDistance(m);
|
||||
/* if not k points, add it */
|
||||
if (distances_vector.size() < k)
|
||||
{
|
||||
distances_vector.push_back(tmp_distance);
|
||||
points_vector.push_back(reference_point_list[i].getCoordinates());
|
||||
dist_max = (dist_max < tmp_distance) ? tmp_distance : dist_max;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if tmp_dst < dist_max, should add it and remove previous greatest dist. */
|
||||
if (dist_max > tmp_distance)
|
||||
{
|
||||
/* remove old max */
|
||||
for (j = 0 ; j < distances_vector.size() ; j++)
|
||||
if (distances_vector[j] == dist_max)
|
||||
{
|
||||
dist_max = tmp_distance;
|
||||
distances_vector.erase(distances_vector.begin() + j);
|
||||
points_vector.erase(points_vector.begin() + j);
|
||||
distances_vector.push_back(tmp_distance);
|
||||
points_vector.push_back(reference_point_list[i].getCoordinates());
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Else nothing needs to be done */
|
||||
}
|
||||
}
|
||||
for (i = 0 ; i < distances_vector.size() ; i++)
|
||||
total += (1 / distances_vector[i]);
|
||||
|
||||
for (i = 0 ; i < distances_vector.size() ; i++)
|
||||
for (i = 0 ; i < reference_point_list.size() ; i++)
|
||||
if (point_ignored == NULL || (reference_point_list[i].getCoordinates() != *point_ignored))
|
||||
{
|
||||
x += points_vector[i].getX() * (1 / distances_vector[i]) / total;
|
||||
y += points_vector[i].getY() * (1 / distances_vector[i]) / total;
|
||||
z += points_vector[i].getZ() * (1 / distances_vector[i]) / total;
|
||||
tmp_distance = reference_point_list[i].getSsSquareDistance(m);
|
||||
/* if not k points, add it */
|
||||
if (distances_vector.size() < k)
|
||||
{
|
||||
distances_vector.push_back(tmp_distance);
|
||||
points_vector.push_back(reference_point_list[i].getCoordinates());
|
||||
dist_max = (dist_max < tmp_distance) ? tmp_distance : dist_max;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if tmp_dst < dist_max, should add it and remove previous greatest dist. */
|
||||
if (dist_max > tmp_distance)
|
||||
{
|
||||
/* remove old max */
|
||||
for (j = 0 ; j < distances_vector.size() ; j++)
|
||||
if (distances_vector[j] == dist_max)
|
||||
{
|
||||
dist_max = tmp_distance;
|
||||
distances_vector.erase(distances_vector.begin() + j);
|
||||
points_vector.erase(points_vector.begin() + j);
|
||||
distances_vector.push_back(tmp_distance);
|
||||
points_vector.push_back(reference_point_list[i].getCoordinates());
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Else nothing needs to be done */
|
||||
}
|
||||
}
|
||||
for (i = 0 ; i < distances_vector.size() ; i++)
|
||||
total += (1 / distances_vector[i]);
|
||||
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.setZ(z);
|
||||
for (i = 0 ; i < distances_vector.size() ; i++)
|
||||
{
|
||||
x += points_vector[i].getX() * (1 / distances_vector[i]) / total;
|
||||
y += points_vector[i].getY() * (1 / distances_vector[i]) / total;
|
||||
z += points_vector[i].getZ() * (1 / distances_vector[i]) / total;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.setZ(z);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -8,38 +8,38 @@
|
|||
#include "libowlps-positioning.hh"
|
||||
|
||||
class Treatment
|
||||
{
|
||||
private:
|
||||
vector<AccessPoint> access_point_list;
|
||||
vector<ReferencePoint> reference_point_list;
|
||||
vector<Measurement> m;
|
||||
|
||||
public:
|
||||
Treatment(vector<AccessPoint> access_point, vector<ReferencePoint> reference_point)
|
||||
{
|
||||
private:
|
||||
vector<AccessPoint> access_point_list;
|
||||
vector<ReferencePoint> reference_point_list;
|
||||
vector<Measurement> m;
|
||||
|
||||
public:
|
||||
Treatment(vector<AccessPoint> access_point, vector<ReferencePoint> reference_point)
|
||||
{
|
||||
access_point_list = access_point;
|
||||
reference_point_list = reference_point;
|
||||
};
|
||||
~Treatment()
|
||||
{
|
||||
access_point_list.clear();
|
||||
m.clear();
|
||||
reference_point_list.clear();
|
||||
};
|
||||
|
||||
bool apExists(const string &)const;
|
||||
unsigned int apIndex(const string &)const;
|
||||
void makeMeasurementList(vector<couple_info>);
|
||||
|
||||
vector<Point> getkClosestInSs(const unsigned int &k, const Point *point_ignored)const;
|
||||
|
||||
Point kPointsAverage(const vector<Point> &vp)const;
|
||||
Point fbcm(const int &client_idx)const;
|
||||
Point fbcm_friis(const vector<float> friis_idx_list, const float &z)const;
|
||||
Point interlink(const int &client_idx)const;
|
||||
|
||||
vector<float> computeFriisFromRefList(const Point &p);
|
||||
Point getkWeightedInSs(const unsigned int &k, const Point *point_ignored)const ;
|
||||
access_point_list = access_point;
|
||||
reference_point_list = reference_point;
|
||||
};
|
||||
~Treatment()
|
||||
{
|
||||
access_point_list.clear();
|
||||
m.clear();
|
||||
reference_point_list.clear();
|
||||
};
|
||||
|
||||
bool apExists(const string &)const;
|
||||
unsigned int apIndex(const string &)const;
|
||||
void makeMeasurementList(vector<couple_info>);
|
||||
|
||||
vector<Point> getkClosestInSs(const unsigned int &k, const Point *point_ignored)const;
|
||||
|
||||
Point kPointsAverage(const vector<Point> &vp)const;
|
||||
Point fbcm(const int &client_idx)const;
|
||||
Point fbcm_friis(const vector<float> friis_idx_list, const float &z)const;
|
||||
Point interlink(const int &client_idx)const;
|
||||
|
||||
vector<float> computeFriisFromRefList(const Point &p);
|
||||
Point getkWeightedInSs(const unsigned int &k, const Point *point_ignored)const ;
|
||||
};
|
||||
|
||||
#endif // _TREATMENT_HH_
|
||||
|
|
Loading…
Reference in New Issue