OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ossimHdf5Tool Class Reference

#include <ossimHdf5Tool.h>

Inheritance diagram for ossimHdf5Tool:
ossimChipProcTool ossimTool ossimProcessInterface ossimListenerManager ossimObject ossim::JsonInterface ossimReferenced

Public Member Functions

 ossimHdf5Tool ()
 
 ~ossimHdf5Tool ()
 
virtual void setUsage (ossimArgumentParser &ap)
 Initializes the aurgument parser with expected parameters and options. More...
 
virtual bool initialize (ossimArgumentParser &ap)
 Initializes from command line arguments. More...
 
virtual void initialize (const ossimKeywordlist &kwl)
 Reads processing params from KWL and prepares for execute. More...
 
virtual bool execute ()
 Performs the actual product write. More...
 
virtual ossimString getClassName () const
 
- Public Member Functions inherited from ossimChipProcTool
 ossimChipProcTool ()
 default constructor More...
 
virtual ~ossimChipProcTool ()
 virtual destructor More...
 
virtual void clear ()
 Disconnects and clears the dem and image layers. More...
 
virtual void abort ()
 
virtual bool isChipProcessor () const
 Overrides base class implementation to indicate this class supports getChip() calls. More...
 
virtual ossimListenerManagergetManager ()
 
virtual ossimObjectgetObject ()
 
virtual const ossimObjectgetObject () const
 
virtual ossimRefPtr< ossimImageDatagetChip (const ossimIrect &img_rect)
 The meat and potatos of this class. More...
 
virtual ossimRefPtr< ossimImageDatagetChip (const ossimGrect &gnd_rect)
 
ossimRefPtr< ossimImageDatagetChip (const ossimDrect &map_bounding_rect, const ossimDpt &gsd)
 
ossimRefPtr< ossimImageDatagetChip ()
 Get chip method that assumes pre-initialized state. More...
 
const ossimFilenamegetProductFilename () const
 
- Public Member Functions inherited from ossimTool
 ossimTool ()
 
virtual ~ossimTool ()
 
virtual void loadJSON (const Json::Value &json_request)
 Reads processing params from JSON object provided. More...
 
virtual void saveJSON (Json::Value &json) const
 Fetch product as JSON object when applicable Always returns true since using exception on error. More...
 
virtual const std::string & getResponse () const
 Fetch product as string (typically JSON) when applicable, otherwise passes back empty string. More...
 
virtual void getKwlTemplate (ossimKeywordlist &kwl)
 Assigns a template keywordlist to string for initializing derived classes. More...
 
void getAPI (std::string &out) const
 Outputs a JSON representation of the Utility's API. More...
 
std::string getAPI () const
 
void getBuildDate (std::string &s) const
 Gets build date. More...
 
void getRevision (std::string &s) const
 Gets revision. More...
 
void getVersion (std::string &s) const
 Gets version. More...
 
void setOutputStream (std::ostream *os)
 Redirects any console output to the supplied stream for logging or JNI application. More...
 
bool helpRequested () const
 Returns true when the initialization detects a "--help" option, so caller can avoid subsequent execute() call. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossim::JsonInterface
 JsonInterface ()
 
virtual ~JsonInterface ()
 
- Public Member Functions inherited from ossimProcessInterface
 ossimProcessInterface ()
 
virtual ~ossimProcessInterface ()
 
bool needsAborting () const
 
bool isAbortRequested () const
 
bool isAborted () const
 
bool isExecuting () const
 
ossimProcessStatus getProcessStatus () const
 
virtual void setProcessStatus (ossimProcessStatus processStatus)
 
virtual double getPercentComplete () const
 
virtual void setPercentComplete (double percentComplete)
 
void enableEvents ()
 
void disableEvents ()
 
void setCurrentMessage (const ossimString &message)
 
virtual std::ostream & print (std::ostream &out) const
 
- Public Member Functions inherited from ossimListenerManager
 ossimListenerManager ()
 
virtual ~ossimListenerManager ()
 
virtual void fireEvent (ossimEvent &event)
 
virtual bool addListener (ossimListener *listener)
 
virtual bool removeListener (ossimListener *listener)
 
virtual bool findListener (ossimListener *listener)
 

Static Public Attributes

static const char * DESCRIPTION = "Utility for parsing and extracting HDF5 image data."
 Used by ossimUtilityFactory. More...
 

Protected Member Functions

virtual void initProcessingChain ()
 Derived classes initialize their custom chains here. More...
 
virtual void loadImageFiles ()
 Creates chains for image entries associated with specified keyword. More...
 
- Protected Member Functions inherited from ossimChipProcTool
void processRemainingArgs (ossimArgumentParser &ap)
 Intended to be called after derived class has picked off its own options from the parser, and arguments remain (such as input and output filenames). More...
 
virtual void finalizeChain ()
 Called after initProcessingChain() to append common items to the processing chain. More...
 
virtual void loadDemFiles ()
 Loads all DEM files specified in master KWL into the elev manager's database. More...
 
ossimRefPtr< ossimSingleImageChaincreateInputChain (const ossimFilename &image_file, ossim_uint32 entry_index=0)
 Creates the ossimSingleImageChain from image filename and populates the chain with resampler and product output projection on view-side of resampler's IVT. More...
 
void createOutputProjection ()
 Creates the output or view projection. More...
 
ossimRefPtr< ossimMapProjectionnewIdentityProjection ()
 Sets the single image chain for identity operations view to a ossimImageViewAffineTransform. More...
 
ossimRefPtr< ossimMapProjectionnewUtmProjection ()
 Convenience method to get a utm projection. More...
 
virtual void initializeProjectionGsd ()
 Initializes the projection gsd. More...
 
virtual void initializeAOI ()
 Initializes m_aoiViewRect with the output area of interest as specified in master KWL. More...
 
bool getProjectionOrigin (ossimGpt &gpt)
 Reads the KWL for origin latitude and central meridian. More...
 
ossimRefPtr< ossimImageFileWriternewWriter ()
 Creates a new writer. More...
 
void propagateGeometryToChains ()
 Loops through all chains and sets the output projection. More...
 
ossimRefPtr< ossimImageSourcecombineLayers (std::vector< ossimRefPtr< ossimSingleImageChain > > &layers) const
 When multiple input sources are present, this method instantiates a combiner and adds inputs. More...
 
void computeAdjustedViewFromGrect ()
 Initializes m_aoiViewRect given m_aoiGroundRect. More...
 
void setAoiToInputs ()
 Assigns the AOI to be the bounding rect of the union of all inputs. More...
 
void getBandList (ossim_uint32 image_idx, std::vector< ossim_uint32 > &bandList) const
 Gets the band list if BANDS keyword is set. More...
 
void setReaderProps (ossimImageHandler *ih) const
 Passes reader properties to single image handler if any. More...
 
 ossimChipProcTool (const ossimChipProcTool &obj)
 Hidden from use copy constructor. More...
 
const ossimChipProcTooloperator= (const ossimChipProcTool &)
 Hidden from use assignment operator. More...
 
ossimRefPtr< ossimGeoPolygoncreateClipPolygon () const
 
void findCenterGpt (ossimGpt &gpt)
 Tries to determine the AOI center point based on KWL entries, else returns NaNs in gpt. More...
 
ossimRefPtr< ossimImageSourcemosaicDemSources ()
 Some utilities need to work on DEMs as images. More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimListenerManager
 ossimListenerManager (const ossimListenerManager &rhs)
 

Protected Attributes

ossimString m_imageDataPath
 
ossimString m_geomDataPath
 
bool m_dumpInfo
 
bool m_dumpKwl
 
bool m_listDatasets
 
bool m_listNdimDatasets
 
ossimFilename m_geomFilename
 
ossimRefPtr< ossimHdf5m_hdf5
 
- Protected Attributes inherited from ossimChipProcTool
ossimRefPtr< ossimImageGeometrym_geom
 
ossimIrect m_aoiViewRect
 
ossimGrect m_aoiGroundRect
 
std::vector< ossimRefPtr< ossimSingleImageChain > > m_imgLayers
 
std::vector< ossimFilenamem_demSources
 
ossimRefPtr< ossimImageFileWriterm_writer
 
ossimRefPtr< ossimImageChainm_procChain
 
ossimRefPtr< ossimRectangleCutFilterm_cutRectFilter
 
bool m_projIsIdentity
 
ossimDpt m_gsd
 
bool m_geoScaled
 
ossimFilename m_productFilename
 
ossimScalarType m_productScalarType
 
bool m_needCutRect
 
- Protected Attributes inherited from ossimTool
ossimKeywordlist m_kwl
 
std::ostream * m_consoleStream
 
bool m_helpRequested
 
std::string m_response
 
- Protected Attributes inherited from ossimProcessInterface
double thePercentComplete
 
ossimProcessStatus theProcessStatus
 
ossimString theMessage
 
bool theEventFlag
 
- Protected Attributes inherited from ossimListenerManager
std::list< ossimListener * > theListenerList
 
bool theEnabledFlag
 
std::list< ossimListener * > theDelayedAdd
 
std::list< ossimListener * > theDelayedRemove
 
bool theFireEventFlag
 

Additional Inherited Members

- Public Types inherited from ossimProcessInterface
enum  ossimProcessStatus {
  PROCESS_STATUS_UNKNOWN = 0, PROCESS_STATUS_EXECUTING = 1, PROCESS_STATUS_ABORTED = 2, PROCESS_STATUS_ABORT_REQUEST = 3,
  PROCESS_STATUS_NOT_EXECUTING = 4
}
 

Detailed Description

Class for computing the slope on each elevation post and generatinga corresponding slope image. The output scalar type is a normalized float unless unsigned 8-bit is selected via the options.

Definition at line 25 of file ossimHdf5Tool.h.

Constructor & Destructor Documentation

◆ ossimHdf5Tool()

ossimHdf5Tool::ossimHdf5Tool ( )

Definition at line 38 of file ossimHdf5Tool.cpp.

39 : m_dumpInfo (false),
40  m_dumpKwl (false),
41  m_listDatasets (false),
42  m_listNdimDatasets (false)
43 {
44 }
bool m_listNdimDatasets
Definition: ossimHdf5Tool.h:69

◆ ~ossimHdf5Tool()

ossimHdf5Tool::~ossimHdf5Tool ( )

Definition at line 46 of file ossimHdf5Tool.cpp.

47 {
48 }

Member Function Documentation

◆ execute()

bool ossimHdf5Tool::execute ( )
virtual

Performs the actual product write.

Note
Throws ossimException on error.

Reimplemented from ossimChipProcTool.

Definition at line 283 of file ossimHdf5Tool.cpp.

References ossimString::c_str(), ossimChipProcTool::execute(), ossimRefPtr< T >::get(), ossimHdf5::getDatasets(), ossimHdf5::getNdimDatasets(), ossimImageGeometry::getProjection(), ossimHdf5::getRoot(), m_dumpInfo, m_dumpKwl, m_hdf5, ossimChipProcTool::m_imgLayers, m_listDatasets, m_listNdimDatasets, ossimChipProcTool::m_productFilename, ossimFilename::noExtension(), ossimKeywordlist::print(), ossimCoarseGridModel::saveCoarseGrid(), ossimImageGeometry::saveState(), ossimString::string(), ossimRefPtr< T >::valid(), and ossimKeywordlist::write().

284 {
285  // Need to fix output to tiff
286 
287  ostringstream errMsg;
288  if (!m_hdf5.valid())
289  return false;
290 
292  {
293  ossimHdf5Info info (m_hdf5.get());
294  if (m_dumpKwl)
295  {
296  ossimKeywordlist kwl;
297  info.getKeywordlist(kwl);
298  kwl.print(cout);
299  }
300  if (m_dumpInfo)
301  {
302  info.print(cout);
303  }
304 
305  Group root;
306  m_hdf5->getRoot(root);
307  vector<DataSet> datasets;
308  if (m_listDatasets)
309  m_hdf5->getDatasets(root, datasets, true);
310  else if (m_listNdimDatasets)
311  m_hdf5->getNdimDatasets(root, datasets, true);
312  for (ossim_uint32 i=0; i<datasets.size(); ++i)
313  {
314  info.print(cout, datasets[i]);
315  }
316  }
317 
318  if (m_imgLayers.empty())
319  return true;
320 
322  return false;
323 
324  ossimRefPtr<ossimImageGeometry> geom = m_imgLayers[0]->getImageGeometry();
325  if (geom.valid())
326  {
328  if ( proj.valid() )
329  {
331  geomFile.string() += ".geom";
332 
333  // Assume it is coarse grid (case for VIIRS):
334  ossimRefPtr<ossimHdf5GridModel> cg = dynamic_cast<ossimHdf5GridModel*>( proj.get() );
335  if ( cg.valid() )
336  {
337  // this saves geom file as well
338  cg->saveCoarseGrid( geomFile );
339  cout << "Wrote file: " << geomFile << endl;
340  }
341  else
342  {
343  // Save the state to keyword list.
344  ossimKeywordlist geomKwl;
345  geom->saveState(geomKwl);
346 
347  // Write to file:
348  geomKwl.write( geomFile.c_str() );
349  cout << "Wrote file: " << geomFile << endl;
350  }
351  }
352  }
353 
354  return true;
355 }
ossimFilename noExtension() const
virtual std::ostream & print(std::ostream &os) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
bool getRoot(H5::Group &root) const
Assigns the root group.
Definition: ossimHdf5.cpp:93
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
static bool getDatasets(H5::Group group, std::vector< H5::DataSet > &datasetList, bool recursive=false)
Assigns list of datasets under specified group.
Definition: ossimHdf5.cpp:150
ossimRefPtr< ossimHdf5 > m_hdf5
Definition: ossimHdf5Tool.h:71
ossimFilename m_productFilename
unsigned int ossim_uint32
std::vector< ossimRefPtr< ossimSingleImageChain > > m_imgLayers
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
TIFF info class.
Definition: ossimHdf5Info.h:33
bool m_listNdimDatasets
Definition: ossimHdf5Tool.h:69
bool saveCoarseGrid(const ossimFilename &cgFileName) const
Saves the coarse grid to the specified file.
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the transform (if any) and projection (if any) states to the KWL.
static bool getNdimDatasets(H5::Group group, std::vector< H5::DataSet > &datasetList, bool recursive=false)
Assigns list of all multi-dimensional datasets under current active group.
Definition: ossimHdf5.cpp:188
virtual bool execute()
Performs the actual product write.
const std::string & string() const
Definition: ossimString.h:414

◆ getClassName()

virtual ossimString ossimHdf5Tool::getClassName ( ) const
inlinevirtual

Reimplemented from ossimTool.

Definition at line 54 of file ossimHdf5Tool.h.

54 { return "ossimHdf5Tool"; }

◆ initialize() [1/2]

bool ossimHdf5Tool::initialize ( ossimArgumentParser ap)
virtual

Initializes from command line arguments.

Returns
FALSE if –help option requested or no params provided, so that derived classes can
Note
Throws ossimException on error.

Reimplemented from ossimChipProcTool.

Definition at line 79 of file ossimHdf5Tool.cpp.

References ossimKeywordlist::addPair(), ossimChipProcTool::initialize(), ossimTool::m_helpRequested, ossimTool::m_kwl, and ossimArgumentParser::read().

80 {
82  return false;
83  if (m_helpRequested)
84  return true;
85 
86  std::string tempString1;
87  ossimArgumentParser::ossimParameter stringParam1(tempString1);
88  const string TRUE_STR ("true");
89 
90  if ( ap.read("--geom-dataset", stringParam1) || ap.read("--gdata", stringParam1))
91  m_kwl.addPair(GEOM_DATASET_KW, tempString1);
92 
93  if ( ap.read("--geom", stringParam1))
95 
96  if ( ap.read("--image-dataset", stringParam1) || ap.read("--idata", stringParam1))
97  m_kwl.addPair(IMAGE_DATASET_KW, tempString1);
98 
99  if ( ap.read("--list-datasets"))
100  m_kwl.addPair(LIST_DATASETS_KW, TRUE_STR);
101 
102  if ( ap.read("--list-ndims") )
103  m_kwl.addPair(LIST_NDIMS_KW, TRUE_STR);
104 
105  if ( ap.read("--info") )
106  m_kwl.addPair(DUMP_INFO_KW, TRUE_STR);
107 
108  if ( ap.read("--kwl") )
109  m_kwl.addPair(DUMP_KWL_KW, TRUE_STR);
110 
112 
113  if ( ap.argc() > 1 )
114  {
115  // If input file already specified, then remaining arg is output file:
118  else
119  {
120  // No input specified, so remaining args contains the input filename:
121  if (ap.argc() == 2)
123  else
124  {
127  }
128  }
129  }
130 
131  initialize(m_kwl);
132  return true;
133 }
virtual bool initialize(ossimArgumentParser &ap)
Initial method to be ran prior to execute.
ossim_uint32 numberOf(const char *str) const
static const char * OUTPUT_FILE_KW
bool m_helpRequested
Definition: ossimTool.h:150
bool read(const std::string &str)
search for an occurance of a string in the argument list, on sucess remove that occurance from the li...
ossimKeywordlist m_kwl
Definition: ossimTool.h:148
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
void reportRemainingOptionsAsUnrecognized(ossimErrorSeverity severity=OSSIM_BENIGN)
for each remaining option report it as an unrecongnized.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static const char * GEOM_FILE_KW
virtual bool initialize(ossimArgumentParser &ap)
Initializes from command line arguments.
static const char * IMAGE_FILE_KW
int & argc()
return the argument count.

◆ initialize() [2/2]

void ossimHdf5Tool::initialize ( const ossimKeywordlist kwl)
virtual

Reads processing params from KWL and prepares for execute.

Returns TRUE if successful.

Note
Throws ossimException on error.

Reimplemented from ossimChipProcTool.

Definition at line 135 of file ossimHdf5Tool.cpp.

References ossimKeywordlist::addList(), ossimKeywordlist::clear(), ossimKeywordlist::findKey(), m_imageDataPath, and ossimTool::m_kwl.

136 {
137  ostringstream xmsg;
138 
139  // Don't copy KWL if member KWL passed in:
140  if (&kwl != &m_kwl)
141  {
142  // Start with clean options keyword list.
143  m_kwl.clear();
144  m_kwl.addList( kwl, true );
145  }
146 
147  m_imageDataPath = m_kwl.findKey(IMAGE_DATASET_KW);
148  m_geomDataPath = m_kwl.findKey(GEOM_DATASET_KW);
150 
151  m_kwl.getBoolKeywordValue(m_listDatasets, LIST_DATASETS_KW.c_str());
152  m_kwl.getBoolKeywordValue(m_listNdimDatasets, LIST_NDIMS_KW.c_str());
153  m_kwl.getBoolKeywordValue(m_dumpInfo, DUMP_INFO_KW.c_str());
154  m_kwl.getBoolKeywordValue(m_dumpKwl, DUMP_KWL_KW.c_str());
155 
157  if (hdfFile.empty() )
158  {
159  xmsg<<"ERROR: ossimHdf5Tool:"<<__LINE__<<" -- No input filename was specified.";
160  throw ossimException(xmsg.str());
161  }
162 
163  m_hdf5 = new ossimHdf5;
164  if (!m_hdf5->open(hdfFile))
165  {
166  xmsg<<"ERROR: ossimHdf5Tool:"<<__LINE__<<" -- Could not open <"<<hdfFile
167  <<"> as an HDF5 file.";
168  throw ossimException(xmsg.str());
169  }
170 
172  return;
173 
174  // Only if an output file is specified, do we need the services of ossimChipProcTool:
176 
178  if (m_imgLayers.empty())
179  {
180  xmsg<<"ERROR: ossimHdf5Tool:"<<__LINE__<<" -- No input chain available. Make sure an HDF5"
181  " input file name is specified";
182  throw ossimException(xmsg.str());
183  }
184 
185  // If dataset specified, then expect product filename:
187  {
188  m_productFilename = hdfFile;
190  }
191 }
virtual bool initialize(ossimArgumentParser &ap)
Initial method to be ran prior to execute.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
ossimString m_imageDataPath
Definition: ossimHdf5Tool.h:64
static const char * OUTPUT_FILE_KW
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
const char * find(const char *key) const
void addList(const ossimKeywordlist &src, bool overwrite=true)
ossimKeywordlist m_kwl
Definition: ossimTool.h:148
bool open(const ossimFilename &hdf5File)
Opens specified HDF5 file.
Definition: ossimHdf5.cpp:29
ossimRefPtr< ossimHdf5 > m_hdf5
Definition: ossimHdf5Tool.h:71
ossimFilename m_productFilename
ossimFilename m_geomFilename
Definition: ossimHdf5Tool.h:70
std::vector< ossimRefPtr< ossimSingleImageChain > > m_imgLayers
static const char * GEOM_FILE_KW
bool getBoolKeywordValue(bool &rtn_val, const char *keyword, const char *prefix=0) const
[OLK, Aug/2008] Sets the boolean <rtn_val> depending on value associated with keyword for values = (y...
Low-level OSSIM interface to HDF5 libraries.
Definition: ossimHdf5.h:27
bool m_listNdimDatasets
Definition: ossimHdf5Tool.h:69
bool empty() const
Definition: ossimString.h:411
ossimString m_geomDataPath
Definition: ossimHdf5Tool.h:65
static const char * IMAGE_FILE_KW
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.

◆ initProcessingChain()

void ossimHdf5Tool::initProcessingChain ( )
protectedvirtual

Derived classes initialize their custom chains here.

Implements ossimChipProcTool.

Definition at line 266 of file ossimHdf5Tool.cpp.

References ossimImageChain::add(), ossimChipProcTool::combineLayers(), ossimRefPtr< T >::get(), ossimChipProcTool::m_imgLayers, ossimChipProcTool::m_procChain, OSSIM_UINT16, ossimShiftFilter::setMaxPixelValue(), ossimShiftFilter::setMinPixelValue(), and ossimShiftFilter::setNullPixelValue().

267 {
269  m_procChain->add(input_mosaic.get());
270 
272  sf->setNullPixelValue( 0.0 );
273  sf->setMinPixelValue( 1.0 );
274  sf->setMaxPixelValue( 65535.0 );
275  m_procChain->add( sf.get() );
276 
277  // Cast it to uint16:
279  m_procChain->add( cf.get() );
280 
281 }
16 bit unsigned integer
void setNullPixelValue(double null)
Set the null output pixel.
ossimRefPtr< ossimImageSource > combineLayers(std::vector< ossimRefPtr< ossimSingleImageChain > > &layers) const
When multiple input sources are present, this method instantiates a combiner and adds inputs...
Class to shift/stretch input values to given min/max.
ossimRefPtr< ossimImageChain > m_procChain
void setMaxPixelValue(double max)
Set the max output pixel.
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.
void setMinPixelValue(double min)
Set the min output pixel.

◆ loadImageFiles()

void ossimHdf5Tool::loadImageFiles ( )
protectedvirtual

Creates chains for image entries associated with specified keyword.

This is usually the input image sources but could also be used for reading list of color sources.

Note
Throws ossimException on error.

Reimplemented from ossimChipProcTool.

Definition at line 193 of file ossimHdf5Tool.cpp.

References ossimImageChain::add(), ossimSingleImageChain::addGeoPolyCutterPolygon(), ossimImageChain::addLast(), ossimHdf5ImageHandler::addRenderable(), ossimString::empty(), ossimKeywordlist::find(), ossimKeywordlist::findKey(), ossimRefPtr< T >::get(), ossimImageChain::getOutputScalarType(), ossimKeywordNames::IMAGE_FILE_KW, ossimImageChain::initialize(), ossimImageHandlerRegistry::instance(), m_imageDataPath, ossimChipProcTool::m_imgLayers, ossimTool::m_kwl, ossimChipProcTool::m_procChain, ossimChipProcTool::m_productScalarType, ossimImageHandlerRegistry::open(), ossimHdf5ImageHandler::open(), OSSIM_SCALAR_UNKNOWN, ossimImageHandler::setFilename(), ossimScalarRemapper::setOutputScalarType(), ossim::toVector(), and ossimRefPtr< T >::valid().

194 {
195  ostringstream errMsg;
196 
197  // Special handling needed for loading HDF5 file:
199  if (value.empty())
200  {
201  errMsg<<"ERROR: ossimHdf5Tool:"<<__LINE__<<" -- No input HDF5 file name specified.";
202  throw ossimException(errMsg.str());
203  }
204  ossimFilename imageFilename (value);
205 
206  // If explicit image data paths are specified, open the HDF5 handler directly, otherwise assume
207  // there is a plugin factory that will figure it out:
209  if (m_imageDataPath.empty())
210  {
211  // Use the factory system to instantiate handler, then verify it is HDF5:
213  handler = dynamic_cast<ossimHdf5ImageHandler*>(ih.get());
214  if (!handler.valid())
215  {
216  errMsg<<"ERROR: ossimHdf5Tool:"<<__LINE__<<" -- No HDF5 dataset paths were specified"
217  " and no default HDF5-derived handlers were found. Don't know what dataset to "
218  "extract. Use \"--image-dataset\" option to specify.";
219  throw ossimException(errMsg.str());
220  }
221  }
222  else
223  {
224  // Use explicitely-provided dataset names:
225  handler = new ossimHdf5ImageHandler;
226  handler->addRenderable(m_imageDataPath);
227  handler->setFilename(ossimFilename(value));
228  if (!handler->open())
229  {
230  errMsg<<"ERROR: ossimHdf5Tool:"<<__LINE__<<" -- Could not open <"<<value<<"> as an HDF5 file.";
231  throw ossimException(errMsg.str());
232  }
233  }
234 
235 
236  // Init chain with handler:
238  chain->addLast(handler.get());
239 
240  // Set up the remapper:
243  {
246  chain->add(remapper.get());
247  }
248 
249  // Add geo polygon cutter if specifried:
250  ossimString param = m_kwl.findKey(string("clip_poly_lat_lon"));
251  if (!param.empty())
252  {
253  std::vector<ossimGpt> points;
254  ossim::toVector(points, param);
255  if(points.size() >= 3)
256  {
257  ossimGeoPolygon polygon(points);
258  chain->addGeoPolyCutterPolygon(polygon);
259  }
260  }
261 
262  chain->initialize();
263  m_imgLayers.push_back(chain);
264 }
void addRenderable(const ossimString &datasetName)
Adds the dataset name, either the full HDF5 path or the simple object name, to the list of renderable...
bool addLast(ossimConnectableObject *obj)
Adds it to the end.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
ossimString m_imageDataPath
Definition: ossimHdf5Tool.h:64
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
virtual bool open()
The derived class needs to initialize the raster dataset names m_renderableNames in their constructor...
This is the base class for all imagery using HDF5 as the file format.
virtual void initialize()
ossimKeywordlist m_kwl
Definition: ossimTool.h:148
Single image chain class.
ossimRefPtr< ossimImageChain > m_procChain
virtual ossimScalarType getOutputScalarType() const
This call is passed to the head of the list.
virtual void setOutputScalarType(ossimScalarType scalarType)
Sets the output scalar type.
OSSIM_DLL void toVector(std::vector< ossimDpt > &result, const ossimString &stringOfPoints)
Will take a string list separated by spaces and convert to a vector of ossimDpts. ...
virtual void setFilename(const ossimFilename &filename)
Sets the filename.
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.
ossimScalarType m_productScalarType
bool empty() const
Definition: ossimString.h:411
static ossimImageHandlerRegistry * instance()
static const char * IMAGE_FILE_KW
void addGeoPolyCutterPolygon(const vector< ossimGpt > &polygon)

◆ setUsage()

void ossimHdf5Tool::setUsage ( ossimArgumentParser ap)
virtual

Initializes the aurgument parser with expected parameters and options.

It does not output anything. To see the usage, the caller will need to do something like:

ap.getApplicationUsage()->write(<ostream>);

Reimplemented from ossimChipProcTool.

Definition at line 50 of file ossimHdf5Tool.cpp.

References ossimApplicationUsage::addCommandLineOption(), DESCRIPTION, ossimArgumentParser::getApplicationName(), ossimArgumentParser::getApplicationUsage(), ossimApplicationUsage::setCommandLineUsage(), ossimApplicationUsage::setDescription(), and ossimChipProcTool::setUsage().

51 {
52  // Add options.
54  ossimString usageString = ap.getApplicationName();
55  usageString += " hdf5 [options] [--i <input-hdf5-file>] [-o <output-image>]";
56  au->setCommandLineUsage(usageString);
57 
58  // Set the command line options:
60  au->addCommandLineOption("--geom-dataset","<path_to_dataset>"
61  "Full HDF5-internal path to geometry dataset to use for image. ");
62  au->addCommandLineOption("--image-dataset","<path_to_dataset>"
63  "Full HDF5-internal path to pixel dataset to extract. ");
64  au->addCommandLineOption("--list-datasets",
65  "Lists all datasets with extents. ");
66  au->addCommandLineOption("--list-ndims",
67  "Lists all datasets with extents that are of rank 2 or higher.");
68  au->addCommandLineOption("--geom", "[<geomfilename>]\n"
69  "Dumps the geometry keyword-list to the specified file or the console if no filename specified.");
70  au->addCommandLineOption("--info",
71  "Outputs human-readable dump of all objects in the file");
72  au->addCommandLineOption("--kwl",
73  "Outputs keywordlist dump of all objects in the file");
74 
75  // Base class has its own:
77 }
std::string getApplicationName() const
return the application name, as specified by argv[0]
void addCommandLineOption(const ossimString &option, const ossimString &explanation)
void setCommandLineUsage(const ossimString &explanation)
static const char * DESCRIPTION
Used by ossimUtilityFactory.
Definition: ossimHdf5Tool.h:57
ossimApplicationUsage * getApplicationUsage()
virtual void setUsage(ossimArgumentParser &ap)
Initializes the aurgument parser with expected parameters and options.
void setDescription(const ossimString &desc)

Member Data Documentation

◆ DESCRIPTION

const char * ossimHdf5Tool::DESCRIPTION = "Utility for parsing and extracting HDF5 image data."
static

Used by ossimUtilityFactory.

Definition at line 57 of file ossimHdf5Tool.h.

Referenced by ossimToolFactory::getCapabilities(), and setUsage().

◆ m_dumpInfo

bool ossimHdf5Tool::m_dumpInfo
protected

Definition at line 66 of file ossimHdf5Tool.h.

Referenced by execute().

◆ m_dumpKwl

bool ossimHdf5Tool::m_dumpKwl
protected

Definition at line 67 of file ossimHdf5Tool.h.

Referenced by execute().

◆ m_geomDataPath

ossimString ossimHdf5Tool::m_geomDataPath
protected

Definition at line 65 of file ossimHdf5Tool.h.

◆ m_geomFilename

ossimFilename ossimHdf5Tool::m_geomFilename
protected

Definition at line 70 of file ossimHdf5Tool.h.

◆ m_hdf5

ossimRefPtr<ossimHdf5> ossimHdf5Tool::m_hdf5
protected

Definition at line 71 of file ossimHdf5Tool.h.

Referenced by execute().

◆ m_imageDataPath

ossimString ossimHdf5Tool::m_imageDataPath
protected

Definition at line 64 of file ossimHdf5Tool.h.

Referenced by initialize(), and loadImageFiles().

◆ m_listDatasets

bool ossimHdf5Tool::m_listDatasets
protected

Definition at line 68 of file ossimHdf5Tool.h.

Referenced by execute().

◆ m_listNdimDatasets

bool ossimHdf5Tool::m_listNdimDatasets
protected

Definition at line 69 of file ossimHdf5Tool.h.

Referenced by execute().


The documentation for this class was generated from the following files: