diff --git a/owlps-positioning/src/positioning.cc b/owlps-positioning/src/positioning.cc index 52844a2..38480e0 100644 --- a/owlps-positioning/src/positioning.cc +++ b/owlps-positioning/src/positioning.cc @@ -51,7 +51,11 @@ void Positioning::initialise_algorithms() i != algo_names.end() ; ++i) { if (*i == "Real") - algorithms.push_back(new RealPosition) ; + /* In order to compute the errors of the other algorithms, + * Real must be the first for each request, so we add it at + * the begining. + */ + algorithms.insert(algorithms.begin(), new RealPosition) ; else if (*i == "FBCM") { @@ -87,10 +91,23 @@ void Positioning::loop() if (! request) continue ; + Point3D real_position ; + bool compute_error = false ; ResultList results(&request) ; for (algo = algorithms.begin() ; algo != algorithms.end() ; ++algo) - results.add((*algo)->compute(request)) ; + { + Result res((*algo)->compute(request)) ; + if (compute_error) + res.compute_error(real_position) ; + else if ((*algo)->get_name() == "Real") + { + compute_error = true ; + real_position = res.get_position() ; + } + results.add(res) ; + } + output.write(results) ; } } diff --git a/owlps-positioning/src/realposition.hh b/owlps-positioning/src/realposition.hh index 783d440..97dc42b 100644 --- a/owlps-positioning/src/realposition.hh +++ b/owlps-positioning/src/realposition.hh @@ -11,7 +11,7 @@ class RealPosition: public PositioningAlgorithm { public: - RealPosition(void): PositioningAlgorithm("RealPosition") {} + RealPosition(void): PositioningAlgorithm("Real") {} Result compute(const Request &request) ; } ;