[Positioning] InputDataReader: read waypoints
This commit is contained in:
parent
f85c7113ab
commit
428639b814
|
@ -103,8 +103,7 @@ const Request& Input::get_next_request() const
|
|||
{
|
||||
if (! eof())
|
||||
{
|
||||
const Request &request = medium->get_next_request() ;
|
||||
add_request_to_stock(request) ;
|
||||
medium->get_next_request() ;
|
||||
log_current_request() ;
|
||||
}
|
||||
|
||||
|
@ -120,23 +119,6 @@ bool Input::eof() const
|
|||
}
|
||||
|
||||
|
||||
void Input::add_request_to_stock(const Request &request) const
|
||||
{
|
||||
// For the moment we add only the CalibrationRequests to the Stock
|
||||
const CalibrationRequest *calibration_request =
|
||||
dynamic_cast<const CalibrationRequest*>(&request) ;
|
||||
if (calibration_request == NULL)
|
||||
return ;
|
||||
|
||||
// Add request to the Stock
|
||||
const CalibrationRequest &stock_calibration_request =
|
||||
Stock::find_create_calibration_request(*calibration_request) ;
|
||||
|
||||
// Add the request to the request list of its reference point
|
||||
stock_calibration_request.reference_point_backward_link() ;
|
||||
}
|
||||
|
||||
|
||||
void Input::log_current_request() const
|
||||
{
|
||||
for (vector<InputLogMedium*>::const_iterator i = log_media.begin() ;
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#include "inputdatareader.hh"
|
||||
#include "topologyreadercsv.hh"
|
||||
#include "inputcsv.hh"
|
||||
#include "calibrationrequest.hh"
|
||||
#include "configuration.hh"
|
||||
#include "posexcept.hh"
|
||||
#include "topologyreadercsv.hh"
|
||||
#include "stock.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
@ -12,19 +17,36 @@ using namespace std ;
|
|||
|
||||
InputDataReader::InputDataReader()
|
||||
{
|
||||
initialise_topology_media() ;
|
||||
read_topology() ;
|
||||
read_reference_points() ;
|
||||
}
|
||||
|
||||
|
||||
InputDataReader::~InputDataReader()
|
||||
{
|
||||
for (vector<InputMedium*>::const_iterator i =
|
||||
reference_points_media.begin() ;
|
||||
i != reference_points_media.end() ; ++i)
|
||||
delete *i ;
|
||||
reference_points_media.clear() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Operations *** */
|
||||
/* *** Topology *** */
|
||||
|
||||
|
||||
void InputDataReader::initialise_topology_media()
|
||||
void InputDataReader::read_topology()
|
||||
{
|
||||
if (! Configuration::is_configured("data-input.topology-medium"))
|
||||
return ;
|
||||
|
||||
initialise_topology_media() ;
|
||||
}
|
||||
|
||||
|
||||
void InputDataReader::initialise_topology_media()
|
||||
{
|
||||
const vector<string> &media_names =
|
||||
Configuration::string_vector_value("data-input.topology-medium") ;
|
||||
|
||||
|
@ -56,3 +78,82 @@ void InputDataReader::initialise_topology_csv()
|
|||
Configuration::string_value("data-input.areas-csv-file"),
|
||||
Configuration::string_value("data-input.waypoints-csv-file")) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Reference points *** */
|
||||
|
||||
|
||||
void InputDataReader::read_reference_points()
|
||||
{
|
||||
if (! Configuration::is_configured("data-input.reference-points-medium"))
|
||||
return ;
|
||||
|
||||
initialise_reference_points_media() ;
|
||||
read_from_reference_points_media() ;
|
||||
}
|
||||
|
||||
|
||||
void InputDataReader::initialise_reference_points_media()
|
||||
{
|
||||
const vector<string> &media_names =
|
||||
Configuration::string_vector_value("data-input.reference-points-medium") ;
|
||||
|
||||
for (vector<string>::const_iterator i = media_names.begin() ;
|
||||
i != media_names.end() ; ++i)
|
||||
{
|
||||
if (*i == "CSV")
|
||||
initialise_reference_points_csv() ;
|
||||
|
||||
else
|
||||
throw bad_configuration(
|
||||
"Reference points input medium type unknown « "+ *i +" »") ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InputDataReader::initialise_reference_points_csv()
|
||||
{
|
||||
if (! Configuration::is_configured("data-input.reference-points-csv-file"))
|
||||
throw missing_configuration(
|
||||
"No reference points input CSV file is configured") ;
|
||||
|
||||
reference_points_media.push_back(
|
||||
new InputCSV(
|
||||
Configuration::string_value("data-input.reference-points-csv-file"))) ;
|
||||
}
|
||||
|
||||
|
||||
void InputDataReader::read_from_reference_points_media()
|
||||
{
|
||||
for (vector<InputMedium*>::const_iterator i =
|
||||
reference_points_media.begin() ;
|
||||
i != reference_points_media.end() ; ++i)
|
||||
{
|
||||
while (! (*i)->eof())
|
||||
{
|
||||
Request &request =
|
||||
const_cast<Request&>((*i)->get_next_request()) ;
|
||||
if (! request)
|
||||
continue ;
|
||||
CalibrationRequest *calibration_request =
|
||||
dynamic_cast<CalibrationRequest*>(&request) ;
|
||||
|
||||
if (calibration_request == NULL)
|
||||
cerr << "Warning! Invalid calibration request at line "
|
||||
<< (*i)->get_current_line_nb() << endl ;
|
||||
else
|
||||
stock_calibration_request(*calibration_request) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InputDataReader::
|
||||
stock_calibration_request(const CalibrationRequest &request) const
|
||||
{
|
||||
const CalibrationRequest &calibration_request =
|
||||
Stock::find_create_calibration_request(request) ;
|
||||
|
||||
calibration_request.reference_point_backward_link() ;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,32 @@
|
|||
#ifndef _OWLPS_POSITIONING_INPUTDATAREADER_HH_
|
||||
#define _OWLPS_POSITIONING_INPUTDATAREADER_HH_
|
||||
|
||||
class InputMedium ;
|
||||
class CalibrationRequest ;
|
||||
|
||||
#include <vector>
|
||||
|
||||
/// Read input data using parameters in Configuration
|
||||
class InputDataReader
|
||||
{
|
||||
protected:
|
||||
std::vector<InputMedium*> reference_points_media ;
|
||||
|
||||
void read_topology(void) ;
|
||||
void initialise_topology_media(void) ;
|
||||
void initialise_topology_csv(void) ;
|
||||
|
||||
void read_reference_points(void) ;
|
||||
void initialise_reference_points_media(void) ;
|
||||
void initialise_reference_points_csv(void) ;
|
||||
void read_from_reference_points_media(void) ;
|
||||
void stock_calibration_request(
|
||||
const CalibrationRequest &request) const ;
|
||||
|
||||
public:
|
||||
InputDataReader(void) ;
|
||||
|
||||
~InputDataReader(void) {}
|
||||
~InputDataReader(void) ;
|
||||
} ;
|
||||
|
||||
#endif // _OWLPS_POSITIONING_INPUTDATAREADER_HH_
|
||||
|
|
|
@ -119,6 +119,13 @@ data-input.topology-medium = CSV).")
|
|||
("data-input.waypoints-csv-file,W", po::value<string>(),
|
||||
"CSV file to use for waypoints input (when \
|
||||
data-input.topology-medium = CSV).")
|
||||
("data-input.reference-points-medium,R", po::value< vector<string> >()
|
||||
->composing(),
|
||||
"Medium from which reference points are read. You can specify this \
|
||||
option more than once. Allowed: CSV.")
|
||||
("data-input.reference-points-csv-file", po::value<string>(),
|
||||
"CSV file to use for reference points input (when \
|
||||
data-input.reference-points-medium = CSV).")
|
||||
;
|
||||
|
||||
file_options->add(options) ;
|
||||
|
|
Loading…
Reference in New Issue