OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimSlopeTool.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 <ossim/init/ossimInit.h>
11 #include <ossim/base/ossimNotify.h>
13 #include <ossim/base/ossimGrect.h>
14 #include <ossim/base/ossimIrect.h>
16 #include <ossim/base/ossimString.h>
31 #include <iostream>
32 
33 using namespace std;
34 
35 const char* ossimSlopeTool::DESCRIPTION =
36  "Utility for computing the slope at each elevation post and generating "
37  "a corresponding slope image.";
38 
40 : m_recursiveCall (false)
41 {
42 }
43 
45 {
46 }
47 
49 {
50  // Add options.
52  ossimString usageString = ap.getApplicationName();
53  usageString += " slope [options] <output-image>";
54  au->setCommandLineUsage(usageString);
55 
56  // Set the command line options:
58 
59  // Base class has its own:
61 }
62 
64 {
66  return false;
67  if (m_helpRequested)
68  return true;
69 
71  return true;
72 }
73 
75 {
76  // Base class does the heavy work:
78 }
79 
81 {
82  ostringstream key;
83 
84  // Reinitialization needs to skip this method if called recursively:
85  if (m_recursiveCall)
86  return;
87 
88  // Need to establish list of DEM cells given either the bounding rect or explicit DEM cells:
89  if (m_demSources.empty())
90  {
91  // Query elevation manager for cells providing needed coverage:
92  std::vector<ossimFilename> cells;
94 
95  // Insert the list of DEM cells into the KWL as input images:
97  for(ossim_uint32 idx=0; idx<cells.size(); ++idx)
98  {
99  // Add the DEM as an image source to the KWL:
100  ostringstream key;
102  m_kwl.addPair(key.str(), cells[idx].string() );
103  }
104  }
105  else
106  {
107  // DEMs explicitly listed in keywordlist, use these:
108  for(ossim_uint32 idx=0; idx<m_demSources.size(); ++idx)
109  {
110  // Add the DEM as an image source to the KWL:
111  ostringstream key;
113  m_kwl.addPair(key.str(), m_demSources[idx].string() );
114  }
115  }
116 
117  // Remove any occurence of elev_source in the KWL:
119  regex += "*";
120  m_kwl.removeKeysThatMatch(regex);
121 
122  // Reinitialize the object with the DEMs listed as input images and create a mosaic of them:
123  m_recursiveCall = true;
124  initialize(m_kwl);
125  m_recursiveCall = false;
127  m_procChain->add(combiner.get());
128 
129  // Finally add the slope filter:
132  m_procChain->add(slope_filter.get());
133 }
134 
virtual bool initialize(ossimArgumentParser &ap)
Initial method to be ran prior to execute.
std::string getApplicationName() const
return the application name, as specified by argv[0]
virtual void setUsage(ossimArgumentParser &ap)
Initializes the aurgument parser with expected parameters and options.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
Filter class for computing the slope image of the input image connection.
ossimGrect m_aoiGroundRect
Represents serializable keyword/value map.
bool m_helpRequested
Definition: ossimTool.h:150
virtual void initProcessingChain()
Derived classes initialize their custom chains here.
ossimKeywordlist m_kwl
Definition: ossimTool.h:148
ossimRefPtr< ossimImageSource > combineLayers(std::vector< ossimRefPtr< ossimSingleImageChain > > &layers) const
When multiple input sources are present, this method instantiates a combiner and adds inputs...
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
static ossimElevManager * instance()
METHOD: instance() Implements singelton pattern.
void setCommandLineUsage(const ossimString &explanation)
ossimApplicationUsage * getApplicationUsage()
void getCellsForBounds(const std::string &connectionString, const ossim_float64 &minLat, const ossim_float64 &minLon, const ossim_float64 &maxLat, const ossim_float64 &maxLon, std::vector< ossimFilename > &cells, ossim_uint32 maxNumberOfCells=0)
Gets a list of elevation cells needed to cover bounding box.
ossimRefPtr< ossimImageChain > m_procChain
void removeKeysThatMatch(const ossimString &regularExpression)
std::vector< ossimFilename > m_demSources
virtual void setUsage(ossimArgumentParser &ap)
Initializes the aurgument parser with expected parameters and options.
std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
unsigned int ossim_uint32
void processRemainingArgs(ossimArgumentParser &ap)
Intended to be called after derived class has picked off its own options from the parser...
std::vector< ossimRefPtr< ossimSingleImageChain > > m_imgLayers
virtual bool add(ossimConnectableObject *source)
Will return true or false if an image source was added to the chain.
virtual bool initialize(ossimArgumentParser &ap)
Initializes from command line arguments.
void setSlopeType(SlopeType t)
void setDescription(const ossimString &desc)
static const char * DESCRIPTION
Used by ossimUtilityFactory.
static const char * IMAGE_FILE_KW
static const char * ELEVATION_SOURCE_KW