TTConversionLauncher.cc
2.27 KB
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
/*
* OperationsLauncher.cc
*
* Created on: Feb 2017
*
*/
#include <iostream>
#include <cstring>
// Common include modules
#include "OutputFormatTime.hh"
#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() {
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;
}
/**
* 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;
}
// Default value for time format (Option)
AMDA::OutputFormatTime timeFormat = AMDA::OutputFormatTime::FORMAT_OUTPUT_TIME_ISO;
if (argc >= 7) {
// Map time enum between php and C++
// See Request/TTRequestImpl/TTRequestDataClass.php and AMDA_Kernel/src/Common/OutputFormatTime.hh
const string pTimeFormat = argv[6];
if (pTimeFormat.compare("DOY TIME") == 0) timeFormat = AMDA::OutputFormatTime::FORMAT_OUTPUT_TIME_DD;
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;
}
const string ttFormat = argv[5];
if(ttFormat.compare("SPACE") ==0)
timeFormat= AMDA::OutputFormatTime::FORMAT_OUTPUT_TIME_ISO_Z;
TimeTableCatalog::TimeTable ttMgr(timeFormat);
ttMgr.convert(std::string(argv[1]), std::string(argv[2]), std::string(argv[3]), std::string(argv[4]), std::string(argv[5]));
return 0;
}
/**
* Main function
*/
int main(int argc, char *argv[]) {
AMDA::Common::Application lMain;
return lMain.main(argc, argv, ttConversion, true); //Skip plugin load
}