6 #include "getopts/getopts.h"
17 int main(
int argc,
char **argv ) {
22 opts.addOption(
"" ,
"log-level" ,
"Set the log level (debug, warn, info, error)",
true );
23 opts.addOption(
"v",
"version" ,
"Display version info" ,
false );
24 opts.addOption(
"d",
"scan-dir" ,
"Directory to be scanned for layers" ,
true );
25 opts.addOption(
"s",
"result" ,
"File to store scan result" ,
true );
26 opts.addOption(
"l",
"check" ,
"Layer to be checked" ,
true );
27 opts.addOption(
"c",
"config-file",
"Configuration file for openModeller" ,
true );
29 std::string log_level(
"info");
32 std::string config_file;
33 std::string result_file;
35 if ( ! opts.parse( argc, argv ) ) {
37 opts.showHelp( argv[0] );
43 while ( ( option = opts.cycle() ) >= 0 ) {
48 log_level = opts.getArgs( option );
51 printf(
"om_layer %s\n", om.
getVersion().c_str() );
52 printf(
"This is free software; see the source for copying conditions. There is NO\n");
53 printf(
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
57 scan_dir = opts.getArgs( option );
60 result_file = opts.getArgs( option );
63 layer_id = opts.getArgs( option );
66 config_file = opts.getArgs( option );
75 if ( (scan_dir.empty() && layer_id.empty()) || (!scan_dir.empty() && !layer_id.empty()) ) {
77 printf(
"Please specify one and only one of the parameters: --check layer_id, --scan-dir directory\n");
87 if ( ! config_file.empty() ) {
92 if ( layer_id.size() > 0 ) {
100 catch ( std::runtime_error e ) {
102 printf(
"Failed to process raster %s:\n\n%s\n", layer_id.c_str(), e.what() );
114 if ( !
readDirectory( scan_dir.c_str(),
"Layers", oss, 0, &seq ) ) {
116 printf(
"Failed to scan specified directory\n" );
123 if ( ! result_file.empty() ) {
125 ofstream file( result_file.c_str() );
132 std::cout << oss.str().c_str() << endl << flush;
static void loadConfig(const std::string configFile)
static Log * instance()
Returns the instance pointer, creating the object on the first call.
A common interface to rasters.
Log::Level getLogLevel(std::string level)
int main(int argc, char **argv)
void setLevel(Level level)
bool readDirectory(const char *dir, const char *label, ostream &xml, int depth, int *seq)
static RasterFactory & instance()
Raster * create(const string &source, int categ=0)