[Positioning] TCPEvAAL: send area of interest

The areas of interest must be defined as areas in the topology
configuration file. Their names must be integer values, to conform with
the EvAAL naming.
This commit is contained in:
Matteo Cypriani 2011-07-24 13:49:01 +02:00
parent a951717433
commit 593da5e422
2 changed files with 40 additions and 9 deletions

View File

@ -1,10 +1,13 @@
#include "outputtcpsocketevaal.hh"
#include "request.hh"
#include "resultlist.hh"
#include "area.hh"
#include "stock.hh"
#include "posexcept.hh"
#include <sstream>
#include <cstdio> // For perror()
#include <boost/lexical_cast.hpp>
using namespace std ;
@ -91,11 +94,22 @@ bool OutputTCPSocketEvAAL::close_socket()
}
/**
* @param results Must contain only one element, since the EvAAL format
* accepts only one algorithm result.
*/
void OutputTCPSocketEvAAL::write(const ResultList &results)
{
assert(results.get_results().size() == 1) ;
write(results.get_results()[0]) ;
}
void OutputTCPSocketEvAAL::write(const Result &result)
{
const Point3D &position = result.get_position() ;
Timestamp request_time = result.get_request()->get_time_sent() ;
int area_of_interest = 0 ; // FIXME
int area_of_interest = area_of_interest_number(position) ;
ostringstream str ;
str
@ -110,14 +124,27 @@ void OutputTCPSocketEvAAL::write(const Result &result)
}
/**
* @param results Must contain only one element, since the EvAAL format
* accepts only one algorithm result.
*/
void OutputTCPSocketEvAAL::write(const ResultList &results)
int OutputTCPSocketEvAAL::
area_of_interest_number(const Point3D &position) const
{
assert(results.get_results().size() == 1) ;
write(results.get_results()[0]) ;
const Area *area = Stock::in_which_area_is(position) ;
if (area == NULL)
return 0 ;
int aoi_number = 0 ;
try
{
aoi_number = boost::lexical_cast<int>(area->get_name()) ;
}
catch (boost::bad_lexical_cast &e)
{
cerr
<< "Cannot convert the area of interest's name (« "
<< area->get_name() << " ») into an integer value: "
<< e.what() << '\n' ;
}
return aoi_number ;
}

View File

@ -1,6 +1,8 @@
#ifndef _OWLPS_POSITIONING_OUTPUTTCPSOCKETEVAAL_HH_
#define _OWLPS_POSITIONING_OUTPUTTCPSOCKETEVAAL_HH_
class Point3D ;
#include "outputmedium.hh"
#include <string>
@ -39,8 +41,10 @@ public:
/** @name Operations */
//@{
void write(const Result &result) ;
void write(const ResultList &results) ;
void write(const Result &result) ;
/// Get the area of interest number from the position
int area_of_interest_number(const Point3D &position) const ;
/// Closes the socket
bool close_socket(void) ;
//@}