Changes in class TurnInstructions.h to read a text file.

This commit is contained in:
Moises Arcos 2012-02-21 14:08:25 +01:00
parent 091cd57f68
commit 98ecc3c668
2 changed files with 45 additions and 15 deletions

View File

@ -22,6 +22,9 @@
#define TURNINSTRUCTIONS_H_ #define TURNINSTRUCTIONS_H_
#include <string> #include <string>
#include <iostream>
#include <fstream>
using namespace std;
//This is a hack until c++0x is available enough to use scoped enums //This is a hack until c++0x is available enough to use scoped enums
struct TurnInstructionsClass { struct TurnInstructionsClass {
@ -47,21 +50,33 @@ struct TurnInstructionsClass {
//This is a hack until c++0x is available enough to use initializer lists. //This is a hack until c++0x is available enough to use initializer lists.
TurnInstructionsClass(){ TurnInstructionsClass(){
TurnStrings [0] = ""; cout << "########## Entra en TurnInstructionsClass\n";
TurnStrings [1] = "Continue"; // Ahora mismo la ruta estñá puesta de manera manual
TurnStrings [2] = "Turn slight right"; char nameFile[] = "/home/usuario/workspace/Project-OSRM/DataStructures/languages/ES_ES.txt";
TurnStrings [3] = "Turn right"; // Declare an input file stream
TurnStrings [4] = "Turn sharp right"; ifstream fread;
TurnStrings [5] = "U-Turn"; // Open a file for only read
TurnStrings [6] = "Turn sharp left"; fread.open(nameFile, ifstream::in);
TurnStrings [7] = "Turn left"; // Check if there have been any error
TurnStrings [8] = "Turn slight left"; if (!fread){
TurnStrings [9] = "Reach via point"; cout << "fault" << endl;
TurnStrings[10] = "Head"; }
TurnStrings[11] = "Enter round-about"; // Create a buffer to use for read
TurnStrings[12] = "Leave round-about"; char buffer[128];
TurnStrings[13] = "Stay on round-about"; // Read from file to buffer
TurnStrings[14] = "Start"; fread.getline(buffer, 128);
int i = 0;
while (!fread.eof()){
/* Write the result in an array */
if(i<15){
std::string str(buffer);
TurnStrings[i] = str;
i++;
}
/* Read the next line */
fread.getline(buffer, 128);
}
fread.close();
Ordinals[0] = "zeroth"; Ordinals[0] = "zeroth";
Ordinals[1] = "first"; Ordinals[1] = "first";

View File

@ -0,0 +1,15 @@
Continuar
Gire a la derecha
Gire a la derecha
Gire a la derecha aguda
U-Turn
Girar a la izquierda
Gire a la izquierda
Gire a la izquierda
Llegar a un punto intermedio
cabeza
Introduzca rotonda
Deja rotonda
Permanezca en rotonda
Comenzar