Blame view

src/TTConversion/TTConversionLauncher.cc 2.27 KB
81286aae   Elena.Budnik   TT conversion
1
2
3
4
5
6
7
8
9
/*
 * OperationsLauncher.cc
 *
 *  Created on: Feb 2017 
 *     
 */

#include <iostream>
#include <cstring>
5b387233   Vincent Cephirins   RM7926 - Evol - C...
10
11
12
13
14

// Common include modules
#include "OutputFormatTime.hh"


81286aae   Elena.Budnik   TT conversion
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "TimeTableCatalogFactory.hh"
#include "Application.hh"
#include <log4cxx/logger.h>

/**
 * Logger
 */
log4cxx::LoggerPtr _logger(
		log4cxx::Logger::getLogger("AMDA-Kernel.TTConversion"));

/**
 * Shows help on std::cout.
 */
void help() {
5b387233   Vincent Cephirins   RM7926 - Evol - C...
29
30
	std::cout << "Use : ttConversion InputFileName InputFileFormat OutputDir OutputFileName OutputFileFormat [OutputTimeFormat]" << std::endl;
	std::cout << "         OutputTimeFormat with values: ISO (default), DD,  DOUBLE, SPACES or MS" << std::endl;
81286aae   Elena.Budnik   TT conversion
31
32
33
34
35
36
37
38
39
40
41
42
43
44
}	


/**
 * Main for ttConversion binary.
 */
int ttConversion(int argc, char *argv[], AMDA::helpers::Properties& /*properties*/) {

	// executable options
	if (argc < 6 || (argc > 1 && strcmp(argv[1], "--help") == 0)) {
		help();
		return -1;
	}
	
5b387233   Vincent Cephirins   RM7926 - Evol - C...
45
        // Default value for time format (Option)
b3096d5d   Hacene SI HADJ MOHAND   correcting time i...
46
47
          AMDA::OutputFormatTime timeFormat = AMDA::OutputFormatTime::FORMAT_OUTPUT_TIME_ISO;
          if (argc >= 7) {
5b387233   Vincent Cephirins   RM7926 - Evol - C...
48
49
50
           // Map time enum between php and C++
           // See Request/TTRequestImpl/TTRequestDataClass.php and AMDA_Kernel/src/Common/OutputFormatTime.hh
           const string pTimeFormat = argv[6];
44751e8b   Hacene SI HADJ MOHAND   I have changed DD...
51
           if (pTimeFormat.compare("DOY TIME") == 0) timeFormat = AMDA::OutputFormatTime::FORMAT_OUTPUT_TIME_DD;
5b387233   Vincent Cephirins   RM7926 - Evol - C...
52
53
54
55
           else if (pTimeFormat.compare("DOUBLE") == 0) timeFormat = AMDA::OutputFormatTime::FORMAT_OUTPUT_TIME_DOUBLE;
           else if (pTimeFormat.compare("SPACES") == 0) timeFormat = AMDA::OutputFormatTime::FORMAT_OUTPUT_TIME_SPACES;
           else if (pTimeFormat.compare("MS") == 0) timeFormat = AMDA::OutputFormatTime::FORMAT_OUTPUT_TIME_MS;
	}
b3096d5d   Hacene SI HADJ MOHAND   correcting time i...
56
57
58
59
60
         const string ttFormat = argv[5];
         if(ttFormat.compare("SPACE") ==0)
            timeFormat= AMDA::OutputFormatTime::FORMAT_OUTPUT_TIME_ISO_Z;
        
          TimeTableCatalog::TimeTable ttMgr(timeFormat);
81286aae   Elena.Budnik   TT conversion
61
		
b3096d5d   Hacene SI HADJ MOHAND   correcting time i...
62
63
64
          ttMgr.convert(std::string(argv[1]), std::string(argv[2]), std::string(argv[3]), std::string(argv[4]), std::string(argv[5]));
          
          return 0;
81286aae   Elena.Budnik   TT conversion
65
66
67
68
69
70
71
72
}

/**
 * Main function
 */
int main(int argc, char *argv[]) {

	AMDA::Common::Application lMain;
76a58853   Benjamin Renard   Skip pluggins loa...
73
	return lMain.main(argc, argv, ttConversion, true); //Skip plugin load
81286aae   Elena.Budnik   TT conversion
74
}