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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
| //Fonction permettant de remplir un tableau des valeur contenu dans le fichier
void RemplirTableau(string p_tableau[][3], int &nbElements)
{
// dimension 3 nécessaire pour la calcul de la position des éléments
string ligne;
string temps;
string latitude;
string longitude;
// le constructeur de ifstream permet d'ouvrir un fichier en lecture
ifstream fichier("gps.txt", ios::in);
if(fichier.good())
{
int i=0;
int k=0;
while(getline(fichier,ligne)) //!fichier.eof()
{
//getline(fichier,ligne);
if(k>0)
{
temps=ligne.substr(0,8);
latitude=ligne.substr(9,9);
longitude=ligne.substr(19,9);
p_tableau[i][0]=temps;
p_tableau[i][1]=latitude;
p_tableau[i][2]=longitude;
nbElements++;
//cout << i << endl;
}
k++;
}
cout<<"J'ai fini de remplir mon fichier" << endl;
fichier.close();
}
}
bool ComparateurDeChaine(string chaineEntree, string chaineAverifier)
{
bool valider = false;
int i=0;
int heure =(int) (chaineAverifier.substr(0,2).c_str());
int minute =(int) (chaineAverifier.substr(3,2).c_str());
int seconde = (int)(chaineAverifier.substr(6,2).c_str());
cout <<heure << endl;
if( heure <=(int) (chaineEntree.substr(0,2).c_str()))
{
if( minute <=(int) (chaineEntree.substr(3,2).c_str()))
if( seconde <= (int)(chaineEntree.substr(6,2).c_str()))
valider =true;
}
return valider;
}
//Tableau les resultat de la recherche dans le grand Tableau
void *CreerTableauCalcul(string &debut, string &fin,string tableauValeur[][3], string tabDonnees[][3],int &nbElement,int elem)
{
int indiceDebut=0;
int indiceFin=0;
int k=0;
for(int z=0;z<elem; z++)
{
cout<< tabDonnees[z][0] << endl;
cout<< tabDonnees[z][1]<< endl;
cout<< tabDonnees[z][2]<< endl;
}
for(int i=0;i<elem; i++)
{
if(ComparateurDeChaine(debut,tabDonnees[i][0]))
{
indiceDebut ++;
cout<< "Apres la premiere Comparaison";
}
if(ComparateurDeChaine(tabDonnees[i][0],fin))
{
indiceFin ++;
cout<< "Apres la deuzieme Comparaison";
}
}
string bidon;
cin>> bidon;
cout<<"DEBUGG";
for(int j=indiceDebut; j>indiceFin; j++)
{
tableauValeur[k][0]=tabDonnees[j][0];
tableauValeur[k][1]=tabDonnees[j][1];
tableauValeur[k][2]=tabDonnees[j][2];
nbElement++;
}
return NULL;
}
int main()
{
int nbElementFichier=0;
int nbElement;
double degreeLongitude, degreeLatitude;
string ligne;
string temps = "00:00:00";
string heureDebut;
string heureFin;
string latitude;
string longitude;
string tabDonnees[1980][3];
string tableauResultat[1980][3];
char *p_tabDonnees;
p_tabDonnees = (char *)(malloc(10*10*sizeof(char));
p_tabDonnees = &tabDonnees;
//Remplir Un tableau des donnees du fichier gps.txt
RemplirTableau(tabDonnees,nbElementFichier);
//cout << "TEST";
do
{
cout<<("Entre Une Heure de debut ");
cin>>(heureDebut);
cout<<("Entre Une Heure de fin ");
cin>>(heureFin);
CreerTableauCalcul( heureDebut, heureFin,tableauResultat,tabDonnees,nbElement,nbElementFichier);
int i=0;
int j=0;
for( i=0;i<nbElement; i++)
{
cout <<nbElement;
for(j=0;j<3;j++)
{
cout << tableauResultat[i][j];
temps=tableauResultat[i][j];
latitude=tableauResultat[i][j+1];
longitude=tableauResultat[i][j+2];
}
degreeLatitude= Nmea2DecDeg((latitude).c_str());
degreeLongitude= Nmea2DecDeg((longitude).c_str());
Convert2UTM(degreeLatitude, degreeLongitude);
}
}while((heureDebut)!="fin");
cout<<("Apres remplir Tableau");
int bidon;
cin >> bidon;
return 0;
} |