OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimDemToolConfig.cpp
Go to the documentation of this file.
1 //**************************************************************************************************
2 //
3 // OSSIM Open Source Geospatial Data Processing Library
4 // See top level LICENSE.txt file for license information
5 //
6 //**************************************************************************************************
7 
8 #include "ossimDemToolConfig.h"
9 
10 #include <ossim/base/ossimCommon.h>
13 #include <memory>
14 #include <ossim/base/ossimNotify.h>
15 
16 using namespace std;
17 using namespace ossim;
18 
20 {
21  static ossimDemToolConfig singleton;
22  return singleton;
23 }
24 
26 {
27 
28  // Register the ISA-common parameters in the params map:
29  //TODO:
30  // readConfig();
31 }
32 
34 {
35  m_paramsMap.clear();
36 }
37 
38 bool ossimDemToolConfig::readConfig(const string& cn)
39 {
40  // This method could eventually curl a spring config server for the param JSON. For now it
41  // is reading the installed share/ossim-isa system directory for config JSON files.
42 
43  // The previous parameters list is cleared first for a fresh start:
44  m_paramsMap.clear();
45 
46  ossimFilename configFilename;
47  Json::Value jsonRoot;
48  try
49  {
50  // First establish the directory location of the default config files:
52  preferencesKWL().findKey( std::string( "ossim_share_directory" ) );
53  shareDir += "/dem";
54  if (!shareDir.isDir())
55  throw ossimException("Nonexistent share drive provided for config files.");
56 
57  // Read the default common parameters first:
58  configFilename = "demToolConfig.json";
59  configFilename.setPath(shareDir);
60  if (!open(configFilename))
61  throw ossimException("Bad file open or parse.");
62 
63  // Read the algorithm-specific default parameters if generic algo name specified as config:
64 // ossimString configName (cn);
65 // configFilename.clear();
66 // if (configName == "crosscorr")
67 // configFilename = "crossCorrConfig.json";
68 // else if (configName == "descriptor")
69 // configFilename = "descriptorConfig.json";
70 // else if (configName == "nasa")
71 // configFilename = "nasaConfig.json";
72 // else if (!configName.empty())
73 // {
74 // // Custom configuration. TODO: the path here is still the install's share directory.
75 // // Eventually want to provide a database access to the config JSON.
76 // configFilename = configName + ".json";
77 // }
78 
79  // Load the specified configuration. This will override the common defaults:
80 // if (!configFilename.empty())
81 // {
82 // configFilename.setPath(shareDir);
83 // if (!open(configFilename))
84 // throw ossimException("Bad file open or parse.");
85 // }
86  }
87  catch (ossimException& e)
88  {
89  ossimNotify(ossimNotifyLevel_WARN)<<"ossimDemToolConfig::readConfig(): Could not open/parse "
90  "config file at <"<< configFilename << ">. Error: "<<e.what()<<endl;
91  return false;
92  }
93  return true;
94 }
95 
Singleton class maintaining parameters affecting the automatic tie point generation.
This code was derived from https://gist.github.com/mshockwave.
Definition: Barrier.h:8
ossimFilename & setPath(const ossimString &p)
bool isDir() const
bool readConfig(const std::string &configName="")
virtual const char * what() const
Returns the error message.
virtual ~ossimDemToolConfig()
Destructor.
static ossimPreferences * instance()
static ossimDemToolConfig & instance()
Singleton implementation.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)