-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrange2.cpp
More file actions
123 lines (105 loc) · 2.89 KB
/
range2.cpp
File metadata and controls
123 lines (105 loc) · 2.89 KB
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
#include <iostream>
#include <fstream>
#include <vector>
#include <iomanip>
#include <string>
#include <stdlib.h>
using namespace std;
#define FILE_NBR 5
string fileName[FILE_NBR] = {"310.csv", "311.csv", "312.csv", "313.csv", "316.csv"};
float min_lat, min_long, max_lat, max_long;
double latR[2] = {
// 40.8044, 40.8136, // columbia university
min_lat, max_lat,
};
double lonR[2] = {
// -73.9656, -73.9559, // columbia university
min_long, max_long, // grand central terminal
};
enum {
ATT,
VERIZON,
TMOBILE,
};
#define CARRIER ATT
// MNC:
// https://en.wikipedia.org/wiki/Mobile_network_codes_in_ITU_region_3xx_(North_America)#United_States_of_America_%E2%80%93_US
class Site {
public:
int mcc, net, area, cell;
double lon, lat;
Site(int _mcc, int _net, int _area, int _cell, double _lon, double _lat) {
mcc = _mcc;
net = _net;
area = _area;
cell = _cell;
lon = _lon;
lat = _lat;
};
};
class MCCMNC {
public:
int mcc, mnc;
MCCMNC(int a, int b) {
mcc = a, mnc = b;
}
};
bool operator==(const MCCMNC& l, const MCCMNC& r) {
return (l.mcc == r.mcc && l.mnc == r.mnc);
}
// input format: top left lat, top left long, bottom right lat, bottom right long
int main(int argc, char const *argv[]) {
latR[0] = atof(argv[1]);
latR[1] = atof(argv[3]);
lonR[0] = atof(argv[2]);
lonR[1] = atof(argv[4]);
string title;
fstream fin[FILE_NBR];
// choose file
for (int i = 0; i < FILE_NBR; i++) {
fin[i].open(fileName[i], ios::in);
fin[i] >> title;
}
vector<Site> sites;
char radio[10];
int mcc, net, area, cell, unit, range, samples, change, created, updated, aveSig;
double lon, lat;
for (int i = 0; i < FILE_NBR; i++) {
while (fin[i] >> title) {
sscanf(title.c_str(), "%[^,],%d,%d,%d,%d,%d,%lf,%lf,%d,%d,%d,%d,%d,%d",
radio, &mcc, &net, &area, &cell, &unit, &lon, &lat, &range, &samples, &change, &created, &updated, &aveSig);
cout.precision(8);
cout.setf(ios::fixed, ios::floatfield);
//cout<<lonR[1];
if (lon < lonR[1] && lon > lonR[0] && lat < latR[1] && lat > latR[0] && radio[0] == 'L') {
//cout << title << endl;
MCCMNC mc = MCCMNC(mcc, net);
switch (CARRIER) {
case ATT:
if (mc == MCCMNC(310, 410) || mc == MCCMNC(313, 100))
sites.push_back(Site(mcc, net, area, cell, lon, lat));
break;
case VERIZON:
if (mc == MCCMNC(311, 480) || mc == MCCMNC(310, 12))
sites.push_back(Site(mcc, net, area, cell, lon, lat));
break;
case TMOBILE:
if (mc == MCCMNC(310, 260) || mc == MCCMNC(310, 120) || mc == MCCMNC(311, 490))
sites.push_back(Site(mcc, net, area, cell, lon, lat));
break;
}
}
}
}
cout << "txLats = [";
for (auto i = sites.begin(); i != sites.end(); i++) {
cout << i->lat << ", ";
}
cout << "];" << endl << "txLons = [";
for (auto i = sites.begin(); i != sites.end(); i++) {
cout << i->lon << ", ";
}
cout << "];" << endl;
//cout << sites.size() << endl;
return 0;
}