Map Matching
main.cpp
Go to the documentation of this file.
1 #include <QtGui/QApplication>
2 
3 #include <limits.h>
4 #include <math.h>
5 #include <stdio.h>
6 #include <vector>
7 
8 #include "myexception.h"
9 
10 #include "GUI/controller.h"
11 #include "solver.h"
12 
13 #include "MainWindow.h"
14 
15 #include "grid.h"
16 #include "pointGPS.h"
17 #include "track.h"
18 
19 using namespace std;
30 void dev_thread()
31 {
32  QThread* thread = new QThread();
33  Solver* solver = new Solver();
34  solver->m_trackFilename = "../Data/Seattle/useful_all_track.csv";
35  solver->m_gridFilename = "../Data/Seattle/useful_all_network.csv";
36  //solver->m_trackFilename = "../Data/Seattle/mini_start_track.csv";
37  //solver->m_gridFilename = "../Data/Seattle/mini_start_network.csv";
38 
39  //solver->m_trackFilename = "../Data/France/Zones/Trace_Z5_L93.csv";
40  //solver->m_gridFilename = "../Data/France/Zones/Route_Ready_Z5_L93.csv";
41 
42  solver->moveToThread(thread);
43  thread->start();
44  Controller* controller = new Controller();
45  //QMetaObject::invokeMethod(solver, "onSignalStart");
46  controller->addSolver(solver);
47  controller->connectSignals();
48  controller->m_qProcessViewer->resize(500, 500);
49  controller->m_qProcessViewer->show();
50 }
51 
52 void dev_grid()
53 {
54  QString gridFile = "../Data/Unit_tests_data_set/gridTestPointsHaveNoDuplicate.csv";
55  Grid grid;
56  grid.readFromCSV(gridFile);
57  grid.buildMarkovMatrix();
58  grid.outputInfos();
59 }
60 
62 {
63  // grid.readFromCSV("../Data/Unit_tests_data_set/gridTestPointsHaveNoDuplicate.csv");
64  QString trackFile = "../Data/Seattle/mini_start_track.csv";
65  QString gridFile = "../Data/Seattle/mini_start_network.csv";
66  int test = 1;
67  switch (test) {
68  case 1:
69  trackFile = "../Data/Seattle/useful_all_track.csv";
70  gridFile = "../Data/Seattle/useful_all_network.csv";
71  }
72 
73  Track track;
74  Grid grid;
75  track.readFromCSV(trackFile);
76  track.outputInfos();
77 
78  grid.setTrackBoundingBox(track.m_xMin, track.m_xMax, track.m_yMin, track.m_yMax);
79  grid.readFromCSV(gridFile);
80  grid.outputInfos();
81  grid.buildMarkovMatrix();
82  //Solver solver();
83  //grid.getRoads(), grid.getPoints(), track.getPointsAsPointer());
84  //solver.initialize();
85 
86  std::cout << "The end." << std::endl;
87 }
88 
89 void dev_file()
90 {
91  File f;
92  f.selectFilesToOpen("shp");
93  cout << "File name : " << f.fileName.at(0).toStdString() << ", file extension : " << f.fileExtension.at(0).toStdString() << endl;
94 
95  cout << f.shp2csv("Point") << endl;
96  cout << "File path : " << f.filePath.at(0).toStdString() << "File name : " << f.fileName.at(0).toStdString() << ", file extension : " << f.fileExtension.at(0).toStdString() << endl;
97 }
98 
99 /*void dev_img()
100 {
101  vector<vector<double> > poly;
102 
103  for (int i = 0; i <= 1000; i += 150) {
104  double x = i + 25;
105  double y = i * 0.75;
106  vector<double> coordinates;
107  coordinates.push_back(x);
108  coordinates.push_back(y);
109  poly.push_back(coordinates);
110  }
111 
112  vector<vector<double> > polyRoad;
113 
114  vector<double> coordinates;
115  coordinates.push_back(1000.25);
116  coordinates.push_back(3352.28);
117  polyRoad.push_back(coordinates);
118 
119  coordinates.clear();
120 
121  coordinates.push_back(2000.0);
122  coordinates.push_back(6000.0);
123  polyRoad.push_back(coordinates);
124 
125  Map m(1280, 1024);
126 
127  m.scaleCalculator(1000.25, 2000.75, 3352.28, 6000.67);
128 
129  m.deltaCalculator(1000.25, 3352.28);
130 
131  m.makePolyline(poly, "green");
132 
133  m.makePolylineFromRoad(polyRoad, "grey");
134 
135  vector<vector<double> > point;
136 
137  vector<double> pcoordinates;
138  pcoordinates.push_back(1800.0);
139  pcoordinates.push_back(4800.0);
140  point.push_back(pcoordinates);
141 
142  m.makePointFromTrack(point, "orange");
143 
144  m.landmarkMaker(200);
145 
146  QLabel* myLabel = new QLabel();
147  myLabel->setPixmap(QPixmap::fromImage(m.img));
148 
149  myLabel->show();
150 
151  m.save("/tmp/test.png");
152 
153  cout << "width : " << m.width << endl;
154  cout << "height : " << m.height << endl;
155  cout << "Facteur d'échelle : " << m.scale << endl;
156 }*/
157 
158 void dev_ui()
159 {
160  //Fenetre non enlevable
161  MainWindow* w = new MainWindow();
162  w->setWindowTitle("Map Matching");
163 
164  w->resize(500, 700);
165  w->show();
166 }
167 
168 /****************************************************************************/
169 /*** Pas de code dans le main, seulement l'appel d'une fonction ci-dessus ***/
170 /****************************************************************************/
171 
172 int main(int argc, char* argv[])
173 {
174  QApplication app(argc, argv);
175 
176  //dev_img();
177 
178  dev_thread();
179  //dev_ui();
180 
181  return app.exec();
182  //return app.closingDown();
183 }
void buildMarkovMatrix()
buildMarkovMatrix
Definition: grid.cpp:264
double m_xMin
Definition: track.h:107
QStringList fileName
Definition: file.h:54
void dev_file()
Definition: main.cpp:89
The File class.
Definition: file.h:13
QProcessViewer * m_qProcessViewer
Definition: controller.h:18
STL namespace.
QString m_gridFilename
Definition: solver.h:54
void dev_grid()
Definition: main.cpp:52
void readFromCSV(QString filename)
Reads a csv file and inserts each point in m_points vector.
Definition: track.cpp:36
QStringList filePath
Definition: file.h:53
void dev_gridAndTrack()
Definition: main.cpp:61
QStringList fileExtension
Definition: file.h:55
void setTrackBoundingBox(double xMin, double xMax, double yMin, double yMax)
Save data about our area of roads.
Definition: grid.cpp:34
Definition: solver.h:16
int shp2csv(QString geometryType)
The function to convert WGS84 ShapeFile(s) to Lambert 93 CSV(s)
Definition: file.cpp:59
void outputInfos()
Definition: grid.cpp:237
The Track class.
Definition: track.h:26
void start()
Definition: solver.cpp:9
double m_yMin
Definition: track.h:109
void outputInfos()
Print some informations to user in console.
Definition: track.cpp:303
int selectFilesToOpen(QString extensionFilter)
The UI to select the file&#39;s path to open.
Definition: file.cpp:26
double m_yMax
Definition: track.h:110
Grid embedded roads. This describes the network.
Definition: grid.h:36
void dev_thread()
Definition: main.cpp:30
QString m_trackFilename
Definition: solver.h:55
int main(int argc, char *argv[])
Definition: main.cpp:172
double m_xMax
Definition: track.h:108
The class Track.
void readFromCSV(QString filename)
Reads a csv file and inserts info into the corresponding attributs.
Definition: grid.cpp:42
void addSolver(Solver *solver)
Definition: controller.cpp:11
void dev_ui()
Definition: main.cpp:158
void connectSignals()
Definition: controller.cpp:16