10 #define DEBUG_READCSV false    11 #define DEBUG_ADDROAD false    17     , m_xMax(
std::numeric_limits<double>::max())
    19     , m_yMax(
std::numeric_limits<double>::max())
    20     , m_xMinGrid(
std::numeric_limits<double>::max())
    22     , m_yMinGrid(
std::numeric_limits<double>::max())
    47     QString stringConverted;
    50     std::ifstream file(filename.toStdString().c_str()); 
    52     std::vector<int> correspondance(4, -1); 
    62         stringConverted = QString::fromStdString(line);
    63         QStringList text = stringConverted.split(
",");
    66         for (
int i = 0; i < text.size(); ++i) {
    67             if (text[i].contains(QString::fromStdString(
"WKT"),
    68                     Qt::CaseInsensitive)) {
    69                 correspondance[0] = i;
    71             } 
else if (text[i].contains(QString::fromStdString(
"Edge ID"),
    72                            Qt::CaseInsensitive)) {
    73                 correspondance[1] = i;
    75             } 
else if (text[i].contains(QString::fromStdString(
"From Node"),
    76                            Qt::CaseInsensitive)) {
    77                 correspondance[2] = i;
    79             } 
else if (text[i].contains(QString::fromStdString(
"To Node ID"),
    80                            Qt::CaseInsensitive)) {
    81                 correspondance[3] = i;
   100         std::vector<std::vector<double> > listOfCoordinates(0);
   104         stringConverted = QString::fromStdString(line);
   105         if (stringConverted.length() != 0) 
   122             QStringList linestringList = stringConverted.split(
"\"");
   130             if (!linestringList[0].isEmpty()) {
   131                 text = linestringList[0].split(
",");
   133             text.append(linestringList[1]);
   135             QStringList afterSplit = linestringList[2].split(
",");
   136             afterSplit.removeFirst();
   138             if (!afterSplit.isEmpty()) {
   144             for (
int i = 0; i < text.size(); ++i) {
   145                 if (i == correspondance[0]) {
   147                     QStringList contenuList = text[i].split(
"LINESTRING (");
   148                     contenuList = contenuList[1].split(
")");
   149                     QString contenu = contenuList[0];
   151                     QStringList listePoints = contenu.split(
",");
   153                         std::cout << 
"Coordonnées points : " << std::endl;
   154                     for (
int j = 0; j < listePoints.size(); ++j) {
   157                         QStringList coordonnees = listePoints[j].split(
" ");
   158                         x = coordonnees[0].toDouble();
   159                         y = coordonnees[1].toDouble();
   163                             std::cout << std::setprecision(150) << x << 
"," << y << std::endl;
   164                         std::vector<double> coordinates;
   165                         coordinates.push_back(x);
   166                         coordinates.push_back(y);
   167                         listOfCoordinates.push_back(coordinates);
   170                 } 
else if (i == correspondance[1]) {
   173                         std::cout << 
"Edge ID : " << text[i].toStdString() << 
" ";
   174                     edgeId = text[i].toLong();
   175                 } 
else if (i == correspondance[2]) {
   178                         std::cout << 
"From Node : " << text[i].toStdString() << 
" ";
   180                 } 
else if (i == correspondance[3]) {
   183                         std::cout << 
"To Node ID : " << text[i].toStdString() << 
" ";
   188                 std::cout << std::endl;
   190                 addRoad(listOfCoordinates, edgeId);
   196 void Grid::addRoad(
const std::vector<std::vector<double> >& listOfCoordinates, 
long edgeId)
   198     int n = listOfCoordinates.size();
   200     bool newPoint = 
true;
   201     int existingPointId = -1; 
   207     for (
const auto& coord : listOfCoordinates) {
   209         PointRoad p(coord[0], coord[1], (curPoint == 0 || curPoint == n - 1));
   211         if (curPoint == 0 || curPoint == n - 1) { 
   214                 existingPointId = got->second;
   240     std::cout << 
"\twith a grand total of " << 
m_vectorOfPoints.size() << 
" points" << std::endl;
   241     std::cout << 
"\tof which " << 
m_mapOfExtPoints.size() << 
" are extremities." << std::endl;
   246     std::stringstream ss;
   270             const std::vector<long>& listOfRoadId = p.vectorOfRoadId();
   271             for (
const auto roadId : listOfRoadId) {
   273                 for (
const auto neighborId : listOfRoadId) {
   274                     got->second.addNeighbor(neighborId);
   276                         std::cout << 
"update neighbour " << std::endl;
   277                         got->second.outputInfos();
   286         std::cout << 
"Resutat: " << std::endl;
   288             it.second.outputInfos();
   298     Road* r1 = &got->second;
   303     Point projR1(k1.at(0), k1.at(1)), projR2(k2.at(0), k2.at(1));
   307     if (prevRoadId == curRoadId) {
   319     std::vector<double> res, bestRes;
   320     double d, bestDistance = std::numeric_limits<double>::max();
   322     for (uint i = 1; i < listOfPointId.size(); i++) {
   325         if (d < bestDistance) {
   335     double d1, d2, dTotal = 0.0;
   340     if (start1 == start2)
   343     if (start1 < start2) {
   353     double d, dTotal = 0.0;
   356     if (listOfPointId.at(0) == node) {
   357         for (uint i = 1; i < listOfPointId.size(); i++) {
   364         for (uint i = listOfPointId.size() - 1; i > 1; i--) {
   378     for (uint i = 1; i < listOfPointId.size(); i++) {
 void buildMarkovMatrix()
buildMarkovMatrix 
 
double distanceToSegment(const Point &p1, const Point &p2) const 
Compute the distance between a point and a segment. 
 
std::string m_gridFullName
 
double getDistanceToExtremity(Point *projR1, int node, Road *r1)
 
bool trackInGrid()
Check if track is in grid. 
 
virtual ~Grid()
Destructor. 
 
const std::vector< int > & vectorOfPointsId() const 
Get the vector of points composing the road. 
 
void addRoad(const std::vector< std::vector< double > > &listOfCoordinates, long edgeId)
Creates a new road and inserts it in m_road. 
 
double m_xMin
The coordinates of the track. 
 
void updateBelongToRoad(long roadId)
 
AllRoadMap m_mapOfAllRoads
 
Road is an element of a network. Road are strongly linked with Points. 
 
bool inFootPrint(double x, double y)
Test if a point is in the defined area of a track. 
 
void updateGrid(double x, double y)
Find max and min of the grid. 
 
std::vector< double > getProjectedPointAndDistance(PointGPS *p, Road *r)
 
void setTrackBoundingBox(double xMin, double xMax, double yMin, double yMax)
Save data about our area of roads. 
 
std::vector< PointRoad > m_vectorOfPoints
 
double distanceToPoint(const Point &p) const 
Calculate distance between two points. 
 
double getDistanceBetweenProjections(Point *projR1, Point *projR2, Road *r1)
 
int getIntersectionIDWith(Road *r) const 
 
void addPoint(int pointId)
Add a point to the road. 
 
AllRoadMap::iterator getRoadEntry(long id)
 
void signalMessage(QString)
 
ExtremityPointMap m_mapOfExtPoints
 
long edgeId() const 
Get the id of the road. 
 
double computeDistanceFraction(PointGPS *prevPoint, PointGPS *curPoint, long prevRoadId, long curRoadId)
 
std::vector< double > projectionOnSegment(const Point &a, const Point &b) const 
 
int getSegmentCounter(Point *p, Road *r)
 
void readFromCSV(QString filename)
Reads a csv file and inserts info into the corresponding attributs.