-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHashMap copy.h
97 lines (79 loc) · 2.47 KB
/
HashMap copy.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#include "geodb.h"
#include "router.h"
#include "stops.h"
#include "tourcmd.h"
#include "tour_generator.h"
#include "HashMap.h"
//
//
//
void print_tour(vector<TourCommand>& tcs)
{
double total_dist = 0;
std::string direction;
double street_distance = 0;
cout << "Starting tour...\n";
for (size_t i = 0; i < tcs.size(); ++i)
{
if (tcs[i].get_command_type() == TourCommand::commentary)
{
cout << "Welcome to " << tcs[i].get_poi() << "!\n";
cout << tcs[i].get_commentary() << "\n";
}
else if (tcs[i].get_command_type() == TourCommand::turn)
{
cout << "Take a " << tcs[i].get_direction() << " turn on " << tcs[i].get_street() << endl;
}
else if (tcs[i].get_command_type() == TourCommand::proceed)
{
total_dist += tcs[i].get_distance();
if (direction.empty())
direction = tcs[i].get_direction();
street_distance += tcs[i].get_distance();
if (i+1 < tcs.size() && tcs[i+1].get_command_type() == TourCommand::proceed
&& tcs[i+1].get_street() == tcs[i].get_street() && tcs[i].get_street() != "a path")
{
continue;
}
cout << "Proceed " << std::fixed << std::setprecision(3) << street_distance << " miles " << direction << " on " << tcs[i].get_street() << endl;
street_distance = 0;
direction.clear();
}
}
cout << "Your tour has finished!\n";
cout << "Total tour distance: " << std::fixed << std::setprecision(3) << total_dist << " miles\n";
}
int main(int argc, char *argv[])
{
// if (argc != 3)
// {
// cout << "usage: BruinTour mapdata.txt stops.txt\n";
// return 1;
// }
GeoDatabase geodb;
if (!geodb.load("/Users/aravpant/Desktop/PracticeTest.txt"))
{
cout << "Unable to load map data: " << argv[1] << endl;
return 1;
}
Router router(geodb);
TourGenerator tg(geodb, router);
Stops stops;
if (!stops.load("/Users/aravpant/Desktop/stops.txt"))
{
cout << "Unable to load tour data: " << argv[2] << endl;
return 1;
}
std::cout << "Routing...\n\n";
vector<TourCommand> tcs = tg.generate_tour(stops);
if (tcs.empty())
cout << "Unable to generate tour!\n";
else
print_tour(tcs);
}