#ifndef WALKRESULT_H
#define WALKRESULT_H

#include <vector>
#include <Indoor/geo/Point3.h>
#include <Indoor/data/Timestamp.h>
#include <fstream>

struct WalkResult {

	struct Entry {
		Timestamp ts;
		Point3 estimation;
		Point3 groundTruth;
		float err;
	};

	std::vector<Entry> entries;

	void serialize(const std::string& file) {
		std::ofstream out(file);
		for (const Entry& e : entries) {
			out << e.ts.ms() << "\t";
			out << e.estimation.x << "\t";
			out << e.estimation.y << "\t";
			out << e.estimation.z << "\t";
			out << e.groundTruth.x << "\t";
			out << e.groundTruth.y << "\t";
			out << e.groundTruth.z << "\t";
			out << e.err << "\n";
		}
		out.close();
	}
	void deserialize(const std::string& file) {
		std::ifstream inp(file);
		while(inp) {
			Entry e;
			uint64_t ms;	inp >> ms;	e.ts = Timestamp::fromMS(ms);
			if (!inp) {break;}
			inp >> e.estimation.x; inp >> e.estimation.y; inp >> e.estimation.z;
			inp >> e.groundTruth.x; inp >> e.groundTruth.y; inp >> e.groundTruth.z;
			inp >> e.err;
			entries.push_back(e);
		}
	}

};

#endif // WALKRESULT_H
