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

#include <ossimGeneralRasterWriter.h>

Inheritance diagram for ossimGeneralRasterWriter:
ossimImageFileWriter ossimImageWriter ossimProcessInterface ossimConnectableObjectListener ossimOutputSource ossimListener ossimSource ossimConnectableObject ossimErrorStatusInterface ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Public Member Functions

 ossimGeneralRasterWriter ()
 default constructor More...
 
virtual void getImageTypeList (std::vector< ossimString > &imageTypeList) const
 void getImageTypeList(std::vector<ossimString>& imageTypeList)const More...
 
virtual ossimString getExtension () const
 Returns a 3-letter extension from the image type descriptor (theOutputImageType) that can be used for image file extensions. More...
 
virtual void set_rr_level (ossim_uint32 rr)
 
virtual bool isOpen () const
 
virtual bool open ()
 
virtual void close ()
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 saves the state of the object. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of an object from a keyword list. More...
 
virtual bool writeStream ()
 Method to write the image to a stream. More...
 
virtual bool setOutputStream (std::ostream &stream)
 Sets the output stream to write to. More...
 
- Public Member Functions inherited from ossimImageFileWriter
 ossimImageFileWriter (const ossimFilename &filename=ossimFilename(), ossimImageSource *inputSource=0, ossimObject *owner=0)
 The writer will own the sequencer. More...
 
virtual ~ossimImageFileWriter ()
 
virtual ossimObjectgetObject ()
 
virtual const ossimObjectgetObject () const
 
virtual bool getOutputHasInternalOverviews (void) const
 Examples of writers that always generate internal overviews are ossim_kakadu_jp2 and ossim_kakadu_nitf_j2k. More...
 
virtual bool hasImageType (const ossimString &imageType) const
 bool hasImageType(const ossimString& imageType) const More...
 
virtual void setTileSize (const ossimIpt &tileSize)
 Sets the output image tiling size if supported by the writer. More...
 
virtual bool writeEnviHeaderFile ()
 Will write an envi header file. More...
 
virtual bool writeErsHeaderFile ()
 Will write an ER Mapper header file. More...
 
virtual bool writeExternalGeometryFile ()
 Will write an external geometry file. More...
 
virtual bool writeFgdcFile ()
 Will write an fgdc file. More...
 
virtual bool writeHistogramFile ()
 Returns true on success, false on error. More...
 
virtual bool writeJpegWorldFile ()
 Will write a jpeg world file. More...
 
virtual bool writeOverviewFile (ossim_uint16 tiff_compress_type=1, ossim_int32 jpeg_compress_quality=75, bool includeR0=false)
 Write out an ossim overview file from the source_file. More...
 
virtual bool writeReadmeFile ()
 Will write a readme file. More...
 
virtual bool writeTiffWorldFile ()
 Will write a world file. More...
 
virtual bool writeWorldFile ()
 Will write a world file. More...
 
virtual bool writeMetaDataFiles ()
 Convenience method that calls meta data write methods that are flagged to be called. More...
 
virtual void setAreaOfInterest (const ossimIrect &inputRect)
 
virtual void changeSequencer (ossimImageSourceSequencer *sequencer)
 Sets the sequencer and connects it to the input of this. More...
 
virtual ossimImageSourceSequencergetSequencer ()
 
virtual void initialize ()
 Initialize method. More...
 
virtual bool execute ()
 Calls: writeFile() writeMetaDataFiles() More...
 
virtual bool setOutputStream (ossimRefPtr< ossimOStream > stream)
 Sets the output stream to write to. More...
 
virtual ossimRefPtr< ossimOStreamgetOutputStream () const
 Method to return the stream attached to output. More...
 
virtual void setPercentComplete (double percentComplete)
 
virtual void setOutputImageType (ossim_int32 type)
 
virtual void setOutputImageType (const ossimString &type)
 
virtual ossim_int32 getOutputImageType () const
 
virtual ossimString getOutputImageTypeString () const
 
virtual void setOutputName (const ossimString &outputName)
 
virtual void setFilename (const ossimFilename &file)
 
virtual const ossimFilenamegetFilename () const
 
virtual bool canConnectMyInputTo (ossim_int32 inputIndex, const ossimConnectableObject *object) const
 required to be overriden by derived classes More...
 
virtual void disconnectInputEvent (ossimConnectionEvent &event)
 
virtual void connectInputEvent (ossimConnectionEvent &event)
 
virtual void propertyEvent (ossimPropertyEvent &event)
 
virtual bool getWriteImageFlag () const
 Control flags... More...
 
virtual bool getWriteHistogramFlag () const
 
virtual bool getWriteOverviewFlag () const
 
virtual bool getScaleToEightBitFlag () const
 
virtual bool getWriteEnviHeaderFlag () const
 
virtual bool getWriteErsHeaderFlag () const
 
virtual bool getWriteExternalGeometryFlag () const
 
virtual bool getWriteFgdcFlag () const
 
virtual bool getWriteJpegWorldFileFlag () const
 
virtual bool getWriteReadmeFlag () const
 
virtual bool getWriteTiffWorldFileFlag () const
 
virtual bool getWriteWorldFileFlag () const
 
virtual void setWriteImageFlag (bool flag)
 
virtual void setWriteOverviewFlag (bool flag)
 
virtual void setWriteHistogramFlag (bool flag)
 
virtual void setScaleToEightBitFlag (bool flag)
 
virtual void setWriteEnviHeaderFlag (bool flag)
 
virtual void setWriteErsHeaderFlag (bool flag)
 
virtual void setWriteExternalGeometryFlag (bool flag)
 
virtual void setWriteFgdcFlag (bool flag)
 
virtual void setWriteJpegWorldFile (bool flag)
 
virtual void setWriteReadme (bool flag)
 
virtual void setWriteTiffWorldFile (bool flag)
 
virtual void setWriteWorldFile (bool flag)
 
virtual ossim_uint16 getOverviewCompressType () const
 
virtual ossim_int32 getOverviewJpegCompressQuality () const
 
virtual void setOverviewCompressType (ossim_uint16 type)
 
virtual void setOverviewJpegCompressQuality (ossim_int32 quality)
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 
virtual bool addListener (ossimListener *listener)
 Overrides base "addListener" this will capture the pointer and then call the base class "addListener". More...
 
virtual bool removeListener (ossimListener *listener)
 Overrides base "removeListener". More...
 
virtual void setPixelType (ossimPixelType type)
 If "point" the coordinate tie points are relative to the center of the pixel. More...
 
virtual void setPixelType (const ossimString &type)
 If "point" the coordinate tie points are relative to the center of the pixel. More...
 
virtual ossimPixelType getPixelType () const
 
virtual void getPixelTypeString (ossimString &type) const
 
- Public Member Functions inherited from ossimImageWriter
 ossimImageWriter (ossimObject *owner=NULL)
 
 ossimImageWriter (ossimObject *owner, ossim_uint32 numberOfInputs, ossim_uint32 numberOfOutputs, bool inputListIsFixed, bool outputListIsFixed)
 
virtual ~ossimImageWriter ()
 
virtual bool setViewingRect (const ossimIrect &aRect)
 
virtual ossimIrect getAreaOfInterest () const
 
- Public Member Functions inherited from ossimOutputSource
 ossimOutputSource (ossimObject *owner=NULL)
 
 ossimOutputSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimOutputSource ()
 
virtual bool open (const ossimString &outputName)
 
virtual const ossimStringgetOutputName ()
 
- 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 std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 
- 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 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 ossimListenerManagergetManager ()
 
void enableEvents ()
 
void disableEvents ()
 
void setCurrentMessage (const ossimString &message)
 
virtual std::ostream & print (std::ostream &out) const
 
- 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 disconnectOutputEvent (ossimConnectionEvent &)
 
virtual void connectOutputEvent (ossimConnectionEvent &)
 
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
 

Protected Member Functions

virtual bool writeFile ()
 Write out the file. More...
 
virtual ~ossimGeneralRasterWriter ()
 Protected ( this is a ossimRefPtr) destructor. More...
 
- Protected Member Functions inherited from ossimImageFileWriter
bool writeWorldFile (const ossimFilename &file)
 Common world file writer method. 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)
 

Private Member Functions

bool writeToBip ()
 Writes image data to output file in BIP(Band Interleaved by Pixel) format. More...
 
bool writeToBil ()
 Writes image data to output file in BIL(Band Interleaved by Line) format. More...
 
bool writeToBsq ()
 Writes image data to output file in BSQ(Band Sequential) format. More...
 
void writeHeader () const
 Writes an ossim header file which can be used to load file in ossim. More...
 
void writeEnviHeader () const
 Writes an envi header file which can be used to load file in envi. More...
 
ossimString getInterleaveString () const
 

Private Attributes

std::ostream * theOutputStream
 
bool theOwnsStreamFlag
 
ossim_uint32 theRlevel
 
ossimByteOrder theOutputByteOrder
 
std::vector< double > theMinPerBand
 Populated while writting the data. More...
 
std::vector< double > theMaxPerBand
 

Additional Inherited Members

- 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
}
 
- Protected Attributes inherited from ossimImageFileWriter
ossimRefPtr< ossimImageSourceSequencertheInputConnection
 
ossimRefPtr< ossimViewControllertheViewController
 
ossimListenertheProgressListener
 
ossimFilename theFilename
 
ossimString theOutputImageType
 
bool theWriteImageFlag
 
bool theWriteOverviewFlag
 
bool theWriteHistogramFlag
 
bool theScaleToEightBitFlag
 
ossim_uint16 theOverviewCompressType
 
ossim_int32 theOverviewJpegCompressQuality
 
bool theWriteEnviHeaderFlag
 External meta data writer flags. More...
 
bool theWriteErsHeaderFlag
 
bool theWriteExternalGeometryFlag
 
bool theWriteFgdcFlag
 
bool theWriteJpegWorldFileFlag
 
bool theWriteReadmeFlag
 
bool theWriteTiffWorldFileFlag
 
bool theWriteWorldFileFlag
 
bool theAutoCreateDirectoryFlag
 
ossimUnitType theLinearUnits
 If not a geographic projection this allows the user to set the linear units of the output tag to be: More...
 
ossimPixelType thePixelType
 OSSIM_PIXEL_IS_POINT = 0, OSSIM_PIXEL_IS_AREA = 1. More...
 
- Protected Attributes inherited from ossimImageWriter
ossimIrect theAreaOfInterest
 
- Protected Attributes inherited from ossimOutputSource
ossimString theOutputName
 
- 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

Definition at line 25 of file ossimGeneralRasterWriter.h.

Constructor & Destructor Documentation

◆ ossimGeneralRasterWriter()

ossimGeneralRasterWriter::ossimGeneralRasterWriter ( )

default constructor

Definition at line 35 of file ossimGeneralRasterWriter.cpp.

References ossimEndian::getSystemEndianType(), OSSIM_GENERAL_RASTER_BSQ, ossimImageFileWriter::setOutputImageType(), ossimImageFileWriter::setWriteExternalGeometryFlag(), and theOutputByteOrder.

36  :
38  theOutputStream(0),
39  theOwnsStreamFlag(false),
40  theRlevel(0),
42  theMinPerBand(0),
43  theMaxPerBand(0)
44 {
46 
47  // Since there is no internal geometry set the flag to write out one.
50 }
virtual void setOutputImageType(ossim_int32 type)
ossimImageFileWriter(const ossimFilename &filename=ossimFilename(), ossimImageSource *inputSource=0, ossimObject *owner=0)
The writer will own the sequencer.
std::vector< double > theMaxPerBand
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
virtual void setWriteExternalGeometryFlag(bool flag)
std::vector< double > theMinPerBand
Populated while writting the data.

◆ ~ossimGeneralRasterWriter()

ossimGeneralRasterWriter::~ossimGeneralRasterWriter ( )
protectedvirtual

Protected ( this is a ossimRefPtr) destructor.

Definition at line 52 of file ossimGeneralRasterWriter.cpp.

References close(), and isOpen().

53 {
54  if(isOpen())
55  {
56  close();
57  }
58 }

Member Function Documentation

◆ close()

void ossimGeneralRasterWriter::close ( )
virtual

Generic interface to allow one to close a consumer. For displays this might minimize the window and free up internal pointers for file writers it will make sure the file stream is closed and flushed.

Implements ossimOutputSource.

Definition at line 93 of file ossimGeneralRasterWriter.cpp.

References theOutputStream, and theOwnsStreamFlag.

Referenced by open(), writeFile(), and ~ossimGeneralRasterWriter().

94 {
95  if (theOutputStream)
96  {
97  theOutputStream->flush();
99  {
100  delete theOutputStream;
101  theOwnsStreamFlag = false;
102  }
103  theOutputStream = 0;
104  }
105 }

◆ getExtension()

ossimString ossimGeneralRasterWriter::getExtension ( ) const
virtual

Returns a 3-letter extension from the image type descriptor (theOutputImageType) that can be used for image file extensions.

Parameters
imageTypestring representing image type.
Returns
the 3-letter string extension.

Reimplemented from ossimImageFileWriter.

Definition at line 819 of file ossimGeneralRasterWriter.cpp.

820 {
821  return "ras";
822  //return getInterleaveString();
823 }

◆ getImageTypeList()

void ossimGeneralRasterWriter::getImageTypeList ( std::vector< ossimString > &  imageTypeList) const
virtual

void getImageTypeList(std::vector<ossimString>& imageTypeList)const

Appends this writer image types to list "imageTypeList".

This writer has the following types: general_raster_bip general_raster_bil general_raster_bsq

Parameters
imageTypeListstl::vector<ossimString> list to append to.

Implements ossimImageFileWriter.

Definition at line 825 of file ossimGeneralRasterWriter.cpp.

826 {
827  imageTypeList.push_back(ossimString("general_raster_bip"));
828  imageTypeList.push_back(ossimString("general_raster_bil"));
829  imageTypeList.push_back(ossimString("general_raster_bsq"));
830  imageTypeList.push_back(ossimString("general_raster_bip_envi"));
831  imageTypeList.push_back(ossimString("general_raster_bil_envi"));
832  imageTypeList.push_back(ossimString("general_raster_bsq_envi"));
833 }

◆ getInterleaveString()

ossimString ossimGeneralRasterWriter::getInterleaveString ( ) const
private
Returns
The interleave as a string of either: bil, bip, or bsq

Definition at line 835 of file ossimGeneralRasterWriter.cpp.

References ossimImageFileWriter::theOutputImageType.

836 {
837  ossimString interleaveType = "unknown";
838  if ( (theOutputImageType == "general_raster_bip") ||
839  (theOutputImageType == "general_raster_bip_envi") )
840  {
841  interleaveType = "bip";
842  }
843  else if ( (theOutputImageType == "general_raster_bil") ||
844  (theOutputImageType == "general_raster_bil_envi") )
845  {
846  interleaveType = "bil";
847  }
848  else if ( (theOutputImageType == "general_raster_bsq") ||
849  (theOutputImageType == "general_raster_bsq_envi") )
850  {
851  interleaveType = "bsq";
852  }
853  return interleaveType;
854 }

◆ isOpen()

bool ossimGeneralRasterWriter::isOpen ( ) const
virtual

Implements ossimOutputSource.

Definition at line 60 of file ossimGeneralRasterWriter.cpp.

References theOutputStream.

Referenced by writeFile(), and ~ossimGeneralRasterWriter().

61 {
62  return ( theOutputStream ? true : false );
63 }

◆ loadState()

bool ossimGeneralRasterWriter::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Method to the load (recreate) the state of an object from a keyword list.

Return true if ok or false on error.

Reimplemented from ossimImageFileWriter.

Definition at line 651 of file ossimGeneralRasterWriter.cpp.

References ossimKeywordNames::BYTE_ORDER_KW, ossim::byteOrder(), ossimKeywordNames::FILENAME_KW, ossimKeywordlist::find(), ossimEndian::getSystemEndianType(), ossimKeywordNames::INPUT_RR_LEVEL_KW, ossimImageFileWriter::loadState(), OSSIM_BIG_ENDIAN, OSSIM_LITTLE_ENDIAN, ossimImageFileWriter::setFilename(), theOutputByteOrder, ossimImageFileWriter::theOutputImageType, and theRlevel.

653 {
654  const char* value;
655 
656  value = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
657  if(value)
658  {
659  setFilename(ossimFilename(value));
660  }
661 
662  value = kwl.find(prefix, ossimKeywordNames::INPUT_RR_LEVEL_KW);
663  if(value)
664  {
665  theRlevel = atoi(value);
666  }
667 
668  if(ossimImageFileWriter::loadState(kwl, prefix))
669  {
670  if( (theOutputImageType!="general_raster_bip") &&
671  (theOutputImageType!="general_raster_bil") &&
672  (theOutputImageType!="general_raster_bsq") &&
673  (theOutputImageType!="general_raster_bip_envi") &&
674  (theOutputImageType!="general_raster_bil_envi") &&
675  (theOutputImageType!="general_raster_bsq_envi")
676  )
677  {
678  theOutputImageType = "general_raster_bsq";
679  }
680  }
681  else
682  {
683  return false;
684  }
685  const char* outputByteOrder = kwl.find(prefix, ossimKeywordNames::BYTE_ORDER_KW);
687  if(outputByteOrder)
688  {
689  ossimString byteOrder = outputByteOrder;
690  byteOrder = byteOrder.downcase();
691  if(byteOrder.contains("little"))
692  {
694  }
695  else if(byteOrder.contains("big"))
696  {
698  }
699  }
700 
701  return true;
702 }
static const char * BYTE_ORDER_KW
const char * find(const char *key) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
static const char * INPUT_RR_LEVEL_KW
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
virtual void setFilename(const ossimFilename &file)
static const char * FILENAME_KW

◆ open()

bool ossimGeneralRasterWriter::open ( )
virtual

Allows a generic interface to open a consumer for writing. If you are a display writer then you would probably show the window or init the device context for writing.

Implements ossimOutputSource.

Definition at line 65 of file ossimGeneralRasterWriter.cpp.

References ossimString::c_str(), close(), ossimString::size(), ossimImageFileWriter::theFilename, theOutputStream, and theOwnsStreamFlag.

Referenced by writeFile().

66 {
67  bool result = false;
68 
69  close();
70 
71  // Check for empty filenames.
72  if ( theFilename.size() )
73  {
74  std::ofstream* os = new std::ofstream();
75  os->open(theFilename.c_str(), ios::out | ios::binary);
76 
77  if(os->is_open())
78  {
79  theOutputStream = os;
80  theOwnsStreamFlag = true;
81  result = true;
82  }
83  else
84  {
85  delete os;
86  os = 0;
87  }
88  }
89 
90  return result;
91 }
std::string::size_type size() const
Definition: ossimString.h:405
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
std::basic_ofstream< char > ofstream
Class for char output file streams.
Definition: ossimIosFwd.h:47

◆ saveState()

bool ossimGeneralRasterWriter::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

saves the state of the object.

Reimplemented from ossimImageFileWriter.

Definition at line 640 of file ossimGeneralRasterWriter.cpp.

References ossimKeywordlist::add(), ossimKeywordNames::BYTE_ORDER_KW, OSSIM_LITTLE_ENDIAN, ossimImageFileWriter::saveState(), and theOutputByteOrder.

642 {
643  kwl.add(prefix,
645  ((theOutputByteOrder==OSSIM_LITTLE_ENDIAN)?"little_endian":"big_endian"),
646  true);
648  prefix);
649 }
static const char * BYTE_ORDER_KW
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)

◆ set_rr_level()

virtual void ossimGeneralRasterWriter::set_rr_level ( ossim_uint32  rr)
inlinevirtual

Definition at line 56 of file ossimGeneralRasterWriter.h.

56 { theRlevel = rr; }

◆ setOutputStream()

bool ossimGeneralRasterWriter::setOutputStream ( std::ostream &  stream)
virtual

Sets the output stream to write to.

The stream will not be closed/deleted by this object.

Parameters
outputThe stream to write to.

Reimplemented from ossimImageFileWriter.

Definition at line 856 of file ossimGeneralRasterWriter.cpp.

References theOutputStream, and theOwnsStreamFlag.

857 {
859  {
860  delete theOutputStream;
861  }
862  theOutputStream = &stream;
863  theOwnsStreamFlag = false;
864  return true;
865 }

◆ writeEnviHeader()

void ossimGeneralRasterWriter::writeEnviHeader ( ) const
private

Writes an envi header file which can be used to load file in envi.

If the output image file is "foo.ras" then the ossim header file will be "foo.hdr".

Definition at line 789 of file ossimGeneralRasterWriter.cpp.

Referenced by writeFile().

790 {
791  static const char MODULE[] = "ossimGeneralRasterWriter::writeEnviHeader";
792 
793  if (traceDebug()) CLOG << " Entered..." << endl;
794 
795  if (!theInputConnection)
796  {
797  return;
798  }
799 
800  // Make a header file name from the image file.
801  ossimFilename headerFile = theFilename;
802  headerFile.setExtension(".hdr"); // ossim meta data
803 
804  ossimString interleaveType = getInterleaveString();
805  ossimKeywordlist kwl;
806  kwl.add(ossimKeywordNames::INTERLEAVE_TYPE_KW, interleaveType.c_str());
807 
810  hdr->initialize();
811  hdr->setFilename(headerFile);
812  hdr->loadState(kwl);
814  hdr->execute();
815 
816  if (traceDebug()) CLOG << " Exited..." << endl;
817 }
virtual void setAreaOfInterest(const ossimIrect &areaOfInterest)
Sets the area of interest to write the meta data for.
#define CLOG
Definition: ossimTrace.h:23
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Initializes the state of the writer.
Represents serializable keyword/value map.
ossimIrect theAreaOfInterest
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
static const char * INTERLEAVE_TYPE_KW
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 void setFilename(const ossimFilename &file)
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
Class for writing a "ENVI" style header.

◆ writeFile()

bool ossimGeneralRasterWriter::writeFile ( )
protectedvirtual

Write out the file.

Returns
true on success, false on error.

Implements ossimImageFileWriter.

Definition at line 107 of file ossimGeneralRasterWriter.cpp.

References close(), ossimString::contains(), ossimErrorStatusInterface::getErrorStatus(), ossimImageFileWriter::getSequencer(), ossimImageSourceSequencer::isMaster(), isOpen(), open(), ossimErrorCodes::OSSIM_OK, ossimImageFileWriter::theInputConnection, ossimImageFileWriter::theOutputImageType, ossimRefPtr< T >::valid(), writeEnviHeader(), writeHeader(), and writeStream().

108 {
109  bool result = false;
110 
112  {
113  //---
114  // Make sure we can open the file. Note only the master process is used for
115  // writing...
116  //---
118  {
119  if (!isOpen())
120  {
121  open();
122  }
123  }
124 
125  result = writeStream();
126 
127  if ( result )
128  {
129  // Do this only on the master process. Note left to right precedence!
130  if (getSequencer() && getSequencer()->isMaster())
131  {
132  //---
133  // Write the header out. We do this last since we must
134  // compute min max pixel while we are writting the image.
135  // since the header is an external text file this is Ok
136  // to do.
137  //---
138  writeHeader();
139 
140  if (theOutputImageType.contains("envi"))
141  {
142  writeEnviHeader();
143  }
144  }
145  }
146 
147  close();
148  }
149 
150  return result;
151 
152 } // End: ossimGeneralRasterWriter::writeFile()
virtual bool writeStream()
Method to write the image to a stream.
static const ossimErrorCode OSSIM_OK
bool valid() const
Definition: ossimRefPtr.h:75
bool contains(char aChar) const
Definition: ossimString.h:58
void writeEnviHeader() const
Writes an envi header file which can be used to load file in envi.
virtual ossimImageSourceSequencer * getSequencer()
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
virtual ossimErrorCode getErrorStatus() const
void writeHeader() const
Writes an ossim header file which can be used to load file in ossim.

◆ writeHeader()

void ossimGeneralRasterWriter::writeHeader ( ) const
private

Writes an ossim header file which can be used to load file in ossim.

Returns true on success, false on error.

Definition at line 704 of file ossimGeneralRasterWriter.cpp.

Referenced by writeFile().

705 {
706  static const char MODULE[] = "ossimGeneralRasterWriter::writeHeader";
707 
708  if (traceDebug()) CLOG << " Entered..." << std::endl;
709 
710  // Make a header file name from the image file.
711  ossimFilename headerFile = theFilename;
712  headerFile.setExtension(".omd"); // ossim meta data
713 
714  std::ofstream os;
715  os.open(headerFile.c_str(), ios::out);
716  if (!os)
717  {
718  ossimNotify(ossimNotifyLevel_FATAL) << MODULE << " Error:\n"
719  << "Could not open: " << headerFile << std::endl;
720  return;
721  }
722 
723  ossimString interleaveType = getInterleaveString();
724 
725  ossimString scalar =
727  getOutputScalarType());
728 
729  os << "// *** ossim meta data general raster header file ***\n"
731  << theFilename.file().c_str() << "\n"
733  << getOutputImageTypeString() << "\n"
735  << interleaveType.c_str() << "\n"
739  << (theAreaOfInterest.lr().y - theAreaOfInterest.ul().y + 1) << "\n"
741  << (theAreaOfInterest.lr().x - theAreaOfInterest.ul().x + 1) << "\n"
743  << scalar.c_str() << "\n"
745  << ((theOutputByteOrder==OSSIM_BIG_ENDIAN)?"big_endian":"little_endian")
746  << "\n"
747  << std::endl;
748 
749  // Output the null/min/max for each band.
750  os << "\n// NOTE: Bands are one based, band1 is the first band."
751  << std::endl;
752 
754  {
756  ossimString::toString(i+1) + ".";
757 
759  getNullPixelValue(i));
760  ossimString min_pix;
761  ossimString max_pix;
762 
763  if(!theMinPerBand.size()||!theMaxPerBand.size())
764  {
766  getMinPixelValue(i));
768  getMaxPixelValue(i));
769  }
770  else
771  {
772  min_pix = ossimString::toString(theMinPerBand[i]);
773  max_pix = ossimString::toString(theMaxPerBand[i]);
774  }
775 
776  os << prefix.c_str() << ossimKeywordNames::NULL_VALUE_KW << ": "
777  << null_pix.c_str() << "\n"
778  << prefix << ossimKeywordNames::MIN_VALUE_KW << ": "
779  << min_pix.c_str() << "\n"
780  << prefix << ossimKeywordNames::MAX_VALUE_KW << ": "
781  << max_pix.c_str() << std::endl;
782  }
783 
784  os.close();
785 
786  if (traceDebug()) CLOG << " Exited..." << endl;
787 }
static const char * BYTE_ORDER_KW
static const char * MIN_VALUE_KW
#define CLOG
Definition: ossimTrace.h:23
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual ossimString getEntryString(ossim_int32 entry_number) const
static const char * MAX_VALUE_KW
static const char * NULL_VALUE_KW
ossimIrect theAreaOfInterest
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * NUMBER_LINES_KW
const ossimIpt & ul() const
Definition: ossimIrect.h:274
std::vector< double > theMaxPerBand
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned int ossim_uint32
const ossimIpt & lr() const
Definition: ossimIrect.h:276
static const char * NUMBER_BANDS_KW
static const char * BAND_KW
virtual ossimString getOutputImageTypeString() const
static const char * INTERLEAVE_TYPE_KW
ossim_int32 y
Definition: ossimIpt.h:142
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
static const char * SCALAR_TYPE_KW
ossimFilename file() const
ossim_int32 x
Definition: ossimIpt.h:141
std::basic_ofstream< char > ofstream
Class for char output file streams.
Definition: ossimIosFwd.h:47
static const char * IMAGE_TYPE_KW
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
std::vector< double > theMinPerBand
Populated while writting the data.
static const char * FILENAME_KW
static const char * NUMBER_SAMPLES_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ writeStream()

bool ossimGeneralRasterWriter::writeStream ( )
virtual

Method to write the image to a stream.

Callers must call setOutputStream(...) method prior to this.

Returns
true on success, false on error.

Reimplemented from ossimImageFileWriter.

Definition at line 154 of file ossimGeneralRasterWriter.cpp.

References ossimErrorStatusInterface::getErrorStatus(), ossimImageSourceSequencer::isMaster(), ossimErrorCodes::OSSIM_OK, ossimNotify(), ossimNotifyLevel_FATAL, ossimImageSourceSequencer::slaveProcessTiles(), ossimImageFileWriter::theInputConnection, ossimImageFileWriter::theOutputImageType, theOutputStream, ossimRefPtr< T >::valid(), writeToBil(), writeToBip(), and writeToBsq().

Referenced by writeFile().

155 {
156  static const char MODULE[] = "ossimGeneralRasterWriter::writeStream";
157 
158  bool result = false;
159 
162  {
163  if ( theInputConnection->isMaster() )
164  {
165  // Write the file with the image data.
166  if ( (theOutputImageType == "general_raster_bip") ||
167  (theOutputImageType == "general_raster_bip_envi") )
168  {
169  result = writeToBip();
170  }
171  else if ( (theOutputImageType == "general_raster_bil") ||
172  (theOutputImageType == "general_raster_bil_envi") )
173  {
174  result = writeToBil();
175  }
176  else if ( (theOutputImageType == "general_raster_bsq") ||
177  (theOutputImageType == "general_raster_bsq_envi") )
178  {
179  result = writeToBsq();
180  }
181  else
182  {
184  << MODULE << " ERROR:"
185  << "\nUnsupported output type: " << theOutputImageType << std::endl;
186  result = false;
187  }
188 
189  if ( result )
190  {
191  // Flush the stream to disk...
192  theOutputStream->flush();
193  }
194  }
195  else // Matching else: if ( theInputConnection->isMaster() )
196  {
197  // Slave process:
199  result = true;
200  }
201  }
202 
203  return result;
204 
205 } // End: ossimGeneralRasterWriter::writeStream()
static const ossimErrorCode OSSIM_OK
bool valid() const
Definition: ossimRefPtr.h:75
bool writeToBil()
Writes image data to output file in BIL(Band Interleaved by Line) format.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
bool writeToBsq()
Writes image data to output file in BSQ(Band Sequential) format.
virtual ossimErrorCode getErrorStatus() const
bool writeToBip()
Writes image data to output file in BIP(Band Interleaved by Pixel) format.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ writeToBil()

bool ossimGeneralRasterWriter::writeToBil ( )
private

Writes image data to output file in BIL(Band Interleaved by Line) format.

Returns
true on success, false on error.

Definition at line 354 of file ossimGeneralRasterWriter.cpp.

Referenced by writeStream().

355 {
356  ossimEndian endian;
357  static const char* const MODULE = "ossimGeneralRasterWriter::writeToBil";
358 
359  if (traceDebug()) CLOG << " Entered." << std::endl;
360 
361  //***
362  // Get an arbitrary tile just to get the size in bytes!
363  // This should be changed later... An ossimImageSource should know
364  // this.
365  //***
368 
375  ossim_uint64 bufferSizeInBytes = 0;
376  ossim_uint64 bytesInLine = 0;
377  unsigned char* buffer = NULL;
378 
379  // Start with a clean min/max.
380  theMinPerBand.clear();
381  theMaxPerBand.clear();
382 
384  bool wroteSomethingOut = false;
386  for(ossim_uint64 i = 0; ((i < tilesHigh)&&(!needsAborting())); ++i)
387  {
388  // Clear the buffer.
389  // Clear the buffer.
390  if(buffer)
391  {
392  memset(buffer, 0, bufferSizeInBytes);
393  }
394 
395  ossimIrect bufferRect(theAreaOfInterest.ul().x,
396  theAreaOfInterest.ul().y + i*tileHeight,
397  theAreaOfInterest.ul().x + (width - 1),
398  theAreaOfInterest.ul().y + i *
399  tileHeight + (tileHeight - 1));
400 
401  // Tile loop in the sample (width) direction.
402  for(ossim_uint64 j = 0; ((j < tilesWide)&&(!needsAborting())); ++j)
403  {
404  // Get the tile and copy it to the buffer.
406  if(id.valid())
407  {
409 
410  if(!buffer)
411  {
412  bytesInLine = id->getScalarSizeInBytes() * width;
413 
414  // Buffer to hold one line x tileHeight
415  bufferSizeInBytes = bytesInLine * tileHeight * bands;
416  buffer = new unsigned char[bufferSizeInBytes];
417  memset(buffer, 0, bufferSizeInBytes);
418  }
419  id->unloadTile(buffer,
420  bufferRect,
421  OSSIM_BIL);
422  }
423  ++tileNumber;
424  }
425 
426  // Get the number of lines to write from the buffer.
427  ossim_uint64 linesToWrite =
428  min(tileHeight,
429  static_cast<ossim_uint64>(theAreaOfInterest.lr().y -
430  bufferRect.ul().y + 1));
431 
432  // Write the buffer out to disk.
433  ossim_uint8* buf = buffer;
434  for (ossim_uint64 ii=0; ((ii<linesToWrite)&(!needsAborting())); ++ii)
435  {
436  for (ossim_uint64 band = 0;
437  ((band < bands)&&(!needsAborting()));
438  ++band)
439  {
440  wroteSomethingOut = true;
442  {
443  endian.swap(scalarType,
444  buf,
445  bytesInLine/ossim::scalarSizeInBytes(scalarType));
446  }
447  theOutputStream->write((char*)buf, bytesInLine);
448  if (theOutputStream->fail())
449  {
451  << MODULE << " ERROR:"
452  << "Error returned writing line!" << std::endl;
453  setErrorStatus();
454  if(buffer)
455  {
456  // Free the memory.
457  delete [] buffer;
458  }
459  return false;
460  }
461 
462  buf += bytesInLine;
463  }
464 
465  } // End of loop to write lines from buffer to tiff file.
466 
467  double tile = tileNumber;
468  double numTiles = numberOfTiles;
469  setPercentComplete(tile / numTiles * 100);
470 
471  if(needsAborting())
472  {
473  setPercentComplete(100.0);
474  }
475 
476  } // End of loop in the line (height) direction.
477 
478  if(buffer)
479  {
480  // Free the memory.
481  delete [] buffer;
482  }
483 
484  if (traceDebug()) CLOG << " Exited." << std::endl;
485 
486  return wroteSomethingOut;
487 }
#define CLOG
Definition: ossimTrace.h:23
ossim_uint32 tileNumber
virtual void computeMinMaxPix(std::vector< ossim_float64 > &minBands, std::vector< ossim_float64 > &maxBands) const
If the minBands and maxBands are empty or not equal to the imageData&#39;s current number of bands it wil...
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
ossimIrect theAreaOfInterest
const ossimIpt & ul() const
Definition: ossimIrect.h:274
std::vector< double > theMaxPerBand
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned long long ossim_uint64
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
const ossimIpt & lr() const
Definition: ossimIrect.h:276
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
ossimScalarType
ossim_int64 getNumberOfTilesHorizontal() const
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
virtual void setPercentComplete(double percentComplete)
std::vector< double > theMinPerBand
Populated while writting the data.
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_int64 getNumberOfTilesVertical() const
#define min(a, b)
Definition: auxiliary.h:75

◆ writeToBip()

bool ossimGeneralRasterWriter::writeToBip ( )
private

Writes image data to output file in BIP(Band Interleaved by Pixel) format.

Returns
true on success, false on error.

Definition at line 207 of file ossimGeneralRasterWriter.cpp.

Referenced by writeStream().

208 {
209  ossimEndian endian;
210  static const char* const MODULE = "ossimGeneralRasterWriter::writeToBip";
211 
212  if (traceDebug()) CLOG << " Entered." << std::endl;
213 
214 
215  //---
216  // Get an arbitrary tile just to get the size in bytes!
217  // This should be changed later... An ossimImageSource should know
218  // this.
219  //---
221 
222  // Start the sequence at the first tile.
224 
231 
232  if (traceDebug())
233  {
235  << "\nossimGeneralRasterWriter::writeToBip DEBUG:"
236  << "\nbands: " << bands
237  << "\ntilesWide: " << tilesWide
238  << "\ntilesHigh: " << tilesHigh
239  << "\ntileHeight: " << tileHeight
240  << "\nnumberOfTiles: " << numberOfTiles
241  << "\nwidth: " << width
242  << std::endl;
243  }
244 
245  //---
246  // Buffer to hold one line x tileHeight
247  //---
248  ossim_uint64 bufferSizeInBytes = 0;
249  ossim_uint64 bytesInLine = 0;
250  unsigned char* buffer = NULL;
251 
252  theMinPerBand.clear();
253  theMaxPerBand.clear();
255  bool wroteSomethingOut = false;
257  for(ossim_uint64 i = 0; ((i < tilesHigh)&&(!needsAborting())); ++i)
258  {
259  // Clear the buffer.
260  if(buffer)
261  {
262  memset(buffer, 0, bufferSizeInBytes);
263  }
264 
265  ossimIrect bufferRect(theAreaOfInterest.ul().x,
266  theAreaOfInterest.ul().y + i*tileHeight,
267  theAreaOfInterest.ul().x + (width - 1),
268  theAreaOfInterest.ul().y + i*tileHeight + (tileHeight - 1));
269  // Tile loop in the sample (width) direction.
270  for(ossim_uint64 j = 0; ((j < tilesWide)&&(!needsAborting())); ++j)
271  {
272  // Get the tile and copy it to the buffer.
274  if(id.valid())
275  {
277  if(!buffer)
278  {
279  bytesInLine = id->getScalarSizeInBytes() * width * bands;
280 
281  //---
282  // Buffer to hold one line x tileHeight
283  //---
284  bufferSizeInBytes = bytesInLine * tileHeight;
285  buffer = new unsigned char[bufferSizeInBytes];
286  memset(buffer, 0, bufferSizeInBytes);
287  }
288  id->unloadTile(buffer,
289  bufferRect,
290  OSSIM_BIP);
291  }
292  ++tileNumber;
293  }
294 
295  // Get the number of lines to write from the buffer.
296  ossim_uint64 linesToWrite =
297  min(tileHeight,
298  static_cast<ossim_uint64>(theAreaOfInterest.lr().y -
299  bufferRect.ul().y + 1));
300  // Write the buffer out to disk.
301  ossim_uint8* buf = buffer;
302  if(buf)
303  {
304  for (ossim_uint64 ii=0; ((ii<linesToWrite)&&(!needsAborting())); ++ii)
305  {
306  std::streamsize lineBytes = bytesInLine;
307  wroteSomethingOut = true;
308 
310  {
311  endian.swap(scalarType,
312  buf,
313  lineBytes/ossim::scalarSizeInBytes(scalarType));
314  }
315  theOutputStream->write((char*)buf, lineBytes);
316  if (theOutputStream->fail())
317  {
319  << MODULE << " ERROR:"
320  << "Error returned writing line!" << std::endl;
321  setErrorStatus();
322  if(buffer)
323  {
324  // Free the memory.
325  delete [] buffer;
326  }
327  return false;
328  }
329 
330  buf += bytesInLine;
331 
332  } // End of loop to write lines from buffer to tiff file.
333  }
334  double tile = tileNumber;
335  double numTiles = numberOfTiles;
336  setPercentComplete(tile / numTiles * 100);
337  if(needsAborting())
338  {
339  setPercentComplete(100.0);
340  }
341 
342  } // End of loop in the line (height) direction.
343  if(buffer)
344  {
345  // Free the memory.
346  delete [] buffer;
347  }
348 
349  if (traceDebug()) CLOG << " Exited." << std::endl;
350 
351  return wroteSomethingOut;
352 }
#define CLOG
Definition: ossimTrace.h:23
ossim_uint32 tileNumber
virtual void computeMinMaxPix(std::vector< ossim_float64 > &minBands, std::vector< ossim_float64 > &maxBands) const
If the minBands and maxBands are empty or not equal to the imageData&#39;s current number of bands it wil...
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
ossimIrect theAreaOfInterest
const ossimIpt & ul() const
Definition: ossimIrect.h:274
std::vector< double > theMaxPerBand
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned long long ossim_uint64
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
const ossimIpt & lr() const
Definition: ossimIrect.h:276
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
ossimScalarType
ossim_int64 getNumberOfTilesHorizontal() const
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
virtual void setPercentComplete(double percentComplete)
std::vector< double > theMinPerBand
Populated while writting the data.
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_int64 getNumberOfTilesVertical() const
#define min(a, b)
Definition: auxiliary.h:75

◆ writeToBsq()

bool ossimGeneralRasterWriter::writeToBsq ( )
private

Writes image data to output file in BSQ(Band Sequential) format.

Returns
true on success, false on error.

Definition at line 489 of file ossimGeneralRasterWriter.cpp.

Referenced by writeStream().

490 {
491  ossimEndian endian;
492  static const char* const MODULE = "ossimGeneralRasterWriter::writeToBsq";
493 
494  if (traceDebug()) CLOG << " Entered." << std::endl;
495 
496  //***
497  // Get an arbitrary tile just to get the size in bytes!
498  // This should be changed later... An ossimImageSource should know
499  // this.
500  //***
502 
503  // Start the sequence at the first tile.
505 
513 
514  ossim_uint64 bytesInLine = 0;
515  ossim_uint64 buf_band_offset = 0;
516 
517  // Use the system "streampos" typedef for future 64 bit seeks (long long).
518  streampos file_band_offset = 0;
519 
520  //***
521  // Buffer to hold one line x tileHeight
522  //***
523  ossim_uint64 bufferSizeInBytes = 0;
524  unsigned char* buffer = NULL;
525 
526  theMinPerBand.clear();
527  theMaxPerBand.clear();
528 
530  bool wroteSomethingOut = false;
532  for(ossim_uint64 i = 0; ((i < tilesHigh)&&(!needsAborting())); ++i)
533  {
534  if(buffer)
535  {
536  // Clear the buffer.
537  memset(buffer, 0, bufferSizeInBytes);
538  }
539 
540  ossimIrect bufferRect(theAreaOfInterest.ul().x,
541  theAreaOfInterest.ul().y + i*tileHeight,
542  theAreaOfInterest.ul().x + (width - 1),
543  theAreaOfInterest.ul().y + i *
544  tileHeight + (tileHeight - 1));
545 
546  // Tile loop in the sample (width) direction.
547  for(ossim_uint64 j = 0; ((j < tilesWide)&&(!needsAborting())); ++j)
548  {
549  // Get the tile and copy it to the buffer.
551  if(id.valid())
552  {
554  if(!buffer)
555  {
556  bytesInLine = id->getScalarSizeInBytes() * width;
557  buf_band_offset = bytesInLine * tileHeight;
558  file_band_offset = height * bytesInLine;
559  bufferSizeInBytes = bytesInLine * tileHeight * bands;
560  buffer = new unsigned char[bufferSizeInBytes];
561  memset(buffer, 0, bufferSizeInBytes);
562  }
563  id->unloadTile(buffer,
564  bufferRect,
565  OSSIM_BSQ);
566  }
567  ++tileNumber;
568  }
569 
570  // Get the number of lines to write from the buffer.
571  ossim_uint64 linesToWrite =
572  min(tileHeight,
573  static_cast<ossim_uint64>(theAreaOfInterest.lr().y -
574  bufferRect.ul().y + 1));
575 
576  // Write the buffer out to disk.
577  ossim_uint64 start_line =
578  static_cast<ossim_uint64>(bufferRect.ul().y -
580  for (ossim_uint64 band = 0; ((band < bands)&&(!needsAborting())); ++band)
581  {
582  ossim_uint8* buf = buffer;
583  buf += buf_band_offset * band;
584 
585  // Put the file pointer in the right spot.
586  streampos pos = file_band_offset * band + start_line * bytesInLine;
587  theOutputStream->seekp(pos, ios::beg);
588  if (theOutputStream->fail())
589  {
590  ossimNotify(ossimNotifyLevel_FATAL) << MODULE << " ERROR:"
591  << "Error returned seeking to image data position!" << std::endl;
592  setErrorStatus();
593  return false;
594  }
595 
596  for (ossim_uint64 ii=0; ((ii<linesToWrite)&&(!needsAborting())); ++ii)
597  {
598  wroteSomethingOut = true;
600  {
601  endian.swap(scalarType,
602  buf,
603  bytesInLine/ossim::scalarSizeInBytes(scalarType));
604  }
605 
606  theOutputStream->write((char*)buf, bytesInLine);
607 
608  if (theOutputStream->fail())
609  {
610  ossimNotify(ossimNotifyLevel_FATAL) << MODULE << " ERROR:"
611  << "Error returned writing line!" << std::endl;
612  setErrorStatus();
613  return false;
614  }
615 
616  buf += bytesInLine;
617  }
618 
619  } // End of loop to write lines from buffer to tiff file.
620 
621  double tile = tileNumber;
622  double numTiles = numberOfTiles;
623  setPercentComplete(tile / numTiles * 100);
624 
625  if(needsAborting())
626  {
627  setPercentComplete(100.0);
628  }
629 
630  } // End of loop in the line (height) direction.
631 
632  // Free the memory.
633  delete [] buffer;
634 
635  if (traceDebug()) CLOG << " Exited." << std::endl;
636 
637  return wroteSomethingOut;
638 }
#define CLOG
Definition: ossimTrace.h:23
ossim_uint32 tileNumber
virtual void computeMinMaxPix(std::vector< ossim_float64 > &minBands, std::vector< ossim_float64 > &maxBands) const
If the minBands and maxBands are empty or not equal to the imageData&#39;s current number of bands it wil...
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
ossim_uint32 height() const
Definition: ossimIrect.h:487
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
ossimIrect theAreaOfInterest
const ossimIpt & ul() const
Definition: ossimIrect.h:274
std::vector< double > theMaxPerBand
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned long long ossim_uint64
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
const ossimIpt & lr() const
Definition: ossimIrect.h:276
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
ossimScalarType
ossim_int64 getNumberOfTilesHorizontal() const
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
virtual void setPercentComplete(double percentComplete)
std::vector< double > theMinPerBand
Populated while writting the data.
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_int64 getNumberOfTilesVertical() const
#define min(a, b)
Definition: auxiliary.h:75

Member Data Documentation

◆ theMaxPerBand

std::vector<double> ossimGeneralRasterWriter::theMaxPerBand
private

Definition at line 152 of file ossimGeneralRasterWriter.h.

◆ theMinPerBand

std::vector<double> ossimGeneralRasterWriter::theMinPerBand
private

Populated while writting the data.

Definition at line 151 of file ossimGeneralRasterWriter.h.

◆ theOutputByteOrder

ossimByteOrder ossimGeneralRasterWriter::theOutputByteOrder
private

Definition at line 146 of file ossimGeneralRasterWriter.h.

Referenced by loadState(), ossimGeneralRasterWriter(), and saveState().

◆ theOutputStream

std::ostream* ossimGeneralRasterWriter::theOutputStream
private

Definition at line 143 of file ossimGeneralRasterWriter.h.

Referenced by close(), isOpen(), open(), setOutputStream(), and writeStream().

◆ theOwnsStreamFlag

bool ossimGeneralRasterWriter::theOwnsStreamFlag
private

Definition at line 144 of file ossimGeneralRasterWriter.h.

Referenced by close(), open(), and setOutputStream().

◆ theRlevel

ossim_uint32 ossimGeneralRasterWriter::theRlevel
private

Definition at line 145 of file ossimGeneralRasterWriter.h.

Referenced by loadState().


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