[Positioning] Add Result::request
Associate a Result with the origin Request.
This commit is contained in:
parent
d5fcfed1f2
commit
1dfe30ea03
|
@ -5,5 +5,5 @@
|
|||
Result CartographyAlgorithm::compute(const Request &request)
|
||||
{
|
||||
Point3D position(select_point(request)) ;
|
||||
return Result(position, name) ;
|
||||
return Result(&request, name, position) ;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ Result FRBHMBasic::compute(const Request &_request)
|
|||
compute_ap_distance_circles() ;
|
||||
Point3D position(multilaterate_2d(closest_in_ss->get_z())) ;
|
||||
|
||||
return Result(position, name) ;
|
||||
return Result(request, name, position) ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ Result MultilaterationAlgorithm::compute(const Request &_request)
|
|||
compute_ap_distance_circles() ;
|
||||
Point3D position(multilaterate()) ;
|
||||
|
||||
return Result(position, name) ;
|
||||
return Result(request, name, position) ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Result RealPosition::compute(const Request &request)
|
|||
|
||||
coordinates = request.get_real_position() ;
|
||||
if (coordinates)
|
||||
return Result(*coordinates, name) ;
|
||||
return Result(&request, name, *coordinates) ;
|
||||
|
||||
return Result(name) ;
|
||||
return Result(&request, name) ;
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@ using namespace std ;
|
|||
/* *** Constructors *** */
|
||||
|
||||
|
||||
Result::Result(const Point3D &_position, const std::string &_algorithm,
|
||||
Result::Result(const Request *_request,
|
||||
const std::string &_algorithm,
|
||||
const Point3D &_position,
|
||||
const Point3D &real_position):
|
||||
position(_position), algorithm(_algorithm)
|
||||
request(_request), algorithm(_algorithm), position(_position)
|
||||
{
|
||||
compute_error(real_position) ;
|
||||
}
|
||||
|
@ -37,6 +39,7 @@ const Result& Result::operator=(const Result &source)
|
|||
if (this == &source)
|
||||
return *this ;
|
||||
|
||||
request = source.request ;
|
||||
algorithm = source.algorithm ;
|
||||
position = source.position ;
|
||||
error = source.error ;
|
||||
|
@ -48,6 +51,7 @@ const Result& Result::operator=(const Result &source)
|
|||
bool Result::operator==(const Result &source) const
|
||||
{
|
||||
return
|
||||
request == source.request &&
|
||||
algorithm == source.algorithm &&
|
||||
position == source.position &&
|
||||
error == source.error ;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef _OWLPS_POSITIONING_RESULT_HH_
|
||||
#define _OWLPS_POSITIONING_RESULT_HH_
|
||||
|
||||
class Request ;
|
||||
|
||||
#include "point3d.hh"
|
||||
|
||||
#include <string>
|
||||
|
@ -9,25 +11,31 @@
|
|||
class Result
|
||||
{
|
||||
protected:
|
||||
/// Computed coordinates of the mobile
|
||||
Point3D position ;
|
||||
/// Request sent by the mobile
|
||||
const Request *request ;
|
||||
/// Algorithm used to compute the position
|
||||
std::string algorithm ;
|
||||
/// Computed coordinates of the mobile
|
||||
Point3D position ;
|
||||
/// Distance error between the real coordinates and the computed point
|
||||
/** The error is set to -1 if the real coordinates are unknown. */
|
||||
float error ;
|
||||
|
||||
public:
|
||||
Result(const std::string &_algorithm = "UnknownAlgorithm"):
|
||||
algorithm(_algorithm), error(-1) {}
|
||||
Result(const Point3D &_position, const std::string &_algorithm):
|
||||
position(_position), algorithm(_algorithm), error(-1) {}
|
||||
Result(const Point3D &_position, const std::string &_algorithm,
|
||||
const Point3D &real_position) ;
|
||||
Result(const Request *_request = NULL,
|
||||
const std::string &_algorithm = "UnknownAlgorithm"):
|
||||
request(_request), algorithm(_algorithm), error(-1) {}
|
||||
Result(const Request *_request, const std::string &_algorithm,
|
||||
const Point3D &_position):
|
||||
request(_request), algorithm(_algorithm), position(_position),
|
||||
error(-1) {}
|
||||
Result(const Request *_request, const std::string &_algorithm,
|
||||
const Point3D &_position, const Point3D &real_position) ;
|
||||
~Result(void) {}
|
||||
|
||||
/** @name Read accessors */
|
||||
//@{
|
||||
const Request* get_request(void) const ;
|
||||
const std::string& get_algorithm(void) const ;
|
||||
const Point3D& get_position(void) const ;
|
||||
float get_error(void) const ;
|
||||
|
@ -60,6 +68,12 @@ public:
|
|||
/* *** Read accessors *** */
|
||||
|
||||
|
||||
inline const Request* Result::get_request() const
|
||||
{
|
||||
return request ;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& Result::get_algorithm() const
|
||||
{
|
||||
return algorithm ;
|
||||
|
|
Loading…
Reference in New Issue