Exemplo n.º 1
0
ShortestDistance::ShortestDistance(char const* OutputFileName, char const* airportsFileName, char const* routesFileName, char const* airlinesFilename):filename(OutputFileName)
{
        ifstream in(OutputFileName);
        getline(in,line);
        if(line.compare("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"))
        {
            in.close();
            clock_t start= clock();
            out.open(OutputFileName);
            airports.open(airportsFileName);
            routes.open(routesFileName);
            airlines.open(airlinesFilename);
            parseAirports(dataMap);
            parseRoutes(dataMap);
            parseAirline(carrierNames);
            writeXML(dataMap, carrierNames);
            cout << "Parsing: " << (clock() - start)/(double)CLOCKS_PER_SEC << " seconds." << endl;
        }
        in.close();
        createTable();
}
Exemplo n.º 2
0
/*
   Calls parseAirports, parseSchedules, and calcRouteTimes if the required files exists.
 */
void timeRoutes(char* airports, char* schedules, char* routes) {
    FILE *airportFile, *scheduleFile, *routeFile;
    char* read = "r";
    airportFile = fopen(airports,read);
    if(!airportFile) {
	fprintf(stderr,"Cannot open file with list of airport names.");
	exit(EXIT_FAILURE);
    }
    flightSys_t* s = createSystem();
    if(s==NULL) {
	printf("createSystem unimplemented\n");
	return;
    }
    printf("***Parse and echo airports***\n");
    parseAirports(s,airportFile);
    fclose(airportFile);
    printAirports(s);
 
  scheduleFile = fopen(schedules,read);
    if(!scheduleFile) {
	fprintf(stderr,"Cannot open file with schedule.");
	exit(EXIT_FAILURE);
    }
    printf("\n***Parse and echo schedules***\n");
    parseSchedule(s,scheduleFile);  
    fclose(scheduleFile);
    routeFile = fopen(routes,read);
    if(!routeFile) {
	fprintf(stderr,"Cannot open file with routes.");
	exit(EXIT_FAILURE);
    }
    printf("\n***Parse and calculate route times***\n");
    calcRouteTimes(s,routeFile);
    fclose(routeFile);

    deleteSystem(s);
}