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

Utility class for generating point-cloud-derived image products. More...

#include <ossimPointCloudTool.h>

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

Public Member Functions

 ossimPointCloudTool ()
 
 ~ossimPointCloudTool ()
 
bool initialize (ossimArgumentParser &ap) override
 Initializes from command line arguments. More...
 
void loadJSON (const Json::Value &json_request) override
 Reads processing params from JSON object provided. More...
 
void saveJSON (Json::Value &json) const override
 Fetch product as JSON object when applicable Always returns true since using exception on error. More...
 
virtual bool execute () override
 Writes product to output file if applicable. More...
 
- Public Member Functions inherited from ossimTool
 ossimTool ()
 
virtual ~ossimTool ()
 
virtual void initialize (const ossimKeywordlist &kwl)
 Reads processing params from KWL and prepares for execute. 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...
 
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
 
virtual ossimString getClassName () 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 ()
 

Protected Types

enum  Operation { HIGHEST_DEM, LOWEST_DEM, HIGHEST_LOWEST }
 

Protected Member Functions

bool initialize ()
 
void setGSD (const double &meters_per_pixel)
 
void usage (ossimArgumentParser &ap)
 
void addArguments (ossimArgumentParser &ap)
 
bool loadPC ()
 
bool loadDem ()
 
- Protected Member Functions inherited from ossimTool
virtual void setUsage (ossimArgumentParser &ap)
 Initializes the aurgument parser with expected parameters and options. More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

enum ossimPointCloudTool::Operation m_operation
 
ossimRefPtr< ossimImageGeometrym_prodGeom
 
ossimRefPtr< ossimPointCloudHandlerm_pcHandler
 
ossimRefPtr< ossimPointCloudImageHandlerm_pciHandler
 
ossimRefPtr< ossimPointCloudUtilityFilterm_pcuFilter
 
double m_gsd
 
ossimFilename m_lutFile
 
ossimFilename m_prodFile
 
ossimFilename m_demFile
 
ossimFilename m_pcFile
 
- Protected Attributes inherited from ossimTool
ossimKeywordlist m_kwl
 
std::ostream * m_consoleStream
 
bool m_helpRequested
 
std::string m_response
 

Friends

class ossimPointCloudUtilityFilter
 

Detailed Description

Utility class for generating point-cloud-derived image products.

Definition at line 26 of file ossimPointCloudTool.h.

Member Enumeration Documentation

◆ Operation

Enumerator
HIGHEST_DEM 
LOWEST_DEM 
HIGHEST_LOWEST 

Definition at line 47 of file ossimPointCloudTool.h.

Constructor & Destructor Documentation

◆ ossimPointCloudTool()

ossimPointCloudTool::ossimPointCloudTool ( )

Definition at line 27 of file ossimPointCloudTool.cpp.

29  m_gsd (0)
30 {
31 }
enum ossimPointCloudTool::Operation m_operation

◆ ~ossimPointCloudTool()

ossimPointCloudTool::~ossimPointCloudTool ( )

Definition at line 33 of file ossimPointCloudTool.cpp.

References m_pcHandler, m_pcuFilter, and m_prodGeom.

34 {
35  m_pcHandler = 0;
36  m_prodGeom = 0;
37  m_pcuFilter = 0;
38 }
ossimRefPtr< ossimImageGeometry > m_prodGeom
ossimRefPtr< ossimPointCloudHandler > m_pcHandler
ossimRefPtr< ossimPointCloudUtilityFilter > m_pcuFilter

Member Function Documentation

◆ addArguments()

void ossimPointCloudTool::addArguments ( ossimArgumentParser ap)
protected

Definition at line 40 of file ossimPointCloudTool.cpp.

References ossimApplicationUsage::addCommandLineOption(), ossimArgumentParser::getApplicationName(), ossimArgumentParser::getApplicationUsage(), and ossimApplicationUsage::setCommandLineUsage().

Referenced by usage().

41 {
42  // Set the general usage:
44  ossimString usageString = ap.getApplicationName();
45  usageString += " [options] <point-cloud-file> <output-image>";
46  au->setCommandLineUsage(usageString);
47 
48  // Set the command line options:
50  "--gsd <meters>",
51  "Specifies output GSD in meters. Defaults to the same "
52  "resolution as input DEM.");
54  "--dem <filename>",
55  "Specifies the input DEM filename. If none provided, the elevation database is "
56  "referenced as specified in prefs file");
58  "--lut <filename>",
59  "Specifies the optional lookup table filename for "
60  "mapping the single-band output image to an RGB. The LUT provided must be "
61  "in the ossimIndexToRgbLutFilter format and must handle the three output "
62  "viewshed values (see --values option).");
64  "--method",
65  "Specify the desired operation. Possible values are:\n"
66  " \"highest-dem\", \"lowest-dem\" (default), or \"highest-lowest\". \n"
67  "Alternatively can be specified in shorthand as \"h-d\", \"l-d\", or \"h-l\", "
68  "respectively.");
70  "--request-api",
71  "Causes applications API to be output as JSON to stdout."
72  " Accepts optional filename to store JSON output.");
74  "--threads <n>",
75  "Number of threads. Defaults to use all available cores. "
76  "For engineering/debug purposes ");
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)
ossimApplicationUsage * getApplicationUsage()

◆ execute()

bool ossimPointCloudTool::execute ( )
overridevirtual

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 234 of file ossimPointCloudTool.cpp.

References ossimKeywordlist::addFile(), ossimConnectableObject::connectMyInputTo(), ossimImageWriterFactoryRegistry::createWriter(), ossimString::empty(), ossimImageFileWriter::execute(), ossimRefPtr< T >::get(), ossimIndexToRgbLutFilter::initialize(), ossimImageWriterFactoryRegistry::instance(), ossimIndexToRgbLutFilter::loadState(), m_lutFile, m_pcuFilter, m_prodFile, ossimNotify(), ossimNotifyLevel_WARN, and ossimRefPtr< T >::valid().

235 {
236  // See if an LUT is requested:
237  ossimImageSource* last_source = m_pcuFilter.get();
239  if (!m_lutFile.empty())
240  {
241  ossimKeywordlist lut_kwl;
242  lut_kwl.addFile(m_lutFile);
243  lutSource = new ossimIndexToRgbLutFilter;
244  if (!lutSource->loadState(lut_kwl))
245  {
246  ossimNotify(ossimNotifyLevel_WARN) << "ossimPointCloudTool::writeFile() ERROR: The LUT "
247  "file <"<<m_lutFile<<"> could not be read. Ignoring remap request.\n"<< std::endl;
248  lutSource = 0;
249  }
250  else
251  {
252  lutSource->connectMyInputTo(last_source);
253  lutSource->initialize();
254  last_source = lutSource.get();
255  }
256  }
257 
258  // Set up the writer:
261  bool success = false;
262  if (writer.valid())
263  {
264  writer->connectMyInputTo(0, last_source);
265  success = writer->execute();
266  }
267 
268  return success;
269 }
Represents serializable keyword/value map.
bool addFile(const char *file)
bool valid() const
Definition: ossimRefPtr.h:75
static ossimImageWriterFactoryRegistry * instance()
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=NULL)
Method to the load (recreate) the state of an object from a keyword list.
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
ossimRefPtr< ossimPointCloudUtilityFilter > m_pcuFilter
bool empty() const
Definition: ossimString.h:411
ossimImageFileWriter * createWriter(const ossimFilename &filename) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool execute()
Calls: writeFile() writeMetaDataFiles()

◆ initialize() [1/2]

bool ossimPointCloudTool::initialize ( ossimArgumentParser ap)
overridevirtual

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 95 of file ossimPointCloudTool.cpp.

References ossimArgumentParser::argc(), ossimString::contains(), HIGHEST_DEM, HIGHEST_LOWEST, initialize(), m_demFile, m_gsd, m_lutFile, m_operation, m_pcFile, m_prodFile, ossimArgumentParser::read(), ossimString::toDouble(), and usage().

96 {
97  if ( (ap.argc() == 1) || ap.read("-h") || ap.read("--help") )
98  {
99  usage(ap);
100  return false;
101  }
102 
103  ossimString ts1;
105 
106  if ( ap.read("--dem", sp1) )
107  m_demFile = ts1;
108 
109  if ( ap.read("--gsd", sp1) )
110  m_gsd = ossimString(ts1).toDouble();
111 
112  if ( ap.read("--lut", sp1) )
113  m_lutFile = ts1;
114 
115  if ( ap.read("--method", sp1) )
116  {
117  if (ts1.contains("highest-dem") || ts1.contains("h-d"))
119  else if (ts1.contains("highest-lowest") || ts1.contains("h-l"))
121  }
122 
123  if ( ap.read("--pc", sp1) )
124  m_demFile = ts1;
125 
126 /*
127  if ( ap.read("--request-api", sp1))
128  {
129  ofstream ofs ( ts1.c_str() );
130  printApiJson(ofs);
131  ofs.close();
132  return false;
133  }
134  if ( ap.read("--request-api"))
135  {
136  printApiJson(cout);
137  return false;
138  }
139 */
140  // There should only be the required command line args left:
141  if (ap.argc() < 3)
142  {
143  usage(ap);
144  return false;
145  }
146 
147  // Parse the required command line params:
148  m_pcFile = ap[1];
149  m_prodFile = ap[2];
150 
151  return initialize();
152 }
enum ossimPointCloudTool::Operation m_operation
void usage(ossimArgumentParser &ap)
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...
bool contains(char aChar) const
Definition: ossimString.h:58
double toDouble() const
int & argc()
return the argument count.

◆ initialize() [2/2]

bool ossimPointCloudTool::initialize ( )
protected

Definition at line 159 of file ossimPointCloudTool.cpp.

References ossimString::empty(), loadDem(), loadPC(), m_demFile, m_pcFile, m_pcuFilter, ossimNotify(), ossimNotifyLevel_WARN, and ossimPointCloudUtilityFilter.

Referenced by initialize().

160 {
161  if (loadPC())
162  {
164  << "ossimPointCloudTool::initialize ERR: Cannot open PC file at <"<<m_pcFile
165  <<">\n"<< endl;
166  return false;
167  }
168 
169  if (!m_demFile.empty() && !loadDem())
170  return false;
171 
173  return true;
174 }
friend class ossimPointCloudUtilityFilter
ossimRefPtr< ossimPointCloudUtilityFilter > m_pcuFilter
bool empty() const
Definition: ossimString.h:411
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ loadDem()

bool ossimPointCloudTool::loadDem ( )
protected

Definition at line 201 of file ossimPointCloudTool.cpp.

References ossimElevManager::addDatabase(), ossimElevManager::clear(), ossimRefPtr< T >::get(), ossimElevManager::instance(), m_demFile, ossim::nan(), ossimImageElevationDatabase::open(), ossimNotify(), ossimNotifyLevel_WARN, ossimElevManager::setDefaultHeightAboveEllipsoid(), and ossimElevManager::setUseGeoidIfNullFlag().

Referenced by initialize().

202 {
203  // DEM provided as file on command line, reset the elev manager to use only this:
205  elevMgr->clear();
207  if(!ied->open(m_demFile))
208  {
210  << "ossimViewshedUtil::initialize ERR: Cannot open DEM file at <"<<m_demFile<<">\n"
211  << std::endl;
212  return false;
213  }
214 
215  elevMgr->addDatabase(ied.get());
216 
217  // When DEM file specified, need to turn off all defaulting to ellipsoid/geoid to make sure
218  // only the DEM file data is processed:
220  elevMgr->setUseGeoidIfNullFlag(false);
221 
222  return true;
223 }
void setUseGeoidIfNullFlag(bool flag)
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
static ossimElevManager * instance()
METHOD: instance() Implements singelton pattern.
void setDefaultHeightAboveEllipsoid(double meters)
virtual bool open(const ossimString &connectionString)
Open a connection to a database.
void addDatabase(ossimElevationDatabase *database, bool set_as_first=false)
Adds a new elevation database to the collection.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ loadJSON()

void ossimPointCloudTool::loadJSON ( const Json::Value &  json_request)
overridevirtual

Reads processing params from JSON object provided.

If all good, the object is ready for subsequent call to execute().

Note
Throws ossimException on error.

Reimplemented from ossimTool.

Definition at line 154 of file ossimPointCloudTool.cpp.

155 {
156 
157 }

◆ loadPC()

bool ossimPointCloudTool::loadPC ( )
protected

Definition at line 176 of file ossimPointCloudTool.cpp.

References ossimRefPtr< T >::get(), ossimImageGeometry::getAsMapProjection(), ossimPointCloudImageHandler::getImageGeometry(), ossimPointCloudHandlerRegistry::instance(), m_gsd, m_pcFile, m_pcHandler, m_pciHandler, m_prodGeom, ossimPointCloudHandlerRegistry::open(), ossimNotify(), ossimNotifyLevel_WARN, ossimMapProjection::setMetersPerPixel(), ossimPointCloudImageHandler::setPointCloudHandler(), and ossimRefPtr< T >::valid().

Referenced by initialize().

177 {
178  // DEM provided as file on command line, reset the elev manager to use only this:
180  if(!m_pcHandler.valid())
181  {
183  << "ossimPointCloudTool::initialize ERR: Cannot open PC file at <"<<m_pcFile
184  <<">\n" << std::endl;
185  return false;
186  }
187 
188  // Use "rasterized" PC to establish best output image geometry:
193  return false;
194 
195  if (m_gsd != 0)
197 
198  return true;
199 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimPointCloudImageHandler > m_pciHandler
const ossimMapProjection * getAsMapProjection() const
Class used for rendering point cloud data into a raster tile.
bool setPointCloudHandler(ossimPointCloudHandler *pch)
Permits backdoor for setting the input point cloud handler object.
ossimRefPtr< ossimImageGeometry > m_prodGeom
ossimRefPtr< ossimPointCloudHandler > m_pcHandler
virtual void setMetersPerPixel(const ossimDpt &gsd)
virtual ossimPointCloudHandler * open(const ossimFilename &fileName) const
ossimRefPtr< ossimImageGeometry > getImageGeometry() override
Returns the image geometry object associated with this tile source or NULL if non defined...
static ossimPointCloudHandlerRegistry * instance()
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ saveJSON()

void ossimPointCloudTool::saveJSON ( Json::Value &  json) const
overridevirtual

Fetch product as JSON object when applicable Always returns true since using exception on error.

Parameters
jsonReturns non-empty object if valid response available.

Reimplemented from ossimTool.

Definition at line 272 of file ossimPointCloudTool.cpp.

273 {
274 
275 }

◆ setGSD()

void ossimPointCloudTool::setGSD ( const double &  meters_per_pixel)
protected

Definition at line 225 of file ossimPointCloudTool.cpp.

References ossimImageGeometry::getAsMapProjection(), m_gsd, m_prodGeom, and ossimMapProjection::setMetersPerPixel().

226 {
227  if (m_prodGeom->getAsMapProjection() && (meters_per_pixel > 0))
228  {
229  m_gsd = meters_per_pixel;
231  }
232 }
const ossimMapProjection * getAsMapProjection() const
ossimRefPtr< ossimImageGeometry > m_prodGeom
virtual void setMetersPerPixel(const ossimDpt &gsd)

◆ usage()

void ossimPointCloudTool::usage ( ossimArgumentParser ap)
protected

Definition at line 79 of file ossimPointCloudTool.cpp.

References addArguments(), ossimInit::addOptions(), ossimArgumentParser::getApplicationUsage(), ossimInit::instance(), ossimNotify(), ossimNotifyLevel_INFO, and ossimApplicationUsage::write().

Referenced by initialize().

80 {
81  // Add global usage options.
83 
84  // Add options.
85  addArguments(ap);
86 
87  // Write usage.
89 
91  <<"\nPerforms specified processing on point-cloud.\n\n"
92  << std::endl;
93 }
void write(std::ostream &output, const UsageMap &um, unsigned int widthOfOutput=80)
void addOptions(ossimArgumentParser &parser)
Definition: ossimInit.cpp:100
ossimApplicationUsage * getApplicationUsage()
static ossimInit * instance()
Definition: ossimInit.cpp:89
void addArguments(ossimArgumentParser &ap)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Friends And Related Function Documentation

◆ ossimPointCloudUtilityFilter

friend class ossimPointCloudUtilityFilter
friend

Definition at line 28 of file ossimPointCloudTool.h.

Referenced by initialize().

Member Data Documentation

◆ m_demFile

ossimFilename ossimPointCloudTool::m_demFile
protected

Definition at line 55 of file ossimPointCloudTool.h.

Referenced by initialize(), and loadDem().

◆ m_gsd

double ossimPointCloudTool::m_gsd
protected

Definition at line 52 of file ossimPointCloudTool.h.

Referenced by initialize(), loadPC(), and setGSD().

◆ m_lutFile

ossimFilename ossimPointCloudTool::m_lutFile
protected

Definition at line 53 of file ossimPointCloudTool.h.

Referenced by execute(), and initialize().

◆ m_operation

enum ossimPointCloudTool::Operation ossimPointCloudTool::m_operation
protected

◆ m_pcFile

ossimFilename ossimPointCloudTool::m_pcFile
protected

Definition at line 56 of file ossimPointCloudTool.h.

Referenced by initialize(), and loadPC().

◆ m_pcHandler

ossimRefPtr<ossimPointCloudHandler> ossimPointCloudTool::m_pcHandler
protected

Definition at line 49 of file ossimPointCloudTool.h.

Referenced by loadPC(), and ~ossimPointCloudTool().

◆ m_pciHandler

ossimRefPtr<ossimPointCloudImageHandler> ossimPointCloudTool::m_pciHandler
protected

Definition at line 50 of file ossimPointCloudTool.h.

Referenced by ossimPointCloudUtilityFilter::getTile(), and loadPC().

◆ m_pcuFilter

ossimRefPtr<ossimPointCloudUtilityFilter> ossimPointCloudTool::m_pcuFilter
protected

Definition at line 51 of file ossimPointCloudTool.h.

Referenced by execute(), initialize(), and ~ossimPointCloudTool().

◆ m_prodFile

ossimFilename ossimPointCloudTool::m_prodFile
protected

Definition at line 54 of file ossimPointCloudTool.h.

Referenced by execute(), and initialize().

◆ m_prodGeom

ossimRefPtr<ossimImageGeometry> ossimPointCloudTool::m_prodGeom
protected

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