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

ossimImageUtil class. More...

#include <ossimImageUtil.h>

Inheritance diagram for ossimImageUtil:
ossimReferenced ossimFileProcessorInterface

Public Member Functions

 ossimImageUtil ()
 default constructor More...
 
virtual ~ossimImageUtil ()
 virtual destructor More...
 
void addOptions (ossimApplicationUsage *au)
 
void addArguments (ossimArgumentParser &ap)
 Adds application arguments to the argument parser. More...
 
bool initialize (ossimArgumentParser &ap)
 Initial method. More...
 
ossim_int32 execute ()
 Execute method. More...
 
virtual void processFile (const ossimFilename &file)
 ProcessFile method. More...
 
void setCreateOverviewsFlag (bool flag)
 Sets create overviews flag keyword CREATE_OVERVIEWS_KW used by processFile method. More...
 
bool createOverviews () const
 
void setCreateThumbnailsFlag (bool flag)
 Sets create thumbnails flag keyword CREATE_THUMBNAILS_KW used by processFile method. More...
 
void setThumbnailType (const std::string &value)
 
void setThumbnailStretchType (const std::string &value)
 
bool createThumbnails () const
 
void setRebuildOverviewsFlag (bool flag)
 Sets the rebuild overview flag keyword REBUILD_OVERVIEWS_KW used by processFile method. More...
 
bool rebuildOverviews () const
 
void setRebuildHistogramFlag (bool flag)
 Sets the rebuild histogram flag keyword REBUILD_HISTOGRAM_KW used by processFile method. More...
 
bool rebuildHistogram () const
 
void setOverviewType (const std::string &type)
 Sets key OVERVIEW_TYPE_KW. More...
 
void setOverviewStopDimension (ossim_uint32 dimension)
 sets the overview stop dimension. More...
 
void setOverviewStopDimension (const std::string &dimension)
 
void setTileSize (ossim_uint32 tileSize)
 Sets the tile size. More...
 
bool getTileSize (ossimIpt &tileSize) const
 Gets the tile size. More...
 
ossim_uint32 getOverviewStopDimension () const
 
void setCreateHistogramFlag (bool flag)
 Sets create histogram flag keyword CREATE_HISTOGRAM_KW used by processFile method. More...
 
bool createHistogram () const
 
void setCreateHistogramFastFlag (bool flag)
 Sets create histogram flag keyword CREATE_HISTOGRAM_FAST_KW used by processFile method. More...
 
bool createHistogramFast () const
 
void setCreateHistogramR0Flag (bool flag)
 Sets create histogram "R0" flag keyword CREATE_HISTOGRAM_R0_KW used by processFile method. More...
 
bool createHistogramR0 () const
 
bool hasHistogramOption () const
 
ossimHistogramMode getHistogramMode () const
 
void setScanForMinMax (bool flag)
 Sets scan for min/max flag keyword SCAN_MIN_MAX_KW used by processFile method. More...
 
bool scanForMinMax () const
 
void setScanForMinMaxNull (bool flag)
 Sets scan for min/max/null flag keyword SCAN_MIN_MAX_KW used by processFile method. More...
 
bool scanForMinMaxNull () const
 
void setCompressionQuality (const std::string &quality)
 Sets the writer property for compression quality. More...
 
void setCompressionType (const std::string &type)
 Sets the compression type to use when building overviews. More...
 
void setCopyAllFlag (bool flag)
 Sets the overview builder copy all flag. More...
 
bool getCopyAllFlag () const
 
void setDumpFilteredImageListFlag (bool flag)
 Sets the dump filteredImageList flag. More...
 
bool getDumpFilterImagesFlag () const
 
void setInternalOverviewsFlag (bool flag)
 Sets the overview builder internal overviews flag. More...
 
bool getInternalOverviewsFlag () const
 
void setOutputDirectory (const std::string &directory)
 Sets the output directory. More...
 
void setOutputFileNamesFlag (bool flag)
 Sets the output file name flag OUTPUT_FILENAMES_KW. More...
 
bool getOutputFileNamesFlag () const
 
void setOverrideFilteredImagesFlag (bool flag)
 Sets the override filtered images flag. More...
 
bool getOverrideFilteredImagesFlag () const
 
void setNumberOfThreads (ossim_uint32 threads)
 Set number of threads to use. More...
 
void setNumberOfThreads (const std::string &threads)
 
const std::vector< std::string > & getFilteredImages () const
 
std::vector< std::string > & getFilteredImages ()
 Non const method to allow access for adding or deleting extensions from the list. More...
 
- 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 ossimFileProcessorInterface
 ossimFileProcessorInterface ()
 default constructor More...
 
virtual ~ossimFileProcessorInterface ()
 virtual destructor. More...
 

Private Member Functions

bool keyIsTrue (const std::string &key) const
 
bool isFiltered (const ossimFilename &f) const
 Convenience method to check file to see is if file should be processed. More...
 
void initializeDefaultFilterList ()
 Initializes the filter list with a default set of filtered out file names. More...
 
void dumpFilteredImageList () const
 Dumps filtered image list to std out. More...
 
void createOverview (ossimRefPtr< ossimImageHandler > &ih, bool &consumedHistogramOptions, bool &consumedCmmOptions)
 
void createOverview (ossimRefPtr< ossimImageHandler > &ih, ossimRefPtr< ossimOverviewBuilderBase > &ob, ossim_uint32 entry, bool useEntryIndex, bool &consumedHistogramOptions)
 
void createThumbnail (ossimRefPtr< ossimImageHandler > &ih)
 
bool hasRequiredOverview (ossimRefPtr< ossimImageHandler > &ih, ossimRefPtr< ossimOverviewBuilderBase > &ob)
 
bool hasCmmOption () const
 
void createHistogram (ossimRefPtr< ossimImageHandler > &ih)
 
void createHistogram (ossimRefPtr< ossimImageHandler > &ih, ossim_uint32 entry, bool useEntryIndex)
 
void computeMinMax (ossimRefPtr< ossimImageHandler > &ih)
 
void computeMinMax (ossimRefPtr< ossimImageHandler > &ih, ossim_uint32 entry, bool useEntryIndex)
 
void usage (ossimArgumentParser &ap)
 Initializes arg parser and outputs usage. More...
 
void outputOverviewWriterTypes () const
 
bool isDirectoryBasedImage (const ossimImageHandler *ih) const
 
void getOverviewType (std::string &type) const
 Initializes type from OVERVIEW_TYPE_KW or sets to default ossim_tiff_box if not found. More...
 
void setProps (ossimPropertyInterface *pi) const
 set reader or writer properties based on cast of pi. More...
 
ossim_uint32 getNumberOfThreads () const
 
ossim_uint32 getNextWriterPropIndex () const
 
ossim_uint32 getNextReaderPropIndex () const
 
ossim_uint32 getThumbnailSize () const
 
int getThumbnailStretchType () const
 
std::string getThumbnailType () const
 
std::string getThumbnailFilename (ossimImageHandler *ih) const
 
void addOption (const std::string &key, ossim_uint32 value)
 Adds option to m_kwl with mutex lock. More...
 
void addOption (const std::string &key, const std::string &value)
 
void setErrorStatus (ossim_int32 status)
 Sets the m_errorStatus for return on execute. More...
 
void executePrepCommands () const
 run prep system commands. More...
 
void executeFileCommands (const ossimFilename &file) const
 run per file system commands. More...
 
void executePostCommands () const
 run post system commands. More...
 
void executeCommands (const std::string &prefix, const ossimFilename &file) const
 system commands. More...
 
void substituteCommandString (const ossimFilename &file, const std::string &prefix, const std::string &commandKey, ossimString &command) const
 Expands variables in a command string. More...
 
void substituteFileStrings (const ossimFilename &file, ossimString &command) const
 Expands file level variables in a command string. More...
 
void gsubDate (const std::string &commandPrefix, ossimString &command) const
 Expands date variables in a command string. More...
 

Private Attributes

ossimRefPtr< ossimKeywordlistm_kwl
 Holds all options passed into intialize except writer props. More...
 
ossimFileWalkerm_fileWalker
 
std::mutex m_mutex
 
ossim_int32 m_errorStatus
 
std::vector< std::string > m_filteredImages
 Hold images we never want to process. More...
 

Additional Inherited Members

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

Detailed Description

ossimImageUtil class.

Utility class for processing image recursively. This is for doing things like:

building overview, histograms, compute min/max, extract vertices.

Definition at line 44 of file ossimImageUtil.h.

Constructor & Destructor Documentation

◆ ossimImageUtil()

ossimImageUtil::ossimImageUtil ( )

default constructor

Definition at line 105 of file ossimImageUtil.cpp.

106  :
107  ossimReferenced(),
109  m_kwl( new ossimKeywordlist() ),
110  m_fileWalker(0),
111  m_mutex(),
112  m_errorStatus(0),
114 {
115 }
Represents serializable keyword/value map.
std::vector< std::string > m_filteredImages
Hold images we never want to process.
ossimFileWalker * m_fileWalker
ossimFileProcessorInterface()
default constructor
ossim_int32 m_errorStatus
std::mutex m_mutex
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.

◆ ~ossimImageUtil()

ossimImageUtil::~ossimImageUtil ( )
virtual

virtual destructor

Definition at line 117 of file ossimImageUtil.cpp.

References m_fileWalker.

118 {
119  if ( m_fileWalker )
120  {
121  delete m_fileWalker;
122  m_fileWalker = 0;
123  }
124 }
ossimFileWalker * m_fileWalker

Member Function Documentation

◆ addArguments()

void ossimImageUtil::addArguments ( ossimArgumentParser ap)

Adds application arguments to the argument parser.

Parameters
apParser to add to.

Definition at line 189 of file ossimImageUtil.cpp.

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

Referenced by usage().

190 {
191  // Set the general usage:
193  ossimString usageString = ap.getApplicationName();
194  usageString += " [options] <file-or-directory-to-walk>";
195  au->setCommandLineUsage(usageString);
196 
197  addOptions(au);
198 
199 } // void ossimImageUtil::addArguments(ossimArgumentParser& ap)
std::string getApplicationName() const
return the application name, as specified by argv[0]
void setCommandLineUsage(const ossimString &explanation)
ossimApplicationUsage * getApplicationUsage()
void addOptions(ossimApplicationUsage *au)

◆ addOption() [1/2]

void ossimImageUtil::addOption ( const std::string &  key,
ossim_uint32  value 
)
private

Adds option to m_kwl with mutex lock.

Parameters
key
value

Definition at line 2182 of file ossimImageUtil.cpp.

References ossimString::toString().

Referenced by setCreateHistogramFastFlag(), setCreateHistogramFlag(), setCreateHistogramR0Flag(), setCreateOverviewsFlag(), setCreateThumbnailsFlag(), setNumberOfThreads(), setOverviewStopDimension(), setRebuildHistogramFlag(), setRebuildOverviewsFlag(), setScanForMinMax(), setScanForMinMaxNull(), setThumbnailStretchType(), setThumbnailType(), and setTileSize().

2183 {
2184  addOption(key, ossimString::toString(value).string());
2185 }
static ossimString toString(bool aValue)
Numeric to string methods.
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ addOption() [2/2]

void ossimImageUtil::addOption ( const std::string &  key,
const std::string &  value 
)
private

Definition at line 2187 of file ossimImageUtil.cpp.

References ossimKeywordlist::addPair(), m_kwl, m_mutex, and ossimRefPtr< T >::valid().

2188 {
2189  m_mutex.lock();
2190  if ( m_kwl.valid() )
2191  {
2192  if ( key.size() && value.size() )
2193  {
2194  m_kwl->addPair( key, value );
2195  }
2196  }
2197  m_mutex.unlock();
2198 }
bool valid() const
Definition: ossimRefPtr.h:75
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
std::mutex m_mutex
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.

◆ addOptions()

void ossimImageUtil::addOptions ( ossimApplicationUsage au)

Definition at line 126 of file ossimImageUtil.cpp.

References ossimApplicationUsage::addCommandLineOption().

Referenced by addArguments().

127 {
128  // Set the command line options:
129  au->addCommandLineOption("-a or --include-fullres", "Copy full res dataset to overview file as well as building reduced res sets. Option only valid with tiff overview builder. Requires -o option.");
130 
131  au->addCommandLineOption("--ch or --create-histogram", "Computes full histogram alongside overview.");
132 
133  au->addCommandLineOption("--chf or --create-histogram-fast", "Computes a histogram in fast mode which samples partial tiles.");
134  au->addCommandLineOption("--ct or --create-thumbnail", "computes a thumbnail of the image");
135  au->addCommandLineOption("--tt or --thumbnail-type", "Can be of of values png or jpeg");
136  au->addCommandLineOption("--tst or --thumbnail-stretch-type", "Can be of values none,auto-minmax,auto-percentile,std-stretch-1,std-stretch-2,std-stretch-3");
137 
138  au->addCommandLineOption("--compression-quality", "Compression quality for TIFF JPEG takes values from 0 to 100, where 100 is best. For J2K plugin, numerically_lossless, visually_lossless, lossy");
139 
140  au->addCommandLineOption("--compute-min-max", "Turns on min, max scanning when reading tiles and writes a dot omd file. This option assumes the null is known.");
141 
142  au->addCommandLineOption("--compute-min-max-null", "Turns on min, max, null scanning when reading tiles and write a dot omd file. This option tries to find a null value which is useful for float data.");
143 
144  au->addCommandLineOption("--compression-type", "Compression type can be: deflate, jpeg, lzw, none or packbits");
145 
146  au->addCommandLineOption("--create-histogram-r0", "Forces create-histogram code to compute a histogram using r0 instead of the starting resolution for the overview builder. Can require a separate pass of R0 layer if the base image has built in overviews.");
147 
148  au->addCommandLineOption("-d", "<output_directory> Write overview to output directory specified.");
149 
150  au->addCommandLineOption("--dump-filtered-image-list", "Outputs list of filtered images and extensions.");
151 
152  au->addCommandLineOption("-h", "Display this information");
153 
154  au->addCommandLineOption("-i or --internal-overviews", "Builds internal overviews. Requires -o option. Option only valid with tiff input image and tiff overview builder. WARNING: Modifies source image and cannot be undone!");
155 
156  au->addCommandLineOption("--list-entries", "Lists the entries within the image");
157 
158  au->addCommandLineOption("--max","Overrides max value for compute-min-max option.");
159 
160  au->addCommandLineOption("--min","Overrides min value for compute-min-max option.");
161 
162  au->addCommandLineOption("--null", "<null_value> Overrides null value for compute-min-max option. e.g. -9999.0 for float data");
163 
164  au->addCommandLineOption("-o", "Creates overviews. (default=ossim_tiff_box)");
165 
166  au->addCommandLineOption("--of or --output-files", "Output image files we can open, exluding overviews.");
167 
168  au->addCommandLineOption("--options","<options.kwl> This can be all or part of the application options. Also used for custom prep, per file and post system commands. To get a template you can turn on trace to the ossimImageUtil class by adding \"-T ossimImageUtil\" to your command.");
169 
170  au->addCommandLineOption("--ot", "<overview_type> Overview type. see list at bottom for valid types. (default=ossim_tiff_box)");
171 
172  au->addCommandLineOption("--override-filtered-images", "Allows processing of file that is in the filtered image list.");
173 
174  au->addCommandLineOption("-r or --rebuild-overviews", "Rebuild overviews even if they are already present.");
175 
176  au->addCommandLineOption("--rebuild-histogram", "Rebuild histogram even if they are already present.");
177 
178  au->addCommandLineOption("--reader-prop", "Adds a property to send to the reader. format is name=value");
179 
180  au->addCommandLineOption("-s", "Stop dimension for overviews. This controls how \nmany layers will be built. If set to 64 then the builder will stop when height and width for current level are less than or equal to 64. Note a default can be set in the ossim preferences file by setting the keyword \"overview_stop_dimension\".");
181 
182  au->addCommandLineOption("--tile-size", "<size> Defines the tile size for overview builder. Tiff option only. Must be a multiple of 16. Size will be used in both x and y directions. Note a default can be set in your ossim preferences file by setting the key \"tile_size\".");
183 
184  au->addCommandLineOption("--threads", "<threads> The number of threads to use. (default=1) Note a default can be set in your ossim preferences file by setting the key \"ossim_threads\".");
185 
186  au->addCommandLineOption("--writer-prop", "Adds a property to send to the writer. format is name=value");
187 }
void addCommandLineOption(const ossimString &option, const ossimString &explanation)

◆ computeMinMax() [1/2]

void ossimImageUtil::computeMinMax ( ossimRefPtr< ossimImageHandler > &  ih)
private

Definition at line 1278 of file ossimImageUtil.cpp.

1279 {
1280  static const char M[] = "ossimImageUtil::computeMinMax #1";
1281  if(traceDebug())
1282  {
1283  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
1284  }
1285 
1286  if ( ih.valid() )
1287  {
1288  // Get the entry list:
1289  std::vector<ossim_uint32> entryList;
1290  ih->getEntryList(entryList);
1291 
1292  bool useEntryIndex = false;
1293  if ( entryList.size() )
1294  {
1295  if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex = true;
1296  }
1297 
1298  for(ossim_uint32 idx = 0; idx < entryList.size(); ++idx)
1299  {
1300  computeMinMax(ih, entryList[idx], useEntryIndex);
1301  }
1302  }
1303 
1304  if(traceDebug())
1305  {
1306  ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
1307  }
1308 
1309 } // End: ossimImageUtil::computeMinMax( ih )
bool valid() const
Definition: ossimRefPtr.h:75
unsigned int ossim_uint32
void computeMinMax(ossimRefPtr< ossimImageHandler > &ih)
virtual void getEntryList(std::vector< ossim_uint32 > &entryList) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ computeMinMax() [2/2]

void ossimImageUtil::computeMinMax ( ossimRefPtr< ossimImageHandler > &  ih,
ossim_uint32  entry,
bool  useEntryIndex 
)
private

Definition at line 1311 of file ossimImageUtil.cpp.

1314 {
1315  static const char M[] = "ossimImageUtil::computeMinMax #2";
1316  if(traceDebug())
1317  {
1318  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
1319  }
1320 
1321  if ( ih.valid() )
1322  {
1323  // Get any min, max, null overrides;
1324  double maxValue = ossim::nan();
1325  double minValue = ossim::nan();
1326  double nullValue = ossim::nan();
1327 
1328  ossimString value = m_kwl->findKey( CMM_MAX_KW );
1329  if ( value.size() )
1330  {
1331  maxValue = value.toDouble();
1332  }
1333 
1334  value = m_kwl->findKey( CMM_MIN_KW );
1335  if ( value.size() )
1336  {
1337  minValue = value.toDouble();
1338  }
1339 
1340  bool hasNull = false;
1341  value = m_kwl->findKey( CMM_NULL_KW );
1342  if ( value.size() )
1343  {
1344  nullValue = value.toDouble();
1345  if ( !ossim::isnan(nullValue) )
1346  {
1347  hasNull = true;
1348  }
1349  }
1350 
1351  // Select the entry.
1352  ih->setCurrentEntry( entry );
1353 
1354  // Build the .omd file name.
1355  ossimFilename omd_file = ih->getFilename();;
1356 
1357  // Check for output directory:
1358  if ( m_kwl->hasKey( OUTPUT_DIRECTORY_KW ) )
1359  {
1360  ossimFilename outputDir;
1361  outputDir.string() = m_kwl->findKey( OUTPUT_DIRECTORY_KW );
1362 
1363  if ( outputDir.exists() && outputDir.isDir() )
1364  {
1365  omd_file = outputDir.dirCat( omd_file.file() );
1366  }
1367  }
1368 
1369  if ( useEntryIndex )
1370  {
1371  ossim_uint32 currentEntry = ih->getCurrentEntry();
1372  omd_file.setExtension("");
1373  omd_file += "_e";
1374  omd_file += ossimString::toString(currentEntry);
1375 
1376  //---
1377  // Note: Set extension was not used here deliberately to avoid
1378  // messing
1379  // up a MODIS file in hdf format with multiple '.'s in the file
1380  // name.
1381  //---
1382  omd_file += ".omd";
1383  }
1384  else
1385  {
1386  omd_file.setExtension("omd");
1387  }
1388 
1390 
1391  //---
1392  // Note: getImageTileWidth/Height will return zero if the image is not
1393  // intenally tiles.
1394  //---
1395  ossimIpt tileWidthHeight( ih->getImageTileWidth(), ih->getImageTileHeight() );
1396  if (!tileWidthHeight.x)
1397  {
1398  //---
1399  // Make the sequencer read entire strips from the image handler
1400  // at a time. This will speed up access time for strip images
1401  //---
1402  tileWidthHeight.x = ih->getBoundingRect().width();
1403  }
1404  if(!tileWidthHeight.y)
1405  {
1406  tileWidthHeight.y = ih->getTileHeight();
1407  }
1408 
1409  if ( traceDebug() )
1410  {
1412  << "Sequencer tile size: " << tileWidthHeight << endl;
1413  }
1414 
1415  is->setTileSize(tileWidthHeight);
1416 
1417  //---
1418  // Make arrays of doubles to hold the min/max values.
1419  // Initialize mins to default maxes and maxes to default mins to be
1420  // safe.
1421  //---
1422  ossim_uint32 i; // for numerous iterations...
1423 
1424  const ossimScalarType ST = ih->getOutputScalarType();
1425 
1426  const double DEFAULT_MIN = ossim::defaultMin(ST);
1427  const double DEFAULT_MAX = ossim::defaultMax(ST);
1428 
1429  const ossim_uint32 BANDS = ih->getNumberOfInputBands();
1430 
1431  vector<double> tmin(BANDS);
1432  vector<double> tmax(BANDS);
1433  vector<double> tnull(BANDS);
1434  for (i = 0; i < BANDS; ++i)
1435  {
1436  tmin[i] = DEFAULT_MAX;
1437  tmax[i] = DEFAULT_MIN;
1438 
1439  if ( hasNull )
1440  {
1441  // User passed in with --null option so set here.
1442  tnull[i] = nullValue;
1443  }
1444  else
1445  {
1446  tnull[i] = ih->getNullPixelValue(i);
1447  }
1448  }
1449 
1450  // Scan the image and compute the min and max.
1451  const double TOTAL_TILES = is->getNumberOfTiles();
1452  double tile_count = 0.0;
1454  << setiosflags(ios::fixed) << setprecision(0);
1455 
1456  if( (ossim::isnan(minValue) ) || (ossim::isnan(maxValue) ) )
1457  {
1459  while(id.valid())
1460  {
1461  if ( hasNull )
1462  {
1463  // Pass null to image data object so it doesn't get picked up as "min".
1464  id->setNullPix( nullValue );
1465  }
1466  id->computeMinMaxPix(tmin, tmax);
1467  id = is->getNextTile();
1468  ++tile_count;
1470  << "\r" << setw(3)
1471  << (tile_count / TOTAL_TILES * 100.0) << "%"
1472  << flush;
1473  }
1474  }
1475 
1476  if(!ossim::isnan(minValue))
1477  {
1478  std::fill(tmin.begin(), tmin.end(), minValue);
1479  }
1480  if(!ossim::isnan(maxValue))
1481  {
1482  std::fill(tmax.begin(), tmax.end(), maxValue);
1483  }
1485  << "\r100%\nFinished..." << endl;
1486 
1487  ossimKeywordlist okwl(omd_file);
1488 
1489  for(i = 0; i < BANDS; ++i)
1490  {
1491  //---
1492  // Check to see if values got assigned. If not flip to default and
1493  // issue a warning.
1494  //---
1495  if (tmin[i] == DEFAULT_MAX)
1496  {
1497  tmin[i] = DEFAULT_MIN;
1499  << "cmm scan for min failed! Using default min."
1500  << std::endl;
1501  }
1502  if (tmax[i] == DEFAULT_MIN)
1503  {
1504  tmax[i] = DEFAULT_MAX;
1506  << "cmm scan for max failed! Using default max."
1507  << std::endl;
1508  }
1509 
1510  ossimString band =
1511  ossimString("band")+ossimString::toString(i+1)+".";
1512 
1513  if (tmin[i] == DEFAULT_MAX)
1514  {
1515  tmin[i] = DEFAULT_MIN;
1516  }
1517  // if (tmax[i] == DEFAULT_MIN){}
1518 
1519  okwl.add(band + "min_value", tmin[i], true);
1520  okwl.add(band + "max_value", tmax[i], true);
1521  okwl.add(band + "null_value", tnull[i], true);
1522 
1523  if( traceDebug() )
1524  {
1526  << setiosflags(ios::fixed) << setprecision(16)
1527  << "band" << ossimString::toString(i+1) << ".min_value: "
1528  << tmin[i]
1529  << "\nband" << ossimString::toString(i+1) << ".max_value: "
1530  << tmax[i]
1531  << "\nband" << ossimString::toString(i+1) << ".null_value: "
1532  << tnull[i] << endl;
1533  }
1534 
1535  } // End of band loop.
1536 
1537  // Add missing info (number of bands, scalar type) to the .omd file
1538  okwl.add("bytes_per_pixel", ossim::scalarSizeInBytes(ST), true);
1539  okwl.add("number_bands", BANDS, true);
1540  okwl.add("scalar_type", (ossimScalarTypeLut::instance()->getEntryString(ST)), true);
1541 
1542  // Write the file to disk:
1543  okwl.write(omd_file);
1545  << "wrote file: " << omd_file << endl;
1546 
1547  ih->loadMetaData();
1548 
1549  } // Matches: if ( ih.valid() )
1550 
1551  if(traceDebug())
1552  {
1553  ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
1554  }
1555 
1556 } // End: ossimImageUtil::computeMinMax( ih, entry, ... )
Represents serializable keyword/value map.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
bool valid() const
Definition: ossimRefPtr.h:75
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
bool hasKey(const std::string &key) const
Checks for key in map.
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
static ossimString toString(bool aValue)
Numeric to string methods.
bool isDir() const
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
virtual void setNullPix(ossim_float64 null_pix)
OSSIM_DLL double defaultMin(ossimScalarType scalarType)
Definition: ossimCommon.cpp:73
bool exists() const
virtual const ossimFilename & getFilename() const
Returns the filename.
std::string::size_type size() const
Definition: ossimString.h:405
virtual ossim_uint32 getImageTileHeight() const =0
Returns the tile width of the image or 0 if the image is not tiled.
unsigned int ossim_uint32
double toDouble() const
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
virtual ossim_uint32 getCurrentEntry() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimScalarType
virtual ossim_uint32 getImageTileWidth() const =0
Returns the tile width of the image or 0 if the image is not tiled.
OSSIM_DLL double defaultMax(ossimScalarType scalarType)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
virtual void loadMetaData()
There is an external file with an omd extension.
ossimFilename dirCat(const ossimFilename &file) const
ossimFilename file() const
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
ossim_int32 x
Definition: ossimIpt.h:141
virtual ossim_uint32 getNumberOfInputBands() const =0
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
virtual void setTileSize(const ossimIpt &tileSize)
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ createHistogram() [1/3]

bool ossimImageUtil::createHistogram ( ) const
Returns
true if CREATE_HISTOGRAM_KW is found and set to true.

Definition at line 1956 of file ossimImageUtil.cpp.

References keyIsTrue().

Referenced by getHistogramMode(), and hasHistogramOption().

1957 {
1958  return keyIsTrue( CREATE_HISTOGRAM_KW );
1959 }
bool keyIsTrue(const std::string &key) const

◆ createHistogram() [2/3]

void ossimImageUtil::createHistogram ( ossimRefPtr< ossimImageHandler > &  ih)
private

Definition at line 1145 of file ossimImageUtil.cpp.

1146 {
1147  static const char M[] = "ossimImageUtil::createHistogram #1";
1148  if(traceDebug())
1149  {
1150  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
1151  }
1152 
1153  if ( ih.valid() )
1154  {
1155  // Get the entry list:
1156  std::vector<ossim_uint32> entryList;
1157  ih->getEntryList(entryList);
1158 
1159  bool useEntryIndex = false;
1160  if ( entryList.size() )
1161  {
1162  if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex = true;
1163  }
1164 
1165  for(ossim_uint32 idx = 0; idx < entryList.size(); ++idx)
1166  {
1167  createHistogram(ih, entryList[idx], useEntryIndex);
1168  }
1169  }
1170 
1171  if(traceDebug())
1172  {
1173  ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
1174  }
1175 }
bool valid() const
Definition: ossimRefPtr.h:75
bool createHistogram() const
unsigned int ossim_uint32
virtual void getEntryList(std::vector< ossim_uint32 > &entryList) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ createHistogram() [3/3]

void ossimImageUtil::createHistogram ( ossimRefPtr< ossimImageHandler > &  ih,
ossim_uint32  entry,
bool  useEntryIndex 
)
private

Definition at line 1178 of file ossimImageUtil.cpp.

1181 {
1182  static const char M[] = "ossimImageUtil::createHistogram #2";
1183  if(traceDebug())
1184  {
1185  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
1186  }
1187 
1188  if ( ih.valid() )
1189  {
1190  if (useEntryIndex)
1191  {
1192  // Set entry before deriving file name.
1193  ih->setCurrentEntry(entry);
1194  ossimNotify(ossimNotifyLevel_NOTICE) << "entry number: "<< entry << std::endl;
1195  }
1196 
1197  ossimFilename outputFile =
1198  ih->getFilenameWithThisExtension(ossimString(".his"), useEntryIndex);
1199 
1200  // Only build if needed:
1201  if ( (outputFile.exists() == false) || rebuildHistogram() )
1202  {
1204  << "Computing histogram for file: " << ih->getFilename() << std::endl;
1205 
1206  // Check handler to see if it's filtering bands.
1207  std::vector<ossim_uint32> originalBandList(0);
1208  if ( ih->isBandSelector() )
1209  {
1210  // Capture for finalize method.
1211  ih->getOutputBandList( originalBandList );
1212 
1213  // Set output list to input.
1215  }
1216 
1219 
1220  histoSource->setMaxNumberOfRLevels(1); // Currently hard coded...
1221 
1222 #if 0 /* TODO tmp drb */
1223  if( !ossim::isnan(histoMin) )
1224  {
1225  histoSource->setMinValueOverride(histoMin);
1226  }
1227 
1228  if( !ossim::isnan(histoMax) )
1229  {
1230  histoSource->setMaxValueOverride(histoMax);
1231  }
1232 
1233  if(histoBins > 0)
1234  {
1235  histoSource->setNumberOfBinsOverride(histoBins);
1236  }
1237 #endif
1238 
1239  if(traceDebug())
1240  {
1242  << "Histogram mode: " << getHistogramMode() << "\n";
1243  }
1244 
1245  // Connect histogram source to image handler.
1246  histoSource->setComputationMode( getHistogramMode() );
1247  histoSource->connectMyInputTo(0, ih.get() );
1248  histoSource->enableSource();
1249 
1250  // Connect writer to histogram source.
1251  writer->connectMyInputTo(0, histoSource.get());
1252  writer->setFilename(outputFile);
1254  writer->addListener(&theStdOutProgress);
1255 
1256  // Compute...
1257  writer->execute();
1258 
1259  writer=0;
1260 
1261  // Reset the band list.
1262  if ( ih->isBandSelector() && originalBandList.size() )
1263  {
1264  ih->setOutputBandList( originalBandList );
1265  }
1266 
1267  } // Matches: if ( (outputFile.exists() == false) || rebuildHistogram() )
1268 
1269  } // Matches: if ( ih.valid() )
1270 
1271  if(traceDebug())
1272  {
1273  ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
1274  }
1275 
1276 } // End: ossimImageUtil::createHistogram #2
virtual bool addListener(ossimListener *listener)
void setComputationMode(ossimHistogramMode mode)
void setNumberOfBinsOverride(ossim_int32 numberOfBinsOverride)
bool valid() const
Definition: ossimRefPtr.h:75
OSSIM_DLL ossimStdOutProgress theStdOutProgress
virtual void getOutputBandList(std::vector< ossim_uint32 > &bandList) const
Initializes bandList.
bool exists() const
virtual const ossimFilename & getFilename() const
Returns the filename.
virtual void setFlushStreamFlag(bool flag)
virtual bool setOutputToInputBandList()
If the image handler "isBandSeletor()" then the band selection of the output are set to input or iden...
virtual void enableSource()
Definition: ossimSource.cpp:84
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
bool rebuildHistogram() const
virtual bool isBandSelector() const
Indicates whether or not the image handler can control output band selection via the setOutputBandLis...
void setMaxValueOverride(ossim_float32 maxValueOverride)
ossimHistogramMode getHistogramMode() const
virtual void setMaxNumberOfRLevels(ossim_uint32 number)
virtual void setFilename(const ossimFilename &filename)
void setMinValueOverride(ossim_float32 minValueOverride)
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
virtual bool setOutputBandList(const std::vector< ossim_uint32 > &band_list)
If the image handler "isBandSeletor()" then the band selection of the output chip can be controlled...
ossimFilename getFilenameWithThisExtension(const ossimString &ext, bool set_e0_prefix=false) const
Returns the image file with extension set using supplentary directory for dirname if set...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ createHistogramFast()

bool ossimImageUtil::createHistogramFast ( ) const
Returns
true if CREATE_HISTOGRAM_FAST_KW is found and set to true.

Definition at line 1966 of file ossimImageUtil.cpp.

References keyIsTrue().

Referenced by getHistogramMode(), and hasHistogramOption().

1967 {
1968  return keyIsTrue( CREATE_HISTOGRAM_FAST_KW );
1969 }
bool keyIsTrue(const std::string &key) const

◆ createHistogramR0()

bool ossimImageUtil::createHistogramR0 ( ) const
Returns
true if CREATE_HISTOGRAM_R0_KW is found and set to true.

Definition at line 1976 of file ossimImageUtil.cpp.

References keyIsTrue().

Referenced by getHistogramMode(), and hasHistogramOption().

1977 {
1978  return keyIsTrue( CREATE_HISTOGRAM_R0_KW );
1979 }
bool keyIsTrue(const std::string &key) const

◆ createOverview() [1/2]

void ossimImageUtil::createOverview ( ossimRefPtr< ossimImageHandler > &  ih,
bool &  consumedHistogramOptions,
bool &  consumedCmmOptions 
)
private

Definition at line 797 of file ossimImageUtil.cpp.

800 {
801  static const char M[] = "ossimImageUtil::createOverview #1";
802  if(traceDebug())
803  {
804  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
805  }
806 
807  if ( ih.valid() )
808  {
809  // Get the entry list:
810  std::vector<ossim_uint32> entryList;
811  ih->getEntryList(entryList);
812 
813  bool useEntryIndex = false;
814  if ( entryList.size() )
815  {
816  if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex = true;
817  }
818 
819  // Create the overview builder:
820  ossimString overviewType;
821  getOverviewType( overviewType.string() );
824  if ( ob.valid() )
825  {
826  // Set up any overview builder options that don't involve histograms.
827  ossimPropertyInterface* pi = dynamic_cast<ossimPropertyInterface*>( ob.get() );
828  if ( pi ) setProps(pi);
829 
830  ossim_uint32 stopDimension = getOverviewStopDimension();
831  if ( stopDimension ) ob->setOverviewStopDimension(stopDimension);
832 
833  if ( ( scanForMinMax() || scanForMinMaxNull() ) && !hasCmmOption() )
834  {
835  //---
836  // If scan is set and we don't have any min, max, null overrides let the
837  // overview builder scan for min, max.
838  //
839  // If min, max, or null option is set, scan will be performed in
840  // separate function.
841  //---
842  ob->setScanForMinMax( scanForMinMax() );
843  ob->setScanForMinMaxNull( scanForMinMaxNull() );
844  consumedCmmOptions = true;
845  }
846 
847  for(ossim_uint32 idx = 0; idx < entryList.size(); ++idx)
848  {
849  createOverview(ih, ob, entryList[idx], useEntryIndex, consumedHistogramOptions);
850  }
851  }
852  else
853  {
855  << "ERROR:\nCould not create builder for: "<< overviewType << std::endl;
857  }
858  }
859 
860  if(traceDebug())
861  {
862  ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
863  }
864 }
ossim_uint32 getOverviewStopDimension() const
bool valid() const
Definition: ossimRefPtr.h:75
bool scanForMinMax() const
void getOverviewType(std::string &type) const
Initializes type from OVERVIEW_TYPE_KW or sets to default ossim_tiff_box if not found.
bool scanForMinMaxNull() const
void createOverview(ossimRefPtr< ossimImageHandler > &ih, bool &consumedHistogramOptions, bool &consumedCmmOptions)
unsigned int ossim_uint32
void setProps(ossimPropertyInterface *pi) const
set reader or writer properties based on cast of pi.
virtual void getEntryList(std::vector< ossim_uint32 > &entryList) const
static ossimOverviewBuilderFactoryRegistry * instance()
instance method for access to theInstance pointer.
void outputOverviewWriterTypes() const
ossimOverviewBuilderBase * createBuilder(const ossimString &typeName) const
Creates a builder from a string.
bool hasCmmOption() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414

◆ createOverview() [2/2]

void ossimImageUtil::createOverview ( ossimRefPtr< ossimImageHandler > &  ih,
ossimRefPtr< ossimOverviewBuilderBase > &  ob,
ossim_uint32  entry,
bool  useEntryIndex,
bool &  consumedHistogramOptions 
)
private

Definition at line 867 of file ossimImageUtil.cpp.

872 {
873  static const char M[] = "ossimImageUtil::createOverview #2";
874  if(traceDebug())
875  {
876  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
877  }
878 
879  if ( ih.valid() && ob.valid() )
880  {
881  if (useEntryIndex)
882  {
883  // Set entry before deriving file name.
884  ih->setCurrentEntry(entry);
885  ossimNotify(ossimNotifyLevel_NOTICE) << "entry number: "<< entry << std::endl;
886  }
887 
888  ossimFilename outputFile =
889  ih->getFilenameWithThisExtension(ossimString(".ovr"), useEntryIndex);
890 
891  if ( rebuildOverviews() )
892  {
893  ih->closeOverview();
894  if ( outputFile.exists() )
895  {
896  outputFile.remove();
897  }
898  }
899 
900  if ( getInternalOverviewsFlag() )
901  {
902  if ( ih->getClassName() == "ossimTiffTileSource")
903  {
904  //---
905  // INTERNAL_OVERVIEWS_FLAG_KW is set to true:
906  // Tiff reader can handle internal overviews. Set the output file to
907  // input file. Do it after the above remove so that if there were
908  // external overviews they will get removed.
909  //---
910  outputFile = ih->getFilename();
911  }
912  else
913  {
915  << "Internal overviews not supported for reader type: "
916  <<ih->getClassName()
917  << "\nIgnoring option..."
918  << endl;
919  }
920  }
921 
922  if ( hasRequiredOverview( ih, ob ) == false )
923  {
924  //---
925  // Set create histogram code...
926  //
927  // Notes:
928  // 1) Must put this logic after any removal of external overview file.
929  //
930  // 2) Base file could have built in overviews, e.g. jp2 files. So the sequensor could
931  // start at R6 even if there is no external overview file.
932  //
933  // 3) If user want the histogram from R0 the overview builder can do as long as
934  // ossimImageHandler::getNumberOfDecimationLevels returns 1. If we are starting
935  // overview building at R6 then we must do the create histogram in a separate path.
936  //---
938  if ( createHistogram() ||
939  ( createHistogramR0() && ( ih->getNumberOfDecimationLevels() == 1 ) ) )
940  {
941  histoMode = OSSIM_HISTO_MODE_NORMAL;
942  }
943  else if ( createHistogramFast() )
944  {
945  histoMode = OSSIM_HISTO_MODE_FAST;
946  }
947 
948  if(traceDebug())
949  {
950  ossimNotify(ossimNotifyLevel_DEBUG) << "Histogram mode: " << histoMode << "\n";
951  }
952 
953  if ( histoMode != OSSIM_HISTO_MODE_UNKNOWN )
954  {
955  consumedHistogramOptions = true;
956  ob->setHistogramMode(histoMode);
957 
959  << "Creating overviews with histogram for file: " << ih->getFilename() << std::endl;
960  }
961  else
962  {
963  if ( histoMode != OSSIM_HISTO_MODE_UNKNOWN )
964  {
965  consumedHistogramOptions = false;
967  << "Creating overviews for file: " << ih->getFilename() << std::endl;
968  }
969  }
970 
971  //---
972  // Set properties, e.g. tile size. Must be set before the call to
973  // ob->setInputSource(...)
974  //---
975  std::vector< ossimRefPtr<ossimProperty> > propertyList(0);
976  ossimIpt tileSize;
977  if ( getTileSize( tileSize ) == true )
978  {
980  tileSize.toString()));
981  ob->setProperties(propertyList);
982  }
983 
984  ob->setOutputFile(outputFile);
985  ob->setInputSource(ih.get());
986 
987  // Create the overview for this entry in this file:
988  if ( ob->execute() == false )
989  {
992  << "Error returned creating overviews for file: " << ih->getFilename() << std::endl;
993  }
994  }
995  else
996  {
997  consumedHistogramOptions = false;
999  << "Image has required reduced resolution data sets." << std::endl;
1000  }
1001  }
1002 
1003  if(traceDebug())
1004  {
1005  ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
1006  }
1007 }
ossimString toString() const
Definition: ossimIpt.cpp:139
bool createHistogramR0() const
bool createHistogramFast() const
static bool remove(const ossimFilename &pathname)
Removes pathname from filesystem if supported by platform.
ossimHistogramMode
void setProperties(std::vector< ossimRefPtr< ossimProperty > > &propertyList)
static const char * OUTPUT_TILE_SIZE_KW
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool setInputSource(ossimImageHandler *imageSource)
Sets the input to the builder.
bool getInternalOverviewsFlag() const
static const ossimErrorCode OSSIM_ERROR
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
bool rebuildOverviews() const
void setErrorStatus(ossim_int32 status)
Sets the m_errorStatus for return on execute.
bool hasRequiredOverview(ossimRefPtr< ossimImageHandler > &ih, ossimRefPtr< ossimOverviewBuilderBase > &ob)
virtual void closeOverview()
If theOverview is initialized it will be deleted and set to NULL.
bool getTileSize(ossimIpt &tileSize) const
Gets the tile size.
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
bool createHistogram() const
bool exists() const
virtual const ossimFilename & getFilename() const
Returns the filename.
virtual bool execute()=0
Builds the overviews.
virtual void setOutputFile(const ossimFilename &file)=0
Sets the output file name.
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
ossimFilename getFilenameWithThisExtension(const ossimString &ext, bool set_e0_prefix=false) const
Returns the image file with extension set using supplentary directory for dirname if set...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void setHistogramMode(ossimHistogramMode mode)
Sets the histogram accumulation mode.

◆ createOverviews()

bool ossimImageUtil::createOverviews ( ) const
Returns
true if CREATE_OVERVIEWS_KW is found and set to true.

Definition at line 1660 of file ossimImageUtil.cpp.

References keyIsTrue().

1661 {
1662  return keyIsTrue( CREATE_OVERVIEWS_KW );
1663 }
bool keyIsTrue(const std::string &key) const

◆ createThumbnail()

void ossimImageUtil::createThumbnail ( ossimRefPtr< ossimImageHandler > &  ih)
private

Definition at line 1008 of file ossimImageUtil.cpp.

References ossimKeywordlist::add(), ossimKeywordNames::BANDS_KW, ossimImageSourceFactoryBase::createImageSource(), and ossimImageSourceFactoryRegistry::instance().

1009 {
1010  ossimKeywordlist bandsKeywordList;
1011  bandsKeywordList.add("type", "ossimBandSelector");
1012  bandsKeywordList.add(ossimKeywordNames::BANDS_KW, "default");
1014  if (!bs)
1015  return;
1016  ossimIrect cutRect;
1021  ossimDrect bounds = ih->getBoundingRect();
1022  ossim_float64 maxSize = ossim::max(bounds.width(), bounds.height());
1023  ossim_float64 thumbnailSize = getThumbnailSize();
1024  ossim_float64 scale = thumbnailSize / maxSize;
1025  ossimFilename thumbnailFilename = getThumbnailFilename(ih.get());
1027  if (scale > 1.0)
1028  {
1029  scale = 1.0;
1030  cutRect = bounds;
1031  }
1032  else
1033  {
1034  cutRect = bounds * scale;
1035  }
1036  cutFilter->setRectangle(cutRect);
1037  if ((scale < .5) && (ih->getNumberOfDecimationLevels() < 2))
1038  {
1039  return;
1040  }
1041 
1042  trans->scale(scale, scale);
1043  renderer->setImageViewTransform(trans.get());
1044  if (!bs.valid())
1045  return;
1046  bs->connectMyInputTo(ih.get());
1047  bs->initialize();
1048  ossim_uint32 bandCount = bs->getNumberOfInputBands();
1049  if ((bandCount == 2) || (bandCount > 3))
1050  {
1051  ossimBandSelector *tempBs = dynamic_cast<ossimBandSelector *>(bs.get());
1052  if (tempBs)
1053  {
1054  tempBs->setThreeBandRgb();
1055  }
1056  }
1057 
1059  stretch->setStretchMode(thumbnailStretchType);
1060  ossimFilename histogramFilename = ih->createDefaultHistogramFilename();
1061 
1062  //if (!histogramFilename.empty())
1063  //{
1064  // histogramFile = m_histogramFilename;
1065  // }
1066  stretch->connectMyInputTo(bs.get());
1067  stretch->openHistogram(histogramFilename);
1068  renderer->connectMyInputTo(stretch.get());
1069 
1070  scalarRemapper->connectMyInputTo(renderer.get());
1071  cutFilter->connectMyInputTo(scalarRemapper.get());
1072  ossimKeywordlist writerKwl;
1073  ossimString ext = thumbnailFilename.ext();
1074  ext = ext.downcase();
1075  writerKwl.add("type", "image/" + ext);
1076  writerKwl.add("filename", thumbnailFilename.c_str());
1077  writerKwl.add("create_external_geometry", "false");
1078  if (ext == "png")
1079  {
1080  writerKwl.add("add_alpha_channel", "true");
1081  }
1083 
1084  if (writer)
1085  {
1086  writer->connectMyInputTo(cutFilter.get());
1087 
1088  writer->execute();
1089 
1090  writer->disconnect();
1091  writer = 0;
1092  }
1093  scalarRemapper->disconnect();
1094  scalarRemapper = 0;
1095  cutFilter->disconnect();
1096  cutFilter = 0;
1097  renderer->disconnect();
1098  renderer = 0;
1099  stretch->disconnect();
1100  stretch = 0;
1101  bs->disconnect();
1102  bs = 0;
1103 }
void setRectangle(const ossimIrect &rect)
T max(T a, T b)
Definition: ossimCommon.h:236
ossim_float64 width() const
Definition: ossimDrect.h:522
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
std::string getThumbnailFilename(ossimImageHandler *ih) const
static ossimImageWriterFactoryRegistry * instance()
void setImageViewTransform(ossimImageViewTransform *transform)
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
void setStretchMode(StretchMode mode, bool rebuildTableFlag=false)
Sets remap mode to mode.
double ossim_float64
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
unsigned int ossim_uint32
int getThumbnailStretchType() const
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
ossim_uint32 getThumbnailSize() const
static const char * BANDS_KW
ossim_float64 height() const
Definition: ossimDrect.h:517
virtual ossimImageSource * createImageSource(const ossimString &name) const
virtual void setThreeBandRgb()
Will set to three bands (rgb) out.
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 ossimFilename createDefaultHistogramFilename() const
ossimImageFileWriter * createWriter(const ossimFilename &filename) const
ossimString ext() const
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
virtual void initialize()=0
virtual void scale(double x, double y)
virtual ossim_uint32 getNumberOfInputBands() const =0
static ossimImageSourceFactoryRegistry * instance()
bool openHistogram(const ossimFilename &histogram_file)
Open the histogram file.
virtual bool execute()
Calls: writeFile() writeMetaDataFiles()

◆ createThumbnails()

bool ossimImageUtil::createThumbnails ( ) const
Returns
true if CREATE_THUMBNAILS_KW is found and set to true.

Definition at line 1669 of file ossimImageUtil.cpp.

References keyIsTrue().

1670 {
1671  return keyIsTrue(CREATE_THUMBNAILS_KW);
1672 }
bool keyIsTrue(const std::string &key) const

◆ dumpFilteredImageList()

void ossimImageUtil::dumpFilteredImageList ( ) const
private

Dumps filtered image list to std out.

Definition at line 2276 of file ossimImageUtil.cpp.

References m_filteredImages, ossimNotify(), and ossimNotifyLevel_NOTICE.

2277 {
2278  ossimNotify(ossimNotifyLevel_NOTICE) << "Filtered image list:\n";
2279  std::vector<std::string>::const_iterator i = m_filteredImages.begin();
2280  while ( i != m_filteredImages.end() )
2281  {
2282  ossimNotify(ossimNotifyLevel_NOTICE) << (*i) << "\n";
2283  ++i;
2284  }
2285  ossimNotify(ossimNotifyLevel_NOTICE) << std::endl;
2286 }
std::vector< std::string > m_filteredImages
Hold images we never want to process.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ execute()

ossim_int32 ossimImageUtil::execute ( )

Execute method.

This launches file walking mechanism.

Returns
int, 0 = good, non-zero something happened. Because this can process multiple files a non-zero return may indicate just one file did not complete, e.g. building overviews.
Note
Throws ossimException on error.

Definition at line 584 of file ossimImageUtil.cpp.

585 {
586  static const char M[] = "ossimImageUtil::execute()";
587 
588  if ( traceDebug() )
589  {
590  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
591  }
592 
593  // Launch any prep system commands:
595 
596  // Get the number of "file*" keywords.
597  ossim_uint32 fileCount = m_kwl->numberOf("file");
598 
599  if ( fileCount )
600  {
601  if ( !m_fileWalker )
602  {
604  }
605 
607 
608  // Must set this so we can stop recursion on directory based images.
610 
611  // This links the file walker back to our "processFile" method.
613 
614  // Wrap in try catch block as excptions can be thrown under the hood.
615  try
616  {
617  // Get the list of files passed to us:
618  std::vector<ossimFilename> files;
619  ossim_uint32 processedFiles = 0;;
620  ossim_uint32 i = 0;
621  while ( processedFiles < fileCount )
622  {
623  ossimString key = FILE_KW;
624  key += ossimString::toString(i);
625  std::string lookup = m_kwl->findKey( key.string() );
626  if ( lookup.size() )
627  {
628  files.push_back( ossimFilename(lookup) );
629  ++processedFiles;
630  }
631 
632  ++i;
633  if ( i > (fileCount + 100) ) break;
634  }
635 
636  //---
637  // If the file count is one and it is not a directory, we will assume
638  // the caller wanted to process that file. So leave the filter list
639  // blank.
640  //---
641  if ( (getOverrideFilteredImagesFlag() == false) && files.size() &&
642  ( (files.size() > 1) || (files[0].isDir() == true) ) )
643  {
644  if ( m_filteredImages.empty() )
645  {
647  }
648  if ( m_fileWalker->getFilteredExtensions().empty() )
649  {
651  }
652  }
653 
654  // Process the files:
655  m_fileWalker->walk( files );
656  }
657  catch (const ossimException& e)
658  {
660  << "Caught exception: " << e.what() << endl;
662  }
663 
664  } // if ( fileCount )
665 
666  // Launch any post system commands:
668 
669  if ( traceDebug() )
670  {
672  << M << " exit status: " << m_errorStatus << std::endl;
673  }
674 
675  // Zero is good, non zero is bad.
676  return m_errorStatus;
677 }
ossim_uint32 numberOf(const char *str) const
void setFileProcessor(ossimFileProcessorInterface *fpi)
Sets ossimFileProcessorInterfacecallback method to process files.
void executePrepCommands() const
run prep system commands.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
std::vector< std::string > m_filteredImages
Hold images we never want to process.
static ossimString toString(bool aValue)
Numeric to string methods.
const std::vector< std::string > & getFilteredExtensions() const
static const ossimErrorCode OSSIM_ERROR
ossimFileWalker * m_fileWalker
void setErrorStatus(ossim_int32 status)
Sets the m_errorStatus for return on execute.
Utility class to walk through directories and get a list of files to process.
virtual const char * what() const
Returns the error message.
unsigned int ossim_uint32
void setNumberOfThreads(ossim_uint32 nThreads)
Sets the max number of threads(jobs) to run at one time.
ossim_int32 m_errorStatus
void initializeDefaultFilterList()
Initializes the filter list with a default set of filtered out file names.
bool getOverrideFilteredImagesFlag() const
void executePostCommands() const
run post system commands.
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
void initializeDefaultFilterList()
Initializes the filter list with a default set of filtered out file names.
void setWaitOnDirFlag(bool flag)
Sets waitOnDir flag.
void walk(const std::vector< ossimFilename > &files)
Takes an array of files.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_uint32 getNumberOfThreads() const
const std::string & string() const
Definition: ossimString.h:414

◆ executeCommands()

void ossimImageUtil::executeCommands ( const std::string &  prefix,
const ossimFilename file 
) const
private

system commands.

Definition at line 2308 of file ossimImageUtil.cpp.

References ossimString::c_str(), ossimKeywordlist::findKey(), ossimKeywordlist::getNumberOfSubstringKeys(), m_kwl, ossimNotify(), ossimNotifyLevel_NOTICE, ossimString::size(), status, ossimString::string(), substituteCommandString(), and ossimString::toString().

Referenced by executeFileCommands(), executePostCommands(), and executePrepCommands().

2310 {
2311  const std::string BASE_KEY = "command";
2312 
2313  // Get the number of test:
2314  const std::string REG_EXP_STR = prefix + BASE_KEY + std::string("[0-9]+");
2315  const ossim_uint32 NUM_COMMANDS = m_kwl->getNumberOfSubstringKeys(REG_EXP_STR);
2316  if ( NUM_COMMANDS )
2317  {
2318  const ossim_uint32 MAX_INDEX = NUM_COMMANDS + 1000; // for skipage...
2319  ossim_uint32 index = 0;
2320  ossim_uint32 processedIndexes = 0;
2321  std::string commandKey;
2322  ossimString command;
2323 
2324  while ( processedIndexes < MAX_INDEX )
2325  {
2326  commandKey = prefix + BASE_KEY + ossimString::toString( index++ ).string();
2327  command.string() = m_kwl->findKey( commandKey );
2328 
2329  if ( command.size() )
2330  {
2331  substituteCommandString( file, prefix, commandKey, command );
2332 
2334  << "executing_command: " << command << std::endl;
2335 
2336  // Launch the command:
2337  int status = system( command.c_str() );
2338 
2340  << "return_status: " << status << std::endl;
2341 
2342  ++processedIndexes;
2343 
2344  if ( processedIndexes == NUM_COMMANDS )
2345  {
2346  break;
2347  }
2348  }
2349  }
2350  }
2351 }
ossim_uint32 getNumberOfSubstringKeys(const ossimString &regularExpression) const
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static ossimString toString(bool aValue)
Numeric to string methods.
void substituteCommandString(const ossimFilename &file, const std::string &prefix, const std::string &commandKey, ossimString &command) const
Expands variables in a command string.
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
return status
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
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
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414

◆ executeFileCommands()

void ossimImageUtil::executeFileCommands ( const ossimFilename file) const
private

run per file system commands.

Definition at line 2295 of file ossimImageUtil.cpp.

References executeCommands().

2296 {
2297  std::string prefix = "file.";
2298  executeCommands( prefix, file );
2299 }
void executeCommands(const std::string &prefix, const ossimFilename &file) const
system commands.

◆ executePostCommands()

void ossimImageUtil::executePostCommands ( ) const
private

run post system commands.

Definition at line 2301 of file ossimImageUtil.cpp.

References executeCommands().

2302 {
2303  std::string prefix = "post.";
2304  ossimFilename file = "";
2305  executeCommands( prefix, file );
2306 }
void executeCommands(const std::string &prefix, const ossimFilename &file) const
system commands.

◆ executePrepCommands()

void ossimImageUtil::executePrepCommands ( ) const
private

run prep system commands.

Definition at line 2288 of file ossimImageUtil.cpp.

References executeCommands().

2289 {
2290  std::string prefix = "prep.";
2291  ossimFilename file = "";
2292  executeCommands( prefix, file );
2293 }
void executeCommands(const std::string &prefix, const ossimFilename &file) const
system commands.

◆ getCopyAllFlag()

bool ossimImageUtil::getCopyAllFlag ( ) const
Returns
true if COPY_ALL_FLAG_KW key is found and value is true; else, false.

Definition at line 1764 of file ossimImageUtil.cpp.

References keyIsTrue().

Referenced by hasRequiredOverview().

1765 {
1766  return keyIsTrue( COPY_ALL_FLAG_KW );
1767 }
bool keyIsTrue(const std::string &key) const

◆ getDumpFilterImagesFlag()

bool ossimImageUtil::getDumpFilterImagesFlag ( ) const
Returns
true if DUMP_FILTERED_IMAGES_KW key is found and value is true; else, false.

DUMP_FILTERED_IMAGES_KW = "dump_filtered_images"

Definition at line 1776 of file ossimImageUtil.cpp.

References keyIsTrue().

1777 {
1778  return keyIsTrue( DUMP_FILTERED_IMAGES_KW );
1779 }
bool keyIsTrue(const std::string &key) const

◆ getFilteredImages() [1/2]

const std::vector< std::string > & ossimImageUtil::getFilteredImages ( ) const
Returns
The list of filtered out files.

Definition at line 2254 of file ossimImageUtil.cpp.

References m_filteredImages.

2255 {
2256  return m_filteredImages;
2257 }
std::vector< std::string > m_filteredImages
Hold images we never want to process.

◆ getFilteredImages() [2/2]

std::vector< std::string > & ossimImageUtil::getFilteredImages ( )

Non const method to allow access for adding or deleting extensions from the list.

The list is used by the private isFiltered method to avoid trying to process unwanted files.

Definition at line 2259 of file ossimImageUtil.cpp.

References m_filteredImages.

2260 {
2261  return m_filteredImages;
2262 }
std::vector< std::string > m_filteredImages
Hold images we never want to process.

◆ getHistogramMode()

ossimHistogramMode ossimImageUtil::getHistogramMode ( ) const
Returns
Histogram mode or OSSIM_HISTO_MODE_UNKNOWN if not set.

Definition at line 1991 of file ossimImageUtil.cpp.

References createHistogram(), createHistogramFast(), createHistogramR0(), OSSIM_HISTO_MODE_FAST, OSSIM_HISTO_MODE_NORMAL, and OSSIM_HISTO_MODE_UNKNOWN.

1992 {
1994  if ( createHistogram() || createHistogramR0() )
1995  {
1996  result = OSSIM_HISTO_MODE_NORMAL;
1997  }
1998  else if ( createHistogramFast() )
1999  {
2000  result = OSSIM_HISTO_MODE_FAST;
2001  }
2002  return result;
2003 }
bool createHistogramR0() const
bool createHistogramFast() const
ossimHistogramMode
bool createHistogram() const

◆ getInternalOverviewsFlag()

bool ossimImageUtil::getInternalOverviewsFlag ( ) const
Returns
true if INTERNAL_OVERVIEWS_FLAG_KW key is found and value is true; else, false.

Definition at line 1797 of file ossimImageUtil.cpp.

References keyIsTrue().

1798 {
1799  return keyIsTrue( INTERNAL_OVERVIEWS_FLAG_KW );
1800 }
bool keyIsTrue(const std::string &key) const

◆ getNextReaderPropIndex()

ossim_uint32 ossimImageUtil::getNextReaderPropIndex ( ) const
private
Returns
the next reader prop index.

Definition at line 2058 of file ossimImageUtil.cpp.

References m_kwl, and ossimKeywordlist::numberOf().

2059 {
2060  ossim_uint32 result = m_kwl->numberOf( READER_PROP_KW.c_str() );
2061  if ( result )
2062  {
2063  ossim_uint32 foundProps = 0;
2064  ossim_uint32 index = 0;
2065 
2066  //---
2067  // Loop until we find the last index used for WRITER_PROP_KW.
2068  // (result+100) is to allow for holes like reader_prop0, reader_prop2...
2069  //---
2070  while ( (foundProps < result) && (index < (result+100) ) )
2071  {
2072  ossimString key = READER_PROP_KW;
2073  key += ossimString::toString(index);
2074  std::string lookup = m_kwl->findKey( key.string() );
2075  if ( lookup.size() )
2076  {
2077  ++foundProps;
2078  }
2079  ++index;
2080  }
2081  result = index;
2082  }
2083  return result;
2084 }
ossim_uint32 numberOf(const char *str) const
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static ossimString toString(bool aValue)
Numeric to string methods.
unsigned int ossim_uint32
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
const std::string & string() const
Definition: ossimString.h:414

◆ getNextWriterPropIndex()

ossim_uint32 ossimImageUtil::getNextWriterPropIndex ( ) const
private
Returns
the next writer prop index.

Definition at line 2030 of file ossimImageUtil.cpp.

References m_kwl, and ossimKeywordlist::numberOf().

2031 {
2032  ossim_uint32 result = m_kwl->numberOf( WRITER_PROP_KW.c_str() );
2033  if ( result )
2034  {
2035  ossim_uint32 foundProps = 0;
2036  ossim_uint32 index = 0;
2037 
2038  //---
2039  // Loop until we find the last index used for WRITER_PROP_KW.
2040  // (result+100) is to allow for holes like writer_prop0, writer_prop2...
2041  //---
2042  while ( (foundProps < result) && (index < (result+100) ) )
2043  {
2044  ossimString key = WRITER_PROP_KW;
2045  key += ossimString::toString(index);
2046  std::string lookup = m_kwl->findKey( key.string() );
2047  if ( lookup.size() )
2048  {
2049  ++foundProps;
2050  }
2051  ++index;
2052  }
2053  result = index;
2054  }
2055  return result;
2056 }
ossim_uint32 numberOf(const char *str) const
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static ossimString toString(bool aValue)
Numeric to string methods.
unsigned int ossim_uint32
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
const std::string & string() const
Definition: ossimString.h:414

◆ getNumberOfThreads()

ossim_uint32 ossimImageUtil::getNumberOfThreads ( ) const
private
Returns
Threads to use. Defaults to 1 if THREADS_KW is not found.

Definition at line 2015 of file ossimImageUtil.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

2016 {
2017  ossim_uint32 result;
2018  std::string lookup = m_kwl->findKey( THREADS_KW );
2019  if ( lookup.size() )
2020  {
2021  result = ossimString(lookup).toUInt32();
2022  }
2023  else
2024  {
2025  result = ossim::getNumberOfThreads();
2026  }
2027  return result;
2028 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossim_uint32 toUInt32() const
OSSIM_DLL ossim_uint32 getNumberOfThreads()
Get the number threads to use from ossimPreferences or ossim::Thread.
unsigned int ossim_uint32
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.

◆ getOutputFileNamesFlag()

bool ossimImageUtil::getOutputFileNamesFlag ( ) const
Returns
true if OUTPUT_FILENAMES_KW key is found and value is true; else, false.

Definition at line 1809 of file ossimImageUtil.cpp.

References keyIsTrue().

1810 {
1811  return keyIsTrue( OUTPUT_FILENAMES_KW );
1812 }
bool keyIsTrue(const std::string &key) const

◆ getOverrideFilteredImagesFlag()

bool ossimImageUtil::getOverrideFilteredImagesFlag ( ) const
Returns
true if DUMP_FILTERED_IMAGES_KW key is found and value is true; else, false.

DUMP_FILTERED_IMAGES_KW = "dump_filtered_images"

Definition at line 1821 of file ossimImageUtil.cpp.

References keyIsTrue().

1822 {
1823  return keyIsTrue( OVERRIDE_FILTERED_IMAGES_KW );
1824 }
bool keyIsTrue(const std::string &key) const

◆ getOverviewStopDimension()

ossim_uint32 ossimImageUtil::getOverviewStopDimension ( ) const
Returns
Overview stop dimension or 0 if OVERVIEW_STOP_DIM_KW is not found.

Definition at line 1940 of file ossimImageUtil.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

1941 {
1942  ossim_uint32 result = 0;
1943  std::string lookup = m_kwl->findKey( OVERVIEW_STOP_DIM_KW );
1944  if ( lookup.size() )
1945  {
1946  result = ossimString(lookup).toUInt32();
1947  }
1948  return result;
1949 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossim_uint32 toUInt32() const
unsigned int ossim_uint32
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.

◆ getOverviewType()

void ossimImageUtil::getOverviewType ( std::string &  type) const
private

Initializes type from OVERVIEW_TYPE_KW or sets to default ossim_tiff_box if not found.

Definition at line 1839 of file ossimImageUtil.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

1840 {
1841  std::string lookup = m_kwl->findKey(OVERVIEW_TYPE_KW);
1842  if ( lookup.size() )
1843  {
1844  type = lookup;
1845  }
1846  else
1847  {
1848  type = "ossim_tiff_box"; // default
1849  }
1850 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.

◆ getThumbnailFilename()

std::string ossimImageUtil::getThumbnailFilename ( ossimImageHandler ih) const
private

Definition at line 2166 of file ossimImageUtil.cpp.

References ossimImageHandler::getFilenameWithThisExtension(), getThumbnailType(), and ossimString::string().

2167 {
2168  ossimFilename thumbnailFilename = ih->getFilenameWithThisExtension("");
2169  std::string thumbnailType = getThumbnailType();
2170  if (thumbnailType == "png")
2171  {
2172  thumbnailFilename = ossimFilename(thumbnailFilename + "thumb.png");
2173  }
2174  else
2175  {
2176  thumbnailFilename = ossimFilename(thumbnailFilename + "thumb.jpg");
2177  }
2178 
2179  return thumbnailFilename.string();
2180 }
std::string getThumbnailType() const
ossimFilename getFilenameWithThisExtension(const ossimString &ext, bool set_e0_prefix=false) const
Returns the image file with extension set using supplentary directory for dirname if set...
const std::string & string() const
Definition: ossimString.h:414

◆ getThumbnailSize()

ossim_uint32 ossimImageUtil::getThumbnailSize ( ) const
private
Returns
the next reader prop index.

Definition at line 2085 of file ossimImageUtil.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

2086 {
2087  ossim_uint32 result;
2088  std::string lookup = m_kwl->findKey(THUMBNAIL_SIZE_KW);
2089  if (lookup.size())
2090  {
2091  result = ossimString(lookup).toUInt32();
2092  }
2093  else
2094  {
2095  result = 256;
2096  }
2097  return result;
2098 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossim_uint32 toUInt32() const
unsigned int ossim_uint32
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.

◆ getThumbnailStretchType()

int ossimImageUtil::getThumbnailStretchType ( ) const
private

Definition at line 2104 of file ossimImageUtil.cpp.

References ossimKeywordlist::findKey(), ossimHistogramRemapper::LINEAR_AUTO_MIN_MAX, and m_kwl.

2105 {
2107 
2108  ossimString typeString = m_kwl->findKey(THUMBNAIL_STRETCH_TYPE_KW);
2109 
2110  if (typeString.empty())
2111  {
2112  typeString = "auto-minmax";
2113  }
2114 
2115  typeString = typeString.downcase();
2116 
2117  if ((typeString == "auto-minmax"))
2118  {
2119  result = ossimHistogramRemapper::StretchMode::LINEAR_AUTO_MIN_MAX;
2120  }
2121  else if ((typeString == "auto-percentile"))
2122  {
2123  result = ossimHistogramRemapper::StretchMode::LINEAR_AUTO_PERCENTILE;
2124  }
2125  else if ((typeString == "std-stretch-1") || (typeString == "std-stretch 1"))
2126  {
2127  result = ossimHistogramRemapper::StretchMode::LINEAR_1STD_FROM_MEAN;
2128  }
2129  else if ((typeString == "std-stretch-2") || (typeString == "std-stretch 2"))
2130  {
2131  result = ossimHistogramRemapper::StretchMode::LINEAR_2STD_FROM_MEAN;
2132  }
2133  else if ((typeString == "std-stretch-3") || (typeString == "std-stretch 3"))
2134  {
2135  result = ossimHistogramRemapper::StretchMode::LINEAR_3STD_FROM_MEAN;
2136  }
2137  else if (typeString == "auto-minmax")
2138  {
2139  result = ossimHistogramRemapper::StretchMode::STRETCH_UNKNOWN;
2140  }
2141  return result;
2142 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
bool empty() const
Definition: ossimString.h:411

◆ getThumbnailType()

std::string ossimImageUtil::getThumbnailType ( ) const
private

Definition at line 2149 of file ossimImageUtil.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

Referenced by getThumbnailFilename().

2150 {
2151  ossimString typeString = m_kwl->findKey(THUMBNAIL_TYPE_KW);
2152  std::string result = "jpeg";
2153 
2154  typeString = typeString.downcase();
2155 
2156  if(typeString != "png" && typeString != "jpeg")
2157  {
2158  typeString = "jpeg";
2159  }
2160 
2161  result = typeString.string();
2162 
2163  return result;
2164 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
const std::string & string() const
Definition: ossimString.h:414

◆ getTileSize()

bool ossimImageUtil::getTileSize ( ossimIpt tileSize) const

Gets the tile size.

Parameters
tileSizeInitialized by this.
Returns
true on success, false if not in options list.

Definition at line 1923 of file ossimImageUtil.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

1924 {
1925  bool result = false;
1926  std::string lookup = m_kwl->findKey( TILE_SIZE_KW );
1927  if ( lookup.size() )
1928  {
1929  ossim_int32 i = ossimString(lookup).toInt32();
1930  if ( (i % 16) == 0 )
1931  {
1932  tileSize.x = i;
1933  tileSize.y = i;
1934  result = true;
1935  }
1936  }
1937  return result;
1938 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossim_int32 toInt32() const
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ gsubDate()

void ossimImageUtil::gsubDate ( const std::string &  commandPrefix,
ossimString command 
) const
private

Expands date variables in a command string.

Definition at line 2389 of file ossimImageUtil.cpp.

References ossimString::find(), ossimKeywordlist::findKey(), ossim::getFormattedTime(), ossimString::gsub(), and m_kwl.

Referenced by substituteCommandString().

2391 {
2392  // Date:
2393  const std::string DATE_VARIABLE = "%{date}";
2394  if ( command.find( DATE_VARIABLE ) )
2395  {
2396  std::string key = ".strf_time_format";
2397  std::string strfTimeFormat = m_kwl->findKey( commandKey, key );
2398  if ( strfTimeFormat.empty() )
2399  {
2400  // yyyymmdd
2401  strfTimeFormat = "%Y%m%d";
2402  }
2403 
2404  //---
2405  // Get the date as a string, e.g 20150411.
2406  // true for gmt time.
2407  //---
2408  std::string date;
2409  ossim::getFormattedTime( strfTimeFormat, true, date );
2410 
2411  if ( date.size() )
2412  {
2413  // Sustitute:
2414  command.gsub( DATE_VARIABLE, date, true );
2415  }
2416  }
2417 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
OSSIM_DLL void getFormattedTime(const std::string &format, bool gmtFlag, std::string &result)
Gets the current time.
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
ossimString & gsub(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false)
Substitutes searchKey string with replacementValue and returns a reference to *this.
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
Definition: ossimString.h:753

◆ hasCmmOption()

bool ossimImageUtil::hasCmmOption ( ) const
private
Returns
true if any compute min, max or null options are set.

Definition at line 1986 of file ossimImageUtil.cpp.

References keyIsTrue().

1987 {
1988  return ( keyIsTrue( CMM_MAX_KW ) || keyIsTrue( CMM_MIN_KW )|| keyIsTrue( CMM_NULL_KW ) );
1989 }
bool keyIsTrue(const std::string &key) const

◆ hasHistogramOption()

bool ossimImageUtil::hasHistogramOption ( ) const
Returns
true if any of the histogram options are set.

Definition at line 1981 of file ossimImageUtil.cpp.

References createHistogram(), createHistogramFast(), and createHistogramR0().

1982 {
1983  return ( createHistogram() || createHistogramFast() || createHistogramR0() );
1984 }
bool createHistogramR0() const
bool createHistogramFast() const
bool createHistogram() const

◆ hasRequiredOverview()

bool ossimImageUtil::hasRequiredOverview ( ossimRefPtr< ossimImageHandler > &  ih,
ossimRefPtr< ossimOverviewBuilderBase > &  ob 
)
private
Returns
true if entry has required overviews.

Definition at line 1105 of file ossimImageUtil.cpp.

References ossimObject::getClassName(), getCopyAllFlag(), ossimImageHandler::getNumberOfDecimationLevels(), ossimImageHandler::getNumberOfLines(), ossimImageHandler::getNumberOfSamples(), ossimOverviewBuilderBase::getOverviewStopDimension(), and ossimRefPtr< T >::valid().

1107 {
1108  bool result = false;
1109  if ( ih.valid() && ob.valid() && ( getCopyAllFlag() == false ) )
1110  {
1111  if ( ih->getClassName() == "ossimCcfTileSource" )
1112  {
1113  // CCF reader does not use external overviews.
1114  result = true;
1115  }
1116  else
1117  {
1118  // Note we always have one rset
1119  ossim_uint32 required = 1;
1120 
1121  ossim_uint32 startingResLevel = ih->getNumberOfDecimationLevels();
1122  ossim_uint32 overviewStopDimension = ob->getOverviewStopDimension();
1123 
1124  ossim_uint32 largestImageDimension =
1125  ih->getNumberOfSamples(0) >
1126  ih->getNumberOfLines(0) ?
1127  ih->getNumberOfSamples(0) :
1128  ih->getNumberOfLines(0);
1129 
1130  while(largestImageDimension > overviewStopDimension)
1131  {
1132  largestImageDimension /= 2;
1133  ++required;
1134  }
1135 
1136  if ( startingResLevel >= required )
1137  {
1138  result = true;
1139  }
1140  }
1141  }
1142  return result;
1143 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
virtual ossim_uint32 getOverviewStopDimension() const
Get the overview stop dimension.
unsigned int ossim_uint32
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
bool getCopyAllFlag() const

◆ initialize()

bool ossimImageUtil::initialize ( ossimArgumentParser ap)

Initial method.

Typically called from application prior to execute. This parses all options and put in keyword list m_kwl.

Parameters
apArg parser to initialize from.
Returns
true, indicating process should continue with execute.

Definition at line 201 of file ossimImageUtil.cpp.

202 {
203  static const char M[] = "ossimImageUtil::initialize(ossimArgumentParser&)";
204  if ( traceDebug() )
205  {
206  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
207  }
208 
209  bool result = true;
210 
211  if ( (ap.argc() == 1) || ap.read("-h") || ap.read("--help") )
212  {
213  usage(ap);
214 
215  // continue_after_init to false
216  result = false;
217  }
218  else
219  {
220  // Start with clean options keyword list.
221  m_kwl->clear();
222 
223  // Used throughout below:
224  std::string ts1;
226  std::string ts2;
228 
229  while ( 1 ) // While forever loop...
230  {
231  if( ap.read("-a") || ap.read("--include-fullres") )
232  {
233  setCopyAllFlag( true );
234  if ( ap.argc() < 2 )
235  {
236  break;
237  }
238  }
239 
240  if( ap.read("--compression-quality", sp1) )
241  {
242  if ( ts1.size() )
243  {
244  setCompressionQuality( ts1 );
245  }
246  if ( ap.argc() < 2 )
247  {
248  break;
249  }
250  }
251 
252  if( ap.read("--compression-type", sp1) )
253  {
254  if ( ts1.size() )
255  {
256  setCompressionType( ts1 );
257  }
258  if ( ap.argc() < 2 )
259  {
260  break;
261  }
262  }
263 
264  if( ap.read("--ch") || ap.read("--create-histogram") )
265  {
266  setCreateHistogramFlag( true );
267  if ( ap.argc() < 2 )
268  {
269  break;
270  }
271  }
272 
273  if( ap.read("--chf") || ap.read("--create-histogram-fast") )
274  {
276  if ( ap.argc() < 2 )
277  {
278  break;
279  }
280  }
281 
282  if( ap.read("--compute-min-max") )
283  {
284  setScanForMinMax( true );
285  if ( ap.argc() < 2 )
286  {
287  break;
288  }
289  }
290 
291  if( ap.read("--compute-min-max-null") )
292  {
293  setScanForMinMaxNull( true );
294  if ( ap.argc() < 2 )
295  {
296  break;
297  }
298  }
299 
300  if( ap.read("--create-histogram-r0") )
301  {
302  setCreateHistogramR0Flag( true );
303  if ( ap.argc() < 2 )
304  {
305  break;
306  }
307  }
308 
309  if( ap.read("-d", sp1) )
310  {
311  setOutputDirectory( ts1 );
312  if ( ap.argc() < 2 )
313  {
314  break;
315  }
316  }
317 
318  if( ap.read("--dump-filtered-image-list") )
319  {
321  if ( ap.argc() < 2 )
322  {
323  break;
324  }
325  }
326 
327  if( ap.read("-i") || ap.read("--internal-overviews") )
328  {
329  setInternalOverviewsFlag( true );
330  if ( ap.argc() < 2 )
331  {
332  break;
333  }
334  }
335 
336  if( ap.read("--max", sp1) )
337  {
338  addOption( CMM_MAX_KW, ts1 );
339  if ( ap.argc() < 2 )
340  {
341  break;
342  }
343  }
344 
345  if( ap.read("--min", sp1) )
346  {
347  addOption( CMM_MIN_KW, ts1 );
348  if ( ap.argc() < 2 )
349  {
350  break;
351  }
352  }
353 
354  if( ap.read("--null", sp1) )
355  {
356  addOption( CMM_NULL_KW, ts1 );
357  if ( ap.argc() < 2 )
358  {
359  break;
360  }
361  }
362 
363  if( ap.read("--options", sp1) )
364  {
365  ossimFilename optionsKwl = ts1;
366  if ( optionsKwl.exists() )
367  {
368  if ( m_kwl->addFile(optionsKwl) == false )
369  {
370  std::string errMsg = "ERROR could not open options keyword list file: ";
371  errMsg += optionsKwl.string();
372  throw ossimException(errMsg);
373  }
374  }
375  else
376  {
377  std::string errMsg = "ERROR options keyword list file does not exists: ";
378  errMsg += optionsKwl.string();
379  throw ossimException(errMsg);
380  }
381  }
382 
383  if( ap.read("--of") || ap.read("--output-files") )
384  {
385  setOutputFileNamesFlag( true );
386  if ( ap.argc() < 2 )
387  {
388  break;
389  }
390  }
391 
392  if (ap.read("-o"))
393  {
395  if (ap.argc() < 2)
396  {
397  break;
398  }
399  }
400  if (ap.read("--ct"))
401  {
403  if (ap.argc() < 2)
404  {
405  break;
406  }
407  }
408  if (ap.read("--tt", sp1) || ap.read("--thumbnail-type", sp1))
409  {
410  setThumbnailType(ts1);
411  if (ap.argc() < 2)
412  {
413  break;
414  }
415  }
416  if (ap.read("--tst", sp1) || ap.read("--thumbnail-stretch-type", sp1))
417  {
419  if (ap.argc() < 2)
420  {
421  break;
422  }
423  }
424 
425  if (ap.read("--ot", sp1))
426  {
427  setOverviewType( ts1 );
428  if ( ap.argc() < 2 )
429  {
430  break;
431  }
432  }
433 
434  if( ap.read("--override-filtered-images") )
435  {
437  if ( ap.argc() < 2 )
438  {
439  break;
440  }
441  }
442 
443  if( ap.read("-r") || ap.read("--rebuild-overviews") )
444  {
445  setRebuildOverviewsFlag( true );
446  if ( ap.argc() < 2 )
447  {
448  break;
449  }
450  }
451 
452  if( ap.read("--rebuild-histogram") )
453  {
454  setRebuildHistogramFlag( true );
455  if ( ap.argc() < 2 )
456  {
457  break;
458  }
459  }
460 
461  while(ap.read("--reader-prop", sp1))
462  {
463  if (ts1.size())
464  {
465  std::string key = READER_PROP_KW;
467  addOption( key, ts1 );
468  }
469  }
470  if ( ap.argc() < 2 )
471  {
472  break;
473  }
474 
475  if( ap.read("-s", sp1) )
476  {
478  if ( ap.argc() < 2 )
479  {
480  break;
481  }
482  }
483 
484  if ( ap.read("--tile-size", sp1))
485  {
486  setTileSize( ossimString(ts1).toInt32() );
487  if ( ap.argc() < 2 )
488  {
489  break;
490  }
491  }
492 
493  if( ap.read("--threads", sp1) )
494  {
495  m_kwl->addPair( THREADS_KW, ts1 );
496  if ( ap.argc() < 2 )
497  {
498  break;
499  }
500  }
501 
502  while(ap.read("--writer-prop", sp1))
503  {
504  if (ts1.size())
505  {
506  std::string key = WRITER_PROP_KW;
508  addOption( key, ts1 );
509  }
510  }
511  if ( ap.argc() < 2 )
512  {
513  break;
514  }
515 
516  // End of arg parsing.
518  if ( ap.errors() )
519  {
521  std::string errMsg = "Unknown option...";
522  throw ossimException(errMsg);
523  }
524 
525  break; // Break from while forever.
526 
527  } // End while (forever) loop.
528 
529  if(ap.argc() > 1)
530  {
531  for (ossim_int32 i = 0; i < (ap.argc()-1); ++i)
532  {
533  ossimString kw = FILE_KW;
534  kw += ossimString::toString(i);
535  std::string value = ap[i+1];
536  m_kwl->addPair(kw.string(), value, true);
537  }
538  }
539  else
540  {
541  if ( getDumpFilterImagesFlag() )
542  {
543  // Caller wants to see filtered image names:
544  if ( m_filteredImages.empty() )
545  {
547  }
548 
549  // Dump our filtered images.
551 
552  if ( !m_fileWalker )
553  {
556  }
557 
558  // Dump the file walker's filtered extensions.
560  }
561  else
562  {
563  usage(ap);
564  }
565 
566  // continue_after_init to false
567  result = false;
568 
569  }
570 
571  } // not usage
572 
573  if ( traceDebug() )
574  {
576  << "m_kwl:\n" << *(m_kwl.get()) << "\n"
577  << M << " exit result = " << (result?"true":"false")
578  << "\n";
579  }
580 
581  return result;
582 }
void dumpFilteredExtensionList() const
Dumps filtered image extenstions to std out.
void setCreateHistogramFastFlag(bool flag)
Sets create histogram flag keyword CREATE_HISTOGRAM_FAST_KW used by processFile method.
bool addFile(const char *file)
std::vector< std::string > m_filteredImages
Hold images we never want to process.
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...
void setCreateHistogramFlag(bool flag)
Sets create histogram flag keyword CREATE_HISTOGRAM_KW used by processFile method.
static ossimString toString(bool aValue)
Numeric to string methods.
void setCopyAllFlag(bool flag)
Sets the overview builder copy all flag.
void setOutputDirectory(const std::string &directory)
Sets the output directory.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
ossimFileWalker * m_fileWalker
void setThumbnailType(const std::string &value)
void setCreateHistogramR0Flag(bool flag)
Sets create histogram "R0" flag keyword CREATE_HISTOGRAM_R0_KW used by processFile method...
void usage(ossimArgumentParser &ap)
Initializes arg parser and outputs usage.
Utility class to walk through directories and get a list of files to process.
void setOverrideFilteredImagesFlag(bool flag)
Sets the override filtered images flag.
void reportRemainingOptionsAsUnrecognized(ossimErrorSeverity severity=OSSIM_BENIGN)
for each remaining option report it as an unrecongnized.
void setCompressionType(const std::string &type)
Sets the compression type to use when building overviews.
bool errors(ossimErrorSeverity severity=OSSIM_BENIGN) const
bool exists() const
void dumpFilteredImageList() const
Dumps filtered image list to std out.
void setTileSize(ossim_uint32 tileSize)
Sets the tile size.
bool getDumpFilterImagesFlag() const
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.
ossim_uint32 getNextWriterPropIndex() const
void setScanForMinMaxNull(bool flag)
Sets scan for min/max/null flag keyword SCAN_MIN_MAX_KW used by processFile method.
void initializeDefaultFilterList()
Initializes the filter list with a default set of filtered out file names.
void setOutputFileNamesFlag(bool flag)
Sets the output file name flag OUTPUT_FILENAMES_KW.
void setScanForMinMax(bool flag)
Sets scan for min/max flag keyword SCAN_MIN_MAX_KW used by processFile method.
ossim_uint32 getNextReaderPropIndex() const
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
void setDumpFilteredImageListFlag(bool flag)
Sets the dump filteredImageList flag.
void setCreateOverviewsFlag(bool flag)
Sets create overviews flag keyword CREATE_OVERVIEWS_KW used by processFile method.
void initializeDefaultFilterList()
Initializes the filter list with a default set of filtered out file names.
void setCompressionQuality(const std::string &quality)
Sets the writer property for compression quality.
void setRebuildOverviewsFlag(bool flag)
Sets the rebuild overview flag keyword REBUILD_OVERVIEWS_KW used by processFile method.
void setCreateThumbnailsFlag(bool flag)
Sets create thumbnails flag keyword CREATE_THUMBNAILS_KW used by processFile method.
void setOverviewType(const std::string &type)
Sets key OVERVIEW_TYPE_KW.
void setThumbnailStretchType(const std::string &value)
void setOverviewStopDimension(ossim_uint32 dimension)
sets the overview stop dimension.
void setRebuildHistogramFlag(bool flag)
Sets the rebuild histogram flag keyword REBUILD_HISTOGRAM_KW used by processFile method.
int & argc()
return the argument count.
void setInternalOverviewsFlag(bool flag)
Sets the overview builder internal overviews flag.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32
void writeErrorMessages(std::ostream &output, ossimErrorSeverity sevrity=OSSIM_BENIGN)
write out error messages at an above specified .
const std::string & string() const
Definition: ossimString.h:414

◆ initializeDefaultFilterList()

void ossimImageUtil::initializeDefaultFilterList ( )
private

Initializes the filter list with a default set of filtered out file names.

Definition at line 2264 of file ossimImageUtil.cpp.

References m_filteredImages, and m_mutex.

2265 {
2266  m_mutex.lock();
2267 
2268  // Common images to filter out, put most common first.
2269  m_filteredImages.push_back(std::string("icon.jpg"));
2270  m_filteredImages.push_back(std::string("logo.jpg"));
2271  m_filteredImages.push_back(std::string("preview.jpg"));
2272 
2273  m_mutex.unlock();
2274 }
std::vector< std::string > m_filteredImages
Hold images we never want to process.
std::mutex m_mutex

◆ isDirectoryBasedImage()

bool ossimImageUtil::isDirectoryBasedImage ( const ossimImageHandler ih) const
private
Returns
true if file is a directory based image and the stager should go on to next directory; false if stager should continue with directory.

Definition at line 1639 of file ossimImageUtil.cpp.

References ossimObject::getClassName().

1640 {
1641  bool result = false;
1642  if ( ih )
1643  {
1644  // Get the image handler name.
1645  ossimString imageHandlerName = ih->getClassName();
1646  if ( (imageHandlerName == "ossimAdrgTileSource") ||
1647  (imageHandlerName == "ossimCibCadrgTileSource") )
1648  {
1649  result = true;
1650  }
1651  }
1652  return result;
1653 }
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64

◆ isFiltered()

bool ossimImageUtil::isFiltered ( const ossimFilename f) const
private

Convenience method to check file to see is if file should be processed.

Parameters
fFile to check.
Returns
true if f is in filter list, false if not.

Definition at line 2207 of file ossimImageUtil.cpp.

References ossimFilename::file(), m_filteredImages, ossimString::size(), and ossimString::string().

2208 {
2209  bool result = false;
2210  if ( file.size() )
2211  {
2212  // Strip full path to base name.
2213  std::string baseName = file.file().string();
2214  if ( baseName.size() )
2215  {
2216  std::vector<std::string>::const_iterator i = m_filteredImages.begin();
2217  while ( i != m_filteredImages.end() )
2218  {
2219  if ( baseName == (*i) )
2220  {
2221  result = true;
2222  break;
2223  }
2224  ++i;
2225  }
2226  }
2227  }
2228 #if 0 /* Please leave for debug. (drb) */
2229  if(traceDebug())
2230  {
2232  << "ossimFileWalker::isFiltered file " << (result?"filtered: ":"not filtered: ")
2233  << file << "\n";
2234  }
2235 #endif
2236 
2237  return result;
2238 }
std::vector< std::string > m_filteredImages
Hold images we never want to process.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ keyIsTrue()

bool ossimImageUtil::keyIsTrue ( const std::string &  key) const
private
Returns
true if key is set to true; false, if not.

Definition at line 2240 of file ossimImageUtil.cpp.

References ossimKeywordlist::findKey(), m_kwl, ossimString::toBool(), and ossimRefPtr< T >::valid().

Referenced by createHistogram(), createHistogramFast(), createHistogramR0(), createOverviews(), createThumbnails(), getCopyAllFlag(), getDumpFilterImagesFlag(), getInternalOverviewsFlag(), getOutputFileNamesFlag(), getOverrideFilteredImagesFlag(), hasCmmOption(), rebuildHistogram(), rebuildOverviews(), scanForMinMax(), and scanForMinMaxNull().

2241 {
2242  bool result = false;
2243  if ( m_kwl.valid() )
2244  {
2245  std::string value = m_kwl->findKey( key );
2246  if ( value.size() )
2247  {
2248  result = ossimString(value).toBool();
2249  }
2250  }
2251  return result;
2252 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
bool valid() const
Definition: ossimRefPtr.h:75
bool toBool() const
String to numeric methods.
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.

◆ outputOverviewWriterTypes()

void ossimImageUtil::outputOverviewWriterTypes ( ) const
private

Definition at line 1625 of file ossimImageUtil.cpp.

References ossimOverviewBuilderFactoryRegistry::getTypeNameList(), ossimOverviewBuilderFactoryRegistry::instance(), ossimNotify(), and ossimNotifyLevel_NOTICE.

Referenced by usage().

1626 {
1628  << "\nValid overview types: " << std::endl;
1629 
1630  std::vector<ossimString> outputType;
1631 
1633  std::copy(outputType.begin(),
1634  outputType.end(),
1635  std::ostream_iterator<ossimString>(ossimNotify(ossimNotifyLevel_NOTICE), "\t\n"));
1636 }
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
Method to populate a list of supported types of all factories registered to this registry.
static ossimOverviewBuilderFactoryRegistry * instance()
instance method for access to theInstance pointer.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ processFile()

void ossimImageUtil::processFile ( const ossimFilename file)
virtual

ProcessFile method.

Satisfies pure virtual ossimFileProcessorInterface::processFile.

This method is linked to the ossimFileWalker::walk method via a callback mechanism. It is called by the ossimFileWalk (caller). In turn this class (callee) calls ossimFileWalker::setRecurseFlag and ossimFileWalker::setAbortFlag to control the waking process.

Parameters
fileto process.

Implements ossimFileProcessorInterface.

Definition at line 683 of file ossimImageUtil.cpp.

684 {
685  static const char M[] = "ossimImageUtil::processFile";
686  if(traceDebug())
687  {
689  << M << " entered...\n" << "file: " << file << "\n";
690  }
691 
692  bool processFileFlag = true;
694  {
695  processFileFlag = !isFiltered( file );
696  }
697 
698  if ( processFileFlag )
699  {
700  ossimNotify(ossimNotifyLevel_NOTICE) << "Processing file: " << file << std::endl;
701 
702  m_mutex.lock();
704  ossimImageHandlerRegistry::instance()->open(file, true, true);
705  m_mutex.unlock();
706 
707  if ( ih.valid() && !ih->hasError() )
708  {
709  // Check for output directory:
710  if ( m_kwl->hasKey( OUTPUT_DIRECTORY_KW ) )
711  {
712  ossimFilename outputDir;
713  outputDir.string() = m_kwl->findKey( OUTPUT_DIRECTORY_KW );
714 
715  if ( outputDir.exists() && outputDir.isDir() )
716  {
717  ih->setSupplementaryDirectory( outputDir );
718  }
719  }
720 
721  if ( isDirectoryBasedImage( ih.get() ) )
722  {
723  // Tell the walker not to recurse this directory.
724  m_mutex.lock();
726  m_mutex.unlock();
727  }
728 
729  // Set any reader props:
730  ossimPropertyInterface* pi = dynamic_cast<ossimPropertyInterface*>(ih.get());
731  if ( pi ) setProps(pi);
732 
733  bool consumedHistogramOptions = false;
734  bool consumedCmmOptions = false;
735 
736  if ( getOutputFileNamesFlag() )
737  {
738  // Simply output the file name of any images we can open:
740  }
741 
742  // Compute/Scan for min, max. Note the overview sequencer may have computed for us.
743  if ( ( scanForMinMax() || scanForMinMaxNull() ) && !consumedCmmOptions )
744  {
745  computeMinMax( ih );
746  }
747 
748  if ( createOverviews() )
749  {
750  // Skip shape files...
751  if ( ih->getClassName() != "ossimOgrGdalTileSource" )
752  {
753  createOverview(ih, consumedHistogramOptions, consumedCmmOptions);
754  }
755  }
756  if (createThumbnails())
757  {
758  for (ossim_uint32 idx = 0; idx < ih->getNumberOfEntries(); ++idx)
759  {
760  ih->setCurrentEntry(idx);
761  if (ih->getNumberOfDecimationLevels() <= 1)
762  {
763  ih->setState(0);
764  ih->openOverview();
765  }
766  createThumbnail(ih);
767  }
768  }
769  // Build stand alone histogram. Note the overview sequencer may have computed for us.
770  if ( hasHistogramOption() && !consumedHistogramOptions)
771  {
772  createHistogram( ih );
773  }
774 
775  // Launch any file system commands.
776  executeFileCommands( file );
777  }
778  else
779  {
780  ossimNotify(ossimNotifyLevel_WARN) << M << "\nCould not open: " << file << std::endl;
781  }
782  }
783  else // Matches: if ( processFileFlag )
784  {
786  << "Filtered file, not processing: " << file << std::endl;
787  }
788 
789  if(traceDebug())
790  {
791  // Since ossimFileWalker is threaded output the file so we know which job exited.
792  ossimNotify(ossimNotifyLevel_DEBUG) << M << "\nfile: " << file << "\nexited...\n";
793  }
794 }
bool createOverviews() const
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
void setRecurseFlag(bool flag)
Sets recurse flag.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
void setState(std::shared_ptr< ossim::ImageHandlerState > state)
bool valid() const
Definition: ossimRefPtr.h:75
bool hasHistogramOption() const
ossimFilename expand() const
Method to do file name expansion.
bool getOutputFileNamesFlag() const
bool hasKey(const std::string &key) const
Checks for key in map.
bool scanForMinMax() const
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
ossimFileWalker * m_fileWalker
bool isDir() const
virtual bool openOverview()
Searches for an overview.
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
bool createHistogram() const
bool scanForMinMaxNull() const
bool isFiltered(const ossimFilename &f) const
Convenience method to check file to see is if file should be processed.
void executeFileCommands(const ossimFilename &file) const
run per file system commands.
bool exists() const
virtual const ossimFilename & getFilename() const
Returns the filename.
void createOverview(ossimRefPtr< ossimImageHandler > &ih, bool &consumedHistogramOptions, bool &consumedCmmOptions)
unsigned int ossim_uint32
void setProps(ossimPropertyInterface *pi) const
set reader or writer properties based on cast of pi.
void computeMinMax(ossimRefPtr< ossimImageHandler > &ih)
virtual ossim_uint32 getNumberOfEntries() const
std::mutex m_mutex
bool createThumbnails() const
bool getOverrideFilteredImagesFlag() const
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
virtual void setSupplementaryDirectory(const ossimFilename &dir)
Sets the supplementary directory.
void createThumbnail(ossimRefPtr< ossimImageHandler > &ih)
bool isDirectoryBasedImage(const ossimImageHandler *ih) const
static ossimImageHandlerRegistry * instance()
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414

◆ rebuildHistogram()

bool ossimImageUtil::rebuildHistogram ( ) const
Returns
true if REBUILD_HISTOGRAM_KW is found and set to true.

Definition at line 1697 of file ossimImageUtil.cpp.

References keyIsTrue().

1698 {
1699  return keyIsTrue( REBUILD_HISTOGRAM_KW );
1700 }
bool keyIsTrue(const std::string &key) const

◆ rebuildOverviews()

bool ossimImageUtil::rebuildOverviews ( ) const
Returns
true if REBUILD_OVERVIEWS_KW is found and set to true.

Definition at line 1683 of file ossimImageUtil.cpp.

References keyIsTrue().

1684 {
1685  return keyIsTrue( REBUILD_OVERVIEWS_KW );
1686 }
bool keyIsTrue(const std::string &key) const

◆ scanForMinMax()

bool ossimImageUtil::scanForMinMax ( ) const
Returns
true if SCAN_MIN_MAX_KW is found and set to true.

Definition at line 1707 of file ossimImageUtil.cpp.

References keyIsTrue().

1708 {
1709  return keyIsTrue( SCAN_MIN_MAX_KW );
1710 }
bool keyIsTrue(const std::string &key) const

◆ scanForMinMaxNull()

bool ossimImageUtil::scanForMinMaxNull ( ) const
Returns
true if SCAN_MIN_MAX_NULL_KW is found and set to true.

Definition at line 1717 of file ossimImageUtil.cpp.

References keyIsTrue().

1718 {
1719  return keyIsTrue( SCAN_MIN_MAX_NULL_KW );
1720 }
bool keyIsTrue(const std::string &key) const

◆ setCompressionQuality()

void ossimImageUtil::setCompressionQuality ( const std::string &  quality)

Sets the writer property for compression quality.

Parameters
qualityFor TIFF JPEG takes values from 1 to 100, where 100 is best. For J2K plugin (if available), numerically_lossless, visually_lossless, lossy.

Definition at line 1722 of file ossimImageUtil.cpp.

1723 {
1724  if ( quality.size() )
1725  {
1726  std::string key = WRITER_PROP_KW;
1728  std::string value = ossimKeywordNames::COMPRESSION_QUALITY_KW;
1729  value += "=";
1730  value += quality;
1731  addOption( key, value );
1732  }
1733 }
static ossimString toString(bool aValue)
Numeric to string methods.
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.
ossim_uint32 getNextWriterPropIndex() const
static const char * COMPRESSION_QUALITY_KW
const std::string & string() const
Definition: ossimString.h:414

◆ setCompressionType()

void ossimImageUtil::setCompressionType ( const std::string &  type)

Sets the compression type to use when building overviews.

Parameters
compression_typeCurrent supported types:
  • deflate
  • jpeg
  • lzw
  • none
  • packbits

Definition at line 1735 of file ossimImageUtil.cpp.

1736 {
1737  if ( type.size() )
1738  {
1739  std::string key = WRITER_PROP_KW;
1741  std::string value = ossimKeywordNames::COMPRESSION_TYPE_KW;
1742  value += "=";
1743  value += type;
1744  addOption( key, value );
1745  }
1746 }
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * COMPRESSION_TYPE_KW
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.
ossim_uint32 getNextWriterPropIndex() const
const std::string & string() const
Definition: ossimString.h:414

◆ setCopyAllFlag()

void ossimImageUtil::setCopyAllFlag ( bool  flag)

Sets the overview builder copy all flag.

Parameters
flag

Definition at line 1748 of file ossimImageUtil.cpp.

1749 {
1750  // Add this for hasRequiredOverview method.
1751  std::string key = COPY_ALL_FLAG_KW;
1752  std::string value = ( flag ? TRUE_KW : FALSE_KW );
1753  addOption( key, value );
1754 
1755  // Add as a writer prop:
1756  key = WRITER_PROP_KW;
1758  value = COPY_ALL_FLAG_KW;
1759  value += "=";
1760  value += ( flag ? TRUE_KW : FALSE_KW );
1761  addOption( key, value );
1762 }
static ossimString toString(bool aValue)
Numeric to string methods.
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.
ossim_uint32 getNextWriterPropIndex() const
const std::string & string() const
Definition: ossimString.h:414

◆ setCreateHistogramFastFlag()

void ossimImageUtil::setCreateHistogramFastFlag ( bool  flag)

Sets create histogram flag keyword CREATE_HISTOGRAM_FAST_KW used by processFile method.

Parameters
flagIf true a histogram will be created in fast mode.

Definition at line 1961 of file ossimImageUtil.cpp.

References addOption().

1962 {
1963  addOption( CREATE_HISTOGRAM_FAST_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1964 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setCreateHistogramFlag()

void ossimImageUtil::setCreateHistogramFlag ( bool  flag)

Sets create histogram flag keyword CREATE_HISTOGRAM_KW used by processFile method.

Parameters
flagIf true a full histogram will be created.

Definition at line 1951 of file ossimImageUtil.cpp.

References addOption().

1952 {
1953  addOption( CREATE_HISTOGRAM_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1954 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setCreateHistogramR0Flag()

void ossimImageUtil::setCreateHistogramR0Flag ( bool  flag)

Sets create histogram "R0" flag keyword CREATE_HISTOGRAM_R0_KW used by processFile method.

Parameters
flagIf true a histogram will be created from R0.

Definition at line 1971 of file ossimImageUtil.cpp.

References addOption().

1972 {
1973  addOption( CREATE_HISTOGRAM_R0_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1974 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setCreateOverviewsFlag()

void ossimImageUtil::setCreateOverviewsFlag ( bool  flag)

Sets create overviews flag keyword CREATE_OVERVIEWS_KW used by processFile method.

Parameters
flagIf true overview will be created if image does not already have the required or if the REBUILD_OVERVIEWS_KW is set.
Note
Number of required overviews is controlled by the ossim preferences keyword overview_stop_dimension.

Definition at line 1655 of file ossimImageUtil.cpp.

References addOption().

1656 {
1657  addOption( CREATE_OVERVIEWS_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1658 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setCreateThumbnailsFlag()

void ossimImageUtil::setCreateThumbnailsFlag ( bool  flag)

Sets create thumbnails flag keyword CREATE_THUMBNAILS_KW used by processFile method.

Parameters
flagIf true thumbnail will be created if image does not already.
Note
Overviews must be created before this works

Definition at line 1664 of file ossimImageUtil.cpp.

References addOption().

1665 {
1666  addOption(CREATE_THUMBNAILS_KW, (flag ? TRUE_KW : FALSE_KW));
1667 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setDumpFilteredImageListFlag()

void ossimImageUtil::setDumpFilteredImageListFlag ( bool  flag)

Sets the dump filteredImageList flag.

Parameters
flag

Definition at line 1769 of file ossimImageUtil.cpp.

1770 {
1771  std::string key = DUMP_FILTERED_IMAGES_KW;
1772  std::string value = ( flag ? TRUE_KW : FALSE_KW );
1773  addOption( key, value );
1774 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setErrorStatus()

void ossimImageUtil::setErrorStatus ( ossim_int32  status)
private

Sets the m_errorStatus for return on execute.

Definition at line 2200 of file ossimImageUtil.cpp.

References m_errorStatus, m_mutex, and status.

2201 {
2202  m_mutex.lock();
2204  m_mutex.unlock();
2205 }
ossim_int32 m_errorStatus
std::mutex m_mutex
return status

◆ setInternalOverviewsFlag()

void ossimImageUtil::setInternalOverviewsFlag ( bool  flag)

Sets the overview builder internal overviews flag.

Parameters
flag

Definition at line 1781 of file ossimImageUtil.cpp.

1782 {
1783  // Add this for hasRequiredOverview method.
1784  std::string key = INTERNAL_OVERVIEWS_FLAG_KW;
1785  std::string value = ( flag ? TRUE_KW : FALSE_KW );
1786  addOption( key, value );
1787 
1788  // Add as a writer prop:
1789  key = WRITER_PROP_KW;
1791  value = INTERNAL_OVERVIEWS_FLAG_KW;
1792  value += "=";
1793  value += ( flag ? TRUE_KW : FALSE_KW );
1794  addOption( key, value );
1795 }
static ossimString toString(bool aValue)
Numeric to string methods.
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.
ossim_uint32 getNextWriterPropIndex() const
const std::string & string() const
Definition: ossimString.h:414

◆ setNumberOfThreads() [1/2]

void ossimImageUtil::setNumberOfThreads ( ossim_uint32  threads)

Set number of threads to use.

This is only used in execute method if a directory is given to application to walk.

Parameters
threadsDefaults to 1 if THREADS_KW is not found.

Definition at line 2005 of file ossimImageUtil.cpp.

References addOption().

2006 {
2007  addOption( THREADS_KW, threads );
2008 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setNumberOfThreads() [2/2]

void ossimImageUtil::setNumberOfThreads ( const std::string &  threads)

Definition at line 2010 of file ossimImageUtil.cpp.

References addOption().

2011 {
2012  addOption( THREADS_KW, threads );
2013 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setOutputDirectory()

void ossimImageUtil::setOutputDirectory ( const std::string &  directory)

Sets the output directory.

Typically overviews and histograms are placed parallel to image file. This overrides.

Parameters
directory

Definition at line 1826 of file ossimImageUtil.cpp.

1827 {
1828  std::string key = OUTPUT_DIRECTORY_KW;
1829  addOption( key, directory );
1830 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setOutputFileNamesFlag()

void ossimImageUtil::setOutputFileNamesFlag ( bool  flag)

Sets the output file name flag OUTPUT_FILENAMES_KW.

If set to true all files that we can successfully open will be output.

Parameters
flag

Definition at line 1802 of file ossimImageUtil.cpp.

1803 {
1804  std::string key = OUTPUT_FILENAMES_KW;
1805  std::string value = ( flag ? TRUE_KW : FALSE_KW );
1806  addOption( key, value );
1807 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setOverrideFilteredImagesFlag()

void ossimImageUtil::setOverrideFilteredImagesFlag ( bool  flag)

Sets the override filtered images flag.

Parameters
flag

Definition at line 1814 of file ossimImageUtil.cpp.

1815 {
1816  std::string key = OVERRIDE_FILTERED_IMAGES_KW;
1817  std::string value = ( flag ? TRUE_KW : FALSE_KW );
1818  addOption( key, value );
1819 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setOverviewStopDimension() [1/2]

void ossimImageUtil::setOverviewStopDimension ( ossim_uint32  dimension)

sets the overview stop dimension.

The overview builder will decimate the image until both dimensions are at or below this dimension.

Parameters
dimension
Note
Recommend a power of 2 value, i.e. 8, 16, 32 and so on.

Definition at line 1898 of file ossimImageUtil.cpp.

References addOption().

1899 {
1900  addOption( OVERVIEW_STOP_DIM_KW, dimension );
1901 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setOverviewStopDimension() [2/2]

void ossimImageUtil::setOverviewStopDimension ( const std::string &  dimension)

Definition at line 1903 of file ossimImageUtil.cpp.

References addOption().

1904 {
1905  addOption( OVERVIEW_STOP_DIM_KW, dimension );
1906 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setOverviewType()

void ossimImageUtil::setOverviewType ( const std::string &  type)

Sets key OVERVIEW_TYPE_KW.

Available types depends on plugins. Known types: ossim_tiff_box ( defualt ) ossim_tiff_nearest ossim_kakadu_nitf_j2k ( kakadu plugin ) gdal_tiff_nearest ( gdal plugin ) gdal_tiff_average ( gdal plugin ) gdal_hfa_nearest ( gdal plugin )
gdal_hfa_average ( gdal plugin )

Parameters
typeOne of the above.

Definition at line 1832 of file ossimImageUtil.cpp.

1833 {
1834  std::string key = OVERVIEW_TYPE_KW;
1835  addOption( key, type );
1836  setCreateOverviewsFlag( true ); // Assume caller wants overviews.
1837 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.
void setCreateOverviewsFlag(bool flag)
Sets create overviews flag keyword CREATE_OVERVIEWS_KW used by processFile method.

◆ setProps()

void ossimImageUtil::setProps ( ossimPropertyInterface pi) const
private

set reader or writer properties based on cast of pi.

Definition at line 1852 of file ossimImageUtil.cpp.

1853 {
1854  if ( pi )
1855  {
1856  ossimString baseKey;
1857  if ( dynamic_cast<ossimImageHandler*>(pi) )
1858  {
1859  baseKey = READER_PROP_KW;
1860  }
1861  else
1862  {
1863  baseKey = WRITER_PROP_KW;
1864  }
1865 
1866  ossim_uint32 propCount = m_kwl->numberOf( baseKey.c_str() );
1867  if ( propCount )
1868  {
1869  ossim_uint32 foundProps = 0;
1870  ossim_uint32 index = 0;
1871 
1872  // (propCount+100) is to allow for holes like reader_prop0, reader_prop2...
1873  while ( (foundProps < propCount) && (index < (propCount+100) ) )
1874  {
1875  ossimString key = baseKey;
1876  key += ossimString::toString(index);
1877  std::string lookup = m_kwl->findKey( key.string() );
1878  if ( lookup.size() )
1879  {
1880  ossimString value = lookup;
1881  std::vector<ossimString> v = value.split("=");
1882  if (v.size() == 2)
1883  {
1884  ossimString propertyName = v[0];
1885  ossimString propertyValue = v[1];
1887  new ossimStringProperty(propertyName, propertyValue);
1888  pi->setProperty( p );
1889  }
1890  ++foundProps;
1891  }
1892  ++index;
1893  }
1894  }
1895  }
1896 }
ossim_uint32 numberOf(const char *str) const
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static ossimString toString(bool aValue)
Numeric to string methods.
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
unsigned int ossim_uint32
ossimRefPtr< ossimKeywordlist > m_kwl
Holds all options passed into intialize except writer props.
virtual void setProperty(const ossimString &name, const ossimString &value)
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
const std::string & string() const
Definition: ossimString.h:414

◆ setRebuildHistogramFlag()

void ossimImageUtil::setRebuildHistogramFlag ( bool  flag)

Sets the rebuild histogram flag keyword REBUILD_HISTOGRAM_KW used by processFile method.

Parameters
flagIf true forces a rebuild of histogram even if image has one already.

Definition at line 1688 of file ossimImageUtil.cpp.

References addOption().

1689 {
1690  addOption( REBUILD_HISTOGRAM_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1691  if ( flag )
1692  {
1693  setCreateHistogramFlag( true ); // Turn on histogram building.
1694  }
1695 }
void setCreateHistogramFlag(bool flag)
Sets create histogram flag keyword CREATE_HISTOGRAM_KW used by processFile method.
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setRebuildOverviewsFlag()

void ossimImageUtil::setRebuildOverviewsFlag ( bool  flag)

Sets the rebuild overview flag keyword REBUILD_OVERVIEWS_KW used by processFile method.

Parameters
flagIf true forces a rebuild of overviews even if image has required number of reduced resolution data sets.
Note
Number of required overviews is controlled by the ossim preferences keyword overview_stop_dimension.

Definition at line 1674 of file ossimImageUtil.cpp.

References addOption().

1675 {
1676  addOption( REBUILD_OVERVIEWS_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1677  if ( flag )
1678  {
1679  setCreateOverviewsFlag( true ); // Turn on overview building.
1680  }
1681 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.
void setCreateOverviewsFlag(bool flag)
Sets create overviews flag keyword CREATE_OVERVIEWS_KW used by processFile method.

◆ setScanForMinMax()

void ossimImageUtil::setScanForMinMax ( bool  flag)

Sets scan for min/max flag keyword SCAN_MIN_MAX_KW used by processFile method.

Parameters
flagIf true a file will be scanned for min/max and a file.omd will be written out.

Definition at line 1702 of file ossimImageUtil.cpp.

References addOption().

1703 {
1704  addOption( SCAN_MIN_MAX_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1705 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setScanForMinMaxNull()

void ossimImageUtil::setScanForMinMaxNull ( bool  flag)

Sets scan for min/max/null flag keyword SCAN_MIN_MAX_KW used by processFile method.

Parameters
flagIf true a file will be scanned for min/max/null and a file.omd will be written out.

Definition at line 1712 of file ossimImageUtil.cpp.

References addOption().

1713 {
1714  addOption( SCAN_MIN_MAX_NULL_KW, ( flag ? TRUE_KW : FALSE_KW ) );
1715 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setThumbnailStretchType()

void ossimImageUtil::setThumbnailStretchType ( const std::string &  value)
Parameters
valuecan be of values none,auto-minmax,auto-percentile,std-stretch-1,std-stretch-2,std-stretch-3

Definition at line 2099 of file ossimImageUtil.cpp.

References addOption().

2100 {
2101  addOption(THUMBNAIL_STRETCH_TYPE_KW, value);
2102 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setThumbnailType()

void ossimImageUtil::setThumbnailType ( const std::string &  value)
Parameters
valuecan be of values png or jpeg

Definition at line 2144 of file ossimImageUtil.cpp.

References addOption().

2145 {
2146  addOption(THUMBNAIL_TYPE_KW, value);
2147 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.

◆ setTileSize()

void ossimImageUtil::setTileSize ( ossim_uint32  tileSize)

Sets the tile size.

Parameters
tileSize
Note
Must be a multiple of 16, i.e. 64, 128, 256 and so on.

Definition at line 1908 of file ossimImageUtil.cpp.

References addOption().

1909 {
1910  if ((tileSize % 16) == 0)
1911  {
1912  addOption( TILE_SIZE_KW, tileSize );
1913  }
1914  else
1915  {
1917  << "ossimImageUtil::setTileSize NOTICE:"
1918  << "\nTile width must be a multiple of 16!"
1919  << std::endl;
1920  }
1921 }
void addOption(const std::string &key, ossim_uint32 value)
Adds option to m_kwl with mutex lock.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ substituteCommandString()

void ossimImageUtil::substituteCommandString ( const ossimFilename file,
const std::string &  prefix,
const std::string &  commandKey,
ossimString command 
) const
private

Expands variables in a command string.

Definition at line 2353 of file ossimImageUtil.cpp.

References ossimString::expandEnvironmentVariable(), gsubDate(), and substituteFileStrings().

Referenced by executeCommands().

2358 {
2359  // Expand any environment vars, e.g. $(env_var_name):
2360  command.expandEnvironmentVariable();
2361 
2362  gsubDate( commandKey, command );
2363 
2364  if ( prefix == "file." )
2365  {
2366  substituteFileStrings( file, command );
2367  }
2368 }
void substituteFileStrings(const ossimFilename &file, ossimString &command) const
Expands file level variables in a command string.
ossimString expandEnvironmentVariable() const
If the variable "$(env_var_name)" is found in the string, where "env_var_name" is any system environm...
void gsubDate(const std::string &commandPrefix, ossimString &command) const
Expands date variables in a command string.

◆ substituteFileStrings()

void ossimImageUtil::substituteFileStrings ( const ossimFilename file,
ossimString command 
) const
private

Expands file level variables in a command string.

Definition at line 2370 of file ossimImageUtil.cpp.

References ossimFilename::file(), ossimString::gsub(), ossimFilename::noExtension(), ossimFilename::path(), ossimString::string(), and true.

Referenced by substituteCommandString().

2372 {
2373  const std::string BASENAME_VARIABLE = "%{basename}";
2374  command.gsub( BASENAME_VARIABLE, file.file().string() );
2375 
2376  const std::string BASENAME_NO_EXT_VARIABLE = "%{basename_no_ext}";
2377  command.gsub( BASENAME_NO_EXT_VARIABLE, file.file().string() );
2378 
2379  const std::string DIRNAME_VARIABLE = "%{dirname}";
2380  command.gsub( DIRNAME_VARIABLE, file.path().string() );
2381 
2382  const std::string FILE_VARIABLE = "%{file}";
2383  command.gsub( FILE_VARIABLE, file.string(), true );
2384 
2385  const std::string FILE_NO_EXT_VARIABLE = "%{file_no_ext}";
2386  command.gsub( FILE_NO_EXT_VARIABLE, file.noExtension().string(), true );
2387 }
ossimFilename noExtension() const
ossimFilename file() const
ossimString & gsub(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false)
Substitutes searchKey string with replacementValue and returns a reference to *this.
ossimFilename path() const
const std::string & string() const
Definition: ossimString.h:414

◆ usage()

void ossimImageUtil::usage ( ossimArgumentParser ap)
private

Initializes arg parser and outputs usage.

Definition at line 1558 of file ossimImageUtil.cpp.

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

1559 {
1560  // Add global usage options.
1562 
1563  // Set app name.
1565 
1566  // Add options.
1567  addArguments(ap);
1568 
1569  // Write usage.
1571 
1573 
1575  << "\nExample commands:\n"
1576 
1577  << "\n// A single image standard tiff overviews, histogram:\n"
1578  << "ossim-preproc -o --ch <file>\n"
1579 
1580  << "\n// A single image with j2k overviews(requires kakadu plugin), histogram:\n"
1581  << "ossim-preproc --ot ossim_kakadu_nitf_j2k --ch <file>\n"
1582  << "\n// j2k, histogram, 4 threads\n"
1583 
1584  << "\n// standard tiff overviews, full histogram, 4 threads:\n"
1585  << "ossim-preproc -r -o --ch --threads 4 <directory_to_walk>\n"
1586 
1587  << "\n// j2k, histogram (fast mode), 4 threads\n"
1588  << "ossim-preproc -r --ot ossim_kakadu_nitf_j2k --chf --threads 4 "
1589  << "<directory_to_walk>\n"
1590 
1591  << "\n// tiff, jpeg compression, histogram, 4 threads\n"
1592  << "ossim-preproc -r --ch --compression-quality 75 --compression-type "
1593  << "jpeg --threads 4 <directory_to_walk>\n"
1594  << "ossim-preproc -r --ch --compression-quality 75 --compression-type "
1595  << "jpeg --threads 4 <directory_to_walk>\n"
1596 
1597  << "\n// Process all the tiffs in a directory feeding \"prep\", \"file\", \"post\" system commands via the --options option which includes indexing file into the omar database via omar-data-mgr app:\n"
1598  << "ossim-preproc --options preproc-options.kwl -r -o --ch *.tif\n"
1599  << "\n// Contents of preproc-options.kwl used in above command:\n"
1600  << "prep.command0: echo start_time: %{date}\n"
1601  << "prep.command0.strf_time_format: %Y%m%d%H%M%S\n"
1602  << "prep.command1: mkdir -p %{date}\n"
1603  << "file.command0: mv %{file_no_ext}.* %{date}/.\n"
1604  << "file.command1: omar-data-mgr -u http://localhost:8080/omar add %{date}/%{basename}\n"
1605  << "post.command0: echo end_time: %{date}\n"
1606  << "post.command0.strf_time_format: %Y%m%d%H%M%S\n"
1607 
1608  << "\nNOTES:\n"
1609  << "\n --ch equals --create-histogram"
1610  << "\n --chf equals --create-histogram-fast"
1611 
1612  << "\n\nExpanded command option variables:\n\n"
1613  << "%{basename} = filename without path\n"
1614  << "%{basename_no_ext} = filename without path and without extension\n"
1615  << "%{date} = Expanded to current zulu time. Default format=yyyymmdd\n"
1616  << " output format controlled by command0.strf_time_format key.\n"
1617  << "%{dirname} = path of filename\n"
1618  << "%{file} = filename being processed\n"
1619  << "%{file_no_ext} = filename with no extension\n"
1620 
1621  << std::endl;
1622 }
void write(std::ostream &output, const UsageMap &um, unsigned int widthOfOutput=80)
std::string getApplicationName() const
return the application name, as specified by argv[0]
void addOptions(ossimArgumentParser &parser)
Definition: ossimInit.cpp:100
void addArguments(ossimArgumentParser &ap)
Adds application arguments to the argument parser.
ossimApplicationUsage * getApplicationUsage()
void setApplicationName(const ossimString &name)
void outputOverviewWriterTypes() const
static ossimInit * instance()
Definition: ossimInit.cpp:89
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Member Data Documentation

◆ m_errorStatus

ossim_int32 ossimImageUtil::m_errorStatus
private

Definition at line 536 of file ossimImageUtil.h.

Referenced by setErrorStatus().

◆ m_fileWalker

ossimFileWalker* ossimImageUtil::m_fileWalker
private

Definition at line 533 of file ossimImageUtil.h.

Referenced by ~ossimImageUtil().

◆ m_filteredImages

std::vector<std::string> ossimImageUtil::m_filteredImages
private

Hold images we never want to process.

Definition at line 539 of file ossimImageUtil.h.

Referenced by dumpFilteredImageList(), getFilteredImages(), initializeDefaultFilterList(), and isFiltered().

◆ m_kwl

ossimRefPtr<ossimKeywordlist> ossimImageUtil::m_kwl
private

◆ m_mutex

std::mutex ossimImageUtil::m_mutex
private

Definition at line 534 of file ossimImageUtil.h.

Referenced by addOption(), initializeDefaultFilterList(), and setErrorStatus().


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