-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStopClass.cpp
131 lines (112 loc) · 3.07 KB
/
StopClass.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "StopClass.h"
//constructor
Stop::Stop(int x, string a, double b, double c) // vector<Stop*>, vector<Route*>)
{
ID = x;
stopID = a;
stopLat = b;
stopLon = c;
}
//default constructor
Stop::~Stop()
{
}
//geters
int Stop::getID() const
{
return ID;
}
string Stop::getstopID() const
{
return stopID;
}
double Stop::getlat() const
{
return stopLat;
}
double Stop::getlon() const
{
return stopLon;
}
vector<pair<Stop*, int>> Stop::getConnectedStop() const
{
return connected_stops;
}
vector<Route*> Stop::getConnectedroute() const
{
return connected_routes;
}
vector < pair<Stop*, Route*>> Stop::getconnected_routes_stops() const
{
return connected_routes_stops;
}
int Stop::getTransfer() const
{
return transfer_stop;
}
//seters
void Stop::setConnectedStop(Stop* x, int y)
{
int a = 0;
for (unsigned int i = 0; i < connected_stops.size(); i++)
if (connected_stops[i].first->getID() == x->getID()) a = 1;
if (a == 0) connected_stops.push_back(make_pair(x, y));
}
void Stop::setConnectedRoutes(Route* y)
{
int a = 0;
for (unsigned int i = 0; i < connected_routes.size(); i++)
if (connected_routes[i]->getrouteID() == y->getrouteID()) a = 1;
if (a == 0) connected_routes.push_back(y);
}
void Stop::setconnectedroutesstops(Stop* x, Route* y)
{
int a = 0;
for (unsigned int i = 0; i < connected_routes.size(); i++)
{
if (connected_routes[i]->getrouteID() == y->getrouteID())
{
int count_0 = -1;
int count_1 = -1;
for (unsigned int j = 0; j < passing_trips.size(); j++)
{
if (passing_trips[j].second.first->getrouteID() == y->getrouteID() &&
passing_trips[j].second.second->getdirection() == "0") count_0 = 1;
if (passing_trips[j].second.first->getrouteID() == y->getrouteID() &&
passing_trips[j].second.second->getdirection() == "1") count_1 = 1;
}
if (count_0 + count_1 == 2) a = 1;
else
{
int count_0_x = -1;
int count_1_x = -1;
for (unsigned int j = 0; j < x->passing_trips.size(); j++)
{
if (x->passing_trips[j].second.first->getrouteID() == y->getrouteID() &&
x->passing_trips[j].second.second->getdirection() == "0") count_0_x = 1;
if (x->passing_trips[j].second.first->getrouteID() == y->getrouteID() &&
x->passing_trips[j].second.second->getdirection() == "1") count_1_x = 1;
}
if (count_0 == count_0_x && count_1 == count_1_x) a = 1;
}
}
}
for (unsigned int i = 0; i < connected_routes_stops.size(); i++)
if (connected_routes_stops[i].second->getrouteID() == y->getrouteID()) a = 1;
if (a == 0) connected_routes_stops.push_back(make_pair(x, y));
}
void Stop::settransfer()
{
int counter_route = 0;
for (unsigned int i = 0; i < connected_routes.size(); i++)
{
for (unsigned int j = 0; j < connected_routes_stops.size(); j++)
{
if (connected_routes[i]->getrouteID() == connected_routes_stops[j].second->getrouteID()) counter_route = counter_route + 1;
}
}
if (connected_routes.size() + connected_routes_stops.size() - counter_route > 1)
transfer_stop = 1;
else transfer_stop = 0;
degree_centrality = connected_routes.size() + connected_routes_stops.size() - counter_route;
}