2012-02-06 16:44:09 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Owl Positioning System (OwlPS).
|
2012-11-03 14:52:33 +01:00
|
|
|
* OwlPS is a project of the University of Franche-Comte
|
2012-02-06 16:44:09 +01:00
|
|
|
* (Université de Franche-Comté), France.
|
2012-11-03 14:52:33 +01:00
|
|
|
*
|
|
|
|
* Copyright © Université de Franche-Comté 2007-2012.
|
|
|
|
*
|
|
|
|
* Corresponding author: Matteo Cypriani <mcy@lm7.fr>
|
|
|
|
*
|
|
|
|
***********************************************************************
|
|
|
|
*
|
|
|
|
* This software is governed by the CeCILL license under French law and
|
|
|
|
* abiding by the rules of distribution of free software. You can use,
|
|
|
|
* modify and/or redistribute the software under the terms of the CeCILL
|
|
|
|
* license as circulated by CEA, CNRS and INRIA at the following URL:
|
|
|
|
* http://www.cecill.info
|
|
|
|
*
|
|
|
|
* As a counterpart to the access to the source code and rights to copy,
|
|
|
|
* modify and redistribute granted by the license, users are provided
|
|
|
|
* only with a limited warranty and the software's authors, the holder
|
|
|
|
* of the economic rights, and the successive licensors have only
|
|
|
|
* limited liability.
|
|
|
|
*
|
|
|
|
* In this respect, the user's attention is drawn to the risks
|
|
|
|
* associated with loading, using, modifying and/or developing or
|
|
|
|
* reproducing the software by the user in light of its specific status
|
|
|
|
* of free software, that may mean that it is complicated to manipulate,
|
|
|
|
* and that also therefore means that it is reserved for developers and
|
|
|
|
* experienced professionals having in-depth computer knowledge. Users
|
|
|
|
* are therefore encouraged to load and test the software's suitability
|
|
|
|
* as regards their requirements in conditions enabling the security of
|
|
|
|
* their systems and/or data to be ensured and, more generally, to use
|
|
|
|
* and operate it in the same conditions as regards security.
|
|
|
|
*
|
|
|
|
* The fact that you are presently reading this means that you have had
|
|
|
|
* knowledge of the CeCILL license and that you accept its terms.
|
|
|
|
*
|
|
|
|
***********************************************************************
|
2012-02-06 16:44:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-12-07 16:03:53 +01:00
|
|
|
#ifndef _OWLPS_POSITIONING_REFERENCEPOINT_HH_
|
|
|
|
#define _OWLPS_POSITIONING_REFERENCEPOINT_HH_
|
|
|
|
|
2010-06-14 17:15:48 +02:00
|
|
|
class AccessPoint ;
|
2010-02-16 19:31:25 +01:00
|
|
|
class CalibrationRequest ;
|
2010-06-02 12:37:43 +02:00
|
|
|
class Request ;
|
2010-01-06 01:18:14 +01:00
|
|
|
|
2009-12-07 16:03:53 +01:00
|
|
|
#include "point3d.hh"
|
2012-02-28 12:51:01 +01:00
|
|
|
#include "measurement.hh"
|
2008-04-11 10:11:29 +02:00
|
|
|
|
|
|
|
#include <vector>
|
2010-01-06 01:18:14 +01:00
|
|
|
#include <ostream>
|
[Positioning] Some ReferencePoint code -> PosUtil
ReferencePoint::complete_with_dummy_measurements(
map<string, Measurement>,
map<string, Measurement>)
becomes PosUtil::complete_with_dummy_measurements(
unordered_map<string, Measurement>,
unordered_map<string, Measurement>)
ReferencePoint::compute_ss_square_distance(
map<string, Measurement>,
map<string, Measurement>)
becomes PosUtil::ss_square_distance(
unordered_map<string, Measurement>,
unordered_map<string, Measurement>)
map<string, Measurement> ReferencePoint::get_all_measurements_sorted()
is now private, returns an unordered_map instead of a map, and is
renamed ReferencePoint::get_all_measurements().
Note that we now use unordered_maps for these functions. The use of
sorted lists (maps) was useless, as stated in the commit message of
e9eab687 (Wed Jun 2 12:37:43 2010 +0200).
2011-05-09 15:19:01 +02:00
|
|
|
#include <boost/tr1/unordered_map.hpp>
|
Incorporation de la dernière version de Julien
Extrait de son courriel :
« Par rapport à la précédente j'ai surtout corrigé des bugs. »
Note : la version du listener portable sur Fonera, envoyée en même temps
par Julien, viendra plus tard (le temps que je l'incorpore).
Détail des changements après analyse du code :
aggregator : correction de bogues.
positioning :
* Ajout d'un fichier de config format boost (cfg/config.cfg).
* Makefile : implantation des cibles "install" et "uninstall" ; la cible
"astyle" devient "style".
* accesspoint.{hh,cc}, area.cc, measurement.hh, point.{hh,cc},
referencepoint.{hh,cc} : cosmétique.
* owlps-positioning.c : correction de la lecture du fichier de config
(ajout d'une option permettant de spécifier un fichier alternatif).
* server.cc : essentiellement correction des requêtes.
* libowlps-positioning.{hh,cc} : passage de "unsigned long long" à
"uint64_t" comme type de retour de timeval_to_ms().
writeInDb :
* Ajout de la gestion d'un fichier de config.
* Ajout de deux scripts pour la BDD.
git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@96 785a6c6c-259e-4ff1-8b91-dc31627914f0
2009-07-01 15:39:58 +02:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Represents a reference point in 3-D space
|
2009-12-07 16:03:53 +01:00
|
|
|
class ReferencePoint: public Point3D
|
2010-05-21 10:35:15 +02:00
|
|
|
{
|
|
|
|
protected:
|
2010-02-16 19:31:25 +01:00
|
|
|
/// List of CalibrationRequest associated with the ReferencePoint
|
|
|
|
/** Note that \em requests is a \em pointer list: only pointers
|
2010-01-16 12:23:07 +01:00
|
|
|
are stored, not values. */
|
2010-02-16 19:31:25 +01:00
|
|
|
std::vector<CalibrationRequest*> requests ;
|
2010-05-21 10:35:15 +02:00
|
|
|
|
[Positioning] Some ReferencePoint code -> PosUtil
ReferencePoint::complete_with_dummy_measurements(
map<string, Measurement>,
map<string, Measurement>)
becomes PosUtil::complete_with_dummy_measurements(
unordered_map<string, Measurement>,
unordered_map<string, Measurement>)
ReferencePoint::compute_ss_square_distance(
map<string, Measurement>,
map<string, Measurement>)
becomes PosUtil::ss_square_distance(
unordered_map<string, Measurement>,
unordered_map<string, Measurement>)
map<string, Measurement> ReferencePoint::get_all_measurements_sorted()
is now private, returns an unordered_map instead of a map, and is
renamed ReferencePoint::get_all_measurements().
Note that we now use unordered_maps for these functions. The use of
sorted lists (maps) was useless, as stated in the commit message of
e9eab687 (Wed Jun 2 12:37:43 2010 +0200).
2011-05-09 15:19:01 +02:00
|
|
|
/** @name Read accessors */
|
2010-06-02 12:37:43 +02:00
|
|
|
//@{
|
[Positioning] Some ReferencePoint code -> PosUtil
ReferencePoint::complete_with_dummy_measurements(
map<string, Measurement>,
map<string, Measurement>)
becomes PosUtil::complete_with_dummy_measurements(
unordered_map<string, Measurement>,
unordered_map<string, Measurement>)
ReferencePoint::compute_ss_square_distance(
map<string, Measurement>,
map<string, Measurement>)
becomes PosUtil::ss_square_distance(
unordered_map<string, Measurement>,
unordered_map<string, Measurement>)
map<string, Measurement> ReferencePoint::get_all_measurements_sorted()
is now private, returns an unordered_map instead of a map, and is
renamed ReferencePoint::get_all_measurements().
Note that we now use unordered_maps for these functions. The use of
sorted lists (maps) was useless, as stated in the commit message of
e9eab687 (Wed Jun 2 12:37:43 2010 +0200).
2011-05-09 15:19:01 +02:00
|
|
|
std::tr1::unordered_map<std::string, Measurement>
|
|
|
|
get_all_measurements(void) const ;
|
2011-06-15 15:17:01 +02:00
|
|
|
/// Returns all the measurements sent by the given mobile
|
|
|
|
std::tr1::unordered_map<std::string, Measurement>
|
|
|
|
get_all_measurements(const std::string &mac_transmitter) const ;
|
2010-06-02 12:37:43 +02:00
|
|
|
//@}
|
|
|
|
|
2010-05-21 10:35:15 +02:00
|
|
|
public:
|
2010-06-02 12:37:43 +02:00
|
|
|
ReferencePoint(const float &_x = 0,
|
|
|
|
const float &_y = 0,
|
|
|
|
const float &_z = 0): Point3D(_x, _y, _z) {}
|
2010-03-05 17:24:18 +01:00
|
|
|
|
2009-12-07 16:03:53 +01:00
|
|
|
ReferencePoint(const Point3D &p): Point3D(p) {}
|
2010-03-05 17:24:18 +01:00
|
|
|
|
2010-02-16 19:31:25 +01:00
|
|
|
ReferencePoint(const ReferencePoint &source):
|
|
|
|
Point3D(source), requests(source.requests) {}
|
2009-12-07 16:03:53 +01:00
|
|
|
|
2010-03-05 17:24:18 +01:00
|
|
|
~ReferencePoint(void) ;
|
2009-12-07 16:03:53 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/** @name Read accessors */
|
|
|
|
//@{
|
2011-12-27 12:07:26 +01:00
|
|
|
/// Returns all the calibration requests
|
2010-02-16 19:31:25 +01:00
|
|
|
const std::vector<CalibrationRequest*>& get_requests(void) const ;
|
2011-12-27 12:07:26 +01:00
|
|
|
/// Returns the calibration requests sent by the given mobile
|
|
|
|
const std::vector<CalibrationRequest*> get_requests(
|
|
|
|
const std::string &mac_transmitter) const ;
|
|
|
|
/// \brief Returns the average SS of all the packets sent by
|
|
|
|
/// \em mac_transmitter
|
2011-06-15 15:17:01 +02:00
|
|
|
double average_measurements(const std::string &mac_transmitter) const ;
|
2010-01-16 12:23:07 +01:00
|
|
|
//@}
|
2009-12-07 16:03:53 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/** @name Write accessors */
|
|
|
|
//@{
|
2010-02-16 19:31:25 +01:00
|
|
|
/// Adds a Request to the \link #requests request list\endlink
|
2011-07-22 10:04:32 +02:00
|
|
|
void add_request(const CalibrationRequest *r) ;
|
2012-05-27 22:45:28 +02:00
|
|
|
/// Deletes a Request from the \link #requests request list\endlink
|
|
|
|
void delete_request(const CalibrationRequest *r) ;
|
2011-06-20 11:43:17 +02:00
|
|
|
/// Deletes all the requests contained in #requests
|
|
|
|
void delete_requests(void) ;
|
2011-07-21 21:39:54 +02:00
|
|
|
/// Deletes the requests that are not sent by an AP
|
|
|
|
bool delete_generated_requests(void) ;
|
2010-06-02 12:37:43 +02:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/** @name Operations */
|
|
|
|
//@{
|
2012-03-02 11:48:40 +01:00
|
|
|
/// Computes the similarity of the ReferencePoint and a Request
|
|
|
|
float similarity(const Request &source) const ;
|
2011-06-14 16:44:17 +02:00
|
|
|
/// Computes the Friis index for the given AccessPoint
|
2010-06-14 17:15:48 +02:00
|
|
|
float friis_index_for_ap(const std::string &ap_mac) const ;
|
2011-06-14 16:44:17 +02:00
|
|
|
/// Computes the Friis indexes sum for the given AccessPoint
|
2010-06-14 17:15:48 +02:00
|
|
|
float friis_indexes_for_ap(
|
|
|
|
const AccessPoint &ap, const double &const_term,
|
|
|
|
int &nb_indexes) const ;
|
2012-02-28 12:51:01 +01:00
|
|
|
/// Computes the Friis index for the given AccessPoint and packet ID
|
|
|
|
float friis_index_for_ap(
|
|
|
|
const std::string &ap_mac, pkt_id_t pkt_id) const ;
|
2010-01-16 12:23:07 +01:00
|
|
|
//@}
|
2009-12-07 16:03:53 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/** @name Operators */
|
|
|
|
//@{
|
2011-07-30 20:38:42 +02:00
|
|
|
ReferencePoint& operator=(const ReferencePoint &source) ;
|
2010-02-16 19:31:25 +01:00
|
|
|
bool operator==(const ReferencePoint &source) const ;
|
|
|
|
bool operator!=(const ReferencePoint &source) const ;
|
2010-01-16 12:23:07 +01:00
|
|
|
//@}
|
2009-12-07 16:03:53 +01:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Displays a ReferencePoint
|
2012-02-28 12:51:01 +01:00
|
|
|
friend std::ostream &operator<<(
|
|
|
|
std::ostream &os, const ReferencePoint &rp) ;
|
2010-06-07 15:09:22 +02:00
|
|
|
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Hashes a ReferencePoint
|
2010-06-07 15:09:22 +02:00
|
|
|
friend std::size_t hash_value(const ReferencePoint &source) ;
|
2009-12-07 16:03:53 +01:00
|
|
|
} ;
|
|
|
|
|
2010-01-05 11:50:24 +01:00
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Read accessors *** */
|
2010-01-05 11:50:24 +01:00
|
|
|
|
|
|
|
|
2010-01-13 15:29:44 +01:00
|
|
|
inline const
|
2010-02-16 19:31:25 +01:00
|
|
|
std::vector<CalibrationRequest*>& ReferencePoint::get_requests() const
|
2010-01-05 11:50:24 +01:00
|
|
|
{
|
2010-02-16 19:31:25 +01:00
|
|
|
return requests ;
|
2010-01-05 11:50:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Write accessors *** */
|
2010-01-05 11:50:24 +01:00
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/**
|
2011-07-22 10:04:32 +02:00
|
|
|
* @param r A pointer to the CalibrationRequest to add. If it is
|
2010-01-16 12:23:07 +01:00
|
|
|
* NULL, nothing will be done.
|
|
|
|
* The memory pointed by this pointer must not be deallocated before
|
|
|
|
* the ReferencePoint destruction (do \em not pass a pointer to a local
|
|
|
|
* variable!).
|
|
|
|
*/
|
2011-07-22 10:04:32 +02:00
|
|
|
inline void ReferencePoint::add_request(const CalibrationRequest *r)
|
2010-01-05 11:50:24 +01:00
|
|
|
{
|
2011-07-22 10:04:32 +02:00
|
|
|
if (r != NULL)
|
|
|
|
requests.push_back(const_cast<CalibrationRequest*>(r)) ;
|
2010-01-05 11:50:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Operators *** */
|
2010-01-05 11:50:24 +01:00
|
|
|
|
|
|
|
|
2010-02-16 19:31:25 +01:00
|
|
|
inline bool ReferencePoint::operator!=(const ReferencePoint &source) const
|
2010-01-05 11:50:24 +01:00
|
|
|
{
|
2010-02-16 19:31:25 +01:00
|
|
|
return !(*this == source) ;
|
2010-01-05 11:50:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-07 14:08:34 +02:00
|
|
|
struct reference_point_equal_to:
|
|
|
|
public std::binary_function<ReferencePoint, ReferencePoint, bool>
|
|
|
|
{
|
|
|
|
bool operator()(const ReferencePoint &source1,
|
|
|
|
const ReferencePoint &source2) const
|
|
|
|
{
|
|
|
|
return
|
|
|
|
static_cast<Point3D>(source1) == static_cast<Point3D>(source2) ;
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-07 16:03:53 +01:00
|
|
|
#endif // _OWLPS_POSITIONING_REFERENCEPOINT_HH_
|