2012-02-06 16:44:09 +01:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-12-11 13:52:21 +01:00
|
|
|
#ifndef _OWLPS_POSITIONING_POSUTIL_HH_
|
|
|
|
#define _OWLPS_POSITIONING_POSUTIL_HH_
|
|
|
|
|
[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
|
|
|
class Measurement ;
|
|
|
|
|
|
|
|
#include <boost/tr1/unordered_map.hpp>
|
2011-06-29 11:32:13 +02:00
|
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
[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
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/// Utilitary class
|
2009-12-11 13:52:21 +01:00
|
|
|
class PosUtil
|
|
|
|
{
|
|
|
|
public:
|
2010-06-10 15:35:55 +02:00
|
|
|
/// The speed of light, in m/s
|
|
|
|
static const unsigned long LIGHT_SPEED = 299792458 ;
|
|
|
|
|
2011-07-13 14:56:06 +02:00
|
|
|
/** @name Maths */
|
|
|
|
//@{
|
|
|
|
/// Return the degree value of \em radians
|
|
|
|
static double rad2deg(const double &radians) ;
|
|
|
|
//@}
|
|
|
|
|
[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 Measurements */
|
|
|
|
//@{
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Mutually completes two Measurement lists with missing APs
|
[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
|
|
|
static void complete_with_dummy_measurements(
|
|
|
|
std::tr1::unordered_map<std::string, Measurement> &measurements1,
|
|
|
|
std::tr1::unordered_map<std::string, Measurement> &measurements2) ;
|
2011-06-20 12:11:20 +02:00
|
|
|
/// Computes the distance between two Measurement lists
|
[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
|
|
|
static float ss_square_distance(
|
|
|
|
std::tr1::unordered_map<std::string, Measurement> &measurements1,
|
|
|
|
std::tr1::unordered_map<std::string, Measurement> &measurements2) ;
|
|
|
|
//@}
|
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/** @name Wi-Fi */
|
|
|
|
//@{
|
|
|
|
/// Converts a Wi-Fi channel to the corresponding frequency in Hz
|
2010-06-23 17:32:35 +02:00
|
|
|
static unsigned long wifi_channel_to_hz(const unsigned long &channel) ;
|
2010-01-16 12:23:07 +01:00
|
|
|
//@}
|
2011-06-29 11:32:13 +02:00
|
|
|
|
|
|
|
/** @name Strings */
|
|
|
|
//@{
|
|
|
|
static void to_upper(std::string &str) ;
|
|
|
|
static void assert_uppercase(const std::string &str) ;
|
2011-07-21 14:37:19 +02:00
|
|
|
static std::string int_to_mac(const uint32_t source) ;
|
2011-06-29 11:32:13 +02:00
|
|
|
//@}
|
2009-12-11 13:52:21 +01:00
|
|
|
} ;
|
|
|
|
|
2011-06-29 11:32:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* *** 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-11 13:52:21 +01:00
|
|
|
#endif // _OWLPS_POSITIONING_POSUTIL_HH_
|