[Positioning] Stock: fix ReferencePoint creation
For each calibration request read, a new ReferencePoint was created in Stock. This is because of the behaviour of unordered_set: as pertaining to unordered_set, two elements are not considered equal if the hashes alone are identical, they must also be actually equal (operator==). The problem was fixed by using a custom equality check function that checks the equality only on the coordinates of the ReferencePoint (as if it was a Point3D).
This commit is contained in:
parent
a39e06cf19
commit
d322221d21
|
@ -9,7 +9,6 @@ class Measurement ;
|
|||
#include "point3d.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
#include <boost/tr1/unordered_map.hpp>
|
||||
|
||||
|
@ -118,4 +117,17 @@ inline bool ReferencePoint::operator!=(const ReferencePoint &source) const
|
|||
|
||||
|
||||
|
||||
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_
|
||||
|
|
|
@ -17,7 +17,9 @@ unordered_map<string, Mobile> Stock::mobiles ;
|
|||
|
||||
unordered_map<string, AccessPoint> Stock::aps ;
|
||||
|
||||
unordered_set<ReferencePoint> Stock::reference_points ;
|
||||
unordered_set<ReferencePoint,
|
||||
boost::hash<ReferencePoint>,
|
||||
reference_point_equal_to> Stock::reference_points ;
|
||||
|
||||
unordered_set<CalibrationRequest> Stock::calibration_requests ;
|
||||
|
||||
|
|
|
@ -31,7 +31,9 @@ private:
|
|||
static std::tr1::unordered_map<std::string, AccessPoint> aps ;
|
||||
|
||||
/// List of known ReferencePoint
|
||||
static std::tr1::unordered_set<ReferencePoint> reference_points ;
|
||||
static std::tr1::unordered_set
|
||||
<ReferencePoint, boost::hash<ReferencePoint>, reference_point_equal_to>
|
||||
reference_points ;
|
||||
|
||||
/// List of known CalibrationRequest
|
||||
static std::tr1::unordered_set<CalibrationRequest> calibration_requests ;
|
||||
|
|
Loading…
Reference in New Issue