[Positioning] Makefile & Compilation fixes
- Updated Makefile to be able to compile each class. - Fixed some compilation errors (CalibrationMeasurement, Point3D, ReferencePoint, WayPoint) and a warning in Measurement.
This commit is contained in:
parent
326f1245ed
commit
d257d08d8d
|
@ -20,40 +20,49 @@ LIBS = -lpq -lboost_program_options-mt
|
|||
|
||||
TARGET = owlps-positioning
|
||||
HEADER = owlps-positioning.hh
|
||||
OBJ = posutil.o point3d.o referencepoint.o waypoint.o building.o area.o wifidevice.o accesspoint.o mobile.o measurement.o calibrationmeasurement.o
|
||||
|
||||
all : ${TARGET}
|
||||
all: $(TARGET)
|
||||
|
||||
% : %.o
|
||||
%: %.o
|
||||
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
%.o : %.cc $(HEADER)
|
||||
%.o: %.cc $(HEADER)
|
||||
$(GXX) $(GXXFLAGS) -c $<
|
||||
|
||||
libowlps-positioning.o : libowlps-positioning.hh
|
||||
positioning.o : point.hh referencepoint.hh accesspoint.hh area.hh measurement.hh libowlps-positioning.hh
|
||||
server.o : server.hh positioning.hh point.hh measurement.hh treatment.hh libowlps-positioning.hh
|
||||
referencepoint.o : referencepoint.hh measurement.hh point.hh
|
||||
accesspoint.o : accesspoint.hh point.hh
|
||||
point.o : point.hh
|
||||
measurement.o : measurement.hh
|
||||
area.o : area.hh point.hh
|
||||
treatment.o : treatment.hh point.hh measurement.hh referencepoint.hh accesspoint.hh libowlps-positioning.hh
|
||||
owlps-positioning.o : server.hh
|
||||
posutil.o: posutil.hh
|
||||
point3d.o: point3d.hh
|
||||
referencepoint.o : referencepoint.hh point3d.hh calibrationmeasurement.hh
|
||||
waypoint.o: point3d.hh building.hh
|
||||
building.o: building.hh
|
||||
area.o: area.hh building.hh point3d.hh
|
||||
wifidevice.o: wifidevice.hh posutil.hh
|
||||
accesspoint.o: accesspoint.hh wifidevice.hh point3d.hh
|
||||
mobile.o: mobile.hh wifidevice.hh
|
||||
measurement.o: measurement.hh mobile.hh accesspoint.hh
|
||||
calibrationmeasurement.o: calibrationmeasurement.hh measurement.hh referencepoint.hh
|
||||
#libowlps-positioning.o: libowlps-positioning.hh
|
||||
#positioning.o: point.hh referencepoint.hh accesspoint.hh area.hh measurement.hh libowlps-positioning.hh
|
||||
#server.o: server.hh positioning.hh point.hh measurement.hh treatment.hh libowlps-positioning.hh
|
||||
#owlps-positioning.o: server.hh
|
||||
#treatment.o: treatment.hh point.hh measurement.hh referencepoint.hh accesspoint.hh libowlps-positioning.hh
|
||||
|
||||
${TARGET} : point.o measurement.o accesspoint.o referencepoint.o positioning.o server.o area.o treatment.o libowlps-positioning.o owlps-positioning.o
|
||||
obj: $(OBJ)
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
|
||||
clean:
|
||||
@rm -fv *~ *.o *.gch *.orig
|
||||
|
||||
purge : clean
|
||||
purge: clean
|
||||
@rm -f $(TARGET)
|
||||
|
||||
install : $(TARGET)
|
||||
install: $(TARGET)
|
||||
@$(CP) $(TARGET) $(INSTALL_DIR) && \
|
||||
chmod 755 $(INSTALL_DIR)/$(TARGET) && \
|
||||
chown root:root $(INSTALL_DIR)/$(TARGET)
|
||||
|
||||
uninstall :
|
||||
uninstall:
|
||||
@$(RM) $(INSTALL_DIR)/$(TARGET)
|
||||
|
||||
style :
|
||||
@$(STYLE) *.cc *.hh
|
||||
style:
|
||||
@$(STYLE) $(OBJ:.o=.hh) $(OBJ:.o=.cc)
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
- AccessPoint : attribut float friis_index ?
|
||||
|
||||
- Mobile : attributs Viterbi ?
|
||||
Cf. l'ancien clientinfo.hh.
|
||||
|
||||
- Accesseurs par références ?
|
||||
getref_mon_attribut() (cf. l'ancien clientinfo.hh)
|
||||
|
|
|
@ -59,6 +59,7 @@ bool CalibrationMeasurement::operator!=(const CalibrationMeasurement &cm)
|
|||
ostream &operator<<(ostream &os, const CalibrationMeasurement &cm)
|
||||
{
|
||||
os
|
||||
<< (Measurement) cm
|
||||
<< "Reference point: " << *cm.reference_point ;
|
||||
<< (Measurement) cm ;
|
||||
|
||||
return os ;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
#ifndef _OWLPS_POSITIONING_CALIBRATIONMEASUREMENT_HH_
|
||||
#define _OWLPS_POSITIONING_CALIBRATIONMEASUREMENT_HH_
|
||||
|
||||
class ReferencePoint ;
|
||||
|
||||
#include "measurement.hh"
|
||||
#include "referencepoint.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
class CalibrationMeasurement: public Measurement
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ void Measurement::update_average_ss()
|
|||
{
|
||||
average_ss = 0 ;
|
||||
|
||||
for (int i=0 ; i < ss_list.size() ; i++)
|
||||
for (unsigned int i=0 ; i < ss_list.size() ; i++)
|
||||
{
|
||||
float ss_mwatts =
|
||||
pow(10, (float) ss_list[i] / 10.0) +
|
||||
|
@ -150,15 +150,15 @@ ostream &operator<<(ostream &os, const Measurement &m)
|
|||
|
||||
os << m.mobile->get_mac_addr() << "->" << m.ap->get_mac_addr() << ": " ;
|
||||
if (m.ss_list.size() == 0)
|
||||
os << "No values";
|
||||
os << "No values" ;
|
||||
else
|
||||
for (i = 0 ; i < m.ss_list.size() ; i++)
|
||||
{
|
||||
os << m.ss_list[i];
|
||||
if (i < m.ss_list.size() - 1)
|
||||
os << ";";
|
||||
os << ";" ;
|
||||
}
|
||||
os << " [AVG=" << m.average_ss << "]";
|
||||
os << " [AVG=" << m.average_ss << "]" ;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ Point3D::Point3D(const float &_x, const float &_y, const float &_z)
|
|||
x = _x ;
|
||||
y = _y ;
|
||||
z = _z ;
|
||||
} ;
|
||||
}
|
||||
|
||||
|
||||
Point3D::Point3D(const Point3D &p)
|
||||
|
|
|
@ -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
|
||||
{
|
||||
return access_point_list;
|
||||
};
|
||||
vector<ReferencePoint> getReferencePointList() const
|
||||
{
|
||||
return reference_point_list;
|
||||
};
|
||||
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).
|
||||
|
||||
void printReferencePointList();
|
||||
void printPointList(vector<ReferencePoint> &point_list);
|
||||
void printAccessPointList() const;
|
||||
void printAreatList();
|
||||
};
|
||||
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();
|
||||
};
|
||||
|
||||
#endif // _POSITIONING_HH_
|
||||
|
|
|
@ -15,7 +15,7 @@ ReferencePoint::~ReferencePoint()
|
|||
/*** Accesseurs lecture ***/
|
||||
|
||||
|
||||
vector<CalibrationMeasurement> ReferencePoint::get_measurements() const
|
||||
vector<CalibrationMeasurement*> ReferencePoint::get_measurements() const
|
||||
{
|
||||
return measurements ;
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ vector<CalibrationMeasurement> ReferencePoint::get_measurements() const
|
|||
/*** Accesseurs écriture ***/
|
||||
|
||||
|
||||
void ReferencePoint::add_measurement(const CalibrationMeasurement &cm)
|
||||
void ReferencePoint::add_measurement(const CalibrationMeasurement *cm)
|
||||
{
|
||||
measurements.push_back(cm) ;
|
||||
measurements.push_back((CalibrationMeasurement *) cm) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,7 +154,7 @@ ReferencePoint ReferencePoint::operator=(const ReferencePoint &rp)
|
|||
}
|
||||
|
||||
|
||||
ReferencePoint ReferencePoint::operator==(const ReferencePoint &rp) const
|
||||
bool ReferencePoint::operator==(const ReferencePoint &rp) const
|
||||
{
|
||||
if (this == &rp)
|
||||
return true ;
|
||||
|
@ -165,7 +165,7 @@ ReferencePoint ReferencePoint::operator==(const ReferencePoint &rp) const
|
|||
}
|
||||
|
||||
|
||||
ReferencePoint ReferencePoint::operator!=(const ReferencePoint &rp) const
|
||||
bool ReferencePoint::operator!=(const ReferencePoint &rp) const
|
||||
{
|
||||
return !(*this == rp) ;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ ostream &operator<<(ostream &os, ReferencePoint &rp)
|
|||
os << "No measurement." << endl ;
|
||||
else
|
||||
for (i = 0 ; i < rp.measurements.size() ; i++)
|
||||
os << endl << rp.measurements[i] ;
|
||||
os << endl << *rp.measurements[i] ;
|
||||
|
||||
return os ;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ using namespace std ;
|
|||
class ReferencePoint: public Point3D
|
||||
{
|
||||
protected:
|
||||
vector<CalibrationMeasurement> measurements ;
|
||||
vector<CalibrationMeasurement*> measurements ;
|
||||
|
||||
public:
|
||||
ReferencePoint(const float &_x = 0, const float &_y = 0, const float &_z = 0):
|
||||
|
@ -23,15 +23,15 @@ public:
|
|||
|
||||
~ReferencePoint() ;
|
||||
|
||||
vector<CalibrationMeasurement> get_measurements() const ;
|
||||
vector<CalibrationMeasurement*> get_measurements() const ;
|
||||
|
||||
void add_measurement(const CalibrationMeasurement &cm) ;
|
||||
void add_measurement(const CalibrationMeasurement *cm) ;
|
||||
// float get_ss_square_distance(const vector<CalibrationMeasurement> &m) const ;
|
||||
// bool get_power_for_ap(const string &ap_mac, float *p) const ;
|
||||
|
||||
ReferencePoint operator=(const ReferencePoint &rp) ;
|
||||
ReferencePoint operator==(const ReferencePoint &rp) const ;
|
||||
ReferencePoint operator!=(const ReferencePoint &rp) const ;
|
||||
bool operator==(const ReferencePoint &rp) const ;
|
||||
bool operator!=(const ReferencePoint &rp) const ;
|
||||
|
||||
friend ostream &operator<<(ostream &os, ReferencePoint &rp) ;
|
||||
} ;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
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 *);
|
||||
};
|
||||
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 *);
|
||||
};
|
||||
|
||||
#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,111 +76,167 @@ 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))
|
||||
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++)
|
||||
{
|
||||
tmp_distance = reference_point_list[i].getSsSquareDistance(m);
|
||||
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 not k points, add it */
|
||||
if (distances_vector.size() < k)
|
||||
if (min_idx != i)
|
||||
{
|
||||
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 */
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
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()))
|
||||
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++)
|
||||
{
|
||||
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;
|
||||
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)
|
||||
for (z = MINMAX_Z_START ; z <= MINMAX_Z_STOP ; z += 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)
|
||||
{
|
||||
minmax_max = 0;
|
||||
for (i = 0 ; i < centres.size() ; i++)
|
||||
|
@ -195,121 +251,65 @@ Point Treatment::fbcm(const int &client_idx)const
|
|||
}
|
||||
}
|
||||
|
||||
/* Clear all vectors */
|
||||
addr.clear();
|
||||
dist_vect.clear();
|
||||
centres.clear();
|
||||
/* Clear all vectors */
|
||||
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++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
/* 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()))
|
||||
{
|
||||
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)
|
||||
i = 0;
|
||||
for (i = 0 ; i < m.size() ; i++)
|
||||
if (apExists(m[i].getMacAddr()))
|
||||
{
|
||||
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;
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
/* Clear all vectors */
|
||||
addr.clear();
|
||||
dist_vect.clear();
|
||||
centres.clear();
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return position */
|
||||
return ret;
|
||||
}
|
||||
/* Clear all vectors */
|
||||
addr.clear();
|
||||
dist_vect.clear();
|
||||
centres.clear();
|
||||
|
||||
/* 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))
|
||||
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++)
|
||||
{
|
||||
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 */
|
||||
}
|
||||
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;
|
||||
}
|
||||
for (i = 0 ; i < distances_vector.size() ; i++)
|
||||
total += (1 / distances_vector[i]);
|
||||
|
||||
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;
|
||||
}
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.setZ(z);
|
||||
|
||||
ret.setX(x);
|
||||
ret.setY(y);
|
||||
ret.setZ(z);
|
||||
|
||||
return ret;
|
||||
}
|
||||
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)
|
||||
{
|
||||
access_point_list = access_point;
|
||||
reference_point_list = 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 ;
|
||||
};
|
||||
~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_
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef _OWLPS_POSITIONING_WAYPOINT_HH_
|
||||
#define _OWLPS_POSITIONING_WAYPOINT_HH_
|
||||
|
||||
#include "building.hh"
|
||||
#include "point3d.hh"
|
||||
#include "building.hh"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
@ -24,7 +24,7 @@ public:
|
|||
Building* get_1st_building(void) const ;
|
||||
vector<Building*> get_buildings(void) const ;
|
||||
|
||||
void add_building(const Building &_b) ;
|
||||
void add_building(const Building *_b) ;
|
||||
|
||||
Waypoint operator=(const Waypoint &wp) ;
|
||||
bool operator==(const Waypoint &wp) const ;
|
||||
|
|
Loading…
Reference in New Issue