[Positioner] CSVStringReader: allow "(X;Y;Z)"
CSVStringReader::read_point3D() now allow the first of the three fields forming a Point3D (that is, X) to start with an opening parenthesis, and the last (Z) to end with a closing parenthesis. That allows an improved clarity for strings containing several points, e.g. "(1;2;3);(4;5;6)".
This commit is contained in:
parent
9944fef40d
commit
2e323be423
|
@ -132,6 +132,10 @@ bool CSVStringReader::read_timestamp(Timestamp &t)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* The first field (X) can start with an opening parenthesis, and the
|
||||
* last one (Z) can finish with a closing parenthesis.
|
||||
*/
|
||||
bool CSVStringReader::read_point3d(Point3D &p)
|
||||
{
|
||||
float coord[3] ;
|
||||
|
@ -142,9 +146,19 @@ bool CSVStringReader::read_point3d(Point3D &p)
|
|||
return false ;
|
||||
++current_field_nb ;
|
||||
|
||||
string field = *token_iterator ;
|
||||
if (field.empty())
|
||||
return false ;
|
||||
|
||||
/* Handle a leading '(' and a trailing ')' */
|
||||
if (i == 0 && field.front() == '(')
|
||||
field.erase(field.begin()) ;
|
||||
if (i == 2 && field.back() == ')')
|
||||
field.pop_back() ;
|
||||
|
||||
try
|
||||
{
|
||||
coord[i] = lexical_cast<float>(*token_iterator) ;
|
||||
coord[i] = lexical_cast<float>(field) ;
|
||||
}
|
||||
catch (bad_lexical_cast &e)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue