#include "libowlps-positioning.hh" /* Tronque le float "f" à "n" décimales et le retourne */ float round_float(float f, int n) { n = (int) pow((double) 10, (double) n) ; float f_dec = modff(f, &f) ; f_dec = floor(f_dec * n) / n ; return f + f_dec ; } /* Explodes a string into substrings based on separator sep. Returns a string vector. */ vector explode(const string &input, const char &sep) { vector vs; string tmp; unsigned int i; for (i = 0 ; i < input.size() ; i++) if (input[i] == sep) { vs.push_back(tmp); tmp.clear(); } else { tmp.push_back(input[i]); } vs.push_back(tmp); tmp.clear(); return vs; } /* Le Format Fred n'est pas utilisé */ vector extractReferencePointInfoFromBuffer(const string &buffer_in) { unsigned int i = 0; string tmp_field; vector ret; /* Extract coordinates */ /* x */ while (buffer_in[i] != ';') { tmp_field.push_back(buffer_in[i]); i++; } ret.push_back(tmp_field); tmp_field.clear(); i++; // go after the ';' /* y */ while (buffer_in[i] != ';') { tmp_field.push_back(buffer_in[i]); i++; } ret.push_back(tmp_field); tmp_field.clear(); i++; /* z */ while (buffer_in[i] != ';') { tmp_field.push_back(buffer_in[i]); i++; } ret.push_back(tmp_field); tmp_field.clear(); i++; /* Extract direction (not used now) */ while (buffer_in[i] != ';') { tmp_field.push_back(buffer_in[i]); i++; } ret.push_back(tmp_field); tmp_field.clear(); i++; while (i <= buffer_in.size()) { if ((buffer_in[i] == ';' || i == buffer_in.size()) && !tmp_field.empty()) // Si on est sur un séparateur et que la valeur lue n'est pas vide, { ret.push_back(tmp_field) ; // on met la valeur lue dans les valeurs de retour. tmp_field.clear() ; } else // Si on n'est pas sur un séparateur, tmp_field.push_back(buffer_in[i]) ; // on ajoute le caractère courant à la suite de la valeur lue. i++ ; } /* Return the vector with each data */ return ret; } uint64_t timeval_to_ms(const struct timeval &d) { return d.tv_sec * 1000 + d.tv_usec / 1000 ; }