-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
60 lines (48 loc) · 1.52 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "boost/filesystem.hpp"
#include <boost/algorithm/string/predicate.hpp>
#include "gps_data.h"
#include "gps_utils.h"
#include "gps_analyze.h"
#include <iostream>
using namespace gps;
using namespace std;
using namespace boost::filesystem;
Tracks read_all_tracks(const std::string& dir){
Tracks result;
path current_dir(dir);
if(!is_directory(current_dir)){
cout << dir << " is not a directory" << endl;
return result;
}
cout << "Reading tracks from '" << dir << "'\n\n";
for (recursive_directory_iterator iter(current_dir), end;
iter != end;
++iter)
{
if (boost::ends_with(iter->path().string(), ".gpx")){
std::cout << iter->path() << "\n";
bool loaded = gps::loadGPX(result, iter->path().c_str());
if(!loaded)
cout << "GPX Load failed" << endl;
}
}
cout << result.size() << " tracks read" << endl << endl;
// Sort chronologically.
// note: addressing points[0] is safe because we discard empty tracks
std::sort(begin(result), end(result), [](auto const& l, auto const& r){
return l.points[0].time < r.points[0].time;
});
return result;
}
int main(int argc, char *argv[])
{
if(argc != 2){
std::cout << "Path name expected" << std::endl;
return -1;
}
const char* source = argv[1];
auto tracks = read_all_tracks(source);
auto unique = unique_dist(tracks);
std::cout << "Total new dist: " << unique << std::endl;
return 0;
}