2012-02-06 16:44:09 +01:00
|
|
|
/*
|
2013-05-29 18:43:35 +02:00
|
|
|
* This file is part of the Owl Positioning System (OwlPS) project.
|
|
|
|
* It is subject to the copyright notice and license terms in the
|
|
|
|
* COPYRIGHT.t2t file found in the top-level directory of this
|
|
|
|
* distribution and at
|
2016-11-03 05:10:34 +01:00
|
|
|
* https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
|
2013-05-29 18:43:35 +02:00
|
|
|
* No part of the OwlPS Project, including this file, may be copied,
|
|
|
|
* modified, propagated, or distributed except according to the terms
|
|
|
|
* contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
|
|
|
|
* distributed along with this file, either separately or by replacing
|
2013-06-22 23:30:17 +02:00
|
|
|
* this notice by the COPYRIGHT.t2t file's contents.
|
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_
|
|
|
|
|
2013-06-14 21:54:26 +02:00
|
|
|
class CapturePoint ;
|
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>
|
2013-05-30 20:13:44 +02:00
|
|
|
#include <unordered_map>
|
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
|
2013-05-30 21:23:05 +02:00
|
|
|
/** Note that `requests` is a *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
|
|
|
//@{
|
2016-11-05 03:02:30 +01:00
|
|
|
/// Returns all the measurements of all the calibration #requests
|
2013-05-30 20:13:44 +02:00
|
|
|
std::unordered_map<std::string, Measurement>
|
[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
|
|
|
get_all_measurements(void) const ;
|
2011-06-15 15:17:01 +02:00
|
|
|
/// Returns all the measurements sent by the given mobile
|
2013-05-30 20:13:44 +02:00
|
|
|
std::unordered_map<std::string, Measurement>
|
2011-06-15 15:17:01 +02:00
|
|
|
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:
|
2013-10-02 20:50:39 +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
|
|
|
|
2016-11-05 03:02:30 +01:00
|
|
|
explicit 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 ;
|
2013-06-04 00:39:10 +02:00
|
|
|
/// Returns the average SS of all the packets sent by `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 */
|
|
|
|
//@{
|
2013-05-30 21:23:05 +02:00
|
|
|
/// Adds a Request to the [requests' list](@ref #requests)
|
2013-10-02 20:38:45 +02:00
|
|
|
void add_request(const CalibrationRequest *const r) ;
|
2013-05-30 21:23:05 +02:00
|
|
|
/// Deletes a Request from the [requests' list](@ref #requests)
|
2013-10-02 20:38:45 +02:00
|
|
|
void delete_request(const CalibrationRequest *const r) ;
|
2011-06-20 11:43:17 +02:00
|
|
|
/// Deletes all the requests contained in #requests
|
|
|
|
void delete_requests(void) ;
|
2013-06-14 21:54:26 +02:00
|
|
|
/// Deletes the requests that are not sent by a CP
|
2011-07-21 21:39:54 +02:00
|
|
|
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 ;
|
2013-06-14 21:54:26 +02:00
|
|
|
/// Computes the Friis index for the given CapturePoint
|
|
|
|
float friis_index_for_cp(const std::string &cp_mac) const ;
|
|
|
|
/// Computes the Friis indexes sum for the given CapturePoint
|
2013-10-02 20:50:39 +02:00
|
|
|
float friis_indexes_for_cp(const CapturePoint &cp,
|
|
|
|
const double const_term,
|
|
|
|
int &nb_indexes) const ;
|
2013-06-14 21:54:26 +02:00
|
|
|
/// Computes the Friis index for the given CapturePoint and packet ID
|
|
|
|
float friis_index_for_cp(
|
2013-10-02 20:38:45 +02:00
|
|
|
const std::string &cp_mac, const 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) ;
|
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
|
2014-05-13 23:50:53 +02:00
|
|
|
* null, nothing will be done.
|
2010-01-16 12:23:07 +01:00
|
|
|
* The memory pointed by this pointer must not be deallocated before
|
2013-05-30 21:23:05 +02:00
|
|
|
* the ReferencePoint destruction (do *not* pass a pointer to a local
|
2010-01-16 12:23:07 +01:00
|
|
|
* 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
|
|
|
{
|
2014-05-13 23:29:08 +02:00
|
|
|
if (r)
|
2011-07-22 10:04:32 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-30 20:13:44 +02:00
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template<> struct hash<ReferencePoint>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* This is a simple call to the hash function for Point3D, because we
|
|
|
|
* do not want to take care of the CalibrationRequest list to hash the
|
|
|
|
* ReferencePoint.
|
|
|
|
*/
|
|
|
|
size_t operator()(const ReferencePoint &source) const
|
|
|
|
{
|
|
|
|
hash<Point3D> h ;
|
|
|
|
return h(source) ;
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
template<> struct equal_to<ReferencePoint>
|
2011-06-07 14:08:34 +02:00
|
|
|
{
|
2013-05-30 20:13:44 +02:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* We want to take into account only the coordinates when comparing
|
|
|
|
* two ReferencePoint in a container.
|
|
|
|
*/
|
2011-06-07 14:08:34 +02:00
|
|
|
bool operator()(const ReferencePoint &source1,
|
|
|
|
const ReferencePoint &source2) const
|
|
|
|
{
|
|
|
|
return
|
|
|
|
static_cast<Point3D>(source1) == static_cast<Point3D>(source2) ;
|
|
|
|
}
|
|
|
|
} ;
|
2013-05-30 20:13:44 +02:00
|
|
|
}
|
2011-06-07 14:08:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-07 16:03:53 +01:00
|
|
|
#endif // _OWLPS_POSITIONING_REFERENCEPOINT_HH_
|