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

ossimGdalOverviewBuilder Class to build overviews from the GDAL library. More...

#include <ossimGdalOverviewBuilder.h>

Inheritance diagram for ossimGdalOverviewBuilder:
ossimOverviewBuilderBase ossimSource ossimProcessInterface ossimConnectableObjectListener ossimConnectableObject ossimErrorStatusInterface ossimListener ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Public Types

enum  ossimGdalOverviewType {
  ossimGdalOverviewType_UNKNOWN = 0, ossimGdalOverviewTiffNearest = 1, ossimGdalOverviewTiffAverage = 2, ossimGdalOverviewHfaNearest = 3,
  ossimGdalOverviewHfaAverage = 4
}
 Enumerations for the type of GDAL overviews to build. More...
 
- Public Types inherited from ossimConnectableObject
enum  ossimConnectableObjectDirectionType { CONNECTABLE_DIRECTION_NONE = 0, CONNECTABLE_DIRECTION_INPUT = 1, CONNECTABLE_DIRECTION_OUTPUT = 2 }
 
typedef std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
 
- Public Types inherited from ossimProcessInterface
enum  ossimProcessStatus {
  PROCESS_STATUS_UNKNOWN = 0, PROCESS_STATUS_EXECUTING = 1, PROCESS_STATUS_ABORTED = 2, PROCESS_STATUS_ABORT_REQUEST = 3,
  PROCESS_STATUS_NOT_EXECUTING = 4
}
 

Public Member Functions

 ossimGdalOverviewBuilder ()
 default constructor More...
 
virtual ~ossimGdalOverviewBuilder ()
 virtual destructor More...
 
bool open (const ossimFilename &file)
 Open that takes a file name. More...
 
virtual bool execute ()
 Builds the overviews. More...
 
virtual bool setInputSource (ossimImageHandler *imageSource)
 
Sets the input to the builder. More...
 
virtual void setOutputFile (const ossimFilename &file)
 Sets the output filename. More...
 
virtual ossimFilename getOutputFile () const
 Returns the output. More...
 
virtual bool setOverviewType (const ossimString &type)
 Sets the overview output type. More...
 
virtual ossimString getOverviewType () const
 Gets the overview type. More...
 
virtual void getTypeNameList (std::vector< ossimString > &typeList) const
 Method to populate class supported types. More...
 
virtual ossimObjectgetObject ()
 
virtual const ossimObjectgetObject () const
 
virtual bool canConnectMyInputTo (ossim_int32 index, const ossimConnectableObject *obj) const
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 Method to set properties. More...
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 Method to populate the list of property names. More...
 
virtual std::ostream & print (std::ostream &out) const
 print method. More...
 
- Public Member Functions inherited from ossimOverviewBuilderBase
 ossimOverviewBuilderBase ()
 default constructor More...
 
virtual bool setOutputWriter (ossimImageFileWriter *outputWriter)
 Sets an optional file writer to the builder. More...
 
virtual bool hasOverviewType (const ossimString &type) const
 Method to check if builder can handle type. More...
 
virtual ossim_uint32 getOverviewStopDimension () const
 Get the overview stop dimension. More...
 
virtual void setOverviewStopDimension (ossim_uint32 dim)
 Sets the overview stop dimension. More...
 
ossimHistogramMode getHistogramMode () const
 Gets the histogram accumulation mode. More...
 
void setHistogramMode (ossimHistogramMode mode)
 Sets the histogram accumulation mode. More...
 
virtual void finalize ()
 Finalize method. More...
 
void setBitMaskSpec (const ossimKeywordlist &bit_mask_spec)
 Specifies parameters (in KWL) for generation of an alpha (bit) mask such that any full or partial null pixels will be masked out. More...
 
void setScanForMinMax (bool flag)
 Turn on/off scan for min max flag. More...
 
bool getScanForMinMax () const
 
void setScanForMinMaxNull (bool flag)
 Turn on/off scan for min, max, null flag. More...
 
bool getScanForMinMaxNull () const
 
- Public Member Functions inherited from ossimSource
 ossimSource (ossimObject *owner=0)
 
 ossimSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimSource ()
 
virtual bool isSourceEnabled () const
 
virtual void enableSource ()
 
virtual void disableSource ()
 
virtual bool getEnableFlag () const
 
virtual void setEnableFlag (bool flag)
 
virtual bool isInitialized () const
 
virtual void setInitializedFlag (bool flag)
 
virtual void initialize ()
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
- Public Member Functions inherited from ossimConnectableObject
 ossimConnectableObject (ossimObject *owner=0)
 Base constructor of this object. More...
 
 ossimConnectableObject (ossimObject *owner, ossim_int32 inputListSize, ossim_int32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimConnectableObject ()
 
void setId (const ossimId &id)
 All connectable objects will have id's. More...
 
const ossimIdgetId () const
 Will allow us to get this object's id. More...
 
const ossimObjectgetOwner () const
 Fetches the current owner, most likely a container but not limited to one. More...
 
virtual void changeOwner (ossimObject *owner)
 Permits changing the object's owner. More...
 
virtual void setDescription (const ossimString &description)
 
virtual ossimString getDescription () const
 
virtual bool isConnected (ossimConnectableObjectDirectionType direction=CONNECTABLE_DIRECTION_INPUT) const
 will check the direction specified to see if all slots are full. More...
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findConnectableObject(const ossimId &id))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(RTTItypeid typeId, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(const ossimString &obj, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findInputObjectOfType(const ossimString &className))
 
virtual ossim_int32 findInputIndex (const ossimConnectableObject *object)
 Return a valid index of the input list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findInputIndex (const ossimId &id)
 Return a valid index of the input list if the passed id is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimConnectableObject *object)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimId &id)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 getMyInputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual ossim_int32 getMyOutputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual bool canConnectMyOutputTo (ossim_int32 myOutputIndex, const ossimConnectableObject *object) const
 default implementation is to allow anyone to connect to us. More...
 
virtual void disconnect (ossimConnectableObject *object=0)
 Will disconnect the object passed in. More...
 
virtual void disconnect (const ossimId &id)
 Will disconnect the object passed in. More...
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyInput (ossim_int32 inputIndex, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given input index and generate a connection event. More...
 
virtual void disconnectMyInput (ossimConnectableObject *input, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Finds the index of the passed in input and calls disconnectMyInput(inputIndex, disconnectOutputFlag, createEventFlag);. More...
 
virtual void disconnectMyInputs (ConnectableObjectList &inputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyOutput (ossim_int32 outputIndex, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given output index and generate a connection event. More...
 
virtual void disconnectMyOutput (ossimConnectableObject *output, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the output object. More...
 
virtual void disconnectMyOutputs (ConnectableObjectList &outputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual void disconnectAllInputs ()
 Will disconnect all of the input objects. More...
 
virtual void disconnectAllOutputs ()
 Will disconnect all of the output objects. More...
 
virtual ossim_int32 connectMyInputTo (ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will try to connect this objects input to the passed in object. More...
 
virtual ossim_int32 connectMyInputTo (ossim_int32 inputIndex, ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will connect the specified input to the passed in object. More...
 
virtual bool connectMyInputTo (ConnectableObjectList &inputList, bool makeOutputConnection=true, bool createEventFlag=true)
 
virtual ossim_int32 connectMyOutputTo (ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
 Will try to connect this objects output to the passed in object. More...
 
virtual bool connectMyOutputTo (ConnectableObjectList &outputList, bool makeInputConnection=true, bool createEventFlag=true)
 
virtual bool connectInputList (ConnectableObjectList &inputList)
 Will disconnect itself from all inputs and reset to the passed in input list. More...
 
virtual bool connectOutputList (ConnectableObjectList &outputList)
 Will disconnect itself from all outputs and reset to the passed in output list. More...
 
virtual ossim_uint32 getNumberOfInputs () const
 Returns the number of input objects. More...
 
virtual ossim_uint32 getNumberOfOutputs () const
 Return the number of output objects. More...
 
ossimConnectableObjectgetInput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetInput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
ossimConnectableObjectgetOutput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetOutput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
virtual void setNumberOfInputs (ossim_int32 numberOfInputs)
 Will set the number of inputs. More...
 
virtual bool getInputListIsFixedFlag () const
 
virtual bool getOutputListIsFixedFlag () const
 
virtual void setNumberOfOutputs (ossim_int32 numberOfInputs)
 Will set the number of outputs. More...
 
const ConnectableObjectListgetInputList () const
 
const ConnectableObjectListgetOutputList () const
 
ConnectableObjectListgetInputList ()
 
ConnectableObjectListgetOutputList ()
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const RTTItypeid &typeInfo, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const ossimString &className, bool recurse=true))
 
virtual void propagateEventToOutputs (ossimEvent &event)
 
virtual void propagateEventToInputs (ossimEvent &event)
 
virtual void setProperty (const ossimString &name, const ossimString &value)
 
virtual ossim_uint32 saveStateOfAllInputs (ossimKeywordlist &kwl, bool saveThisStateFlag=true, ossim_uint32 objectIndex=1, const char *prefix=0) const
 Save the state of all inputs to a keyword list. More...
 
virtual bool fillContainer (ossimConnectableContainer &container)
 Inserts this object and all of its children and inputs into the container provided. More...
 
bool moveInputUp (const ossimId &id)
 Moves the input connection matching id up one in the connection list. More...
 
bool moveInputDown (const ossimId &id)
 Moves the input connection matching id down one in the connection list. More...
 
bool moveInputToTop (const ossimId &id)
 Moves the input connection matching id to the top of the connection list. More...
 
bool moveInputToBottom (const ossimId &id)
 Moves the input connection matching id to the bottom of the connection list. More...
 
virtual void accept (ossimVisitor &visitor)
 We will add a visitor interface for all connectable objects. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
- 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 ossimListenerManager
 ossimListenerManager ()
 
virtual ~ossimListenerManager ()
 
virtual void fireEvent (ossimEvent &event)
 
virtual bool addListener (ossimListener *listener)
 
virtual bool removeListener (ossimListener *listener)
 
virtual bool findListener (ossimListener *listener)
 
- Public Member Functions inherited from ossimPropertyInterface
 ossimPropertyInterface ()
 
virtual ~ossimPropertyInterface ()
 
virtual ossimString getPropertyValueAsString (const ossimString &name) const
 
void getPropertyList (std::vector< ossimRefPtr< ossimProperty > > &propertyList) const
 
void setProperties (std::vector< ossimRefPtr< ossimProperty > > &propertyList)
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
- Public Member Functions inherited from ossimProcessInterface
 ossimProcessInterface ()
 
virtual ~ossimProcessInterface ()
 
virtual void abort ()
 
bool needsAborting () const
 
bool isAbortRequested () const
 
bool isAborted () const
 
bool isExecuting () const
 
ossimProcessStatus getProcessStatus () const
 
virtual void setProcessStatus (ossimProcessStatus processStatus)
 
virtual double getPercentComplete () const
 
virtual void setPercentComplete (double percentComplete)
 
virtual ossimListenerManagergetManager ()
 
void enableEvents ()
 
void disableEvents ()
 
void setCurrentMessage (const ossimString &message)
 
- Public Member Functions inherited from ossimConnectableObjectListener
 ossimConnectableObjectListener ()
 
virtual ~ossimConnectableObjectListener ()
 
virtual void processEvent (ossimEvent &event)
 ProcessEvent. More...
 
virtual void objectDestructingEvent (ossimObjectDestructingEvent &)
 
virtual void connectionEvent (ossimConnectionEvent &)
 
virtual void disconnectInputEvent (ossimConnectionEvent &)
 
virtual void disconnectOutputEvent (ossimConnectionEvent &)
 
virtual void connectInputEvent (ossimConnectionEvent &)
 
virtual void connectOutputEvent (ossimConnectionEvent &)
 
virtual void propertyEvent (ossimPropertyEvent &)
 
virtual void addObjectEvent (ossimContainerEvent &)
 
virtual void removeObjectEvent (ossimContainerEvent &)
 
virtual void containerEvent (ossimContainerEvent &)
 
virtual void refreshEvent (ossimRefreshEvent &)
 
- Public Member Functions inherited from ossimListener
 ossimListener ()
 
virtual ~ossimListener ()
 
void enableListener ()
 
void disableListener ()
 
void setListenerEnableFlag (bool flag)
 
bool isListenerEnabled () const
 
bool getListenerEnableFlag () const
 

Private Member Functions

bool generateHfaStats () const
 
ossimString getGdalResamplingType () const
 
ossimString getExtensionFromType () const
 

Private Attributes

ossimGdalDatasettheDataset
 
ossimFilename theOutputFile
 
ossimGdalOverviewType theOverviewType
 
std::vector< ossim_int32theLevels
 
bool theGenerateHfaStatsFlag
 

Additional Inherited Members

- Protected Member Functions inherited from ossimOverviewBuilderBase
virtual ~ossimOverviewBuilderBase ()
 virtual destructor More...
 
ossim_uint32 getRequiredResLevels (const ossimImageHandler *ih) const
 Gets the required number of res levels. More...
 
void initializePreferenceSettings ()
 Initializes preference settings. More...
 
void initializeScanOptions ()
 Checks scalar type and turns on scanning for min, max, nulls if needed. More...
 
- Protected Member Functions inherited from ossimSource
 ossimSource (const ossimSource &rhs)
 
const ossimSourceoperator= (const ossimSource &rhs)
 
- Protected Member Functions inherited from ossimConnectableObject
ossimConnectableObjectfindObjectOfType (ConnectableObjectList *connectableList, ossimVisitor &visitor)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimListenerManager
 ossimListenerManager (const ossimListenerManager &rhs)
 
- Protected Attributes inherited from ossimOverviewBuilderBase
ossim_uint32 m_overviewStopDimension
 
ossimHistogramMode m_histoMode
 
ossimKeywordlist m_bitMaskSpec
 
ossimRefPtr< ossimImageHandlerm_imageHandler
 
std::vector< ossim_uint32m_originalBandList
 
ossimRefPtr< ossimBitMaskWriterm_maskWriter
 
ossimRefPtr< ossimMaskFilterm_maskFilter
 
ossimFilename m_outputFile
 
bool m_scanForMinMax
 
bool m_scanForMinMaxNull
 
bool m_scanFloatData
 
- Protected Attributes inherited from ossimSource
bool theEnableFlag
 
bool theInitializedFlag
 
- Protected Attributes inherited from ossimConnectableObject
ossimId theId
 
ossimString theDescription
 
ossimObjecttheOwner
 
bool theInputListIsFixedFlag
 Indicates whether the theInputObjectList is fixed. More...
 
bool theOutputListIsFixedFlag
 Indicates whether the theOutputObjectList is fixed. More...
 
ConnectableObjectList theInputObjectList
 Holds a list of input objects. More...
 
ConnectableObjectList theOutputObjectList
 Holds a list of output objects. More...
 
- Protected Attributes inherited from ossimListenerManager
std::list< ossimListener * > theListenerList
 
bool theEnabledFlag
 
std::list< ossimListener * > theDelayedAdd
 
std::list< ossimListener * > theDelayedRemove
 
bool theFireEventFlag
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 
- Protected Attributes inherited from ossimProcessInterface
double thePercentComplete
 
ossimProcessStatus theProcessStatus
 
ossimString theMessage
 
bool theEventFlag
 
- Protected Attributes inherited from ossimListener
bool theListenerEnableFlag
 

Detailed Description

ossimGdalOverviewBuilder Class to build overviews from the GDAL library.

Definition at line 31 of file ossimGdalOverviewBuilder.h.

Member Enumeration Documentation

◆ ossimGdalOverviewType

Constructor & Destructor Documentation

◆ ossimGdalOverviewBuilder()

ossimGdalOverviewBuilder::ossimGdalOverviewBuilder ( )

◆ ~ossimGdalOverviewBuilder()

ossimGdalOverviewBuilder::~ossimGdalOverviewBuilder ( )
virtual

virtual destructor

Definition at line 48 of file ossimGdalOverviewBuilder.cpp.

References theDataset.

49 {
50  if ( theDataset )
51  {
52  delete theDataset;
53  theDataset = 0;
54  }
55 }

Member Function Documentation

◆ canConnectMyInputTo()

bool ossimGdalOverviewBuilder::canConnectMyInputTo ( ossim_int32  index,
const ossimConnectableObject obj 
) const
virtual
Returns
true if input is an image handler. Satisfies pure virtual.

Implements ossimConnectableObject.

Definition at line 494 of file ossimGdalOverviewBuilder.cpp.

References PTR_CAST.

497 {
498  if ( (index == 0) &&
500  {
501  return true;
502  }
503 
504  return false;
505 }
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
This class defines an abstract Handler which all image handlers(loaders) should derive from...

◆ execute()

bool ossimGdalOverviewBuilder::execute ( )
virtual

Builds the overviews.

Returns
true on success, false on error.
Note
If setOutputFile was not called the output name will be derived from the image name. If image was "foo.tif" the overview file will be "foo.rrd" or "foo.ovr".

Implements ossimOverviewBuilderBase.

Definition at line 161 of file ossimGdalOverviewBuilder.cpp.

162 {
163  if (traceDebug())
164  {
166  << "ossimGdalOverviewBuilder::execute entered..."
167  << endl;
168  }
169 
170  bool result = false;
171 
173  {
174  return result;
175  }
176 
177  // Get the output file.
178  ossimFilename overviewFile = getOutputFile();
179 
180  // Check the file. Disallow same file overview building.
181  if (theDataset->getImageHandler()->getFilename() == overviewFile)
182  {
184  << "Source image file and overview file cannot be the same!"
185  << std::endl;
186  return result;
187  }
188 
190  {
191  theDataset->setGdalAcces(GA_Update);
193  if (generateHfaStats() == false)
194  {
195  cerr << " generateHfaStats failed..." << endl;
196  }
197  else
198  {
199  // delete theDataset;
200  // return true;
201  }
202  }
203 
204  // theDataset->setGdalAcces(GA_Update);
205 
207 
208  // Get the number of bands.
209  // ossim_uint32 bands = theDataset->getImageHandler()->
210  // getNumberOfOutputBands();
211 
212  // Get the resampling string.
213  ossimString pszResampling = getGdalResamplingType();
214 
215  // Compute the number of levels.
217  ossim_uint32 minBound = ossim::min( bounds.width(), bounds.height() );
218 
219  //---
220  // Set the decimation levels. If set through the property interface use
221  // that; else compute.
222  //---
223  ossim_int32 numberOfLevels = 0;
224 
225  if (theLevels.size())
226  {
227  numberOfLevels = theLevels.size();
228  }
229  else
230  {
232  while (minBound > stopDim)
233  {
234  minBound = minBound / 2;
235  ++numberOfLevels;
236  }
237 
238  if (numberOfLevels == 0)
239  {
240  return result; // nothing to do.
241  }
242  }
243 
244  ossim_int32* levelDecimationFactor = new ossim_int32[numberOfLevels];
245 
246  ossim_uint32 idx;
247 
248  if (theLevels.size())
249  {
250  for (idx = 0; idx < theLevels.size(); ++idx)
251  {
252  levelDecimationFactor[idx] = theLevels[idx];
253  }
254  }
255  else
256  {
257  levelDecimationFactor[0] = 2;
258  for(idx = 1; idx < static_cast<ossim_uint32>(numberOfLevels); ++idx)
259  {
260  levelDecimationFactor[idx] = levelDecimationFactor[idx-1]*2;
261  }
262  }
263 
264  if (traceDebug())
265  {
267  << "ossimGdalOverviewBuilder::execute DEBUG:"
268  << "\noverviewFilename: " << overviewFile
269  << "\npszResampling: " << pszResampling
270  << "\nnumberOfLevels: " << numberOfLevels
271  << endl;
272  for(idx = 0; idx < static_cast<ossim_uint32>(numberOfLevels); ++idx)
273  {
275  << "levelDecimationFactor["
276  << idx << "]: " << levelDecimationFactor[idx]
277  << endl;
278  }
279  }
280 
281  CPLErr eErr = CE_None;
282 
285  {
286  CPLSetConfigOption("USE_RRD", "YES");
287  }
288 
289  if( theDataset->BuildOverviews( pszResampling.c_str(),
290  numberOfLevels,
291  levelDecimationFactor,
292  0,
293  0,
294  GDALTermProgress,
295  0 ) != CE_None )
296  {
298  << "Overview building failed." << std::endl;
299  }
300 
301  if ( levelDecimationFactor )
302  {
303  delete [] levelDecimationFactor;
304  levelDecimationFactor = 0;
305  }
306 
307  if (eErr == CE_None )
308  {
309  result = true;
310  }
311 
312  if (result == true)
313  {
315  << "Wrote file: " << overviewFile << std::endl;
316  }
317 
318  return result;
319 }
void initGdalOverviewManager()
Calls gdal&#39;s oOvManager.Initialize.
ossimGdalOverviewType theOverviewType
std::vector< ossim_int32 > theLevels
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimImageHandler * getImageHandler() const
virtual ossim_uint32 getOverviewStopDimension() const
Get the overview stop dimension.
void setGdalAcces(GDALAccess access)
Set the access data member.
virtual const ossimFilename & getFilename() const
Returns the filename.
ossimString getGdalResamplingType() const
unsigned int ossim_uint32
T min(T a, T b)
Definition: ossimCommon.h:203
ossim_uint32 width() const
Definition: ossimIrect.h:500
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 getOutputFile() const
Returns the output.
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ generateHfaStats()

bool ossimGdalOverviewBuilder::generateHfaStats ( ) const
private

Definition at line 378 of file ossimGdalOverviewBuilder.cpp.

References ossimString::c_str(), ossimString::empty(), ossimFilename::file(), ossimImageHandler::getFilename(), ossimGdalDataset::getImageHandler(), getOutputFile(), and theDataset.

379 {
380  // GDALAllRegister();
381 
382  //---
383  // Equivalent:
384  // gdal_translate -of HFA -co AUX=YES -co STATISTICS=YES
385  // -co DEPENDENT_FILE=utm.tif utm.tif utm.aux
386  //---
387  bool result = false;
388 
389  if (!theDataset)
390  {
391  return result;
392  }
393  if (!theDataset->getImageHandler())
394  {
395  return result;
396  }
397 
398  ossimFilename sourceImageFile =
400  if (sourceImageFile.empty())
401  {
402  return result;
403  }
404 
405  // This is the output driver.
406  GDALDriverH hDriver = GDALGetDriverByName( "HFA" );
407  if (!hDriver)
408  {
409  return false;
410  }
411 
412  // This is the source data set.
413  GDALDatasetH hDataset = theDataset;
414 
415  GDALDatasetH hOutDS = 0;
416  int bStrict = true;
417 
418  char** papszCreateOptions = 0;
419  GDALProgressFunc pfnProgress = GDALTermProgress;
420 
421  ossimString s = "DEPENDENT_FILE=";
422  s += sourceImageFile.file(); // Must not have absolute path...
423 
424  papszCreateOptions = CSLAddString( papszCreateOptions, "AUX=YES");
425  papszCreateOptions = CSLAddString( papszCreateOptions, "STATISTICS=YES");
426  papszCreateOptions = CSLAddString( papszCreateOptions, s.c_str() );
427 
428  hOutDS = GDALCreateCopy( hDriver,
429  getOutputFile().c_str(),
430  hDataset,
431  bStrict,
432  papszCreateOptions,
433  pfnProgress,
434  0 );
435 
436  CSLDestroy( papszCreateOptions );
437  if( hOutDS != 0 )
438  {
439  GDALClose( hOutDS );
440  }
441 
442  return true;
443 }
const ossimImageHandler * getImageHandler() const
virtual const ossimFilename & getFilename() const
Returns the filename.
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
bool empty() const
Definition: ossimString.h:411
virtual ossimFilename getOutputFile() const
Returns the output.
ossimFilename file() const

◆ getExtensionFromType()

ossimString ossimGdalOverviewBuilder::getExtensionFromType ( ) const
private
Returns
extension like "ovr" or "rrd".

Definition at line 465 of file ossimGdalOverviewBuilder.cpp.

References ossimGdalOverviewHfaAverage, ossimGdalOverviewHfaNearest, and theOverviewType.

Referenced by getOutputFile().

466 {
467  ossimString result;
468  switch (theOverviewType)
469  {
472  result = "aux";
473  break;
474 
475  default:
476  result = "ovr";
477  break;
478  }
479  return result;
480 }
ossimGdalOverviewType theOverviewType

◆ getGdalResamplingType()

ossimString ossimGdalOverviewBuilder::getGdalResamplingType ( ) const
private

◆ getObject() [1/2]

ossimObject * ossimGdalOverviewBuilder::getObject ( )
virtual
Returns
ossimObject* to this object. Satisfies pure virtual.

Implements ossimProcessInterface.

Definition at line 484 of file ossimGdalOverviewBuilder.cpp.

485 {
486  return this;
487 }

◆ getObject() [2/2]

const ossimObject * ossimGdalOverviewBuilder::getObject ( ) const
virtual
Returns
const ossimObject* to this object. Satisfies pure virtual.

Implements ossimProcessInterface.

Definition at line 489 of file ossimGdalOverviewBuilder.cpp.

490 {
491  return this;
492 }

◆ getOutputFile()

ossimFilename ossimGdalOverviewBuilder::getOutputFile ( ) const
virtual

Returns the output.

This will be derived from the input file if not explicitly set.

Returns
The output filename.

Implements ossimOverviewBuilderBase.

Definition at line 62 of file ossimGdalOverviewBuilder.cpp.

References getExtensionFromType(), ossimImageHandler::getFilename(), ossimGdalDataset::getImageHandler(), ossimFilename::NIL, ossimGdalOverviewHfaAverage, ossimGdalOverviewHfaNearest, ossimFilename::setExtension(), theDataset, theOutputFile, and theOverviewType.

Referenced by generateHfaStats().

63 {
65  {
66  if (theDataset)
67  {
69  {
70  ossimFilename outputFile =
72 
73  switch (theOverviewType)
74  {
77  outputFile.setExtension(getExtensionFromType());
78  break;
79  default:
80  outputFile += ".ovr";
81  break;
82  }
83  return outputFile;
84  }
85  }
86  }
87 
88  return theOutputFile;
89 }
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
ossimString getExtensionFromType() const
ossimGdalOverviewType theOverviewType
const ossimImageHandler * getImageHandler() const
virtual const ossimFilename & getFilename() const
Returns the filename.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.

◆ getOverviewType()

ossimString ossimGdalOverviewBuilder::getOverviewType ( ) const
virtual

Gets the overview type.

Satisfies pure virtual from ossimOverviewBuilderBase.

Returns
The overview output type as a string.

Implements ossimOverviewBuilderBase.

Definition at line 143 of file ossimGdalOverviewBuilder.cpp.

144 {
145  return ossimString(OVR_TYPE[theOverviewType]);
146 }
ossimGdalOverviewType theOverviewType

◆ getPropertyNames()

void ossimGdalOverviewBuilder::getPropertyNames ( std::vector< ossimString > &  propertyNames) const
virtual

Method to populate the list of property names.

Parameters
propertyNamesList to populate. This does not clear the list just adds to it.

Reimplemented from ossimSource.

Definition at line 360 of file ossimGdalOverviewBuilder.cpp.

362 {
363  propertyNames.push_back(ossimString("levels"));
364  propertyNames.push_back(ossimString("generate-hfa-stats"));
365 }

◆ getTypeNameList()

void ossimGdalOverviewBuilder::getTypeNameList ( std::vector< ossimString > &  typeList) const
virtual

Method to populate class supported types.

Satisfies pure virtual from ossimOverviewBuilderBase.

Parameters
typeListList of ossimStrings to add to.

Implements ossimOverviewBuilderBase.

Definition at line 148 of file ossimGdalOverviewBuilder.cpp.

◆ open()

bool ossimGdalOverviewBuilder::open ( const ossimFilename file)

Open that takes a file name.

Parameters
fileThe file to open.
Returns
true on success, false on error.

Definition at line 91 of file ossimGdalOverviewBuilder.cpp.

References ossimGdalDataset::open(), and theDataset.

92 {
93  if (theDataset)
94  {
95  delete theDataset;
96  }
98  return theDataset->open(file);
99 }
ossimGdalDataset This is a gdal data set that wraps an ossim image handler.
bool open(const ossimFilename &file)
open method.

◆ print()

std::ostream & ossimGdalOverviewBuilder::print ( std::ostream &  out) const
virtual

print method.

Returns
std::ostream&

Reimplemented from ossimProcessInterface.

Definition at line 367 of file ossimGdalOverviewBuilder.cpp.

References ossimString::c_str(), and theOutputFile.

368 {
369  out << "ossimGdalOverviewBuilder::print"
370  << "\nfilename: " << theOutputFile.c_str()
371  << "\noverview_type: "
372  << OVR_TYPE[theOverviewType]
373  << "\nresampling type: " << getGdalResamplingType()
374  << std::endl;
375  return out;
376 }
ossimGdalOverviewType theOverviewType
ossimString getGdalResamplingType() const
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

◆ setInputSource()

bool ossimGdalOverviewBuilder::setInputSource ( ossimImageHandler imageSource)
virtual


Sets the input to the builder.

Satisfies pure virtual from ossimOverviewBuilderBase.

Parameters
imageSourceThe input to the builder.
Returns
True on successful initializion, false on error.

Reimplemented from ossimOverviewBuilderBase.

Definition at line 101 of file ossimGdalOverviewBuilder.cpp.

References ossimGdalDataset::setImageHandler(), and theDataset.

102 {
103  if ( !imageSource )
104  {
105  return false;
106  }
107 
108  if (theDataset)
109  {
110  delete theDataset;
111  }
112 
114  theDataset->setImageHandler(imageSource);
115  return true;
116 }
void setImageHandler(ossimImageHandler *ih)
Sets theImageHandler.
ossimGdalDataset This is a gdal data set that wraps an ossim image handler.

◆ setOutputFile()

void ossimGdalOverviewBuilder::setOutputFile ( const ossimFilename file)
virtual

Sets the output filename.

Satisfies pure virtual from ossimOverviewBuilderBase.

Parameters
fileThe output file name.

Implements ossimOverviewBuilderBase.

Definition at line 57 of file ossimGdalOverviewBuilder.cpp.

References theOutputFile.

58 {
59  theOutputFile = file;
60 }

◆ setOverviewType()

bool ossimGdalOverviewBuilder::setOverviewType ( const ossimString type)
virtual

Sets the overview output type.

Satisfies pure virtual from ossimOverviewBuilderBase.

Currently handled types are: "ossim_tiff_nearest" and "ossim_tiff_box"

Parameters
typeThis should be the string representing the type. This method will do nothing if type is not handled and return false.
Returns
true if type is handled, false if not.

Implements ossimOverviewBuilderBase.

Definition at line 118 of file ossimGdalOverviewBuilder.cpp.

◆ setProperty()

void ossimGdalOverviewBuilder::setProperty ( ossimRefPtr< ossimProperty property)
virtual

Method to set properties.

Parameters
propertyProperty to set.
Note
Currently supported property: name=levels, value should be list of levels separated by a comma with no spaces. Example: "2,4,8,16,32,64"

Reimplemented from ossimSource.

Definition at line 321 of file ossimGdalOverviewBuilder.cpp.

References ossimString::downcase(), and ossimRefPtr< T >::valid().

322 {
323  if (property.valid() == false)
324  {
325  return;
326  }
327 
328  ossimString s = property->getName();
329  s.downcase();
330  if ( s == "levels" )
331  {
332  ossimString value;
333  property->valueToString(value);
334 
335  if (traceDebug())
336  {
338  << "ossimGdalOverviewBuilder::setProperty DEBUG:"
339  << std::endl;
340  }
341  theLevels.clear();
342  std::vector<ossimString> v1 = value.split(",");
343  for (ossim_uint32 i = 0; i < v1.size(); ++i)
344  {
345  ossim_int32 level = v1[i].toInt32();
346  theLevels.push_back(level);
347  if (traceDebug())
348  {
350  << "level[" << i << "]: " << level << std::endl;
351  }
352  }
353  }
354  else if ( s == "generate-hfa-stats" )
355  {
357  }
358 }
bool valid() const
Definition: ossimRefPtr.h:75
std::vector< ossim_int32 > theLevels
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
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

Member Data Documentation

◆ theDataset

ossimGdalDataset* ossimGdalOverviewBuilder::theDataset
private

◆ theGenerateHfaStatsFlag

bool ossimGdalOverviewBuilder::theGenerateHfaStatsFlag
private

Definition at line 176 of file ossimGdalOverviewBuilder.h.

◆ theLevels

std::vector<ossim_int32> ossimGdalOverviewBuilder::theLevels
private

Definition at line 175 of file ossimGdalOverviewBuilder.h.

◆ theOutputFile

ossimFilename ossimGdalOverviewBuilder::theOutputFile
private

Definition at line 173 of file ossimGdalOverviewBuilder.h.

Referenced by getOutputFile(), print(), and setOutputFile().

◆ theOverviewType

ossimGdalOverviewType ossimGdalOverviewBuilder::theOverviewType
private

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