owlps/owlps-positioning/src/accesspointsreadercsv.cc
Florian Taillard 8d2a2b3e5a [Positioning] Fix accesspoint reading frequency
Change long to unsigned long in accesspointsreadercsv.cc.
The frequency value exceed a long lenght in arch 32bits.
2011-04-18 13:52:43 +02:00

58 lines
1.2 KiB
C++

#include "accesspointsreadercsv.hh"
#include "point3d.hh"
#include "stock.hh"
#include "posexcept.hh"
using namespace std ;
/* *** Constructors *** */
AccessPointsReaderCSV::AccessPointsReaderCSV(const string &file_name):
file(file_name)
{
read_access_points() ;
}
/* *** Operations *** */
void AccessPointsReaderCSV::read_access_points()
{
while (file.next_line())
process_access_point_line() ;
}
void AccessPointsReaderCSV::process_access_point_line()
{
string mac ;
if (! file.read_field(mac))
throw malformed_input_data("Cannot read access point MAC address!") ;
Point3D coord ;
if (! file.read_point3d(coord))
throw malformed_input_data("Cannot read access point coordinates!") ;
unsigned long frequency ;
if (! file.read_field(frequency))
throw malformed_input_data("Cannot read access point frequency!") ;
float gain ;
if (! file.read_field(gain))
throw malformed_input_data("Cannot read access point gain!") ;
float power ;
if (! file.read_field(power))
throw malformed_input_data("Cannot read access point power!") ;
string ip("") ;
AccessPoint ap(coord, ip, mac, gain, power, frequency) ;
Stock::find_create_ap(ap) ;
}