esri_assignment/src/main.cpp

41 lines
1.1 KiB
C++

#include <fstream>
#include <iostream>
#include "protocol_buffers_definitions/recordings.pb.h"
using namespace ::indoors::proto;
int main(int argc, char* argv[])
{
// Verify that the version of the library that we linked against is
// compatible with the version of the headers we compiled against.
GOOGLE_PROTOBUF_VERIFY_VERSION;
std::cout << "ESRI C++ code assignment\n";
Recording recording;
Position positions;
std::fstream input(argv[1], std::ios::in | std::ios::binary);
if (!recording.ParseFromIstream(&input)) {
std::cerr << "Failed to parse input file.\n";
return -1;
}
std::cout.precision(17);
for (int i=0; i < recording.magnetics_size(); i++) {
auto const& s = recording.magnetics(i);
std::cout << s.t() << ": [" << s.x() << ", " << s.y() << ", " << s.z() << "]\n";
}
for (int i=0; i < recording.positions_size(); i++) {
auto const& s = recording.positions(i);
std::cout << s.t() << ": [" << s.x() << ", " << s.y() << "]\n";
}
// Optional: Delete all global objects allocated by libprotobuf.
google::protobuf::ShutdownProtobufLibrary();
return 0;
}