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

#include <ossimGdalWriter.h>

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

Public Types

enum  ossimGdalOverviewType { ossimGdalOverviewType_NONE = 0, ossimGdalOverviewType_NEAREST = 1, ossimGdalOverviewType_AVERAGE = 2 }
 
- 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

 ossimGdalWriter ()
 
virtual ~ossimGdalWriter ()
 
 ossimGdalWriter (ossimImageSource *inputSource, const ossimFilename &filename)
 
virtual void getImageTypeList (std::vector< ossimString > &imageTypeList) const
 void getImageTypeList(std::vector<ossimString>& imageTypeList)const More...
 
virtual bool hasImageType (const ossimString &imageType) const
 bool hasImageType(const ossimString& imageType) 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 bool isOpen () const
 
virtual bool open ()
 
virtual void close ()
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 
virtual void setOutputImageType (const ossimString &type)
 
void setLut (const ossimNBandLutDataObject &lut)
 
- 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 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 writeStream ()
 Method to write the image to a stream. More...
 
virtual bool setOutputStream (ossimRefPtr< ossimOStream > stream)
 Sets the output stream to write to. More...
 
virtual bool setOutputStream (std::ostream &str)
 tmp drb 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 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 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
 

Static Public Member Functions

static void getSupportedWriters (vector< ossimString > &writers)
 

Protected Member Functions

virtual bool writeFile ()
 Write out the file. More...
 
virtual bool writeBlockFile ()
 
virtual void writeProjectionInfo (GDALDatasetH dataset)
 
virtual void writeColorMap (int bands)
 
virtual void setOptions (ossimKeywordlist &kwl, const char *prefix=NULL)
 
void deleteGdalDriverOptions ()
 
ossimString convertToDriverName (const ossimString &imageTypeName) const
 
GDALDataType getGdalDataType (ossimScalarType scalar)
 
void getGdalPropertyNames (std::vector< ossimString > &propertyNames) const
 
const ossimRefPtr< ossimXmlNodegetGdalOptions () const
 
ossim_int32 findOptionIdx (const ossimString &name) const
 
void allocateGdalDriverOptions ()
 
void storeProperty (const ossimString &name, const ossimString &value)
 
bool getStoredPropertyValue (const ossimString &name, ossimString &value) const
 
bool validProperty (const ossimString &name) const
 
ossimString gdalOverviewTypeToString () const
 
ossimGdalOverviewType gdalOverviewTypeFromString (const ossimString &typeString) const
 
void buildGdalOverviews ()
 
void appendGdalOption (const ossimString &name, const ossimString &value, bool replaceFlag=true)
 
void postProcessOutput () const
 Method called after good writeFile to clean up any unwanted files. More...
 
bool isLutEnabled () const
 
void checkColorLut ()
 
bool isInputDataIndexed ()
 Check input to see if it's indexed. 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)
 

Protected Attributes

ossimString theDriverName
 
GDALDriverH theDriver
 
GDALDatasetH theDataset
 
ossimIpt theJpeg2000TileSize
 
ossimKeywordlist theDriverOptionValues
 
char ** theGdalDriverOptions
 
ossimGdalOverviewType theGdalOverviewType
 
bool theColorLutFlag
 
ossimRefPtr< ossimNBandLutDataObjecttheColorLut
 
ossimFilename theLutFilename
 
ossimRefPtr< ossimNBandToIndexFiltertheNBandToIndexFilter
 
- 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 19 of file ossimGdalWriter.h.

Member Enumeration Documentation

◆ ossimGdalOverviewType

Enumerator
ossimGdalOverviewType_NONE 
ossimGdalOverviewType_NEAREST 
ossimGdalOverviewType_AVERAGE 

Definition at line 22 of file ossimGdalWriter.h.

Constructor & Destructor Documentation

◆ ossimGdalWriter() [1/2]

ossimGdalWriter::ossimGdalWriter ( )

Definition at line 59 of file ossimGdalWriter.cpp.

61  theDriverName(""),
62  theDriver((GDALDriverH)0),
63  theDataset((GDALDatasetH)0),
68  theColorLutFlag(false),
69  theColorLut(0),
72 {
73 }
ossimRefPtr< ossimNBandToIndexFilter > theNBandToIndexFilter
GDALDriverH theDriver
ossimFilename theLutFilename
ossimImageFileWriter(const ossimFilename &filename=ossimFilename(), ossimImageSource *inputSource=0, ossimObject *owner=0)
The writer will own the sequencer.
ossimKeywordlist theDriverOptionValues
ossimGdalOverviewType theGdalOverviewType
ossimRefPtr< ossimNBandLutDataObject > theColorLut
ossimString theDriverName
ossimIpt theJpeg2000TileSize
char ** theGdalDriverOptions
GDALDatasetH theDataset

◆ ~ossimGdalWriter()

ossimGdalWriter::~ossimGdalWriter ( )
virtual

Definition at line 75 of file ossimGdalWriter.cpp.

References close(), deleteGdalDriverOptions(), theDataset, and theDriverName.

76 {
78  close();
79  theDataset = 0;
80  theDriverName = "";
81 }
ossimString theDriverName
GDALDatasetH theDataset
virtual void close()

◆ ossimGdalWriter() [2/2]

ossimGdalWriter::ossimGdalWriter ( ossimImageSource inputSource,
const ossimFilename filename 
)

Member Function Documentation

◆ allocateGdalDriverOptions()

void ossimGdalWriter::allocateGdalDriverOptions ( )
protected

Definition at line 895 of file ossimGdalWriter.cpp.

References deleteGdalDriverOptions(), ossimKeywordlist::find(), ossimImageSourceSequencer::getOutputScalarType(), ossimKeywordlist::getSubstringKeyList(), OSSIM_UINT8, theDriverOptionValues, theGdalDriverOptions, ossimImageFileWriter::theInputConnection, ossimString::toDouble(), and ossimRefPtr< T >::valid().

896 {
898  ossimString regExpression = (ossimString("^")+
899  "property[0-9]+");
900  vector<ossimString> keys = theDriverOptionValues.getSubstringKeyList( regExpression );
901 
902  if(keys.size())
903  {
904  ossim_uint32 i = 0;
905  theGdalDriverOptions = new char*[keys.size()+1];
906  for(i = 0 ; i < keys.size(); ++i)
907  {
908  ossimString name = theDriverOptionValues.find(keys[i] +".name");
909  ossimString value = theDriverOptionValues.find(keys[i] +".value");
910 
911  //---
912  // Special hack...
913  //
914  // Lossless compression for non 8 bit data not supported for kakadu.
915  //---
916  if (theInputConnection.valid() && (GDALGetDriverByName("JP2KAK")) && (name == "QUALITY"))
917  {
919  {
920  double d = value.toDouble();
921  if (d >= 99.5)
922  {
923  if (traceDebug())
924  {
926  << "DEBUG:"
927  << "\nLossless quality not valid for non 8 bit data"
928  << "\nResetting to 99.0"
929  << std::endl;
930  }
931 
932  value = "99.0";
933  }
934  }
935  }
936 
937  // ESH 01/2009 -- For HFA handling of SRS's that come from pcs codes:
938  // use new option in HFA driver (gdal-1.6.0). This option forces the
939  // coordinate system tags to be more compatible with ArcGIS. We might
940  // have to add in a check for the pcs code here if that is possible.
941  //---
942  // Special hack...
943  //---
944  if ( (GDALGetDriverByName("HFA")) &&
945  (name == "FORCETOPESTRING") )
946  {
947  value = "TRUE";
948  }
949 
950  ossimString combine = name + "=" + value;
951 
952  theGdalDriverOptions[i] = new char[combine.size() + 1];
953  strcpy(theGdalDriverOptions[i], combine.c_str());
954 
955  if (traceDebug())
956  {
958  << "\nkey: " << keys[i]
959  << "\nname: " << name
960  << "\nvalue: " << value
961  << "\ngdal option: " << combine
962  << std::endl;
963  }
964  }
965  theGdalDriverOptions[keys.size()] = 0;
966  }
967 }
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
void combine(const std::string &left, const std::string &right, char separator, std::string &result)
ossimKeywordlist theDriverOptionValues
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned int ossim_uint32
double toDouble() const
std::vector< ossimString > getSubstringKeyList(const ossimString &regularExpression) const
char ** theGdalDriverOptions
8 bit unsigned integer
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ appendGdalOption()

void ossimGdalWriter::appendGdalOption ( const ossimString name,
const ossimString value,
bool  replaceFlag = true 
)
protected

Definition at line 969 of file ossimGdalWriter.cpp.

References ossimKeywordlist::add(), ossimKeywordlist::find(), ossimKeywordlist::getSubstringKeyList(), theDriverOptionValues, and ossimString::toString().

972 {
973  ossimString regExpression = (ossimString("^")+
974  "property[0-9]+");
975  vector<ossimString> keys = theDriverOptionValues.getSubstringKeyList( regExpression );
976  if(keys.size())
977  {
978  ossim_uint32 i = 0;
979  for(i = 0 ; i < keys.size(); ++i)
980  {
981  ossimString tempName = theDriverOptionValues.find(keys[i] +".name");
982  if(tempName == name)
983  {
984  if(replaceFlag)
985  {
986  theDriverOptionValues.add(keys[i]+".value",
987  value,
988  true);
989  }
990 
991  return;
992  }
993  }
994  }
995  ossimString prefix = "property" + ossimString::toString((ossim_uint32)keys.size()) + ".";
996 
997  theDriverOptionValues.add(prefix,
998  "name",
999  name,
1000  true);
1001  theDriverOptionValues.add(prefix,
1002  "value",
1003  value,
1004  true);
1005 }
const char * find(const char *key) const
static ossimString toString(bool aValue)
Numeric to string methods.
ossimKeywordlist theDriverOptionValues
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
unsigned int ossim_uint32
std::vector< ossimString > getSubstringKeyList(const ossimString &regularExpression) const

◆ buildGdalOverviews()

void ossimGdalWriter::buildGdalOverviews ( )
protected

Definition at line 1794 of file ossimGdalWriter.cpp.

References gdalOverviewTypeToString(), ossimImageSourceSequencer::getBoundingRect(), ossimIrect::height(), ossim::min(), ossimNotify(), ossimNotifyLevel_WARN, theDataset, ossimImageFileWriter::theInputConnection, and ossimIrect::width().

1795 {
1796 
1797  if(!theDataset)
1798  {
1799  return;
1800  }
1802 
1803  ossim_uint32 minValue = ossim::min((ossim_uint32)bounds.width(),
1804  (ossim_uint32)bounds.height());
1805 
1806  int nLevels = static_cast<int>(std::log((double)minValue)/std::log(2.0));
1807  int idx = 0;
1808  if(nLevels)
1809  {
1810  ossim_int32* levelsPtr = new ossim_int32[nLevels];
1811  *levelsPtr = 2;
1812  for(idx = 1; idx < nLevels;++idx)
1813  {
1814  levelsPtr[idx] = levelsPtr[idx-1]*2;
1815  }
1816  if(GDALBuildOverviews(theDataset,
1817  gdalOverviewTypeToString().c_str(),
1818  nLevels,
1819  levelsPtr,
1820  0,
1821  0,
1822  GDALTermProgress,
1823  0)!=CE_None)
1824  {
1825  ossimNotify(ossimNotifyLevel_WARN) << "ossimGdalWriter::buildGdalOverviews(): Overview building failed"
1826  << std::endl;
1827  }
1828  delete [] levelsPtr;
1829  }
1830 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
ossimString gdalOverviewTypeToString() const
unsigned int ossim_uint32
T min(T a, T b)
Definition: ossimCommon.h:203
ossim_uint32 width() const
Definition: ossimIrect.h:500
GDALDatasetH theDataset
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ checkColorLut()

void ossimGdalWriter::checkColorLut ( )
protected

Definition at line 264 of file ossimGdalWriter.cpp.

References ossimConnectableContainerInterface::findAllObjectsOfType(), ossimRefPtr< T >::get(), ossimConnectableObject::getInputList(), ossimImageHandler::getLut(), ossimImageHandler::hasLut(), PTR_CAST, setLut(), STATIC_TYPE_INFO, and ossimImageFileWriter::theInputConnection.

265 {
266  bool needColorLut = false;
267  bool needLoop = true;
270  if (imageInputs.size() > 0)
271  {
272  for (ossim_uint32 i = 0; i < imageInputs.size(); i++)
273  {
274  if (needLoop == false)
275  {
276  break;
277  }
278  ossimImageChain* source = PTR_CAST(ossimImageChain, imageInputs[i].get());
279  if (source)
280  {
282  for (ossim_uint32 j = 0; j < imageChains.size(); j++)
283  {
284  if (needLoop == false)
285  {
286  break;
287  }
288  ossimImageChain* imageChain = PTR_CAST(ossimImageChain, imageChains[j].get());
289  if (imageChain)
290  {
293 
294  for (ossim_uint32 h= 0; h < imageHandlers.size(); h++)
295  {
296  ossimImageHandler* handler =
297  PTR_CAST(ossimImageHandler, imageHandlers[h].get());
298  if (handler)
299  {
300  if (handler->hasLut() != 0) //
301  {
302  colorLut = handler->getLut();
303  needColorLut = true;
304  }
305  else //if not all handlers have color luts, ignore the color lut.
306  {
307  needColorLut = false;
308  needLoop = false;
309  break;
310  }
311  }
312  }
313  }
314  }
315  }
316  }
317  }
318 
319  if (needColorLut && colorLut )
320  {
321  setLut(*colorLut.get());
322  }
323 }
virtual ossimRefPtr< ossimNBandLutDataObject > getLut() const
void setLut(const ossimNBandLutDataObject &lut)
virtual ossimConnectableObject::ConnectableObjectList findAllObjectsOfType(const RTTItypeid &typeInfo, bool recurse=true)=0
const ConnectableObjectList & getInputList() const
std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned int ossim_uint32
#define STATIC_TYPE_INFO(T)
Definition: ossimRtti.h:319
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual bool hasLut() const

◆ close()

void ossimGdalWriter::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 101 of file ossimGdalWriter.cpp.

References theDataset.

Referenced by ~ossimGdalWriter().

102 {
103  if(theDataset)
104  {
105  GDALClose(theDataset);
106  theDataset = 0;
107  }
108 }
GDALDatasetH theDataset

◆ convertToDriverName()

ossimString ossimGdalWriter::convertToDriverName ( const ossimString imageTypeName) const
protected

Definition at line 1026 of file ossimGdalWriter.cpp.

References ossimString::c_str(), and ossimString::substitute().

Referenced by getExtension(), getGdalOptions(), getGdalPropertyNames(), open(), and setProperty().

1027 {
1028  ossimString strippedName = imageTypeName;
1029  strippedName = strippedName.substitute("gdal_", "");
1030  if(GDALGetDriverByName(strippedName.c_str()))
1031  {
1032  return strippedName;
1033  }
1034 
1035  // check for mime types
1036  //
1037  if(imageTypeName == "image/jp2")
1038  {
1039  if(GDALGetDriverByName("JP2KAK"))
1040  {
1041  return "JP2KAK";
1042  }
1043  else if(GDALGetDriverByName("JPEG2000"))
1044  {
1045  return "JPEG2000";
1046  }
1047  else if(GDALGetDriverByName("JP2MrSID"))
1048  {
1049  return "JP2MrSID";
1050  }
1051  }
1052  if(imageTypeName == "image/png")
1053  {
1054  return "PNG";
1055  }
1056  if(imageTypeName == "image/wbmp")
1057  {
1058  return "BMP";
1059  }
1060  if(imageTypeName == "image/bmp")
1061  {
1062  return "BMP";
1063  }
1064  if(imageTypeName == "image/jpeg")
1065  {
1066  return "JPEG";
1067  }
1068  if(imageTypeName == "image/gif")
1069  {
1070  return "GIF";
1071  }
1072 
1073 
1074  // keep these for backward compatibility
1075  //
1076  if( imageTypeName == "gdal_imagine_hfa")
1077  {
1078  return "HFA";
1079  }
1080  if(imageTypeName == "gdal_nitf_rgb_band_separate")
1081  {
1082  return "NITF";
1083  }
1084  if(imageTypeName == "gdal_jpeg2000")
1085  {
1086  if(GDALGetDriverByName("JP2KAK"))
1087  {
1088  return "JP2KAK";
1089  }
1090  else if(GDALGetDriverByName("JPEG2000"))
1091  {
1092  return "JPEG2000";
1093  }
1094  else if(GDALGetDriverByName("JP2MrSID"))
1095  {
1096  return "JP2MrSID";
1097  }
1098  }
1099  if(imageTypeName == "gdal_arc_info_aig")
1100  {
1101  return "AIG";
1102  }
1103  if(imageTypeName == "gdal_arc_info_gio")
1104  {
1105  return "GIO";
1106  }
1107  if(imageTypeName == "gdal_arc_info_ascii_grid")
1108  {
1109  return "AAIGrid";
1110  }
1111  if(imageTypeName == "gdal_mrsid")
1112  {
1113  return "MrSID";
1114  }
1115  if(imageTypeName == "gdal_jp2mrsid")
1116  {
1117  return "JP2MrSID";
1118  }
1119  if(imageTypeName == "gdal_png")
1120  {
1121  return "PNG";
1122  }
1123  if(imageTypeName == "gdal_jpeg")
1124  {
1125  return "JPEG";
1126  }
1127 
1128  if(imageTypeName == "gdal_gif")
1129  {
1130  return "GIF";
1131  }
1132  if(imageTypeName == "gdal_dted")
1133  {
1134  return "DTED";
1135  }
1136  if(imageTypeName == "gdal_usgsdem")
1137  {
1138  return "USGSDEM";
1139  }
1140  if(imageTypeName == "gdal_bmp")
1141  {
1142  return "BMP";
1143  }
1144  if(imageTypeName == "gdal_raw_envi")
1145  {
1146  return "ENVI";
1147  }
1148  if(imageTypeName == "gdal_raw_esri")
1149  {
1150  return "EHdr";
1151  }
1152  if(imageTypeName == "gdal_raw_pci")
1153  {
1154  return "PAux";
1155  }
1156  if(imageTypeName == "gdal_pcidsk")
1157  {
1158  return "PCIDSK";
1159  }
1160  if(imageTypeName == "gdal_sdts")
1161  {
1162  return "SDTS";
1163  }
1164  if(imageTypeName == "gdal_jp2ecw")
1165  {
1166  return "JP2ECW";
1167  }
1168  if(imageTypeName == "gdal_ecw")
1169  {
1170  return "ECW";
1171  }
1172  return imageTypeName;
1173 }
ossimString substitute(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
Substitutes searchKey string with replacementValue and returns a string.
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

◆ deleteGdalDriverOptions()

void ossimGdalWriter::deleteGdalDriverOptions ( )
protected

Definition at line 1007 of file ossimGdalWriter.cpp.

References theGdalDriverOptions.

Referenced by allocateGdalDriverOptions(), and ~ossimGdalWriter().

1008 {
1009  int i = 0;
1010 
1012  {
1013  char* currentOption = theGdalDriverOptions[i];
1014 
1015  while(currentOption)
1016  {
1017  ++i;
1018  delete [] currentOption;
1019  currentOption = theGdalDriverOptions[i];
1020  }
1021  delete [] theGdalDriverOptions;
1023  }
1024 }
char ** theGdalDriverOptions

◆ findOptionIdx()

ossim_int32 ossimGdalWriter::findOptionIdx ( const ossimString name) const
protected

◆ gdalOverviewTypeFromString()

ossimGdalWriter::ossimGdalOverviewType ossimGdalWriter::gdalOverviewTypeFromString ( const ossimString typeString) const
protected

Definition at line 1776 of file ossimGdalWriter.cpp.

References ossimString::downcase(), ossimGdalOverviewType_AVERAGE, ossimGdalOverviewType_NEAREST, ossimGdalOverviewType_NONE, and ossimString::trim().

Referenced by setProperty().

1777 {
1778  ossimString tempType = typeString;
1779  tempType = tempType.downcase();
1780  tempType = tempType.trim();
1781 
1782  if(tempType == "nearest")
1783  {
1785  }
1786  else if(tempType == "average")
1787  {
1789  }
1790 
1792 }
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48

◆ gdalOverviewTypeToString()

ossimString ossimGdalWriter::gdalOverviewTypeToString ( ) const
protected

Definition at line 1755 of file ossimGdalWriter.cpp.

References ossimGdalOverviewType_AVERAGE, ossimGdalOverviewType_NEAREST, ossimGdalOverviewType_NONE, and theGdalOverviewType.

Referenced by buildGdalOverviews().

1756 {
1757  switch(theGdalOverviewType)
1758  {
1760  {
1761  return "none";
1762  }
1764  {
1765  return "nearest";
1766  }
1768  {
1769  return "average";
1770  }
1771  }
1772 
1773  return "none";
1774 }
ossimGdalOverviewType theGdalOverviewType

◆ getExtension()

ossimString ossimGdalWriter::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 1245 of file ossimGdalWriter.cpp.

References ossimString::c_str(), convertToDriverName(), ossimString::downcase(), ossimString::split(), and ossimImageFileWriter::theOutputImageType.

1246 {
1247  ossimString result;
1248 
1250  GDALDriverH driver = GDALGetDriverByName(driverName.c_str());
1251 
1252  if(driver)
1253  {
1254  result = ossimString(GDALGetMetadataItem(driver, GDAL_DMD_EXTENSION, 0));
1255  std::vector<ossimString> splitString;
1256  result.split(splitString, "/");
1257  if(!splitString.empty()) result = splitString[0];
1258  }
1259  return result;
1260 
1261  // we now use the metadata interface to get access to a drivers default file extension
1262 #if 0
1263  ossimString imgTypeStr(theOutputImageType);
1264  imgTypeStr.downcase();
1265 
1266  // mime types
1267  if(imgTypeStr == "image/jp2")
1268  {
1269  return ossimString("jp2");
1270  }
1271  if(imgTypeStr == "image/png")
1272  {
1273  return ossimString("png");
1274  }
1275  if(imgTypeStr == "image/wbmp")
1276  {
1277  return ossimString("bmp");
1278  }
1279  if(imgTypeStr == "image/bmp")
1280  {
1281  return ossimString("bmp");
1282  }
1283  if(imgTypeStr == "image/jpeg")
1284  {
1285  return ossimString("jpg");
1286  }
1287  if(imgTypeStr == "image/gif")
1288  {
1289  return ossimString("gif");
1290  }
1291 
1292 
1293  // keep these for backward compatibility
1294  //
1295  if( imgTypeStr == "gdal_imagine_hfa")
1296  {
1297  return ossimString("hfa");
1298  }
1299  if(imgTypeStr == "gdal_nitf_rgb_band_separate")
1300  {
1301  return ossimString("ntf");
1302  }
1303  if(imgTypeStr == "gdal_jpeg2000")
1304  {
1305  return ossimString("jp2");
1306  }
1307  if(imgTypeStr == "gdal_arc_info_aig")
1308  {
1309  return ossimString("aig");
1310  }
1311  if(imgTypeStr == "gdal_arc_info_gio")
1312  {
1313  return ossimString("gio");
1314  }
1315  if(imgTypeStr == "gdal_arc_info_ascii_grid")
1316  {
1317  return ossimString("aig");
1318  }
1319  if(imgTypeStr == "gdal_mrsid")
1320  {
1321  return ossimString("sid");
1322  }
1323  if(imgTypeStr == "gdal_jp2mrsid")
1324  {
1325  return ossimString("jp2");
1326  }
1327  if(imgTypeStr == "gdal_png")
1328  {
1329  return ossimString("png");
1330  }
1331  if(imgTypeStr == "gdal_jpeg")
1332  {
1333  return ossimString("jpg");
1334  }
1335 
1336  if(imgTypeStr == "gdal_gif")
1337  {
1338  return ossimString("gif");
1339  }
1340  if(imgTypeStr == "gdal_dted")
1341  {
1342  return ossimString("dte");
1343  }
1344  if(imgTypeStr == "gdal_usgsdem")
1345  {
1346  return ossimString("dem");
1347  }
1348  if(imgTypeStr == "gdal_bmp")
1349  {
1350  return ossimString("bmp");
1351  }
1352  if(imgTypeStr == "gdal_raw_envi")
1353  {
1354  return ossimString("raw");
1355  }
1356  if(imgTypeStr == "gdal_raw_esri")
1357  {
1358  return ossimString("raw");
1359  }
1360  if(imgTypeStr == "gdal_raw_pci")
1361  {
1362  return ossimString("raw");
1363  }
1364  if(imgTypeStr == "gdal_pcidsk")
1365  {
1366  return ossimString("pix");
1367  }
1368  if(imgTypeStr == "gdal_sdts")
1369  {
1370  return ossimString("sdt");
1371  }
1372  if(imgTypeStr == "gdal_jp2ecw")
1373  {
1374  return ossimString("jp2");
1375  }
1376  if(imgTypeStr == "gdal_ecw")
1377  {
1378  return ossimString("ecw");
1379  }
1380  return ossimString("ext");
1381 #endif
1382 }
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.
ossimString convertToDriverName(const ossimString &imageTypeName) 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

◆ getGdalDataType()

GDALDataType ossimGdalWriter::getGdalDataType ( ossimScalarType  scalar)
protected

Definition at line 854 of file ossimGdalWriter.cpp.

References OSSIM_DOUBLE, OSSIM_FLOAT, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SSHORT16, OSSIM_UCHAR, OSSIM_USHORT11, and OSSIM_USHORT16.

855 {
856  GDALDataType dataType = GDT_Unknown;
857 
858  switch(scalar)
859  {
860  case OSSIM_UCHAR:
861  {
862  dataType = GDT_Byte;
863  break;
864  }
865  case OSSIM_USHORT11:
866  case OSSIM_USHORT16:
867  {
868  dataType = GDT_UInt16;
869  break;
870  }
871  case OSSIM_SSHORT16:
872  {
873  dataType = GDT_Int16;
874  break;
875  }
876  case OSSIM_FLOAT:
878  {
879  dataType = GDT_Float32;
880  break;
881  }
882  case OSSIM_DOUBLE:
884  {
885  dataType = GDT_Float64;
886  break;
887  }
888  default:
889  break;
890  }
891 
892  return dataType;
893 }
32 bit normalized floating point
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
32 bit floating point
16 bit unsigned iteger
64 bit floating point
16 bit signed integer
8 bit unsigned iteger

◆ getGdalOptions()

const ossimRefPtr< ossimXmlNode > ossimGdalWriter::getGdalOptions ( ) const
protected

Definition at line 1655 of file ossimGdalWriter.cpp.

References ossimString::c_str(), convertToDriverName(), ossimXmlNode::findChildNodes(), and ossimImageFileWriter::theOutputImageType.

Referenced by getGdalPropertyNames().

1656 {
1658  GDALDriverH driver = GDALGetDriverByName(driverName.c_str());
1659 
1660  if(driver)
1661  {
1662  const char* metaData = GDALGetMetadataItem(driver, GDAL_DMD_CREATIONOPTIONLIST, 0);
1663  if(metaData)
1664  {
1665  istringstream in(metaData);
1666  ossimRefPtr<ossimXmlNode> node = new ossimXmlNode(in);
1667  vector<ossimRefPtr<ossimXmlNode> > nodelist;
1668  node->findChildNodes("Option", nodelist);
1669  if(nodelist.size())
1670  {
1671  return node;
1672  }
1673  }
1674  }
1675  return 0;
1676 }
void findChildNodes(const ossimString &rel_xpath, ossimXmlNode::ChildListType &nodelist) const
ossimString convertToDriverName(const ossimString &imageTypeName) 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
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32

◆ getGdalPropertyNames()

void ossimGdalWriter::getGdalPropertyNames ( std::vector< ossimString > &  propertyNames) const
protected

Definition at line 1614 of file ossimGdalWriter.cpp.

References ossimString::c_str(), convertToDriverName(), ossimXmlNode::findChildNodes(), getGdalOptions(), ossimImageFileWriter::theOutputImageType, and ossimRefPtr< T >::valid().

Referenced by validProperty().

1615 {
1617  GDALDriverH driver = GDALGetDriverByName(driverName.c_str());
1618 
1619  if(driver)
1620  {
1622 
1623  if(node.valid())
1624  {
1625  vector<ossimRefPtr<ossimXmlNode> > nodelist;
1626  node->findChildNodes("Option", nodelist);
1627 
1628  if(traceDebug())
1629  {
1630  ossimNotify(ossimNotifyLevel_DEBUG) << "GDAL XML PROPERTY LIST" << std::endl
1631  << node.get() << std::endl;
1632  }
1633  ossim_uint32 idx = 0;
1634  for(idx= 0; idx < nodelist.size(); ++idx)
1635  {
1636  ossimRefPtr<ossimXmlAttribute> name = nodelist[idx]->findAttribute("name");
1637  if(name.valid())
1638  {
1639  if(traceDebug())
1640  {
1641  ossimNotify(ossimNotifyLevel_DEBUG) << "Adding property = " << name->getValue() << std::endl;
1642  }
1643  propertyNames.push_back(driverName + "_" + name->getValue());
1644  }
1645  }
1646  }
1647  }
1648  if(traceDebug())
1649  {
1650  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalWriter::getPropertyNames: leaving......." << std::endl;
1651  }
1652 
1653 }
void findChildNodes(const ossimString &rel_xpath, ossimXmlNode::ChildListType &nodelist) const
bool valid() const
Definition: ossimRefPtr.h:75
const ossimString & getValue() const
ossimString convertToDriverName(const ossimString &imageTypeName) const
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
const ossimRefPtr< ossimXmlNode > getGdalOptions() const
unsigned int ossim_uint32
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getImageTypeList()

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

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

Appends this writer image types to list "imageTypeList".

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

Implements ossimImageFileWriter.

Definition at line 1175 of file ossimGdalWriter.cpp.

Referenced by ossimGdalImageWriterFactory::getImageTypeList().

1176 {
1177  int driverCount = GDALGetDriverCount();
1178  int idx = 0;
1179 
1180  for(idx = 0; idx < driverCount; ++idx)
1181  {
1182  GDALDriverH driver = GDALGetDriver(idx);
1183 
1184 
1185  if(driver)
1186  {
1187  const char* metaData = GDALGetMetadataItem(driver, GDAL_DCAP_CREATE, 0);
1188  if(metaData)
1189  {
1190  imageTypeList.push_back("gdal_" + ossimString(GDALGetDriverShortName(driver)));
1191  }
1192  else
1193  {
1194  metaData = GDALGetMetadataItem(driver, GDAL_DCAP_CREATECOPY, 0);
1195  if(metaData)
1196  {
1197  imageTypeList.push_back("gdal_" + ossimString(GDALGetDriverShortName(driver)));
1198  }
1199  }
1200  }
1201  }
1202 }

◆ getProperty()

ossimRefPtr< ossimProperty > ossimGdalWriter::getProperty ( const ossimString name) const
virtual

Reimplemented from ossimImageFileWriter.

Definition at line 1432 of file ossimGdalWriter.cpp.

1433 {
1434 
1435  if(traceDebug())
1436  {
1437  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalWriter::getProperty: entered..." << std::endl;
1438  }
1439 
1440  if(!validProperty(name))
1441  {
1442  return ossimImageFileWriter::getProperty(name);
1443  }
1444 
1445  if(name == "HFA_USE_RRD")
1446  {
1447  return new ossimBooleanProperty(name, ossimString(CPLGetConfigOption(name.c_str(),"NO")).toBool());
1448  }
1449  else if(name == "gdal_overview_type")
1450  {
1452 
1453  prop->addConstraint("none");
1454  prop->addConstraint("nearest");
1455  prop->addConstraint("average");
1456 
1457  return prop;
1458  }
1461  GDALDriverH driver = GDALGetDriverByName(driverName.c_str());
1462  if(traceDebug())
1463  {
1464  ossimNotify(ossimNotifyLevel_DEBUG) << "Driver name = " << driverName << "\n"
1465  << "name = " << name << std::endl;
1466  }
1467 
1468  bool storedValueFlag=false;
1469  ossimString storedValue;
1470 
1471  if(node.valid()&&driver&&name.contains(driverName))
1472  {
1473  ossimString storedName = name;
1474  storedName = storedName.substitute(driverName+"_","");
1475  storedValueFlag = getStoredPropertyValue(storedName,
1476  storedValue);
1477  vector<ossimRefPtr<ossimXmlNode> > nodelist;
1478  node->findChildNodes("Option", nodelist);
1479  ossim_uint32 idx = 0;
1480  for(idx = 0; idx < nodelist.size(); ++idx)
1481  {
1482  ossimRefPtr<ossimXmlAttribute> nameAttribute = nodelist[idx]->findAttribute("name");
1483  if(nameAttribute.valid())
1484  {
1485  if((driverName+"_"+nameAttribute->getValue())== name)
1486  {
1487  ossimRefPtr<ossimXmlAttribute> type = nodelist[idx]->findAttribute("type");
1488 
1489  vector<ossimRefPtr<ossimXmlNode> > valuelist;
1490 
1491  if(type.valid())
1492  {
1493  ossimRefPtr<ossimXmlAttribute> descriptionAttribute = nodelist[idx]->findAttribute("description");
1494  nodelist[idx]->findChildNodes("Value",
1495  valuelist);
1496  ossimString description;
1497  ossimString typeValue = type->getValue();
1498  typeValue = typeValue.downcase();
1499 
1500  if(descriptionAttribute.valid())
1501  {
1502  description = descriptionAttribute->getValue();
1503  }
1504  if((typeValue == "int")||
1505  (typeValue == "integer"))
1506  {
1507  ossimNumericProperty* prop = new ossimNumericProperty(name,
1508  storedValue);
1510  prop->setDescription(description);
1511  return prop;
1512  }
1513  else if(typeValue == "unsigned int")
1514  {
1515  ossimNumericProperty* prop = new ossimNumericProperty(name,
1516  storedValue);
1518  prop->setDescription(description);
1519  return prop;
1520  }
1521  else if(typeValue == "float")
1522  {
1523  ossimNumericProperty* prop = new ossimNumericProperty(name,
1524  storedValue);
1526  prop->setDescription(description);
1527  return prop;
1528  }
1529  else if(typeValue == "boolean")
1530  {
1531  ossimBooleanProperty* prop = new ossimBooleanProperty(name,
1532  storedValue.toBool());
1533 
1534  prop->setDescription(description);
1535  return prop;
1536  }
1537  else if((typeValue == "string-select")||
1538  (typeValue == "string"))
1539  {
1540  ossim_uint32 idx2 = 0;
1541  ossimString defaultValue = "";
1542 
1543  if(storedValueFlag)
1544  {
1545  defaultValue = storedValue;
1546  }
1547  else if(valuelist.size())
1548  {
1549  defaultValue = valuelist[0]->getText();
1550  }
1551  ossimStringProperty* prop = new ossimStringProperty(name,
1552  defaultValue,
1553  false);
1554  for(idx2 = 0; idx2 < valuelist.size();++idx2)
1555  {
1556  prop->addConstraint(valuelist[idx2]->getText());
1557  }
1558  prop->setDescription(description);
1559  return prop;
1560  }
1561  else
1562  {
1563  if(traceDebug())
1564  {
1565  ossimNotify(ossimNotifyLevel_INFO) << "************************TYPE VALUE = " << typeValue << " NOT HANDLED************"<< std::endl;
1566  ossimNotify(ossimNotifyLevel_INFO) << "************************DEFAULTING TO TEXT ************" << std::endl;
1567  }
1568  ossim_uint32 idx2 = 0;
1569  ossimString defaultValue = "";
1570 
1571  if(storedValueFlag)
1572  {
1573  defaultValue = storedValue;
1574  }
1575  else if(valuelist.size())
1576  {
1577  defaultValue = valuelist[0]->getText();
1578  }
1579  ossimStringProperty* prop = new ossimStringProperty(name,
1580  defaultValue,
1581  false);
1582  for(idx2 = 0; idx2 < valuelist.size();++idx2)
1583  {
1584  prop->addConstraint(valuelist[idx2]->getText());
1585  }
1586  prop->setDescription(description);
1587  return prop;
1588  }
1589  }
1590  }
1591  }
1592  }
1593  }
1594 
1595  if(traceDebug())
1596  {
1597  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalWriter::getProperty: entered..." << std::endl;
1598  }
1599  return 0;
1600 }
bool getStoredPropertyValue(const ossimString &name, ossimString &value) const
ossimString substitute(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
Substitutes searchKey string with replacementValue and returns a string.
void findChildNodes(const ossimString &rel_xpath, ossimXmlNode::ChildListType &nodelist) const
bool valid() const
Definition: ossimRefPtr.h:75
bool contains(char aChar) const
Definition: ossimString.h:58
void addConstraint(const ossimString &value)
const ossimString & getValue() const
ossimString convertToDriverName(const ossimString &imageTypeName) const
virtual void setNumericType(ossimNumericPropertyType type)
const ossimRefPtr< ossimXmlNode > getGdalOptions() const
bool toBool() const
String to numeric methods.
ossimString gdalOverviewTypeToString() const
unsigned int ossim_uint32
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
void setDescription(const ossimString &description)
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 validProperty(const ossimString &name) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getPropertyNames()

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

Reimplemented from ossimImageFileWriter.

Definition at line 1602 of file ossimGdalWriter.cpp.

1603 {
1604  if(traceDebug())
1605  {
1606  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalWriter::getPropertyNames: entered......." << std::endl;
1607  }
1609  propertyNames.push_back("gdal_overview_type");
1610  propertyNames.push_back("HFA_USE_RRD");
1611  getGdalPropertyNames(propertyNames);
1612 }
void getGdalPropertyNames(std::vector< ossimString > &propertyNames) const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getStoredPropertyValue()

bool ossimGdalWriter::getStoredPropertyValue ( const ossimString name,
ossimString value 
) const
protected

Definition at line 1711 of file ossimGdalWriter.cpp.

References ossimKeywordlist::find(), ossimKeywordlist::getSubstringKeyList(), and theDriverOptionValues.

1713 {
1714  ossimString regExpression = (ossimString("^") +
1715  "property[0-9]+");
1716 
1717  vector<ossimString> keys = theDriverOptionValues.getSubstringKeyList( regExpression );
1718  ossim_uint32 idx = 0;
1719  for(idx = 0; idx < keys.size(); ++idx)
1720  {
1721  ossimString storedName = theDriverOptionValues.find(keys[idx] +".name");
1722  if(storedName == name)
1723  {
1724  value = ossimString(theDriverOptionValues.find(keys[idx] +".value"));
1725  return true;
1726  }
1727  }
1728 
1729  return false;
1730 }
const char * find(const char *key) const
ossimKeywordlist theDriverOptionValues
unsigned int ossim_uint32
std::vector< ossimString > getSubstringKeyList(const ossimString &regularExpression) const

◆ getSupportedWriters()

void ossimGdalWriter::getSupportedWriters ( vector< ossimString > &  writers)
static

Definition at line 255 of file ossimGdalWriter.cpp.

256 {
257 }

◆ hasImageType()

bool ossimGdalWriter::hasImageType ( const ossimString imageType) const
virtual

bool hasImageType(const ossimString& imageType) const

Parameters
imageTypestring representing image type.
Returns
true if "imageType" is supported by writer.

Reimplemented from ossimImageFileWriter.

Definition at line 1204 of file ossimGdalWriter.cpp.

References ossimImageFileWriter::hasImageType().

Referenced by ossimGdalImageWriterFactory::createWriter().

1205 {
1206  // check for non standard image types found in the
1207  // getImageTypeList
1208  //
1209  if((imageType == "gdal_imagine_hfa") ||
1210  (imageType == "gdal_nitf_rgb_band_separate") ||
1211  (imageType == "gdal_jpeg2000") ||
1212  (imageType == "gdal_jp2ecw") ||
1213  (imageType == "gdal_arc_info_aig") ||
1214  (imageType == "gdal_arc_info_gio") ||
1215  (imageType == "gdal_arc_info_ascii_grid") ||
1216  (imageType == "gdal_mrsid") ||
1217  (imageType == "image/mrsid") ||
1218  (imageType == "gdal_jp2mrsid") ||
1219  (imageType == "image/jp2mrsid") ||
1220  (imageType == "gdal_png") ||
1221  (imageType == "image/png") ||
1222  (imageType == "image/bmp") ||
1223  (imageType == "image/wbmp") ||
1224  (imageType == "gdal_jpeg") ||
1225  (imageType == "image/jpeg") ||
1226  (imageType == "gdal_gif") ||
1227  (imageType == "image/gif") ||
1228  (imageType == "gdal_dted") ||
1229  (imageType == "image/dted") ||
1230  (imageType == "gdal_bmp") ||
1231  (imageType == "gdal_xpm") ||
1232  (imageType == "image/x-xpixmap") ||
1233  (imageType == "gdal_raw_envi") ||
1234  (imageType == "gdal_raw_esri") ||
1235  (imageType == "gdal_raw_esri") ||
1236  (imageType == "gdal_pcidsk") ||
1237  (imageType == "gdal_sdts"))
1238  {
1239  return true;
1240  }
1241 
1242  return ossimImageFileWriter::hasImageType(imageType);
1243 }
virtual bool hasImageType(const ossimString &imageType) const
bool hasImageType(const ossimString& imageType) const

◆ isInputDataIndexed()

bool ossimGdalWriter::isInputDataIndexed ( )
protected

Check input to see if it's indexed.

Returns
True if input data is indexed pallete data, false if not.

Definition at line 1863 of file ossimGdalWriter.cpp.

References ossimImageSource::isIndexedData(), ossimImageFileWriter::theInputConnection, and ossimRefPtr< T >::valid().

1864 {
1865  bool result = false;
1866  if ( theInputConnection.valid() )
1867  {
1868  result = theInputConnection->isIndexedData();
1869  }
1870  return result;
1871 }
virtual bool isIndexedData() const
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageSourceSequencer > theInputConnection

◆ isLutEnabled()

bool ossimGdalWriter::isLutEnabled ( ) const
protected

Definition at line 259 of file ossimGdalWriter.cpp.

References theColorLutFlag.

260 {
261  return (theColorLutFlag);
262 }

◆ isOpen()

bool ossimGdalWriter::isOpen ( ) const
virtual

Implements ossimOutputSource.

Definition at line 83 of file ossimGdalWriter.cpp.

References theDriver.

84 {
85  return (theDriver != 0);
86 }
GDALDriverH theDriver

◆ loadState()

bool ossimGdalWriter::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 181 of file ossimGdalWriter.cpp.

References ossimKeywordlist::find(), and ossimImageFileWriter::loadState().

Referenced by ossimGdalImageWriterFactory::getImageFileWritersByMimeType(), and ossimGdalImageWriterFactory::getImageFileWritersBySuffix().

183 {
184  ossimImageFileWriter::loadState(kwl, prefix);
185 
186  ossimString regExpression = (ossimString("^") +
187  ossimString(prefix) +
188  "property[0-9]+");
189  const char* hfa_use_rrd = kwl.find(prefix, "HFA_USE_RRD");
190 
191  if(hfa_use_rrd)
192  {
193  CPLSetConfigOption("HFA_USE_RRD", hfa_use_rrd);
194  }
195  if (traceDebug())
196  {
198  << "ossimGdalWriter::loadState entered ..."
199  << "\nprefix: " << (prefix?prefix:"null")
200  << "\nregExpression: " << regExpression
201  << "\nkwl:" << kwl << std::endl;
202  }
203  const char* overviewType = kwl.find(prefix, "gdal_overview_type");
204 
205  if(overviewType)
206  {
208  }
209 
210  ossimString newPrefix = ossimString(prefix) + "lut.";
211 
212  const char* colorLutFlag = kwl.find(prefix, "color_lut_flag");
213  if(colorLutFlag)
214  {
215  theColorLutFlag = ossimString(colorLutFlag).toBool();
216  }
217  else
218  {
219  theColorLutFlag = false;
220  }
221 
222  theLutFilename = ossimFilename(kwl.find(prefix, "lut_filename"));
224  if ( theColorLut.valid() == false ) theColorLut = new ossimNBandLutDataObject();
225  if(theLutFilename != "")
226  {
228  }
229  else
230  {
231  theColorLut->loadState(kwl, newPrefix.c_str());
232  }
233 
234  vector<ossimString> keys = kwl.getSubstringKeyList( regExpression );
236 
238 
240  regExpression);
241 
242  if(prefix)
243  {
245  }
246 
247  if (traceDebug())
248  {
250  << "ossimGdalWriter::loadState exiting..." << std::endl;
251  }
252  return true;
253 }
void stripPrefixFromAll(const ossimString &regularExpression)
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossimFilename theLutFilename
ossimKeywordlist theDriverOptionValues
bool toBool() const
String to numeric methods.
ossimGdalOverviewType theGdalOverviewType
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
bool open(const ossimFilename &lutFile)
Reads in an external lut file.
void extractKeysThatMatch(ossimKeywordlist &kwl, const ossimString &regularExpression) const
ossimRefPtr< ossimNBandLutDataObject > theColorLut
std::vector< ossimString > getSubstringKeyList(const ossimString &regularExpression) 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
class ossimNBandLutDataObject
ossimGdalOverviewType gdalOverviewTypeFromString(const ossimString &typeString) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Loads the state of the object by reading in the keywords listed in the save state.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ open()

bool ossimGdalWriter::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 88 of file ossimGdalWriter.cpp.

References ossimString::c_str(), convertToDriverName(), theDriver, theDriverName, and ossimImageFileWriter::theOutputImageType.

89 {
91  theDriver = GDALGetDriverByName(theDriverName.c_str());
92 
93  if(theDriver)
94  {
95  return true;
96  }
97 
98  return false;
99 }
GDALDriverH theDriver
ossimString convertToDriverName(const ossimString &imageTypeName) const
ossimString theDriverName
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

◆ postProcessOutput()

void ossimGdalWriter::postProcessOutput ( ) const
protected

Method called after good writeFile to clean up any unwanted files.

Definition at line 1832 of file ossimGdalWriter.cpp.

References ossimFilename::exists(), ossimNotify(), ossimNotifyLevel_NOTICE, ossimFilename::remove(), theDriver, and ossimImageFileWriter::theFilename.

1833 {
1834  //---
1835  // DRB 20081029
1836  // Trac #419:
1837  //
1838  // The file.aux.xml file contains nodata value keys which is causing view
1839  // issues with ArcMap and Erdas Imagine when null values are present in
1840  // valid image data.
1841  //---
1842  if (theDriver)
1843  {
1844  ossimString driverName = GDALGetDriverShortName(theDriver);
1845  if ( (driverName == "JP2MrSID") || (driverName != "JP2KAK") ||
1846  (driverName == "JPEG2000") )
1847  {
1848  ossimFilename auxXmlFile = theFilename;
1849  auxXmlFile += ".aux.xml";
1850  if ( auxXmlFile.exists() )
1851  {
1852  if ( auxXmlFile.remove() )
1853  {
1855  << "ossimGdalWriter::postProcessOutput NOTICE:"
1856  << "\nFile removed: " << auxXmlFile << std::endl;
1857  }
1858  }
1859  }
1860  }
1861 }
static bool remove(const ossimFilename &pathname)
Removes pathname from filesystem if supported by platform.
GDALDriverH theDriver
bool exists() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ saveState()

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

saves the state of the object.

Reimplemented from ossimImageFileWriter.

Definition at line 125 of file ossimGdalWriter.cpp.

127 {
128 
129  if (traceDebug())
130  {
132  << "ossimGdalWriter::saveState entered ..."
133  << "\nprefix: " << prefix << std::endl;
134  }
135 
136  ossimString rrdOption = CPLGetConfigOption("HFA_USE_RRD","");
137  if(rrdOption != "")
138  {
139  kwl.add(prefix,
140  "HFA_USE_RRD",
141  rrdOption,
142  true);
143  }
144  kwl.add(prefix,
145  "gdal_overview_type",
147  true);
148  kwl.add(prefix, theDriverOptionValues);
149 
150  kwl.add(prefix,
151  "color_lut_flag",
153  true);
154 
155  if(theColorLutFlag)
156  {
157  if(theLutFilename != "")
158  {
159  kwl.add(prefix,
160  "lut_filename",
162  true);
163  }
164  else
165  {
166  if ( theColorLut.valid() )
167  {
168  ossimString newPrefix = ossimString(prefix) + "lut.";
169  theColorLut->saveState(kwl, newPrefix.c_str());
170  }
171  }
172  }
173 
174  return ossimImageFileWriter::saveState(kwl, prefix);
175 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
ossimFilename theLutFilename
ossimKeywordlist theDriverOptionValues
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossimString gdalOverviewTypeToString() const
unsigned int ossim_uint32
ossimRefPtr< ossimNBandLutDataObject > theColorLut
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) 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
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setLut()

void ossimGdalWriter::setLut ( const ossimNBandLutDataObject lut)

Definition at line 116 of file ossimGdalWriter.cpp.

References ossimNBandLutDataObject::dup(), theColorLut, and theColorLutFlag.

Referenced by checkColorLut().

117 {
118  theColorLutFlag = true;
120 }
ossimRefPtr< ossimNBandLutDataObject > theColorLut
class ossimNBandLutDataObject

◆ setOptions()

void ossimGdalWriter::setOptions ( ossimKeywordlist kwl,
const char *  prefix = NULL 
)
protectedvirtual

Definition at line 824 of file ossimGdalWriter.cpp.

826 {
827  ossimString regExpression = ossimString("^(") +
828  ossimString(prefix) +
829  "option[0-9]+.)";
830 
831 // while(numberOfMatches < static_cast<unsigned long>(numberOfSources))
832 // {
833 // ossimString newPrefix = prefix;
834 // newPrefix += ossimString("option");
835 // newPrefix += ossimString::toString(i);
836 // newPrefix += ossimString(".");
837 
838 // const char* name = kwl.find(newPrefix.c_str(), "name");
839 // const char* value = kwl.find(newPrefix.c_str(), "value");
840 
841 // if(ossimString(name) == "tilewidth")
842 // {
843 // theJpeg2000TileSize.x = ossimString(value).toInt();
844 // }
845 // else if(ossimString(name) == "tileheight")
846 // {
847 // theJpeg2000TileSize.y = ossimString(value).toInt();
848 // }
849 // }
850 
851 }

◆ setOutputImageType()

void ossimGdalWriter::setOutputImageType ( const ossimString type)
virtual

◆ setProperty()

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

Reimplemented from ossimImageFileWriter.

Definition at line 1384 of file ossimGdalWriter.cpp.

References ossimKeywordlist::clear(), convertToDriverName(), gdalOverviewTypeFromString(), ossimProperty::getName(), ossimNBandLutDataObject::open(), ossimImageFileWriter::setProperty(), storeProperty(), ossimString::substitute(), theColorLut, theColorLutFlag, theDriverOptionValues, theGdalOverviewType, theLutFilename, ossimImageFileWriter::theOutputImageType, ossimString::toBool(), ossimRefPtr< T >::valid(), validProperty(), and ossimProperty::valueToString().

1385 {
1386  if(!property.valid()) return;
1387  ossimString propName = property->getName();
1388  if(!validProperty(property->getName()))
1389  {
1390  if(property->getName() == "image_type")
1391  {
1393  }
1395  return;
1396  }
1397 
1399  ossimString name = property->getName();
1400 
1401  if(name == "HFA_USE_RRD")
1402  {
1403  bool value = property->valueToString().toBool();
1404  CPLSetConfigOption("HFA_USE_RRD", value?"YES":"NO");
1405  }
1406  else if(name == "gdal_overview_type")
1407  {
1409  }
1410  else if (name == "format")
1411  {
1412  storeProperty(name,
1413  property->valueToString());
1414  }
1415  else if(name == "lut_file")
1416  {
1419  }
1420  else if(name == "color_lut_flag")
1421  {
1422  theColorLutFlag = property->valueToString().toBool();
1423  }
1424  else
1425  {
1426  name = name.substitute(driverName+"_","");
1427  storeProperty(name,
1428  property->valueToString());
1429  }
1430 }
virtual void valueToString(ossimString &valueResult) const =0
ossimString substitute(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
Substitutes searchKey string with replacementValue and returns a string.
bool valid() const
Definition: ossimRefPtr.h:75
ossimString convertToDriverName(const ossimString &imageTypeName) const
ossimFilename theLutFilename
void storeProperty(const ossimString &name, const ossimString &value)
ossimKeywordlist theDriverOptionValues
bool toBool() const
String to numeric methods.
ossimGdalOverviewType theGdalOverviewType
bool open(const ossimFilename &lutFile)
Reads in an external lut file.
ossimRefPtr< ossimNBandLutDataObject > theColorLut
virtual void setProperty(ossimRefPtr< ossimProperty > property)
ossimGdalOverviewType gdalOverviewTypeFromString(const ossimString &typeString) const
bool validProperty(const ossimString &name) const
const ossimString & getName() const

◆ storeProperty()

void ossimGdalWriter::storeProperty ( const ossimString name,
const ossimString value 
)
protected

Definition at line 1678 of file ossimGdalWriter.cpp.

References ossimKeywordlist::add(), ossimString::c_str(), ossimKeywordlist::find(), ossimKeywordlist::getSize(), ossimKeywordlist::getSubstringKeyList(), theDriverOptionValues, and ossimString::toString().

Referenced by setProperty().

1680 {
1681  ossimString regExpression = (ossimString("^") +
1682  "property[0-9]+");
1683 
1684  vector<ossimString> keys = theDriverOptionValues.getSubstringKeyList( regExpression );
1685  ossim_uint32 idx = 0;
1686  for(idx = 0; idx < keys.size(); ++idx)
1687  {
1688  ossimString storedName = theDriverOptionValues.find(keys[idx] +".name");
1689 
1690  if(storedName == name)
1691  {
1692  theDriverOptionValues.add(keys[idx] +".value",
1693  value,
1694  true);
1695  return;
1696  }
1697  }
1698  ossimString prefix = (ossimString("property") +
1700  ".");
1701  theDriverOptionValues.add(prefix.c_str(),
1702  "name",
1703  name,
1704  true);
1705  theDriverOptionValues.add(prefix.c_str(),
1706  "value",
1707  value,
1708  true);
1709 }
const char * find(const char *key) const
static ossimString toString(bool aValue)
Numeric to string methods.
ossimKeywordlist theDriverOptionValues
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
unsigned int ossim_uint32
std::vector< ossimString > getSubstringKeyList(const ossimString &regularExpression) const
ossim_uint32 getSize() 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

◆ validProperty()

bool ossimGdalWriter::validProperty ( const ossimString name) const
protected

Definition at line 1732 of file ossimGdalWriter.cpp.

References getGdalPropertyNames().

Referenced by setProperty().

1733 {
1734  std::vector<ossimString> propertyNames;
1735 
1736  if((name == "gdal_overview_type")||
1737  (name == "HFA_USE_RRD") || name == "format")
1738  {
1739  return true;
1740  }
1741  getGdalPropertyNames(propertyNames);
1742 
1743  ossim_uint32 idx = 0;
1744  for(idx = 0; idx < propertyNames.size(); ++idx)
1745  {
1746  if(name == propertyNames[idx])
1747  {
1748  return true;
1749  }
1750  }
1751 
1752  return false;
1753 }
void getGdalPropertyNames(std::vector< ossimString > &propertyNames) const
unsigned int ossim_uint32

◆ writeBlockFile()

bool ossimGdalWriter::writeBlockFile ( )
protectedvirtual

Definition at line 619 of file ossimGdalWriter.cpp.

References ossimString::c_str(), ossimRefPtr< T >::get(), ossimImageSourceSequencer::setAreaOfInterest(), MEMTiledDataset::setNoDataValueFlag(), ossimImageSourceSequencer::setToStartOfSequence(), ossimImageWriter::theAreaOfInterest, theDataset, theDriver, ossimImageFileWriter::theFilename, theGdalDriverOptions, ossimImageFileWriter::theInputConnection, and writeProjectionInfo().

620 {
623 
624  MEMTiledDataset* tiledDataset = new MEMTiledDataset(theInputConnection.get());
625 
626  //---
627  // DRB 20081017
628  // Trac #404: Setting no data value for imagine (hfa) and j2k causing view
629  // issues with ArcMap and Erdas Imagine when null values are present in
630  // valid image data.
631  //---
632  if (theDriver)
633  {
634  ossimString driverName = GDALGetDriverShortName(theDriver);
635  if ( (driverName == "HFA") || (driverName == "JP2MrSID") ||
636  (driverName == "JP2KAK") || (driverName == "JPEG2000") )
637  {
638  tiledDataset->setNoDataValueFlag(false);
639  }
640  }
641 
642  ossimString driverName="null";
643  if (theDriver)
644  {
645  driverName = GDALGetDriverShortName(theDriver);
646  }
647 
648  writeProjectionInfo(tiledDataset);
649  theDataset = GDALCreateCopy( theDriver,
650  theFilename.c_str(),
651  tiledDataset ,
652  true,
654  (GDALProgressFunc)&gdalProgressFunc,
655  this);
656 
657  if(theDataset&&!needsAborting())
658  {
660  {
662  }
663  close();
664  }
665  else
666  {
667  if(traceDebug())
668  {
669  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalWriter::writeBlockFile(): Unable to create dataset for file " << theFilename << std::endl;
670  }
671  return false;
672  }
673  // Trac #299: Ingest tasks are failing when generating png thumbnails
674  // ESH 08/2008: Added in a NULL check on theDataset, since GDALGetDriverShortName
675  // crashes the app if given a NULL pointer.
676  if( theDataset && ossimString(GDALGetDriverShortName(theDataset)) == ossimString("PNG") )
677  {
679  }
680 
681  return true;
682 }
ossimIrect theAreaOfInterest
GDALDriverH theDriver
void setNoDataValueFlag(bool flag)
DRB - 20081020 If true (default) the no data value will be set to null pixel value.
virtual void setAreaOfInterest(const ossimIrect &areaOfInterest)
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
ossimGdalOverviewType theGdalOverviewType
virtual void writeProjectionInfo(GDALDatasetH dataset)
virtual void setWriteExternalGeometryFlag(bool flag)
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
char ** theGdalDriverOptions
GDALDatasetH theDataset
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual void close()

◆ writeColorMap()

void ossimGdalWriter::writeColorMap ( int  bands)
protectedvirtual

Definition at line 684 of file ossimGdalWriter.cpp.

References ossimNBandLutDataObject::getEntryLabels(), ossimNBandLutDataObject::getNumberOfBands(), ossimNBandLutDataObject::getNumberOfEntries(), theColorLut, theDataset, and ossimRefPtr< T >::valid().

685 {
686  if ( theDataset && theColorLut.valid() )
687  {
688  bool hasAlpha = (theColorLut->getNumberOfBands() == 4);
689 
690  for (int band = 0; band < bands; band++)
691  {
692  GDALRasterBandH aBand=0;
693  aBand = GDALGetRasterBand(theDataset, band+1);
694  if(aBand)
695  {
696  bool hasEntryLabel = false;
698  std::vector<ossimString> entryLabels = theColorLut->getEntryLabels(band);
699  if (entryLabels.size() == entryNum)
700  {
701  hasEntryLabel = true;
702  }
703 
704  GDALColorTable* gdalColorTable = new GDALColorTable();
705  for(ossim_uint32 entryIndex = 0; entryIndex < entryNum; entryIndex++)
706  {
707  GDALColorEntry colorEntry;
708  colorEntry.c1 = (*theColorLut)[entryIndex][0];
709  colorEntry.c2 = (*theColorLut)[entryIndex][1];
710  colorEntry.c3 = (*theColorLut)[entryIndex][2];
711  colorEntry.c4 = hasAlpha ? (*theColorLut)[entryIndex][3] : 255;
712 #if 0
713  if (hasEntryLabel)
714  {
715  char* labelName = const_cast<char*>(entryLabels[entryIndex].c_str());
716  colorEntry.poLabel = labelName;
717  }
718  else
719  {
720  colorEntry.poLabel = NULL;
721  }
722 #endif
723 
724  gdalColorTable->SetColorEntry(entryIndex, &colorEntry);
725  }
726 
727  GDALSetRasterColorTable(aBand, gdalColorTable);
728  delete gdalColorTable;
729  }
730  }
731  }
732 }
std::vector< ossimString > getEntryLabels(ossim_uint32 band)
ossim_uint32 getNumberOfBands() const
bool valid() const
Definition: ossimRefPtr.h:75
ossim_uint32 getNumberOfEntries() const
unsigned int ossim_uint32
ossimRefPtr< ossimNBandLutDataObject > theColorLut
GDALDatasetH theDataset

◆ writeFile()

bool ossimGdalWriter::writeFile ( )
protectedvirtual

Write out the file.

Returns
true on success, false on error.

Implements ossimImageFileWriter.

Definition at line 325 of file ossimGdalWriter.cpp.

326 {
327  bool result = true; // On failure set to false.
328 
329  const char *MODULE = "ossimGdalWriter::writeFile()";
330 
331  if(traceDebug())
332  {
333  CLOG << "entered..." << std::endl;
334  }
335 
336  if(theDataset)
337  {
338  close();
339  }
340 
341  checkColorLut();
342 
343  //---
344  // If isInputDataIndexed is true the data fed to writer is already in palette index form so
345  // the addition of the ossimNBandToIndexFilter is not needed.
346  //---
347  if( isLutEnabled() && !isInputDataIndexed() )
348  {
356  }
357  else
358  {
360  }
361 
362  //---
363  // setup gdal driver options
364  //---
365  ossimRefPtr<ossimProperty> blockSize =
366  getProperty(theDriverName+ossimString("_BLOCKSIZE"));
367  if(blockSize.valid())
368  {
369  ossim_uint32 size = blockSize->valueToString().toUInt32();
370  ossimIpt tileSize;
371  if(size > 0)
372  {
373  tileSize = ossimIpt(size, size);
374  theInputConnection->setTileSize(tileSize);
375  }
376  else
377  {
378  ossimIpt defaultSize = theInputConnection->getTileSize();
379  if(defaultSize.y != defaultSize.x)
380  {
381  defaultSize.y = defaultSize.x;
382  theInputConnection->setTileSize(defaultSize);
383  }
384  blockSize->setValue(ossimString::toString(defaultSize.x));
385  setProperty(blockSize);
386  theInputConnection->setTileSize(defaultSize);
387  }
388  }
390 
391  if(!theInputConnection->isMaster()) // MPI slave process...
392  {
395  {
398  }
399  result = true;
400  }
401  else // MPI master process.
402  {
403  open();
404 
405  if(isOpen())
406  {
407  GDALDataType gdalType = getGdalDataType(theInputConnection->
408  getOutputScalarType());
410 
411  theDataset = GDALCreate( theDriver ,
412  theFilename.c_str(),
413  (int)theAreaOfInterest.width(),
414  (int)theAreaOfInterest.height(),
415  (int)bandCount,
416  gdalType,
418 
419  // ESH 09/2009 -- If no raster bands do block write.
420  int nRasterBands = GDALGetRasterCount( theDataset );
421 
422  if(theDataset && nRasterBands>0)
423  {
425 
426  if (theColorLutFlag)
427  {
428  writeColorMap(nRasterBands);
429  }
430 
432  ossimRefPtr<ossimImageData> currentTile =
434  ossimRefPtr<ossimImageData> outputTile =
435  (ossimImageData*)currentTile->dup();
436  outputTile->initialize();
437 
438  //---
439  // DRB 20081017
440  // Trac #404: Setting no data value for imagine (hfa) and j2k
441  // causing view issues with ArcMap and Erdas Imagine when null
442  // values are present in
443  // valid image data.
444  //---
445  if (theDriver)
446  {
447  ossimString driverName = GDALGetDriverShortName(theDriver);
448  if ( (driverName != "HFA") && (driverName != "JP2MrSID") &&
449  (driverName != "JP2KAK") && (driverName != "JPEG2000") )
450  {
451  for(ossim_uint32 band = 0;
452  band < currentTile->getNumberOfBands();
453  ++band)
454  {
455  GDALRasterBandH aBand =
456  GDALGetRasterBand(theDataset, band+1);
457  if(aBand)
458  {
459  GDALSetRasterNoDataValue(
460  aBand, theInputConnection->getNullPixelValue(band));
461  }
462  }
463  if(traceDebug())
464  {
466  << "GDALSetRasterNoDataValue called for driver: "
467  << driverName << std::endl;
468  }
469  }
470  else
471  {
472  if(traceDebug())
473  {
475  << "GDALSetRasterNoDataValue not called for driver: "
476  << driverName << std::endl;
477  }
478  }
479 
480  // ESH 05/2009: Add min/max to gdal metadata
481  ossim_uint32 numberOfBands = currentTile->getNumberOfBands();
482  for( ossim_uint32 idx = 0; idx < numberOfBands; ++idx )
483  {
484  GDALRasterBandH aBand =
485  GDALGetRasterBand(theDataset, idx+1);
486  if(aBand)
487  {
488  // GDAL always assumes "area".
489  GDALSetMetadataItem( aBand, "AREA_OR_POINT", "Area", 0 );
490 
491  double minPix = (double)currentTile->getMinPix( idx );
492  double maxPix = (double)currentTile->getMaxPix( idx );
493 
494  // Only set the metadata if the values makes some sense.
495  if ( maxPix > 0.0 && minPix < maxPix )
496  {
497  char szValue[128];
498  sprintf( szValue, "%.14g", minPix );
499  GDALSetMetadataItem( aBand, "STATISTICS_MINIMUM", szValue, 0 );
500 
501  sprintf( szValue, "%.14g", maxPix );
502  GDALSetMetadataItem( aBand, "STATISTICS_MAXIMUM", szValue, 0 );
503  }
504  }
505  }
506  }
507 
508  ossim_uint32 numberOfTiles =
511 
513  while(currentTile.valid()&&(!needsAborting()))
514  {
515  ossimIrect clipRect =
517  outputTile->setImageRectangle(clipRect);
518  outputTile->loadTile(currentTile.get());
519  //ossimIpt offset = currentTile->getOrigin() -
520  //theAreaOfInterest.ul();
521  ossimIpt offset = clipRect.ul() - theAreaOfInterest.ul();
522 
523  for(ossim_uint32 band = 0;
524  ((band < (currentTile->getNumberOfBands()))&&
525  (!needsAborting()));
526  ++band)
527  {
528  GDALRasterBandH aBand=0;
529  aBand = GDALGetRasterBand(theDataset, band+1);
530 
531  if(aBand)
532  {
533  GDALRasterIO( aBand,
534  GF_Write,
535  offset.x,
536  offset.y,
537  clipRect.width(),
538  clipRect.height(),
539  outputTile->getBuf(band),
540  outputTile->getWidth(),
541  outputTile->getHeight(),
542  gdalType,
543  0,
544  0);
545  }
546 
547  ++tileNumber;
548  ossimProcessProgressEvent event(this,
549  ((double)tileNumber/
550  (double)numberOfTiles)*100.0,
551  "",
552  false);
553 
554  fireEvent(event);
555  }
556  currentTile = theInputConnection->getNextTile();
557 
558  }
559 
560  if(theDataset)
561  {
562  close();
564  (!needsAborting()))
565  {
566  theDataset= GDALOpen( theFilename.c_str(), GA_Update );
567 
568  if( theDataset == 0 )
569  {
570  theDataset = GDALOpen( theFilename.c_str(), GA_ReadOnly );
571  }
573  close();
574  }
575  }
576  else
577  {
579  << "ossimGdalWriter::writeFile unable to create dataset"
580  << std::endl;
581  result = false;
582  }
583 
584  } // End of "if (theDataset)"
585  else
586  {
587  result = writeBlockFile();
588  }
589 
590  }
591  else // open failed...
592  {
593  result = false;
594  if(traceDebug())
595  {
596  CLOG << "Unable to open file for writing. Exiting ..."
597  << std::endl;
598  }
599  }
600 
601  if (result)
602  {
603  // Clean up files...
605  }
606 
607  } // End of "else // MPI master process."
608 
610  {
613  }
614 
615  return result;
616 
617 } // End of: ossimGdalWriter::writeFile
void setLut(ossimNBandLutDataObject &lut)
virtual void valueToString(ossimString &valueResult) const =0
virtual ossim_uint32 getWidth() const
ossimRefPtr< ossimNBandToIndexFilter > theNBandToIndexFilter
virtual const ossim_float64 * getMaxPix() const
virtual ossim_uint32 getNumberOfBands() const
#define CLOG
Definition: ossimTrace.h:23
virtual void setImageRectangle(const ossimIrect &rect)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
ossim_uint32 tileNumber
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
bool valid() const
Definition: ossimRefPtr.h:75
ossim_uint32 height() const
Definition: ossimIrect.h:487
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
ossimIrect theAreaOfInterest
static ossimString toString(bool aValue)
Numeric to string methods.
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual bool isOpen() const
virtual ossim_uint32 getHeight() const
GDALDriverH theDriver
virtual void fireEvent(ossimEvent &event)
virtual void initialize()
Initialize the data buffer.
virtual ossimObject * dup() const
ossimConnectableObject * getInput(ossim_uint32 index=0)
returns the object at the specified index.
virtual void writeColorMap(int bands)
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
virtual bool open()
yy_size_t size
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned int ossim_uint32
ossimGdalOverviewType theGdalOverviewType
bool isInputDataIndexed()
Check input to see if it&#39;s indexed.
virtual bool writeBlockFile()
virtual ossimIrect getImageRectangle() const
ossimRefPtr< ossimNBandLutDataObject > theColorLut
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimString theDriverName
virtual const ossim_float64 * getMinPix() const
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
GDALDataType getGdalDataType(ossimScalarType scalar)
bool isLutEnabled() const
virtual void writeProjectionInfo(GDALDatasetH dataset)
ossim_int32 y
Definition: ossimIpt.h:142
virtual const void * getBuf() 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
virtual ossimIpt getTileSize() const
ossim_int32 x
Definition: ossimIpt.h:141
char ** theGdalDriverOptions
GDALDatasetH theDataset
virtual void setTileSize(const ossimIpt &tileSize)
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
void postProcessOutput() const
Method called after good writeFile to clean up any unwanted files.
virtual bool setValue(const ossimString &value)=0
void allocateGdalDriverOptions()
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual void close()

◆ writeProjectionInfo()

void ossimGdalWriter::writeProjectionInfo ( GDALDatasetH  dataset)
protectedvirtual

Definition at line 734 of file ossimGdalWriter.cpp.

References ossimMapProjection::getDecimalDegreesPerPixel(), ossimImageSource::getImageGeometry(), ossimMapProjection::getMetersPerPixel(), ossimMapProjection::getPcsCode(), ossimImageGeometry::getProjection(), ossimMapProjection::getProjectionName(), ossimMapProjection::isGeographic(), ossimMapProjection::lineSampleToEastingNorthing(), ossimMapProjection::lineSampleToWorld(), PTR_CAST, ossimMapProjection::saveState(), ossimImageWriter::theAreaOfInterest, ossimImageFileWriter::theInputConnection, ossimIrect::ul(), ossimRefPtr< T >::valid(), ossimDpt::x, and ossimDpt::y.

Referenced by writeBlockFile().

735 {
736  // Get current input geometry
738  if(geom.valid())
739  {
740  const ossimMapProjection* mapProj =
742 
743  if (mapProj)
744  {
745  ossim_uint32 pcs_code = mapProj->getPcsCode();
746  if (pcs_code == 0)
747  pcs_code = 32767;
748 
749  double geoTransform[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
750 
751  ossimDpt tiePoint;
752  ossimDpt scale;
753  if (mapProj->isGeographic())
754  {
755  // Get the ground tie point.
756  ossimGpt gpt;
757  mapProj->lineSampleToWorld(theAreaOfInterest.ul(), gpt);
758  tiePoint = gpt;
759 
760  // Get the scale.
761  scale.x = mapProj->getDecimalDegreesPerPixel().x;
762  scale.y = -mapProj->getDecimalDegreesPerPixel().y;
763  }
764  else
765  {
766  // Get the easting northing tie point.
768  tiePoint);
769 
770  // Get the scale.
771  scale.x = mapProj->getMetersPerPixel().x;
772  scale.y = -mapProj->getMetersPerPixel().y;
773  }
774 
775  geoTransform[1] = scale.x;
776  geoTransform[5] = scale.y;
777  geoTransform[0] = tiePoint.x;
778  geoTransform[3] = tiePoint.y;
779 
780  //---
781  // Since OSSIM is pixel_is_point, shift the tie point by
782  // half a pixel since GDAL output is pixel_is_area.
783  //---
784  geoTransform[0] -= fabs(scale.x) / 2.0;
785  geoTransform[3] += fabs(scale.y) / 2.0;
786 
787  // Translate projection information to GDAL settable WKT
788  ossimString wktString = "";
789  if( mapProj->getProjectionName() == ossimString("ossimBngProjection") )
790  {
791  wktString = "PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB 1936\","
792  "DATUM[\"OSGB_1936\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646]],PRIMEM[\""
793  "Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],"
794  "PARAMETER[\"latitude_of_origin\",49],PARAMETER[\"central_meridian\",-2],PARAMETER[\""
795  "scale_factor\",0.999601272],PARAMETER[\"false_easting\",400000],PARAMETER[\"false_"
796  "northing\",-100000],UNIT[\"meter\",1]]";
797  }
798  else if (mapProj->getProjectionName() == ossimString("ossimAlbersProjection") )
799  {
800  wktString = "PROJCS[\"Albers Conical Equal Area\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\","
801  "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],"
802  "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6269\"]],PRIMEM[\"Greenwich\",0,"
803  "AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],"
804  "AUTHORITY[\"EPSG\",\"4269\"]],PROJECTION[\"Albers_Conic_Equal_Area\"],PARAMETER[\"standard_parallel_1\",29.5],"
805  "PARAMETER[\"standard_parallel_2\",45.5],PARAMETER[\"latitude_of_center\",23],PARAMETER[\"longitude_of_center\",-96],"
806  "PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"meters\",1]]";
807  }
808  else
809  {
810  ossimKeywordlist kwl;
811  mapProj->saveState(kwl);
812  wktString = translator.fromOssimKwl(kwl);
813  }
814 
815  // Set GDAL projection and corner coordinates.
816  GDALSetProjection(dataset, wktString.c_str());
817  GDALSetGeoTransform(dataset, geoTransform);
818 
819  } // matches: if (mapProj)
820 
821  } // matches: if(geom.valid())
822 }
virtual const ossimDpt & getDecimalDegreesPerPixel() const
Returns decimal degrees per pixel as an ossimDpt with "x" representing longitude and "y" representing...
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getPcsCode() const
Returns the EPSG PCS code or 32767 if the projection is a custom (non-EPSG) projection.
ossimString fromOssimKwl(const ossimKeywordlist &kwl, const char *prefix=NULL) const
double y
Definition: ossimDpt.h:165
ossimIrect theAreaOfInterest
virtual bool isGeographic() const
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual ossimGpt lineSampleToWorld(const ossimDpt &projectedPoint) const
virtual void lineSampleToEastingNorthing(const ossimDpt &liineSample, ossimDpt &eastingNorthing) const
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
virtual ossimString getProjectionName() const
Returns the projection name.
unsigned int ossim_uint32
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
double x
Definition: ossimDpt.h:164
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 ossimDpt getMetersPerPixel() const

Member Data Documentation

◆ theColorLut

ossimRefPtr<ossimNBandLutDataObject> ossimGdalWriter::theColorLut
protected

Definition at line 139 of file ossimGdalWriter.h.

Referenced by setLut(), setProperty(), and writeColorMap().

◆ theColorLutFlag

bool ossimGdalWriter::theColorLutFlag
protected

Definition at line 138 of file ossimGdalWriter.h.

Referenced by isLutEnabled(), setLut(), and setProperty().

◆ theDataset

GDALDatasetH ossimGdalWriter::theDataset
protected

◆ theDriver

GDALDriverH ossimGdalWriter::theDriver
protected

Definition at line 129 of file ossimGdalWriter.h.

Referenced by isOpen(), open(), postProcessOutput(), and writeBlockFile().

◆ theDriverName

ossimString ossimGdalWriter::theDriverName
protected

Definition at line 127 of file ossimGdalWriter.h.

Referenced by open(), and ~ossimGdalWriter().

◆ theDriverOptionValues

ossimKeywordlist ossimGdalWriter::theDriverOptionValues
protected

◆ theGdalDriverOptions

char** ossimGdalWriter::theGdalDriverOptions
protected

◆ theGdalOverviewType

ossimGdalOverviewType ossimGdalWriter::theGdalOverviewType
protected

Definition at line 136 of file ossimGdalWriter.h.

Referenced by gdalOverviewTypeToString(), and setProperty().

◆ theJpeg2000TileSize

ossimIpt ossimGdalWriter::theJpeg2000TileSize
protected

Definition at line 132 of file ossimGdalWriter.h.

◆ theLutFilename

ossimFilename ossimGdalWriter::theLutFilename
protected

Definition at line 140 of file ossimGdalWriter.h.

Referenced by setProperty().

◆ theNBandToIndexFilter

ossimRefPtr<ossimNBandToIndexFilter> ossimGdalWriter::theNBandToIndexFilter
mutableprotected

Definition at line 141 of file ossimGdalWriter.h.


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