78 lines
1.8 KiB
C++
78 lines
1.8 KiB
C++
/*
|
|
* This file is part of the Owl Positioning System (OwlPS).
|
|
* OwlPS is a project of the University of Franche-Comté
|
|
* (Université de Franche-Comté), France.
|
|
*/
|
|
|
|
|
|
#ifndef _OWLPS_POSITIONING_POSUTIL_HH_
|
|
#define _OWLPS_POSITIONING_POSUTIL_HH_
|
|
|
|
class Measurement ;
|
|
|
|
#include <boost/tr1/unordered_map.hpp>
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
|
|
|
/// Utilitary class
|
|
class PosUtil
|
|
{
|
|
public:
|
|
/// The speed of light, in m/s
|
|
static const unsigned long LIGHT_SPEED = 299792458 ;
|
|
|
|
/** @name Maths */
|
|
//@{
|
|
/// Return the degree value of \em radians
|
|
static double rad2deg(const double &radians) ;
|
|
//@}
|
|
|
|
/** @name Measurements */
|
|
//@{
|
|
/// Mutually completes two Measurement lists with missing APs
|
|
static void complete_with_dummy_measurements(
|
|
std::tr1::unordered_map<std::string, Measurement> &measurements1,
|
|
std::tr1::unordered_map<std::string, Measurement> &measurements2) ;
|
|
/// Computes the distance between two Measurement lists
|
|
static float ss_square_distance(
|
|
std::tr1::unordered_map<std::string, Measurement> &measurements1,
|
|
std::tr1::unordered_map<std::string, Measurement> &measurements2) ;
|
|
//@}
|
|
|
|
/** @name Wi-Fi */
|
|
//@{
|
|
/// Converts a Wi-Fi channel to the corresponding frequency in Hz
|
|
static unsigned long wifi_channel_to_hz(const unsigned long &channel) ;
|
|
//@}
|
|
|
|
/** @name Strings */
|
|
//@{
|
|
static void to_upper(std::string &str) ;
|
|
static void assert_uppercase(const std::string &str) ;
|
|
static std::string int_to_mac(const uint32_t source) ;
|
|
//@}
|
|
} ;
|
|
|
|
|
|
|
|
/* *** Strings *** */
|
|
|
|
|
|
inline void PosUtil::to_upper(std::string &str)
|
|
{
|
|
boost::to_upper(str) ;
|
|
}
|
|
|
|
|
|
inline void PosUtil::assert_uppercase(const std::string &str)
|
|
{
|
|
#ifndef NDEBUG
|
|
std::string str_up(str) ;
|
|
to_upper(str_up) ;
|
|
assert(str_up == str) ;
|
|
#endif // NDEBUG
|
|
}
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_POSUTIL_HH_
|