195 lines
6.0 KiB
C++
195 lines
6.0 KiB
C++
/*
|
|
* This file is part of the Owl Positioning System (OwlPS).
|
|
* OwlPS is a project of the University of Franche-Comte
|
|
* (Université de Franche-Comté), France.
|
|
*
|
|
* 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.
|
|
*
|
|
***********************************************************************
|
|
*/
|
|
|
|
|
|
#ifndef _OWLPS_POSITIONING_REFERENCEPOINT_HH_
|
|
#define _OWLPS_POSITIONING_REFERENCEPOINT_HH_
|
|
|
|
class AccessPoint ;
|
|
class CalibrationRequest ;
|
|
class Request ;
|
|
|
|
#include "point3d.hh"
|
|
#include "measurement.hh"
|
|
|
|
#include <vector>
|
|
#include <ostream>
|
|
#include <boost/tr1/unordered_map.hpp>
|
|
|
|
/// Represents a reference point in 3-D space
|
|
class ReferencePoint: public Point3D
|
|
{
|
|
protected:
|
|
/// List of CalibrationRequest associated with the ReferencePoint
|
|
/** Note that \em requests is a \em pointer list: only pointers
|
|
are stored, not values. */
|
|
std::vector<CalibrationRequest*> requests ;
|
|
|
|
/** @name Read accessors */
|
|
//@{
|
|
std::tr1::unordered_map<std::string, Measurement>
|
|
get_all_measurements(void) const ;
|
|
/// 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 ;
|
|
//@}
|
|
|
|
public:
|
|
ReferencePoint(const float &_x = 0,
|
|
const float &_y = 0,
|
|
const float &_z = 0): Point3D(_x, _y, _z) {}
|
|
|
|
ReferencePoint(const Point3D &p): Point3D(p) {}
|
|
|
|
ReferencePoint(const ReferencePoint &source):
|
|
Point3D(source), requests(source.requests) {}
|
|
|
|
~ReferencePoint(void) ;
|
|
|
|
/** @name Read accessors */
|
|
//@{
|
|
/// Returns all the calibration requests
|
|
const std::vector<CalibrationRequest*>& get_requests(void) const ;
|
|
/// 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
|
|
double average_measurements(const std::string &mac_transmitter) const ;
|
|
//@}
|
|
|
|
/** @name Write accessors */
|
|
//@{
|
|
/// Adds a Request to the \link #requests request list\endlink
|
|
void add_request(const CalibrationRequest *r) ;
|
|
/// Deletes a Request from the \link #requests request list\endlink
|
|
void delete_request(const CalibrationRequest *r) ;
|
|
/// Deletes all the requests contained in #requests
|
|
void delete_requests(void) ;
|
|
/// Deletes the requests that are not sent by an AP
|
|
bool delete_generated_requests(void) ;
|
|
//@}
|
|
|
|
/** @name Operations */
|
|
//@{
|
|
/// Computes the similarity of the ReferencePoint and a Request
|
|
float similarity(const Request &source) const ;
|
|
/// Computes the Friis index for the given AccessPoint
|
|
float friis_index_for_ap(const std::string &ap_mac) const ;
|
|
/// Computes the Friis indexes sum for the given AccessPoint
|
|
float friis_indexes_for_ap(
|
|
const AccessPoint &ap, const double &const_term,
|
|
int &nb_indexes) const ;
|
|
/// 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 ;
|
|
//@}
|
|
|
|
/** @name Operators */
|
|
//@{
|
|
ReferencePoint& operator=(const ReferencePoint &source) ;
|
|
bool operator==(const ReferencePoint &source) const ;
|
|
bool operator!=(const ReferencePoint &source) const ;
|
|
//@}
|
|
|
|
/// Displays a ReferencePoint
|
|
friend std::ostream &operator<<(
|
|
std::ostream &os, const ReferencePoint &rp) ;
|
|
|
|
/// Hashes a ReferencePoint
|
|
friend std::size_t hash_value(const ReferencePoint &source) ;
|
|
} ;
|
|
|
|
|
|
|
|
/* *** Read accessors *** */
|
|
|
|
|
|
inline const
|
|
std::vector<CalibrationRequest*>& ReferencePoint::get_requests() const
|
|
{
|
|
return requests ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Write accessors *** */
|
|
|
|
|
|
/**
|
|
* @param r A pointer to the CalibrationRequest to add. If it is
|
|
* 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!).
|
|
*/
|
|
inline void ReferencePoint::add_request(const CalibrationRequest *r)
|
|
{
|
|
if (r != NULL)
|
|
requests.push_back(const_cast<CalibrationRequest*>(r)) ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Operators *** */
|
|
|
|
|
|
inline bool ReferencePoint::operator!=(const ReferencePoint &source) const
|
|
{
|
|
return !(*this == source) ;
|
|
}
|
|
|
|
|
|
|
|
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) ;
|
|
}
|
|
} ;
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_REFERENCEPOINT_HH_
|