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

#include <ossimVerticesFinderTool.h>

Inheritance diagram for ossimVerticesFinderTool:
ossimTool ossimObject ossim::JsonInterface ossimReferenced

Public Member Functions

 ossimVerticesFinderTool ()
 
 ~ossimVerticesFinderTool ()
 
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 ()
 Writes product to output file if applicable. More...
 
virtual ossimString getClassName () const
 
virtual void getKwlTemplate (ossimKeywordlist &kwl)
 Assigns a template keywordlist to string for initializing derived classes. More...
 
- 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 clear ()
 Disconnects and clears the DEM and image layers. More...
 
virtual void abort ()
 Kills current (asynchronous) process. 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...
 
virtual bool isChipProcessor () const
 Overrides base class implementation to indicate this class supports getChip() calls. 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 ()
 

Static Public Attributes

static const char * DESCRIPTION
 Used by ossimUtilityFactory. More...
 

Protected Attributes

ossimFilename m_inputFile
 
ossimFilename m_outputFile
 
ossim_uint32 m_entryIndex
 
- Protected Attributes inherited from ossimTool
ossimKeywordlist m_kwl
 
std::ostream * m_consoleStream
 
bool m_helpRequested
 
std::string m_response
 

Additional Inherited Members

- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Detailed Description

Class for determining the active image corner vertices inside larger null-filled image rectangle.

Definition at line 18 of file ossimVerticesFinderTool.h.

Constructor & Destructor Documentation

◆ ossimVerticesFinderTool()

ossimVerticesFinderTool::ossimVerticesFinderTool ( )

Definition at line 27 of file ossimVerticesFinderTool.cpp.

28 : m_entryIndex (0)
29 {
30 }

◆ ~ossimVerticesFinderTool()

ossimVerticesFinderTool::~ossimVerticesFinderTool ( )

Definition at line 32 of file ossimVerticesFinderTool.cpp.

33 {
34 }

Member Function Documentation

◆ execute()

bool ossimVerticesFinderTool::execute ( )
virtual

Writes product to output file if applicable.

The product may also beAlways returns true since using exception on error.

Note
Throws ossimException on error.

Implements ossimTool.

Definition at line 126 of file ossimVerticesFinderTool.cpp.

References ossimListenerManager::addListener(), ossimVertexExtractor::execute(), ossimRefPtr< T >::get(), ossimImageHandler::getBoundingRect(), ossimImageHandlerRegistry::instance(), m_entryIndex, ossimTool::m_helpRequested, m_inputFile, m_outputFile, ossimImageHandlerRegistry::open(), ossimVertexExtractor::setAreaOfInterest(), ossimImageHandler::setCurrentEntry(), ossimVertexExtractor::setOutputName(), and ossimRefPtr< T >::valid().

127 {
128  if (m_helpRequested)
129  return true;
130 
131  ostringstream errMsg;
132 
133  // Get an image handler for the input file.
135  if (ih.valid())
136  {
138  }
139  else
140  {
141  errMsg<<"ERROR ossimVerticesFinderUtil:"<<__LINE__<<" Unsupported image file format for <"
142  << m_inputFile<<">. Cannot open file.";
143  throw ossimException(errMsg.str());
144  }
145 
146  // Give the image handler to the vertex extractor as an input source.
148 
149  // Set the file name.
151 
152  // Set the area of interest to the full bounding rect of the source.
154 
155  // Add a listener for the percent complete to standard output.
156  ossimStdOutProgress prog(0, true);
157  ve->addListener(&prog);
158 
159  // Start the extraction...
160  bool success = ve->execute();
161  return success;
162 }
virtual bool addListener(ossimListener *listener)
void setAreaOfInterest(const ossimIrect &rect)
Class ossimVertexExtractor.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
bool m_helpRequested
Definition: ossimTool.h:150
bool valid() const
Definition: ossimRefPtr.h:75
virtual void setOutputName(const ossimString &filename)
static ossimImageHandlerRegistry * instance()
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
virtual bool setCurrentEntry(ossim_uint32 entryIdx)

◆ getClassName()

virtual ossimString ossimVerticesFinderTool::getClassName ( ) const
inlinevirtual

Reimplemented from ossimTool.

Definition at line 32 of file ossimVerticesFinderTool.h.

32 { return "ossimVerticesFinderUtil"; }

◆ getKwlTemplate()

void ossimVerticesFinderTool::getKwlTemplate ( ossimKeywordlist kwl)
virtual

Assigns a template keywordlist to string for initializing derived classes.

Reimplemented from ossimTool.

Definition at line 165 of file ossimVerticesFinderTool.cpp.

References ossimKeywordlist::add(), ossimKeywordNames::ENTRY_KW, ossimKeywordNames::IMAGE_FILE_KW, and ossimKeywordNames::OUTPUT_FILE_KW.

166 {
167  kwl.add(ossimKeywordNames::ENTRY_KW, "<sub-image entry index>");
168  kwl.add(ossimKeywordNames::IMAGE_FILE_KW, "<input-raster-file>");
169  kwl.add(ossimKeywordNames::OUTPUT_FILE_KW, "<output-vertices-file>");
170 }
static const char * OUTPUT_FILE_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static const char * ENTRY_KW
static const char * IMAGE_FILE_KW

◆ initialize() [1/2]

bool ossimVerticesFinderTool::initialize ( ossimArgumentParser ap)
virtual

Initializes from command line arguments.

This base class has some common arguments to read. The derived class should call this implementation in addition to setting its own arguments.

Parameters
apRepresents command line.
Returns
FALSE if –help option requested or no params provided, so that derived classes can exit without error.
Note
Throws ossimException on error.

Reimplemented from ossimTool.

Definition at line 55 of file ossimVerticesFinderTool.cpp.

References ossimKeywordlist::add(), ossimKeywordlist::addPair(), ossimArgumentParser::argc(), ossimKeywordNames::ENTRY_KW, ossimKeywordNames::IMAGE_FILE_KW, ossimTool::initialize(), ossimTool::m_helpRequested, ossimTool::m_kwl, ossimNotify(), ossimNotifyLevel_NOTICE, ossimKeywordNames::OUTPUT_FILE_KW, ossimArgumentParser::read(), and ossimArgumentParser::remove().

56 {
57  if (!ossimTool::initialize(ap))
58  return false;
59  if (m_helpRequested)
60  return true;
61 
62  std::string tempString1;
63  ossimArgumentParser::ossimParameter stringParam1(tempString1);
64 
65  if ( ap.read("-e", stringParam1) || ap.read("--entry", stringParam1) )
66  m_kwl.addPair( std::string(ossimKeywordNames::ENTRY_KW), tempString1 );
67 
68  cout<<ap.argc()<<endl;//TODO:REMOVE
69 
70  if ( ap.argc() > 1 )
71  {
73  ap.remove(1);
74  }
75  if ( ap.argc() > 1 )
76  {
78  ap.remove(1);
79  }
80  if ( ap.argc() > 1 )
81  {
82  ossimNotify(ossimNotifyLevel_NOTICE)<<"ossimVerticesFinderUtil:"<<__LINE__<<" Too many "
83  "arguments provided on command line. Ignoring superfluous entries.";
84  }
85 
87  return true;
88 }
static const char * OUTPUT_FILE_KW
virtual bool initialize(ossimArgumentParser &ap)
Initializes from command line arguments.
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 add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual bool initialize(ossimArgumentParser &ap)
Initializes from command line arguments.
Definition: ossimTool.cpp:58
static const char * ENTRY_KW
void remove(int pos, int num=1)
remove one or more arguments from the argv argument list, and decrement the argc respectively.
static const char * IMAGE_FILE_KW
int & argc()
return the argument count.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ initialize() [2/2]

void ossimVerticesFinderTool::initialize ( const ossimKeywordlist kwl)
virtual

Reads processing params from KWL and prepares for execute.

Returns TRUE if successful.

Parameters
kwlFull keyword-list representing state
Note
Throws ossimException on error.

Reimplemented from ossimTool.

Definition at line 90 of file ossimVerticesFinderTool.cpp.

References ossimKeywordlist::addList(), ossimKeywordlist::clear(), ossimFilename::dirCat(), ossimString::empty(), ossimKeywordNames::ENTRY_KW, ossimFilename::fileNoExtension(), ossimKeywordlist::find(), ossimKeywordNames::IMAGE_FILE_KW, ossimFilename::isReadable(), m_entryIndex, m_inputFile, ossimTool::m_kwl, m_outputFile, ossimKeywordNames::OUTPUT_FILE_KW, ossimFilename::path(), and ossimString::toUInt32().

91 {
92  ostringstream errMsg;
93 
94  // Don't copy KWL if member KWL passed in:
95  if (&kwl != &m_kwl)
96  {
97  // Start with clean options keyword list.
98  m_kwl.clear();
99  m_kwl.addList( kwl, true );
100  }
101 
103 
105 
107  if (!value.empty())
108  m_entryIndex = value.toUInt32();
109 
110  // See if an LUT is requested:
112  {
113  errMsg<<"ERROR ossimVerticesFinderUtil:"<<__LINE__<<" Input filename was not provided or "
114  " file <"<<m_inputFile <<"> is not readable. "<<ends;
115  throw ossimException(errMsg.str());
116  }
117 
118  if (m_outputFile.empty())
119  {
122  m_outputFile += "_vertices.kwl";
123  }
124 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
static const char * OUTPUT_FILE_KW
const char * find(const char *key) const
void addList(const ossimKeywordlist &src, bool overwrite=true)
ossimKeywordlist m_kwl
Definition: ossimTool.h:148
ossim_uint32 toUInt32() const
bool isReadable() const
static const char * ENTRY_KW
ossimFilename fileNoExtension() const
ossimFilename dirCat(const ossimFilename &file) const
bool empty() const
Definition: ossimString.h:411
static const char * IMAGE_FILE_KW
ossimFilename path() const

◆ setUsage()

void ossimVerticesFinderTool::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>);

This base class has some common arguments to add. The derived class should call this implementation in addition to setting its own arguments.

Reimplemented from ossimTool.

Definition at line 36 of file ossimVerticesFinderTool.cpp.

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

37 {
38  // Add options.
40  ossimString usageString = ap.getApplicationName();
41  usageString += " vertices [options] <input-image> [<output-vertices.kwl>]";
42  au->setCommandLineUsage(usageString);
43 
44  // Set the command line options:
46 
47  // Base class has its own:
49 
50  au->addCommandLineOption("-e or --entry",
51  "<entry> For multi image handlers which entry do you wish to extract. "
52  "For list of entries use: \"ossim-info -i <your_image>\" ");
53 }
static const char * DESCRIPTION
Used by ossimUtilityFactory.
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)
ossimApplicationUsage * getApplicationUsage()
virtual void setUsage(ossimArgumentParser &ap)
Initializes the aurgument parser with expected parameters and options.
Definition: ossimTool.cpp:41
void setDescription(const ossimString &desc)

Member Data Documentation

◆ DESCRIPTION

const char * ossimVerticesFinderTool::DESCRIPTION
static
Initial value:
=
"Utility for determining the active image corner vertices inside larger null-filled image "
"rectangle."

Used by ossimUtilityFactory.

Definition at line 37 of file ossimVerticesFinderTool.h.

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

◆ m_entryIndex

ossim_uint32 ossimVerticesFinderTool::m_entryIndex
protected

Definition at line 42 of file ossimVerticesFinderTool.h.

Referenced by execute(), and initialize().

◆ m_inputFile

ossimFilename ossimVerticesFinderTool::m_inputFile
protected

Definition at line 40 of file ossimVerticesFinderTool.h.

Referenced by execute(), and initialize().

◆ m_outputFile

ossimFilename ossimVerticesFinderTool::m_outputFile
protected

Definition at line 41 of file ossimVerticesFinderTool.h.

Referenced by execute(), and initialize().


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