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
| void LireFichierNGSIM()
{
QVector <int> identificationVehicule;
QVector <double>heureEntreeVehicule;
QVector <int>identificationVoie;
QString monfichier = "D:/ngsim-0750am-0805am.txt";
QFile fichier(monfichier);
fichier.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream ngsim(&fichier);
ngsim.setCodec("UTF-8");
QString ligne;
int identifiant_veh,identifiant_voie_veh;
double heure_entree_veh;
long nombreDeLignes = 0;
if (! ngsim.atEnd())
{
while (!ngsim.atEnd())
{
ligne = ngsim.readLine();
nombreDeLignes++;
}
cout << "nombreDeLignes =" << nombreDeLignes << endl;
for (int i=0; i < nombreDeLignes; i++)
{
ligne = ngsim.readLine();
QTextStream in(&ligne);
in >> dec >> identifiant_veh;
in >> dec >> heure_entree_veh;
in >> dec >> identifiant_voie_veh;
cout << identifiant_veh<<" "<<heure_entree_veh<<" "<<identifiant_voie_veh<< endl;
identificationVehicule.append(identifiant_veh);
heureEntreeVehicule.append(heure_entree_veh);
identificationVoie.append(identifiant_voie_veh);
}//for i
}//if
} |
Partager