Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
63
tools/track_analyzing/track_analyzer/cmd_gpx.cpp
Normal file
63
tools/track_analyzing/track_analyzer/cmd_gpx.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#include "track_analyzing/track.hpp"
|
||||
#include "track_analyzing/track_analyzer/utils.hpp"
|
||||
|
||||
#include "routing_common/num_mwm_id.hpp"
|
||||
|
||||
#include "storage/routing_helpers.hpp"
|
||||
#include "storage/storage.hpp"
|
||||
|
||||
#include "base/file_name_utils.hpp"
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace track_analyzing
|
||||
{
|
||||
using namespace routing;
|
||||
using namespace std;
|
||||
|
||||
void CmdGPX(string const & logFile, string const & outputDirName, string const & userID)
|
||||
{
|
||||
if (outputDirName.empty())
|
||||
{
|
||||
LOG(LERROR, ("Converting to GPX error: the path to the output files is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
storage::Storage storage;
|
||||
shared_ptr<NumMwmIds> numMwmIds = CreateNumMwmIds(storage);
|
||||
MwmToTracks mwmToTracks;
|
||||
ParseTracks(logFile, numMwmIds, mwmToTracks);
|
||||
for (auto const & kv : mwmToTracks)
|
||||
{
|
||||
auto const & mwmName = numMwmIds->GetFile(kv.first).GetName();
|
||||
size_t i = 0;
|
||||
for (auto const & track : kv.second)
|
||||
{
|
||||
if (!userID.empty() && track.first != userID)
|
||||
continue;
|
||||
|
||||
auto const path = base::JoinPath(outputDirName, mwmName + to_string(i) + ".gpx");
|
||||
ofstream ofs(path, ofstream::out);
|
||||
ofs << "<gpx>\n";
|
||||
ofs << "<metadata>\n";
|
||||
ofs << "<desc>" << track.first << "</desc>\n";
|
||||
ofs << "</metadata>\n";
|
||||
for (auto const & point : track.second)
|
||||
{
|
||||
ofs << "<wpt lat=\"" << point.m_latLon.m_lat << "\" lon=\"" << point.m_latLon.m_lon << "\">"
|
||||
<< "</wpt>\n";
|
||||
}
|
||||
|
||||
ofs << "</gpx>\n";
|
||||
if (!userID.empty())
|
||||
break;
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace track_analyzing
|
||||
Loading…
Add table
Add a link
Reference in a new issue