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

ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakadu library for decompression. More...

#include <ossimKakaduNitfReader.h>

Inheritance diagram for ossimKakaduNitfReader:
ossimNitfTileSource ossimImageHandler ossimImageSource ossimSource ossimConnectableObject ossimErrorStatusInterface ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Public Types

enum  { SIGNATURE_BOX_SIZE = 12 }
 Anonymous enumerations: More...
 
- Public Types inherited from ossimNitfTileSource
enum  ReadMode {
  READ_MODE_UNKNOWN = 0, READ_BIB_BLOCK = 1, READ_BIP_BLOCK = 2, READ_BIR_BLOCK = 3,
  READ_BSQ_BLOCK = 4, READ_BIB = 5, READ_BIP = 6, READ_BIR = 7,
  READ_JPEG_BLOCK = 8
}
 
- Public Types inherited from ossimImageHandler
enum  ossimImageHandlerOverviewCompressionType {
  OSSIM_OVERVIEW_COMPRESSION_NONE = 0, OSSIM_OVERVIEW_COMPRESSION_JPEG, OSSIM_OVERVIEW_COMPRESSION_LZW, OSSIM_OVERVIEW_COMPRESSION_DEFLATE,
  OSSIM_OVERVIEW_COMPRESSION_PACKBITS
}
 
- 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 Member Functions

 ossimKakaduNitfReader ()
 default construtor More...
 
virtual ~ossimKakaduNitfReader ()
 virtural destructor More...
 
virtual ossimString getShortName () const
 Returns short name. More...
 
virtual ossimString getLongName () const
 Returns long name. More...
 
virtual ossim_uint32 getNumberOfDecimationLevels () const
 Returns the number of decimation levels. More...
 
virtual ossim_uint32 getNumberOfLines (ossim_uint32 resLevel=0) const
 Gets number of lines for res level. More...
 
virtual ossim_uint32 getNumberOfSamples (ossim_uint32 resLevel=0) const
 Gets the number of samples for res level. More...
 
virtual void setMinPixelValue (ossim_uint32 band, const ossim_float64 &pix)
 convenience method to set min pixel value. More...
 
virtual void setMaxPixelValue (ossim_uint32 band, const ossim_float64 &pix)
 convenience method to set max pixel value. More...
 
virtual void setNullPixelValue (ossim_uint32 band, const ossim_float64 &pix)
 convenience method to set null pixel value. More...
 
virtual ossim_float64 getMinPixelValue (ossim_uint32 band=0) const
 
virtual ossim_float64 getMaxPixelValue (ossim_uint32 band=0) const
 
virtual ossim_float64 getNullPixelValue (ossim_uint32 band=0) const
 
- Public Member Functions inherited from ossimNitfTileSource
 ossimNitfTileSource ()
 
virtual bool open ()
 Returns true if the image_file can be opened and is a valid nitf file. More...
 
bool open (std::shared_ptr< ossim::istream > &str, const std::string &connectionString)
 This open takes a stream and stores/captures the shared pointer on success. More...
 
virtual void close ()
 Closes file and destroys all memory allocated. More...
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIrect &tileRect, ossim_uint32 resLevel=0)
 
virtual ossim_uint32 getNumberOfInputBands () const
 
virtual ossim_uint32 getNumberOfOutputBands () const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Method to save the state of an object to a keyword list. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of an object from a keyword list. More...
 
virtual ossimScalarType getOutputScalarType () const
 Returns the output pixel type of the tile source. More...
 
virtual ossim_uint32 getTileWidth () const
 Returns the width of the output tile. More...
 
virtual ossim_uint32 getTileHeight () const
 Returns the height of the output tile. More...
 
virtual ossim_uint32 getImageTileWidth () const
 Returns the tile width of the image or 0 if the image is not tiled. More...
 
virtual ossim_uint32 getImageTileHeight () const
 Returns the tile width of the image or 0 if the image is not tiled. More...
 
virtual bool isOpen () const
 Derived classes must implement this method to be concrete. More...
 
virtual ossim_uint32 getCurrentEntry () const
 
virtual void getEntryList (std::vector< ossim_uint32 > &entryList) const
 
ossim_uint32 getNumberOfEntries () const
 
virtual bool setCurrentEntry (ossim_uint32 entryIdx)
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 
ossimString getSecurityClassification () const
 
bool getCacheEnabledFlag () const
 
void setCacheEnabledFlag (bool flag)
 
const ossimNitfFileHeadergetFileHeader () const
 
ossimNitfFileHeadergetFileHeader ()
 
const ossimNitfImageHeadergetCurrentImageHeader () const
 
ossimNitfImageHeadergetCurrentImageHeader ()
 
virtual bool getRgbBandList (std::vector< ossim_uint32 > &bandList) const
 Convenience method to get the zero based rgb output band list. More...
 
- Public Member Functions inherited from ossimImageHandler
 ossimImageHandler ()
 Constructor (default): More...
 
virtual ~ossimImageHandler ()
 Destructor: Derived classes should implement. More...
 
virtual void initialize ()
 initialize Does nothing in this class. More...
 
virtual bool openOverview ()
 Searches for an overview. More...
 
virtual bool openOverview (const ossimFilename &overview_file)
 Calls closeOverview(), then attempts to open the overview_file. More...
 
virtual void closeOverview ()
 If theOverview is initialized it will be deleted and set to NULL. More...
 
virtual const ossimImageHandlergetOverview () const
 
virtual bool hasOverviews () const
 
virtual ossimFilename createDefaultOverviewFilename () const
 
virtual ossimFilename createDefaultGeometryFilename () const
 
virtual ossimFilename createDefaultMetadataFilename () const
 
virtual ossimFilename createDefaultHistogramFilename () const
 
virtual ossimFilename createDefaultValidVerticesFilename () const
 
virtual bool writeValidImageVertices (const std::vector< ossimIpt > &vertices, const ossimFilename &file=ossimFilename(""))
 Outputs vertices to file and updates the internal vertex array variable "theValidImageVertices". More...
 
virtual bool openValidVertices (const ossimFilename &vertices_file)
 Opens the valid image vertices file and sets theValidImageVerticesFile variable. More...
 
virtual bool openValidVertices ()
 Creates vertices file name based on image, then tries to open. More...
 
virtual bool open (const ossimFilename &imageFile, ossim_uint32 entryIndex)
 Opens the image file. More...
 
virtual bool open (const ossimFilename &imageFile)
 
virtual bool open (std::shared_ptr< ossim::ImageHandlerState > state)
 
virtual bool buildHistogram (int numberOfRLevels=0, ossimHistogramMode mode=OSSIM_HISTO_MODE_NORMAL)
 Build a histogram for image file. More...
 
virtual bool buildAllHistograms (int numberOfRLevels=0, ossimHistogramMode mode=OSSIM_HISTO_MODE_NORMAL)
 Build a histograms for all image entries. More...
 
virtual bool buildOverview (ossimImageHandlerOverviewCompressionType compressionType=OSSIM_OVERVIEW_COMPRESSION_NONE, ossim_uint32 quality=75, ossimFilterResampler::ossimFilterResamplerType resampleType=ossimFilterResampler::ossimFilterResampler_BOX, bool includeFullResFlag=false)
 Will build over file for theImageFile. More...
 
virtual bool buildAllOverviews (ossimImageHandlerOverviewCompressionType compressionType=OSSIM_OVERVIEW_COMPRESSION_NONE, ossim_uint32 quality=75, ossimFilterResampler::ossimFilterResamplerType resampleType=ossimFilterResampler::ossimFilterResampler_BOX, bool includeFullResFlag=false)
 Will build over file for all image entries. More...
 
virtual bool buildOverview (const ossimFilename &filename, ossimImageHandlerOverviewCompressionType compressionType=OSSIM_OVERVIEW_COMPRESSION_NONE, ossim_uint32 quality=75, ossimFilterResampler::ossimFilterResamplerType resampleType=ossimFilterResampler::ossimFilterResampler_BOX, bool includeFullResFlag=false)
 Will build an over file for filename. More...
 
ossimRefPtr< ossimMultiResLevelHistogramgetImageHistogram () const
 Fetches the current entry image's histogram. More...
 
virtual ossimRefPtr< ossimImageGeometrygetImageGeometry ()
 Returns the image geometry object associated with this tile source or NULL if non defined. More...
 
virtual void setImageGeometry (ossimImageGeometry *geom)
 Sets the image geometry object. More...
 
virtual void saveImageGeometry () const
 Saves the image geometry to a file that will be made based on the image file name. More...
 
virtual void saveImageGeometry (const ossimFilename &geometry_file) const
 Saves the image geometry to a file that will be made based on the image file name. More...
 
virtual ossimIrect getImageRectangle (ossim_uint32 resLevel=0) const
 Returns zero-based bounding rectangle of the image. More...
 
virtual ossimIrect getBoundingRect (ossim_uint32 resLevel=0) const
 Returns zero-based bounding rectangle of the image. More...
 
virtual void getDecimationFactor (ossim_uint32 resLevel, ossimDpt &result) const
 
virtual void getDecimationFactors (vector< ossimDpt > &decimations) const
 This returns all decimation for all levels. More...
 
virtual ossim_uint32 getNumberOfReducedResSets () const
 This method is obsolete. More...
 
virtual void setFilename (const ossimFilename &filename)
 Sets the filename. More...
 
virtual const ossimFilenamegetFilename () const
 Returns the filename. More...
 
virtual bool isValidRLevel (ossim_uint32 resLevel) const
 Determines if the passed in reslution level is valid. More...
 
bool canConnectMyInputTo (ossim_int32 inputIndex, const ossimConnectableObject *object) const
 Connection rule. More...
 
virtual void getValidImageVertices (vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
 ordering specifies how the vertices should be arranged. More...
 
virtual bool isBandSelector () const
 Indicates whether or not the image handler can control output band selection via the setOutputBandList method. More...
 
virtual bool setOutputBandList (const std::vector< ossim_uint32 > &band_list)
 If the image handler "isBandSeletor()" then the band selection of the output chip can be controlled. More...
 
virtual bool setOutputToInputBandList ()
 If the image handler "isBandSeletor()" then the band selection of the output are set to input or identity. More...
 
virtual bool isIdentityBandList (const std::vector< ossim_uint32 > &bandList) const
 Convenience method to see if band list is identity. More...
 
virtual bool isImageTiled () const
 Indicates whether or not the image is tiled internally. More...
 
virtual bool hasMetaData () const
 
virtual ossimRefPtr< ossimNBandLutDataObjectgetLut () const
 
virtual bool hasLut () const
 
virtual void loadMetaData ()
 There is an external file with an omd extension. More...
 
virtual void getEntryName (ossim_uint32 entryIdx, std::string &name) const
 Get the name of entry as a string. More...
 
virtual void getEntryNames (std::vector< ossimString > &entryNames) const
 
bool useEntryIndex () const
 Convenience method to determine if entry index should be used for support files, e.g. More...
 
ossimFilename getOverviewFile () const
 
ossimFilename getFilenameWithThisExtension (const ossimString &ext, bool set_e0_prefix=false) const
 Returns the image file with extension set using supplentary directory for dirname if set. More...
 
void getFilenameWithThisExt (const ossimString &ext, ossimFilename &f) const
 Returns the image file with extension set using supplentary directory for dirname if set. More...
 
ossim_uint32 getStartingResLevel () const
 
void setStartingResLevel (ossim_uint32 level)
 
bool getOpenOverviewFlag () const
 
void setOpenOverviewFlag (bool flag)
 Sets theOpenOverviewFlag. More...
 
virtual void setSupplementaryDirectory (const ossimFilename &dir)
 Sets the supplementary directory. More...
 
virtual const ossimFilenamegetSupplementaryDirectory () const
 Returns the supplementary directory. More...
 
const ossimStringgetImageID () const
 Fetches the image ID. More...
 
void setImageID (const ossimString &id)
 Sets the image ID in case it is externally generated. More...
 
ossimPixelType getPixelType () const
 Returns the raster pixel alignment type. More...
 
template<class T >
std::shared_ptr< T > getStateAs ()
 
template<class T >
std::shared_ptr< const T > getStateAs () const
 
std::shared_ptr< ossim::ImageHandlerState > getState ()
 
std::shared_ptr< const ossim::ImageHandlerState > getState () const
 
void setState (std::shared_ptr< ossim::ImageHandlerState > state)
 
- Public Member Functions inherited from ossimImageSource
 ossimImageSource (ossimObject *owner=0)
 
 ossimImageSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimImageSource ()
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIpt &origin, ossim_uint32 resLevel=0)
 
virtual bool getTile (ossimImageData *result, ossim_uint32 resLevel=0)
 Method to get a tile. More...
 
virtual ossimObjectgetObject ()
 For RTTI support. More...
 
virtual const ossimObjectgetObject () const
 For RTTI support. More...
 
virtual void getDecimationFactors (std::vector< ossimDpt > &decimations) const
 Will return an array of all decimations for each resolution level. More...
 
virtual void getOutputBandList (std::vector< ossim_uint32 > &bandList) const
 Initializes bandList. More...
 
virtual void getBoundingRect (ossimIrect &rect, ossim_uint32 resLevel=0) const
 Gets the bounding rectangle of the source. More...
 
virtual void getValidImageVertices (std::vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
 ordering specifies how the vertices should be arranged. More...
 
virtual void setImageGeometry (const ossimImageGeometry *geom)
 Default implementation sets geometry of the first input to the geometry specified. More...
 
virtual bool isIndexedData () const
 
- Public Member Functions inherited from ossimSource
 ossimSource (ossimObject *owner=0)
 
 ossimSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimSource ()
 
virtual bool isSourceEnabled () const
 
virtual void enableSource ()
 
virtual void disableSource ()
 
virtual bool getEnableFlag () const
 
virtual void setEnableFlag (bool flag)
 
virtual bool isInitialized () const
 
virtual void setInitializedFlag (bool flag)
 
virtual 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 getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossimListenerManager
 ossimListenerManager ()
 
virtual ~ossimListenerManager ()
 
virtual void fireEvent (ossimEvent &event)
 
virtual bool addListener (ossimListener *listener)
 
virtual bool removeListener (ossimListener *listener)
 
virtual bool findListener (ossimListener *listener)
 
- Public Member Functions inherited from ossimPropertyInterface
 ossimPropertyInterface ()
 
virtual ~ossimPropertyInterface ()
 
virtual ossimString getPropertyValueAsString (const ossimString &name) const
 
void getPropertyList (std::vector< ossimRefPtr< ossimProperty > > &propertyList) const
 
void setProperties (std::vector< ossimRefPtr< ossimProperty > > &propertyList)
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 

Protected Member Functions

virtual bool getOverviewTile (ossim_uint32 resLevel, ossimImageData *result)
 Gets an overview tile. More...
 
virtual bool loadBlock (ossim_uint32 x, ossim_uint32 y)
 Loads a block of data to theCacheTile. More...
 
virtual bool parseFile ()
 Parses "theImageFile" and initializes all nitf headers. More...
 
virtual bool allocate ()
 Allocates everything for current entry. More...
 
virtual bool allocateBuffers ()
 Allocates buffers for current entry. More...
 
virtual bool canUncompress (const ossimNitfImageHeader *hdr) const
 Checks header to see is we can decompress entry. More...
 
virtual void initializeReadMode ()
 Initializes the data member "theReadMode" from the current entry. More...
 
virtual bool scanForJpegBlockOffsets ()
 This method simply checks for Start of Codestream (SOC) marker as the Kakadu library handles finding tiles for us. More...
 
virtual void initializeSwapBytesFlag ()
 Sets the "theSwapBytesFlag" from the current entry. More...
 
virtual void initializeCacheTileInterLeaveType ()
 Initializes the data member "theCacheTileInterLeaveType". More...
 
virtual ossim_int32 get_capabilities ()
 Gets kdu source capability. More...
 
virtual ossim_int32 read (kdu_core::kdu_byte *buf, ossim_int32 num_bytes)
 Read method. More...
 
virtual bool seek (kdu_core::kdu_long offset)
 Seek method. More...
 
virtual kdu_core::kdu_long get_pos ()
 Get file position relative to the start of code stream offset. More...
 
- Protected Member Functions inherited from ossimNitfTileSource
virtual ~ossimNitfTileSource ()
 
void setBoundingRectangle (const ossimIrect &imageRect)
 
 ossimNitfTileSource (const ossimNitfTileSource &obj)
 Copy constructor, disallow... More...
 
ossimNitfTileSourceoperator= (const ossimNitfTileSource &rhs)
 Operator=, disallow... More...
 
bool loadTile (const ossimIrect &clipRect)
 Returns true on success, false on error. More...
 
ossim_uint32 getBlockNumber (const ossimIpt &block_origin) const
 
void destroy ()
 Deletes all memory allocated by this object. More...
 
virtual void initializeScalarType ()
 Initializes the data member "theScalarType" from the current entry. More...
 
void initializeBandCount ()
 Initializes the data member "theNumberOfBands" from the current entry. More...
 
bool initializeBlockSize ()
 Initializes the data member "theBlockSize" from the current entry. More...
 
virtual bool initializeImageRect ()
 Initializes the data members "theImageRect" and "theBlockRect" from the current entry. More...
 
void initializeCacheSize ()
 Initializes the data member "theCacheSize". More...
 
void initializeCacheTile ()
 Initializes the cache tile size(width and height). More...
 
virtual void initializeCompressedBuf ()
 Initializes the data member theCompressedBuf. More...
 
virtual void initializeOutputTile ()
 Initializes the output tile size(width and height). More...
 
void initializeLut ()
 Initializes "theLut" if applicable. More...
 
bool loadBlockFromCache (ossim_uint32 x, ossim_uint32 y, const ossimIrect &clipRect)
 Loads a block of data to theCacheTile. More...
 
bool getPosition (std::streamoff &position, ossim_uint32 x, ossim_uint32 y, ossim_uint32 band) const
 
ossim_uint32 getNumberOfBlocks () const
 
std::streampos getBandOffset () const
 
std::streampos getBlockOffset () const
 
void explodePackedBits (ossimRefPtr< ossimImageData > packedBuffer) const
 
void convertTransparentToNull (ossimRefPtr< ossimImageData > tile) const
 
ossim_uint32 getPartialReadSize (const ossimIpt &blockOrigin) const
 
bool isVqCompressed (const ossimString &compressionCode) const
 
void vqUncompressC4 (ossimRefPtr< ossimImageData > destination, ossim_uint8 *source)
 Uncompresses Vector Quantization unmasked image data. More...
 
void vqUncompressM4 (ossimRefPtr< ossimImageData > destination, ossim_uint8 *source)
 Uncompresses Vector Quantization masked image data. More...
 
void lutUncompress (ossimRefPtr< ossimImageData > destination, ossim_uint8 *source)
 
virtual bool uncompressJpegBlock (ossim_uint32 x, ossim_uint32 y)
 Uncompresses a jpeg block using the jpeg-6b library. More...
 
bool loadJpegQuantizationTables (jpeg_decompress_struct &cinfo) const
 Loads one of the default tables based on COMRAT value. More...
 
bool loadJpegHuffmanTables (jpeg_decompress_struct &cinfo) const
 Loads default huffman tables. More...
 
virtual void establishDecimationFactors ()
 Virtual method determines the decimation factors at each resolution level. More...
 
- Protected Member Functions inherited from ossimImageHandler
virtual ossimRefPtr< ossimImageGeometrygetExternalImageGeometry () const
 Returns the image geometry object associated with this tile source or NULL if non defined. More...
 
virtual ossimRefPtr< ossimImageGeometrygetInternalImageGeometry () const
 
bool initVertices (const char *file)
 Opens file and attempts to initialize the valid image vertices. More...
 
virtual void completeOpen ()
 Will complete the opening process. More...
 
void initImageParameters (ossimImageGeometry *geom) const
 Convenience method to set things needed in the image geometry from the image handler. More...
 
virtual bool setOutputBandList (const std::vector< ossim_uint32 > &inBandList, std::vector< ossim_uint32 > &outBandList)
 Convenience method to set output band list. More...
 
void getFilenameWithNoExtension (ossimFilename &f) const
 Get filename with no extension, using supplentary directory for dirname if set. More...
 
- Protected Member Functions inherited from ossimImageSource
 ossimImageSource (const ossimImageSource &rhs)
 
const ossimImageSourceoperator= (const ossimImageSource &)
 
- Protected Member Functions inherited from ossimSource
 ossimSource (const ossimSource &rhs)
 
const ossimSourceoperator= (const ossimSource &rhs)
 
- Protected Member Functions inherited from ossimConnectableObject
ossimConnectableObjectfindObjectOfType (ConnectableObjectList *connectableList, ossimVisitor &visitor)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimListenerManager
 ossimListenerManager (const ossimListenerManager &rhs)
 

Private Member Functions

bool isEntryJ2k () const
 Checks current entry image header to see if it is j2k. More...
 
bool checkJp2Signature ()
 Checks for jp2 signature block. More...
 
void configureChannelMapping ()
 Initializes m_channels to be used with copyRegionToTile if it makes sense. More...
 
std::ostream & dumpTiles (std::ostream &out)
 Method to print out tile info. More...
 

Private Attributes

std::streamoff m_startOfCodestreamOffset
 
kdu_supp::jp2_family_src * m_jp2FamilySrc
 
kdu_supp::jp2_source * m_jp2Source
 
kdu_supp::kdu_channel_mapping * m_channels
 
kdu_core::kdu_codestream m_codestream
 
kdu_core::kdu_thread_env * m_threadEnv
 
kdu_core::kdu_thread_queue * m_openTileThreadQueue
 
ossim_uint32 m_sourcePrecisionBits
 
ossim_uint32 m_minDwtLevels
 
std::vector< ossimIrectm_imageDims
 Image dimensions for each level. More...
 
ossim_float64 m_minSampleValue
 min/max/null These are class attributes so that when behaving as an overview the owner or base image handler can pass its min/max/null to us. More...
 
ossim_float64 m_maxSampleValue
 
ossim_float64 m_nullSampleValue
 

Additional Inherited Members

- Protected Attributes inherited from ossimNitfTileSource
ossimRefPtr< ossimImageDatatheTile
 
ossimRefPtr< ossimImageDatatheCacheTile
 
ossimRefPtr< ossimNitfFiletheNitfFile
 
std::vector< ossimRefPtr< ossimNitfImageHeader > > theNitfImageHeader
 
ReadMode theReadMode
 
ossimScalarType theScalarType
 
bool theSwapBytesFlag
 
ossim_uint32 theNumberOfInputBands
 
ossim_uint32 theNumberOfOutputBands
 
ossim_uint32 theBlockSizeInBytes
 
ossim_uint32 theReadBlockSizeInBytes
 
ossim_uint32 theNumberOfImages
 
ossim_uint32 theCurrentEntry
 
ossimIrect theImageRect
 
std::shared_ptr< ossim::istreamtheFileStr
 
std::vector< ossim_uint32theSelectorBandList
 
std::vector< ossim_uint32theOutputBandList
 
ossimIpt theCacheSize
 
ossimInterleaveType theCacheTileInterLeaveType
 
bool theCacheEnabledFlag
 
std::vector< ossim_uint32theEntryList
 
ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId
 
bool thePackedBitsFlag
 
ossimIrect theBlockImageRect
 
std::vector< ossim_uint8theCompressedBuf
 
std::vector< std::streamoff > theNitfBlockOffset
 
std::vector< ossim_uint32theNitfBlockSize
 
bool m_jpegOffsetsDirty
 
- Protected Attributes inherited from ossimImageHandler
ossimFilename theImageFile
 
ossimFilename theOverviewFile
 
ossimFilename theSupplementaryDirectory
 
ossimRefPtr< ossimImageHandlertheOverview
 
vector< ossimIpttheValidImageVertices
 
ossimImageMetaData theMetaData
 
ossimRefPtr< ossimImageGeometrytheGeometry
 
ossimRefPtr< ossimNBandLutDataObjecttheLut
 
std::vector< ossimDpttheDecimationFactors
 
ossimString theImageID
 
ossim_uint32 theStartingResLevel
 theStartingResLevel If set to something other than zero(default) this is indicative that the reader is an overview. More...
 
bool theOpenOverviewFlag
 If true opening of overviews will be attempted. More...
 
ossimPixelType thePixelType
 
std::shared_ptr< ossim::ImageHandlerState > m_state
 
- 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
 

Detailed Description

ossimKakaduNitfReader class for reading NITF images with JPEG2000 (J2K) compressed blocks using kakadu library for decompression.

Definition at line 44 of file ossimKakaduNitfReader.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Anonymous enumerations:

Enumerator
SIGNATURE_BOX_SIZE 

Definition at line 50 of file ossimKakaduNitfReader.h.

Constructor & Destructor Documentation

◆ ossimKakaduNitfReader()

ossimKakaduNitfReader::ossimKakaduNitfReader ( )

default construtor

◆ ~ossimKakaduNitfReader()

ossimKakaduNitfReader::~ossimKakaduNitfReader ( )
virtual

virtural destructor

Definition at line 76 of file ossimKakaduNitfReader.cpp.

References ossimNitfTileSource::close(), m_channels, m_codestream, m_jp2FamilySrc, m_jp2Source, m_openTileThreadQueue, m_threadEnv, ossimNotify(), and ossimNotifyLevel_WARN.

77 {
78  // Kakadu kdu_thread_entity::terminate throws exceptions...
79  try
80  {
81  // Cleanup processing environment
82  if ( m_threadEnv )
83  {
84  m_threadEnv->terminate(m_openTileThreadQueue, true);
85 
86  // Terminates background codestream processing.
87  m_threadEnv->cs_terminate(m_codestream);
88 
89  m_threadEnv->destroy();
90  delete m_threadEnv;
91  m_threadEnv = 0;
92  }
93 
94  if ( m_codestream.exists() )
95  {
96  m_codestream.destroy();
97  }
98 
100  {
102  }
103  if ( m_jp2Source )
104  {
105  delete m_jp2Source;
106  m_jp2Source = 0;
107  }
108  if ( m_jp2FamilySrc )
109  {
110  delete m_jp2FamilySrc;
111  m_jp2FamilySrc = 0;
112  }
113  if ( m_channels )
114  {
115  m_channels->clear();
116  delete m_channels;
117  m_channels = 0;
118  }
119  }
120  catch ( kdu_core::kdu_exception exc )
121  {
122  // kdu_exception is an int typedef.
123  if ( m_threadEnv != 0 )
124  {
125  m_threadEnv->handle_exception(exc);
126  }
127  ostringstream e;
128  e << "ossimKakaduNitfReader::~ossimKakaduNitfReader\n"
129  << "Caught exception from kdu_region_decompressor: " << exc << "\n";
130  ossimNotify(ossimNotifyLevel_WARN) << e.str() << std::endl;
131  }
132  catch ( std::bad_alloc& )
133  {
134  if ( m_threadEnv != 0 )
135  {
136  m_threadEnv->handle_exception(KDU_MEMORY_EXCEPTION);
137  }
138  std::string e =
139  "Caught exception from kdu_region_decompressor: std::bad_alloc";
140  ossimNotify(ossimNotifyLevel_WARN) << e << std::endl;
141  }
142  catch( ... )
143  {
144  std::string e =
145  "Caught unhandled exception from kdu_region_decompressor";
146  ossimNotify(ossimNotifyLevel_WARN) << e << std::endl;
147  }
148 
150 }
kdu_core::kdu_codestream m_codestream
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
kdu_supp::jp2_source * m_jp2Source
kdu_supp::kdu_channel_mapping * m_channels
virtual void close()
Closes file and destroys all memory allocated.
kdu_core::kdu_thread_queue * m_openTileThreadQueue
kdu_supp::jp2_family_src * m_jp2FamilySrc
kdu_core::kdu_thread_env * m_threadEnv
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Member Function Documentation

◆ allocate()

bool ossimKakaduNitfReader::allocate ( )
protectedvirtual

Allocates everything for current entry.

This is called on an open() or a entry change to an already open nitf file.

This does not allocate buffers and tiles to keep open and setCurrentEntry times to a minimum. Buffers are allocated on first grab of pixel data by allocatBuffers method.

Overrides ossimNitfTileSource::allocate

Returns
True on success, false on error.

Reimplemented from ossimNitfTileSource.

Definition at line 528 of file ossimKakaduNitfReader.cpp.

529 {
530  static const char MODULE[] = "ossimKakaduNitfReader::allocate";
531 
532  if (traceDebug())
533  {
534  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
535 
536  }
537 
538  bool result = ossimNitfTileSource::allocate();
539 
540  if ( isEntryJ2k() && result )
541  {
542  // This only finds "Start Of Codestream" (SOC) so it's fast.
543  result = scanForJpegBlockOffsets();
544 
545  if (traceDebug())
546  {
548  if( hdr )
549  {
551  << "start_of_data: " << hdr->getDataLocation() << "\n";
552  }
554  << "start_of_codestream: " << m_startOfCodestreamOffset << "\n";
555  }
556 
557  if ( result )
558  {
559  // Kakadu throws exceptions so wrap in try block.
560  try
561  {
562  // Position to start of code stream prior to create call.
563  theFileStr->seekg(m_startOfCodestreamOffset, ios_base::beg);
564 
565  //---
566  // Initialize the codestream. The class ossimKakaduNitfReader is a
567  // kdu_compressed source so we feed ourself to the codestream.
568  //---
569 
570  // Construct multi-threaded processing environment if required.
571  if ( m_threadEnv )
572  {
573  m_threadEnv->terminate(NULL, true);
574  m_threadEnv->cs_terminate(m_codestream);
575  m_threadEnv->destroy();
576  }
577 
578  if( m_codestream.exists() )
579  {
580  m_codestream.destroy();
581  }
582 
583  if ( !m_threadEnv )
584  {
585  m_threadEnv = new kdu_thread_env();
586  }
587 
588  m_threadEnv->create(); // Creates the single "owner" thread
589 
590  // Check for threads in prefs file.
591  ossim_uint32 threads = 1;
592  const char* lookup = ossimPreferences::instance()->findPreference("kakadu_threads");
593  if ( lookup )
594  {
595  threads = ossimString::toUInt32(lookup);
596  if ( threads > 1 )
597  {
598  for (ossim_uint32 nt=1; nt < threads; ++nt)
599  {
600  if ( !m_threadEnv->add_thread() )
601  {
602  if (traceDebug())
603  {
604  ossimNotify(ossimNotifyLevel_WARN) << "Unable to create thread!\n";
605  }
606  }
607  }
608  }
609  }
610 
611  m_openTileThreadQueue = m_threadEnv->add_queue(NULL,NULL,"open_tile_q");
612 
613  if ( checkJp2Signature() )
614  {
615  // Note we must be at the JP2 signature block at this point for the open call.
616  m_jp2FamilySrc = new jp2_family_src();
617  m_jp2FamilySrc->open(this);
618 
619  if (m_jp2FamilySrc->exists())
620  {
621  m_jp2Source = new kdu_supp::jp2_source();
622 
624  m_jp2Source->read_header();
625 
626  if (traceDebug())
627  {
628  jp2_colour colour = m_jp2Source->access_colour();
629  if ( colour.exists() )
630  {
632  << "jp2 color space: " << colour.get_space() << endl;
633  }
634  }
635  }
637  }
638  else
639  {
640  m_codestream.create(this, m_threadEnv);
641  }
642 
643  if ( m_codestream.exists() )
644  {
645  //---
646  // We have to store things here in this non-const method because
647  // NONE of the kakadu methods are const.
648  //---
649  m_minDwtLevels = m_codestream.get_min_dwt_levels();
650 
651  //---
652  // NOTE: ossimNitfTileSource::allocate() calls open overview
653  // before the number of levels is known.
654  // Set the starting res level for the overview now that the levels
655  // are known.
656  //---
657  if ( theOverview.valid() )
658  {
660  }
661 
662  // ASSUMPTION: All bands same bit depth.
663  m_sourcePrecisionBits = m_codestream.get_bit_depth(0, true);
664 
665  m_codestream.set_persistent(); // ????
666  m_codestream.enable_restart(); // ????
667 
668  // Get the image and tile dimensions.
669  std::vector<ossimIrect> tileDims;
671  m_imageDims,
672  tileDims) == false )
673  {
675  << __FILE__ << " " << __LINE__ << " " << MODULE
676  << "Could not ascertain dimensions!" << std::endl;
677  result = false;
678  }
679 
680  kdu_dims region_of_interest;
681  region_of_interest.pos.x = 0;
682  region_of_interest.pos.y = 0;
683  region_of_interest.size.x = m_imageDims[0].width();
684  region_of_interest.size.y = m_imageDims[0].height();
685 
686  m_codestream.apply_input_restrictions(
687  0, // first_component
688  0, // max_components (0 = all remaining will appear)
689  0, // highest resolution level
690  0, // max_layers (0 = all layers retained)
691  &region_of_interest, // expanded out to block boundary.
692  KDU_WANT_OUTPUT_COMPONENTS);
693 
694  // Configure the kdu_channel_mapping if it makes sense.
696 
697  if (traceDebug())
698  {
700  << "m_codestream.get_num_components(false): "
701  << m_codestream.get_num_components(false)
702  << "\nm_codestream.get_num_components(true): "
703  << m_codestream.get_num_components(true)
704  << "\nm_codestream.get_bit_depth(0, true): "
705  << m_codestream.get_bit_depth(0, true)
706  << "\nm_codestream.get_signed(0, true): "
707  << m_codestream.get_signed(0, true)
708  << "\nm_codestream.get_min_dwt_levels(): "
709  << m_codestream.get_min_dwt_levels()
710  << "\ntheNumberOfInputBands: "
712  << "\ntheNumberOfOutputBands: "
714  << "\nthreads: " << threads
715  << "\n";
716  for ( std::vector<ossimIrect>::size_type i = 0; i < m_imageDims.size(); ++i )
717  {
719  << "m_imageDims[" << i << "]: " << m_imageDims[i] << "\n";
720  }
721  }
722  }
723  else // if ( m_codestream.exists() )
724  {
725  result = false;
726  }
727 
728  } // End: try block
729  catch( const ossimException& e )
730  {
731  result = false;
732  if (traceDebug())
733  {
735  << MODULE << " Caught exception: " << e.what() << std::endl;
736  }
737  }
738  catch( ... )
739  {
740  result = false;
741  if (traceDebug())
742  {
744  << MODULE << " Caught unknown exception!" << std::endl;
745  }
746  }
747 
748  } // Matches: if ( result )
749 
750  } // Matches: if ( isEntryJ2k() && result )
751 
752  if (traceDebug())
753  {
755  << MODULE << " exit status = " << (result?"true":"false\n")
756  << std::endl;
757  }
758 
759  return result;
760 
761 } // End: ossimKakaduNitfReader::allocate()
virtual bool scanForJpegBlockOffsets()
This method simply checks for Start of Codestream (SOC) marker as the Kakadu library handles finding ...
kdu_core::kdu_codestream m_codestream
ossim_uint32 theNumberOfInputBands
bool valid() const
Definition: ossimRefPtr.h:75
std::shared_ptr< ossim::istream > theFileStr
std::streamoff m_startOfCodestreamOffset
ossim_uint32 toUInt32() const
void configureChannelMapping()
Initializes m_channels to be used with copyRegionToTile if it makes sense.
virtual bool allocate()
Allocates everything for current entry.
kdu_supp::jp2_source * m_jp2Source
const char * findPreference(const char *key) const
virtual const char * what() const
Returns the error message.
unsigned int ossim_uint32
kdu_core::kdu_thread_queue * m_openTileThreadQueue
virtual ossim_uint64 getDataLocation() const =0
const ossimNitfImageHeader * getCurrentImageHeader() const
static ossimPreferences * instance()
kdu_supp::jp2_family_src * m_jp2FamilySrc
void setStartingResLevel(ossim_uint32 level)
bool isEntryJ2k() const
Checks current entry image header to see if it is j2k.
ossimRefPtr< ossimImageHandler > theOverview
kdu_core::kdu_thread_env * m_threadEnv
bool checkJp2Signature()
Checks for jp2 signature block.
bool getCodestreamDimensions(kdu_core::kdu_codestream &codestream, std::vector< ossimIrect > &imageDims, std::vector< ossimIrect > &tileDims)
Gets image and tile dimensions from codestream for each resolution level (rlevel).
std::vector< ossimIrect > m_imageDims
Image dimensions for each level.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_uint32 theNumberOfOutputBands

◆ allocateBuffers()

bool ossimKakaduNitfReader::allocateBuffers ( )
protectedvirtual

Allocates buffers for current entry.

This is called on first getTile().

Overrides ossimNitfTileSource::allocateBuffers

Returns
True on success, false on error.

Reimplemented from ossimNitfTileSource.

Definition at line 763 of file ossimKakaduNitfReader.cpp.

References ossimNitfTileSource::allocateBuffers(), ossimNitfTileSource::getNumberOfOutputBands(), ossim::isnan(), m_maxSampleValue, m_minSampleValue, m_nullSampleValue, ossimImageData::setMaxPix(), ossimImageData::setMinPix(), ossimImageData::setNullPix(), ossimNitfTileSource::theCacheTile, ossimNitfTileSource::theTile, and ossimRefPtr< T >::valid().

764 {
765  bool result = ossimNitfTileSource::allocateBuffers();
766  if ( result )
767  {
768  //---
769  // The ossimImageHandler::openOverview can set our min, max and null before we
770  // have our tiles allocated.
771  //
772  // Set the min, max, and null in case we're being used as an overview handler
773  // and it is out of sync with the base image. Example is dted null is -32767
774  // not default -32768.
775  //---
776  const ossim_uint32 BANDS = getNumberOfOutputBands();
777  for (ossim_uint32 band = 0; band < BANDS; ++band)
778  {
779  if ( theTile.valid() )
780  {
782  {
784  }
786  {
788  }
790  {
792  }
793  }
794  if ( theCacheTile.valid() )
795  {
797  {
799  }
801  {
803  }
805  {
807  }
808  }
809  }
810  }
811  return result;
812 
813 } // End: ossimKakaduNitfReader::allocateBuffer()
bool valid() const
Definition: ossimRefPtr.h:75
ossim_float64 m_minSampleValue
min/max/null These are class attributes so that when behaving as an overview the owner or base image ...
virtual void setNullPix(ossim_float64 null_pix)
unsigned int ossim_uint32
ossimRefPtr< ossimImageData > theCacheTile
ossimRefPtr< ossimImageData > theTile
virtual void setMaxPix(ossim_float64 max_pix)
virtual ossim_uint32 getNumberOfOutputBands() const
virtual void setMinPix(ossim_float64 min_pix)
virtual bool allocateBuffers()
Allocates buffers for current entry.
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ canUncompress()

bool ossimKakaduNitfReader::canUncompress ( const ossimNitfImageHeader hdr) const
protectedvirtual

Checks header to see is we can decompress entry.

If compression code is not "C8" calls base canUncompress as you could have a J2k entry and a jpeg entry.

Overrides ossimNitfTileSource::canUncompress

Parameters
hdrPointer to image header.
Returns
true if reader can uncompress nitf.

Reimplemented from ossimNitfTileSource.

Definition at line 815 of file ossimKakaduNitfReader.cpp.

References ossimNitfTileSource::canUncompress(), and ossimNitfImageHeader::getCompressionCode().

816 {
817  bool result = false;
818  if (hdr)
819  {
820  if (hdr->getCompressionCode() == "C8") // j2k
821  {
822  result = true;
823  }
824  else
825  {
827  }
828  }
829  return result;
830 }
virtual bool canUncompress(const ossimNitfImageHeader *hdr) const
virtual ossimString getCompressionCode() const =0

◆ checkJp2Signature()

bool ossimKakaduNitfReader::checkJp2Signature ( )
private

Checks for jp2 signature block.

Note the stream is repositioned to start of data after the check so that the jp2 open code does not have to reposition.

Returns
true if jp2, false if not.

Definition at line 973 of file ossimKakaduNitfReader.cpp.

References ossimNitfTileSource::getCurrentImageHeader(), ossimNitfImageHeader::getDataLocation(), SIGNATURE_BOX_SIZE, and ossimNitfTileSource::theFileStr.

Referenced by scanForJpegBlockOffsets().

974 {
975  bool result = false;
977  if( hdr )
978  {
979  std::streamoff startOfDataPos = hdr->getDataLocation();
980 
981  // Seek to the start of data.
982  theFileStr->seekg(startOfDataPos, ios_base::beg);
983  if ( theFileStr->good() )
984  {
985  const ossim_uint8 J2K_SIGNATURE_BOX[SIGNATURE_BOX_SIZE] =
986  {0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20,0x0d,0x0a,0x87,0x0a};
987 
989 
990  // Read in the box.
991  theFileStr->read((char*)box, SIGNATURE_BOX_SIZE);
992  result = true;
993  for (ossim_uint32 i = 0; i < SIGNATURE_BOX_SIZE; ++i)
994  {
995  if (box[i] != J2K_SIGNATURE_BOX[i])
996  {
997  result = false;
998  break;
999  }
1000  }
1001  }
1002 
1003  // Seek back to the start of data.
1004  theFileStr->seekg(startOfDataPos, ios_base::beg);
1005  }
1006 
1007  return result;
1008 }
std::shared_ptr< ossim::istream > theFileStr
unsigned int ossim_uint32
virtual ossim_uint64 getDataLocation() const =0
const ossimNitfImageHeader * getCurrentImageHeader() const
unsigned char ossim_uint8

◆ configureChannelMapping()

void ossimKakaduNitfReader::configureChannelMapping ( )
private

Initializes m_channels to be used with copyRegionToTile if it makes sense.

Definition at line 1010 of file ossimKakaduNitfReader.cpp.

References m_channels, m_codestream, m_jp2Source, and ossimNitfTileSource::theNumberOfOutputBands.

1011 {
1012  bool result = false;
1013 
1014  if ( m_channels )
1015  {
1016  m_channels->clear();
1017  }
1018  else
1019  {
1020  m_channels = new kdu_channel_mapping;
1021  }
1022 
1023  if ( m_jp2Source )
1024  {
1025  // Currently ignoring alpha:
1026  result = m_channels->configure(m_jp2Source, false);
1027  }
1028  else
1029  {
1030  result = m_channels->configure(m_codestream);
1031  }
1032 
1033  if ( result )
1034  {
1035  // If we the mapping doesn't have all our bands we don't use it.
1036  if ( m_channels->get_num_colour_channels() != static_cast<int>(theNumberOfOutputBands) )
1037  {
1038  result = false;
1039  }
1040  }
1041 
1042  if ( !result )
1043  {
1044  m_channels->clear();
1045  delete m_channels;
1046  m_channels = 0;
1047  }
1048 }
kdu_core::kdu_codestream m_codestream
kdu_supp::jp2_source * m_jp2Source
kdu_supp::kdu_channel_mapping * m_channels
ossim_uint32 theNumberOfOutputBands

◆ dumpTiles()

std::ostream & ossimKakaduNitfReader::dumpTiles ( std::ostream &  out)
private

Method to print out tile info.

For debug only.

Definition at line 1050 of file ossimKakaduNitfReader.cpp.

References ossimNitfTileSource::getCurrentImageHeader(), ossimNitfImageHeader::getNumberOfBlocksPerCol(), ossimNitfImageHeader::getNumberOfBlocksPerRow(), m_startOfCodestreamOffset, ossimJ2kSizRecord::parseStream(), ossimJ2kSotRecord::parseStream(), ossimJ2kTlmRecord::parseStream(), ossimJ2kCodRecord::parseStream(), ossimJ2kCodRecord::print(), ossimJ2kSotRecord::print(), ossimJ2kSizRecord::print(), ossimJ2kTlmRecord::print(), ossimNitfTileSource::theFileStr, and ossimJ2kSotRecord::thePsot.

1051 {
1052  //---
1053  // NOTE:
1054  // SOC = 0xff4f Start of Codestream
1055  // SOT = 0xff90 Start of tile
1056  // SOD = 0xff93 Last marker in each tile
1057  // EOC = 0xffd9 End of Codestream
1058  //---
1059 
1061  if(hdr)
1062  {
1063  // Capture the starting position.
1064  std::streampos currentPos = theFileStr->tellg();
1065 
1066  // Seek to the first block.
1067  theFileStr->seekg(m_startOfCodestreamOffset, ios_base::beg);
1068  if (theFileStr->good())
1069  {
1070  out << "offset to codestream: " << m_startOfCodestreamOffset << "\n";
1071 
1072  //---
1073  // Read the first two bytes and test for SOC (Start Of Codestream)
1074  // marker.
1075  //---
1076  ossim_uint8 markerField[2];
1077  theFileStr->read( (char*)markerField, 2);
1078 
1079  bool foundSot = false;
1080  if ( (markerField[0] == 0xff) && (markerField[1] == 0x4f) )
1081  {
1082  // Get the SIZ marker and dump it.
1083  theFileStr->read( (char*)markerField, 2);
1084  if ( (markerField[0] == 0xff) && (markerField[1] == 0x51) )
1085  {
1086  ossimJ2kSizRecord siz;
1087  siz.parseStream( *theFileStr );
1088  siz.print(out);
1089  }
1090 
1091  // Find the firt tile marker.
1092  char c;
1093  while ( theFileStr->get(c) )
1094  {
1095  if (static_cast<ossim_uint8>(c) == 0xff)
1096  {
1097  if ( theFileStr->get(c) )
1098  {
1099  out << "marker: 0xff" << hex << (ossim_uint16)c << dec << endl;
1100 
1101  if (static_cast<ossim_uint8>(c) == 0x52)
1102  {
1103  out << "\nFound COD...\n\n" << endl;
1104  ossimJ2kCodRecord cod;
1105  cod.parseStream( *theFileStr );
1106  cod.print(out);
1107 
1108  }
1109  else if (static_cast<ossim_uint8>(c) == 0x55)
1110  {
1111  out << "\nFound TLM...\n\n" << endl;
1112  ossimJ2kTlmRecord tlm;
1113  tlm.parseStream( *theFileStr );
1114  tlm.print(out);
1115  }
1116  else if (static_cast<ossim_uint8>(c) == 0x90)
1117  {
1118  foundSot = true;
1119  break;
1120  }
1121  }
1122  }
1123  }
1124  }
1125 
1126  if (foundSot) // At SOT marker...
1127  {
1128  const ossim_uint32 BLOCKS =
1130  for (ossim_uint32 i = 0; i < BLOCKS; ++i)
1131  {
1132  std::streamoff pos = theFileStr->tellg();
1133  out << "sot pos: " << pos << endl;
1134  ossimJ2kSotRecord sotRecord;
1135  sotRecord.parseStream( *theFileStr );
1136  pos += sotRecord.thePsot;
1137  sotRecord.print(out);
1138  theFileStr->seekg(pos, ios_base::beg);
1139  }
1140  }
1141  }
1142 
1143  // If the last byte is read, the eofbit must be reset.
1144  if ( theFileStr->eof() )
1145  {
1146  theFileStr->clear();
1147  }
1148 
1149  // Put the stream back to the where it was.
1150  theFileStr->seekg(currentPos);
1151  }
1152 
1153  return out;
1154 }
virtual ossim_int32 getNumberOfBlocksPerRow() const =0
void parseStream(ossim::istream &in)
Parse method.
std::shared_ptr< ossim::istream > theFileStr
std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
std::streamoff m_startOfCodestreamOffset
void parseStream(std::istream &in)
Parse method.
unsigned short ossim_uint16
void parseStream(ossim::istream &in)
Parse method.
unsigned int ossim_uint32
ossim_uint32 thePsot
The length in bytes of this record including the SOT marker.
std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
const ossimNitfImageHeader * getCurrentImageHeader() const
std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
virtual ossim_int32 getNumberOfBlocksPerCol() const =0
unsigned char ossim_uint8
void parseStream(ossim::istream &in)
Parse method.

◆ get_capabilities()

ossim_int32 ossimKakaduNitfReader::get_capabilities ( )
inlineprotectedvirtual

Gets kdu source capability.

Overrides kdu_compressed_source::get_capabilities

Returns
KDU_SOURCE_CAP_SEEKABLE

Definition at line 369 of file ossimKakaduNitfReader.h.

370 {
371  return ( KDU_SOURCE_CAP_SEEKABLE | KDU_SOURCE_CAP_SEQUENTIAL );
372 }

◆ get_pos()

kdu_core::kdu_long ossimKakaduNitfReader::get_pos ( )
inlineprotectedvirtual

Get file position relative to the start of code stream offset.

Overrides kdu_compressed_source::get_pos

Returns
Position in codestream.

Definition at line 395 of file ossimKakaduNitfReader.h.

References m_startOfCodestreamOffset, and ossimNitfTileSource::theFileStr.

396 {
397  //---
398  // Must subtract the SOC(start of code stream) from the real file position
399  // since positions are relative to SOC.
400  //---
401  return static_cast<kdu_core::kdu_long>(theFileStr->tellg() - m_startOfCodestreamOffset );
402 }
std::shared_ptr< ossim::istream > theFileStr
std::streamoff m_startOfCodestreamOffset

◆ getLongName()

ossimString ossimKakaduNitfReader::getLongName ( ) const
virtual

Returns long name.

Returns
"ossim kakadu nitf reader"

Reimplemented from ossimNitfTileSource.

Definition at line 157 of file ossimKakaduNitfReader.cpp.

158 {
159  return ossimString("ossim kakadu nitf reader");
160 }

◆ getMaxPixelValue()

ossim_float64 ossimKakaduNitfReader::getMaxPixelValue ( ossim_uint32  band = 0) const
virtual
Returns
the max pixel value either from base class call or theMaxPixelValue if set.

Reimplemented from ossimNitfTileSource.

Definition at line 351 of file ossimKakaduNitfReader.cpp.

References ossimImageHandler::getMaxPixelValue(), ossim::isnan(), and m_maxSampleValue.

352 {
354  {
356  }
357  return m_maxSampleValue;
358 }
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ getMinPixelValue()

ossim_float64 ossimKakaduNitfReader::getMinPixelValue ( ossim_uint32  band = 0) const
virtual
Returns
the min pixel value either from base class call or theMinPixelValue if set.

Reimplemented from ossimNitfTileSource.

Definition at line 342 of file ossimKakaduNitfReader.cpp.

References ossimImageHandler::getMinPixelValue(), ossim::isnan(), and m_minSampleValue.

343 {
345  {
347  }
348  return m_minSampleValue;
349 }
virtual double getMinPixelValue(ossim_uint32 band=0) const
Retuns the min pixel value.
ossim_float64 m_minSampleValue
min/max/null These are class attributes so that when behaving as an overview the owner or base image ...
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ getNullPixelValue()

ossim_float64 ossimKakaduNitfReader::getNullPixelValue ( ossim_uint32  band = 0) const
virtual
Returns
the null pixel value either from base class call or theNullPixelValue if set.

Reimplemented from ossimNitfTileSource.

Definition at line 360 of file ossimKakaduNitfReader.cpp.

References ossimImageHandler::getNullPixelValue(), ossim::isnan(), and m_nullSampleValue.

361 {
363  {
365  }
366  return m_nullSampleValue;
367 }
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ getNumberOfDecimationLevels()

ossim_uint32 ossimKakaduNitfReader::getNumberOfDecimationLevels ( ) const
virtual

Returns the number of decimation levels.

This returns the total number of decimation levels. It is important to note that res level 0 or full resolution is included in the list and has decimation values 1.0, 1.0

Returns
The number of decimation levels.

Reimplemented from ossimImageHandler.

Definition at line 162 of file ossimKakaduNitfReader.cpp.

References ossimImageHandler::getNumberOfDecimationLevels(), isEntryJ2k(), m_minDwtLevels, ossimImageHandler::theOverview, and ossimRefPtr< T >::valid().

163 {
164  ossim_uint32 result = 1; // Add r0
165  if ( isEntryJ2k() )
166  {
167  if (m_minDwtLevels)
168  {
169  //---
170  // Add internal overviews.
171  //---
172  result += m_minDwtLevels;
173  }
174 
175  if (theOverview.valid())
176  {
178  }
179  }
180  else
181  {
183  }
184  return result;
185 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
unsigned int ossim_uint32
bool isEntryJ2k() const
Checks current entry image header to see if it is j2k.
ossimRefPtr< ossimImageHandler > theOverview

◆ getNumberOfLines()

ossim_uint32 ossimKakaduNitfReader::getNumberOfLines ( ossim_uint32  resLevel = 0) const
virtual

Gets number of lines for res level.

Overrides ossimNitfTileSource::getNumberOfLines

Parameters
resLevelReduced resolution level to return lines of. Default = 0
Returns
The number of lines for specified reduced resolution level.

Reimplemented from ossimNitfTileSource.

Definition at line 187 of file ossimKakaduNitfReader.cpp.

References ossimNitfTileSource::getNumberOfLines(), ossimImageHandler::getNumberOfLines(), isEntryJ2k(), ossimImageHandler::isValidRLevel(), m_imageDims, m_minDwtLevels, ossimImageHandler::theOverview, ossimImageHandler::theStartingResLevel, and ossimRefPtr< T >::valid().

189 {
190  ossim_uint32 result = 0;
191  if ( isEntryJ2k() )
192  {
193  if ( isValidRLevel(resLevel) )
194  {
195  ossim_uint32 level = resLevel;
196 
197  if (theStartingResLevel) // This is an overview.
198  {
199  //---
200  // Adjust the level to be relative to the reader using this as
201  // overview.
202  //---
203  level = resLevel - theStartingResLevel;
204  }
205 
206  if (level <= m_minDwtLevels)
207  {
208  result = m_imageDims[level].height();
209  }
210  else if ( theOverview.valid() )
211  {
212  // Note the non-adjusted resLevel is passed to this by design.
213  result = theOverview->getNumberOfLines(resLevel);
214  }
215  }
216  }
217  else // Not our entry.
218  {
219  result = ossimNitfTileSource::getNumberOfLines(resLevel);
220  }
221  return result;
222 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const
Returns the number of lines in the image.
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
unsigned int ossim_uint32
bool isEntryJ2k() const
Checks current entry image header to see if it is j2k.
ossimRefPtr< ossimImageHandler > theOverview
std::vector< ossimIrect > m_imageDims
Image dimensions for each level.
ossim_uint32 theStartingResLevel
theStartingResLevel If set to something other than zero(default) this is indicative that the reader i...

◆ getNumberOfSamples()

ossim_uint32 ossimKakaduNitfReader::getNumberOfSamples ( ossim_uint32  resLevel = 0) const
virtual

Gets the number of samples for res level.

Overrides ossimNitfTileSource::getNumberOfSamples

Parameters
resLevelReduced resolution level to return samples of. Default = 0
Returns
The number of samples for specified reduced resolution level.

Reimplemented from ossimNitfTileSource.

Definition at line 224 of file ossimKakaduNitfReader.cpp.

References ossimNitfTileSource::getNumberOfSamples(), ossimImageHandler::getNumberOfSamples(), isEntryJ2k(), ossimImageHandler::isValidRLevel(), m_imageDims, m_minDwtLevels, ossimImageHandler::theOverview, ossimImageHandler::theStartingResLevel, and ossimRefPtr< T >::valid().

226 {
227  ossim_uint32 result = 0;
228  if ( isEntryJ2k() )
229  {
230  if ( isValidRLevel(resLevel) )
231  {
232  ossim_uint32 level = resLevel;
233 
234  if (theStartingResLevel) // This is an overview.
235  {
236  //---
237  // Adjust the level to be relative to the reader using this as
238  // overview.
239  //---
240  level = resLevel - theStartingResLevel;
241  }
242 
243  if (level <= m_minDwtLevels)
244  {
245  result = m_imageDims[level].width();
246  }
247  else if ( theOverview.valid() )
248  {
249  // Note the non-adjusted resLevel is passed to this by design.
250  result = theOverview->getNumberOfSamples(resLevel);
251  }
252  }
253  }
254  else // Not our entry.
255  {
256  result = ossimNitfTileSource::getNumberOfSamples(resLevel);
257  }
258  return result;
259 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const
Returns the number of samples in the image.
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
unsigned int ossim_uint32
bool isEntryJ2k() const
Checks current entry image header to see if it is j2k.
ossimRefPtr< ossimImageHandler > theOverview
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
std::vector< ossimIrect > m_imageDims
Image dimensions for each level.
ossim_uint32 theStartingResLevel
theStartingResLevel If set to something other than zero(default) this is indicative that the reader i...

◆ getOverviewTile()

bool ossimKakaduNitfReader::getOverviewTile ( ossim_uint32  resLevel,
ossimImageData result 
)
protectedvirtual

Gets an overview tile.

Overrides ossimImageHandler::getOverviewTile

Parameters
resLevelThe resolution level to pull from with resLevel 0 being full res.
resultThe tile to stuff. Note The requested rectangle in full image space and bands should be set in the result tile prior to passing. This method will subtract the subImageOffset if needed for external overview call since they do not know about the sub image offset.
Returns
true on success false on error. Typically this will return false if resLevel==0 unless the overview has r0. If return is false, result is undefined so caller should handle appropriately with makeBlank or whatever.

Reimplemented from ossimImageHandler.

Definition at line 369 of file ossimKakaduNitfReader.cpp.

References ossim::copyRegionToTile(), ossimImageData::getImageRectangle(), ossimImageData::getNumberOfBands(), ossimNitfTileSource::getNumberOfOutputBands(), ossimImageHandler::getOverviewTile(), ossimImageSource::getTile(), isEntryJ2k(), ossimImageHandler::isValidRLevel(), m_channels, m_codestream, m_minDwtLevels, m_openTileThreadQueue, m_threadEnv, ossimNotify(), ossimNotifyLevel_WARN, status, ossimImageHandler::theOverview, ossimImageHandler::theStartingResLevel, ossimRefPtr< T >::valid(), and ossimException::what().

Referenced by loadBlock().

371 {
372  bool status = false;
373 
374  // static bool traced = false;
375 
376  // Must be j2k entry, not past number of levels, bands must match.
377  if ( isEntryJ2k() )
378  {
379  if ( isValidRLevel(resLevel) && result &&
380  (result->getNumberOfBands() == getNumberOfOutputBands()) )
381  {
382  ossim_uint32 level = resLevel - theStartingResLevel;
383 
384 #if 0 /* please leave for debug */
385  cout << "ovr get tile res level: " << resLevel
386  << " start level: " << theStartingResLevel
387  << "\nlevel: " << level
388  << "\nrect3: " << result->getImageRectangle() << endl;
389 #endif
390 
391  if (level <= m_minDwtLevels)
392  {
393  // Internal overviews...
394  try
395  {
396  if ( m_channels )
397  {
399  m_codestream,
400  static_cast<int>(level),
401  m_threadEnv,
403  result);
404  }
405  else
406  {
408  static_cast<int>(level),
409  m_threadEnv,
411  result);
412  }
413  }
414  catch(const ossimException& e)
415  {
417  << __FILE__ << ":" << __LINE__ << " caught exception\n"
418  << e.what() << std::endl;
419  status = false;
420  }
421 
422  } // matches: if (resLevel <= m_minDwtLevels)
423  else if ( theOverview.valid() )
424  {
425  //---
426  // Note: Passing non-adjusted "resLevel" to get tile by design.
427  //---
428  status = theOverview->getTile(result, resLevel);
429  }
430  }
431  else // Failed range check.
432  {
434  << __FILE__ << " " << __LINE__
435  << "Range error." << std::endl;
436  status = false;
437  }
438 
439  } // matches: if ( isEntryJ2k() )
440  else
441  {
442  // Not our entry, call the base.
443  status = ossimNitfTileSource::getOverviewTile(resLevel, result);
444  }
445 
446  return status;
447 
448 } // End: bool ossimKakaduNitfReader::getOverviewTile( ... )
kdu_core::kdu_codestream m_codestream
virtual ossim_uint32 getNumberOfBands() const
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Method to get an overview tile.
kdu_supp::kdu_channel_mapping * m_channels
virtual const char * what() const
Returns the error message.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
kdu_core::kdu_thread_queue * m_openTileThreadQueue
return status
bool isEntryJ2k() const
Checks current entry image header to see if it is j2k.
ossimRefPtr< ossimImageHandler > theOverview
bool copyRegionToTile(kdu_supp::kdu_channel_mapping *channelMapping, kdu_core::kdu_codestream &codestream, int discard_levels, kdu_core::kdu_thread_env *threadEnv, kdu_core::kdu_thread_queue *threadQueue, ossimImageData *destTile)
Copies region from codestream to tile at a given rlevel.
kdu_core::kdu_thread_env * m_threadEnv
virtual ossim_uint32 getNumberOfOutputBands() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_uint32 theStartingResLevel
theStartingResLevel If set to something other than zero(default) this is indicative that the reader i...
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)

◆ getShortName()

ossimString ossimKakaduNitfReader::getShortName ( ) const
virtual

Returns short name.

Returns
"ossim_kakadu_nitf_reader"

Reimplemented from ossimNitfTileSource.

Definition at line 152 of file ossimKakaduNitfReader.cpp.

153 {
154  return ossimString("ossim_kakadu_nitf_reader");
155 }

◆ initializeCacheTileInterLeaveType()

void ossimKakaduNitfReader::initializeCacheTileInterLeaveType ( )
protectedvirtual

Initializes the data member "theCacheTileInterLeaveType".

Overrides ossimNitfTileSource::initializeCacheTileInterLeaveType

Reimplemented from ossimNitfTileSource.

Definition at line 946 of file ossimKakaduNitfReader.cpp.

References ossimNitfTileSource::initializeCacheTileInterLeaveType(), isEntryJ2k(), OSSIM_BSQ, and ossimNitfTileSource::theCacheTileInterLeaveType.

947 {
948  if ( isEntryJ2k() )
949  {
950  // Always band separate here.
952  }
953  else
954  {
956  }
957 }
virtual void initializeCacheTileInterLeaveType()
Initializes the data member "theCacheTileInterLeaveType".
ossimInterleaveType theCacheTileInterLeaveType
bool isEntryJ2k() const
Checks current entry image header to see if it is j2k.

◆ initializeReadMode()

void ossimKakaduNitfReader::initializeReadMode ( )
protectedvirtual

Initializes the data member "theReadMode" from the current entry.

Overrides ossimNitfTileSource::initializeReadMode

Reimplemented from ossimNitfTileSource.

Definition at line 832 of file ossimKakaduNitfReader.cpp.

References ossimNitfImageHeader::getCompressionCode(), ossimNitfTileSource::getCurrentImageHeader(), ossimNitfImageHeader::getIMode(), ossimNitfTileSource::initializeReadMode(), ossimNitfTileSource::READ_JPEG_BLOCK, ossimNitfTileSource::READ_MODE_UNKNOWN, and ossimNitfTileSource::theReadMode.

833 {
836  if (hdr)
837  {
838  if (hdr->getCompressionCode() == "C8") // j2k
839  {
840  if ( (hdr->getIMode() == "B") && (hdr->getCompressionCode()== "C8") )
841  {
843  }
844  }
845  else
846  {
848  }
849  }
850 }
virtual ossimString getIMode() const =0
IMODE = B, IC = C3 "JPEG compressed blocks".
const ossimNitfImageHeader * getCurrentImageHeader() const
virtual ossimString getCompressionCode() const =0
virtual void initializeReadMode()
Initializes the data member "theReadMode" from the current entry.

◆ initializeSwapBytesFlag()

void ossimKakaduNitfReader::initializeSwapBytesFlag ( )
protectedvirtual

Sets the "theSwapBytesFlag" from the current entry.

Overrides ossimNitfTileSource::initializeSwapBytesFlag

Reimplemented from ossimNitfTileSource.

Definition at line 933 of file ossimKakaduNitfReader.cpp.

References ossimNitfTileSource::initializeSwapBytesFlag(), isEntryJ2k(), and ossimNitfTileSource::theSwapBytesFlag.

934 {
935  if ( isEntryJ2k() )
936  {
937  // Kakadu library handles.
938  theSwapBytesFlag = false;
939  }
940  else
941  {
943  }
944 }
virtual void initializeSwapBytesFlag()
Initializes the data member "theSwapBytesFlag" from the current entry.
bool isEntryJ2k() const
Checks current entry image header to see if it is j2k.

◆ isEntryJ2k()

bool ossimKakaduNitfReader::isEntryJ2k ( ) const
private

Checks current entry image header to see if it is j2k.

Returns
true if j2k, false if not.

Definition at line 959 of file ossimKakaduNitfReader.cpp.

References ossimNitfImageHeader::getCompressionCode(), and ossimNitfTileSource::getCurrentImageHeader().

Referenced by getNumberOfDecimationLevels(), getNumberOfLines(), getNumberOfSamples(), getOverviewTile(), initializeCacheTileInterLeaveType(), initializeSwapBytesFlag(), and loadBlock().

960 {
961  bool result = false;
963  if (hdr)
964  {
965  if (hdr->getCompressionCode() == "C8") // j2k
966  {
967  result = true;
968  }
969  }
970  return result;
971 }
const ossimNitfImageHeader * getCurrentImageHeader() const
virtual ossimString getCompressionCode() const =0

◆ loadBlock()

bool ossimKakaduNitfReader::loadBlock ( ossim_uint32  x,
ossim_uint32  y 
)
protectedvirtual

Loads a block of data to theCacheTile.

Parameters
xStarting x position of block to load.
yStarting y position of block to load.
Returns
true on success, false on error.
Note
x and y are zero based relative to the upper left corner so any sub image offset should be subtracted off.

Reimplemented from ossimNitfTileSource.

Definition at line 450 of file ossimKakaduNitfReader.cpp.

References ossimAppFixedTileCache::addTile(), ossimRefPtr< T >::get(), getOverviewTile(), ossimAppFixedTileCache::instance(), isEntryJ2k(), ossimNitfTileSource::loadBlock(), ossimNotify(), ossimNotifyLevel_WARN, ossimImageData::setImageRectangle(), ossimNitfTileSource::theCacheId, ossimNitfTileSource::theCacheSize, ossimNitfTileSource::theCacheTile, ossimIpt::x, x, ossimIpt::y, and y.

451 {
452 
453  bool result = true;
454 
455  if ( isEntryJ2k() )
456  {
457  ossimIpt ul(x, y);
458 
459  ossimIpt lr(ul.x + theCacheSize.x - 1,
460  ul.y + theCacheSize.y - 1);
461 
462  // Set the cache rectangle to be an even j2k tile.
464 
465  // Let the getOverviewTile do the rest of the work.
466  if ( getOverviewTile(0, theCacheTile.get()) )
467  {
468  // Add it to the cache for the next time.
470  }
471  else
472  {
474  << __FILE__ << ":" << __LINE__
475  << "\nossimKakaduNitfReader::loadBlock failed!"
476  << std::endl;
477  result = false;
478  }
479  }
480  else
481  {
483  }
484 
485  return result;
486 }
ossim_uint32 x
virtual void setImageRectangle(const ossimIrect &rect)
ossim_uint32 y
static ossimAppFixedTileCache * instance(ossim_uint32 maxSize=0)
ossimRefPtr< ossimImageData > theCacheTile
ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Gets an overview tile.
bool isEntryJ2k() const
Checks current entry image header to see if it is j2k.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
virtual bool loadBlock(ossim_uint32 x, ossim_uint32 y)
Loads a block of data to theCacheTile.
ossimRefPtr< ossimImageData > addTile(ossimAppFixedCacheId cacheId, ossimRefPtr< ossimImageData > data, bool duplicateData=true)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ parseFile()

bool ossimKakaduNitfReader::parseFile ( )
protectedvirtual

Parses "theImageFile" and initializes all nitf headers.

Overrides ossimNitfTileSource::parseFile

Returns
True on success, false on error.

Reimplemented from ossimNitfTileSource.

Definition at line 488 of file ossimKakaduNitfReader.cpp.

489 {
490  static const char MODULE[] = "ossimKakaduNitfReader::parseFile";
491 
492  if (traceDebug())
493  {
494  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
495  }
496 
497  bool result = ossimNitfTileSource::parseFile();
498 
499  if (result)
500  {
501  //---
502  // Look through the entries to see if any are j2k; if not, set result to
503  // false so the ossimNitfTileSource will pick this file up instead of
504  // ossimKakaduNitfReader.
505  //---
506 
507  result = false; // Must prove we have a j2k entry.
508 
509  for (ossim_uint32 i = 0; i < theNumberOfImages; ++i)
510  {
511  if (theNitfImageHeader[i]->getCompressionCode() == "C8") // j2k
512  {
513  result = true;
514  break;
515  }
516  }
517  }
518 
519  if (traceDebug())
520  {
522  << MODULE << " exit status = " << (result?"true\n":"false\n");
523  }
524 
525  return result;
526 }
ossim_uint32 theNumberOfImages
unsigned int ossim_uint32
virtual bool parseFile()
Parses "theImageFile" and initializes all nitf headers.
std::vector< ossimRefPtr< ossimNitfImageHeader > > theNitfImageHeader
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ read()

ossim_int32 ossimKakaduNitfReader::read ( kdu_core::kdu_byte *  buf,
ossim_int32  num_bytes 
)
inlineprotectedvirtual

Read method.

Implements pure virtual kdu_compressed_source::read

Parameters
bufBuffer to fill.
num_bytesBytes to read.
Returns
Actual bytes read.

Definition at line 374 of file ossimKakaduNitfReader.h.

References ossimNitfTileSource::theFileStr.

375 {
376  theFileStr->read((char*)buf, num_bytes);
377  return theFileStr->gcount();
378 }
std::shared_ptr< ossim::istream > theFileStr

◆ scanForJpegBlockOffsets()

bool ossimKakaduNitfReader::scanForJpegBlockOffsets ( )
protectedvirtual

This method simply checks for Start of Codestream (SOC) marker as the Kakadu library handles finding tiles for us.

Overrides ossimNitfTileSource::scanForJpegBlockOffsets

Returns
true on success, false on error.

Reimplemented from ossimNitfTileSource.

Definition at line 852 of file ossimKakaduNitfReader.cpp.

References checkJp2Signature(), ossimNitfTileSource::getCurrentImageHeader(), ossimNitfImageHeader::getDataLocation(), m_startOfCodestreamOffset, and ossimNitfTileSource::theFileStr.

853 {
854  bool result = false;
855 
857  if( hdr )
858  {
859  // Capture the start of data. This is start of j2k main header.
861 
862  if ( checkJp2Signature() )
863  {
864  result = true;
865  }
866  else
867  {
868  //---
869  // Kakadu library finds j2k tiles. We only find the "Start Of Codestream"(SOC)
870  // which should be at getDataLocation() but not in all cases.
871  //---
872 
873  // Seek to the first block.
874  theFileStr->seekg(m_startOfCodestreamOffset, ios_base::beg);
875  if ( theFileStr->good() )
876  {
877  //---
878  // Read the first two bytes and test for SOC (Start Of Codestream)
879  // marker.
880  //---
881  ossim_uint8 markerField[2];
882  theFileStr->read( (char*)markerField, 2);
883 
884  if ( (markerField[0] == 0xff) && (markerField[1] == 0x4f) )
885  {
886  result = true;
887  }
888  else
889  {
890  //---
891  // Scan the file from the beginning for SOC. This handles cases
892  // where the data does not fall on "hdr->getDataLocation()".
893  //
894  // Changed for multi-enty nitf where first entry is j2k, second is
895  // uncompressed. Need to test at site. 02 August 2013 (drb)
896  //---
897  // theFileStr->seekg(0, ios_base::beg);
898  theFileStr->seekg(m_startOfCodestreamOffset, ios_base::beg);
899  char c;
900  while ( theFileStr->get(c) )
901  {
902  if (static_cast<ossim_uint8>(c) == 0xff)
903  {
904  if ( theFileStr->get(c) )
905  {
906  if (static_cast<ossim_uint8>(c) == 0x4f)
907  {
910  result = true;
911  break;
912  }
913  }
914  }
915  }
916  }
917 
918  if ( (result == true) && traceDump() )
919  {
921  }
922 
923  } // matches: if (theFileStr->good())
924 
925  } // if ( isJp2() ) ... else {
926 
927  } // matches: if (hdr)
928 
929  return result;
930 
931 } // End: bool ossimKakaduNitfReader::scanForJpegBlockOffsets()
std::shared_ptr< ossim::istream > theFileStr
std::streamoff m_startOfCodestreamOffset
std::ostream & dumpTiles(std::ostream &out)
Method to print out tile info.
virtual ossim_uint64 getDataLocation() const =0
const ossimNitfImageHeader * getCurrentImageHeader() const
bool checkJp2Signature()
Checks for jp2 signature block.
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ seek()

bool ossimKakaduNitfReader::seek ( kdu_core::kdu_long  offset)
inlineprotectedvirtual

Seek method.

Overrides kdu_compressed_source::seek

Parameters
offsetSeek position relative to the start of code stream offset.
Returns
true on success, false on error.

Definition at line 380 of file ossimKakaduNitfReader.h.

References m_startOfCodestreamOffset, and ossimNitfTileSource::theFileStr.

381 {
382  // If the last byte is read, the eofbit must be reset.
383  if ( theFileStr->eof() )
384  {
385  theFileStr->clear();
386  }
387 
388  //---
389  // All seeks are relative to the start of code stream.
390  //---
391  theFileStr->seekg(offset+m_startOfCodestreamOffset, ios_base::beg);
392  return theFileStr->good();
393 }
std::shared_ptr< ossim::istream > theFileStr
std::streamoff m_startOfCodestreamOffset

◆ setMaxPixelValue()

void ossimKakaduNitfReader::setMaxPixelValue ( ossim_uint32  band,
const ossim_float64 pix 
)
virtual

convenience method to set max pixel value.

Added for overview readers so that the image handler that owns the overview reader can pass on it's max value.

Parameters
bandZero based band to set.
pixMax pixel value.

Reimplemented from ossimImageHandler.

Definition at line 280 of file ossimKakaduNitfReader.cpp.

References m_maxSampleValue, ossimImageData::setMaxPix(), ossimImageHandler::setMaxPixelValue(), ossimNitfTileSource::theCacheTile, ossimNitfTileSource::theTile, and ossimRefPtr< T >::valid().

282 {
283  //---
284  // Store and call base ossimImageHandler::setMaxPixelValue in case someone
285  // does a save state on the ossimImageHandler::theMetaData.
286  //---
287  m_maxSampleValue = pix;
289  if ( theTile.valid() )
290  {
291  theTile->setMaxPix(pix, band);
292  }
293  if ( theCacheTile.valid() )
294  {
295  theCacheTile->setMaxPix(pix, band);
296  }
297 }
virtual void setMaxPixelValue(ossim_uint32 band, const ossim_float64 &pix)
convenience method to set max pixel value.
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageData > theCacheTile
ossimRefPtr< ossimImageData > theTile
virtual void setMaxPix(ossim_float64 max_pix)

◆ setMinPixelValue()

void ossimKakaduNitfReader::setMinPixelValue ( ossim_uint32  band,
const ossim_float64 pix 
)
virtual

convenience method to set min pixel value.

Added for overview readers so that the image handler that owns the overview reader can pass on it's min value.

Parameters
bandZero based band to set.
pixMin pixel value.

Reimplemented from ossimImageHandler.

Definition at line 261 of file ossimKakaduNitfReader.cpp.

References m_minSampleValue, ossimImageData::setMinPix(), ossimImageHandler::setMinPixelValue(), ossimNitfTileSource::theCacheTile, ossimNitfTileSource::theTile, and ossimRefPtr< T >::valid().

263 {
264  //---
265  // Store and call base ossimImageHandler::setMinPixelValue in case someone
266  // does a save state on the ossimImageHandler::theMetaData.
267  //---
268  m_minSampleValue = pix;
270  if ( theTile.valid() )
271  {
272  theTile->setMinPix(pix, band);
273  }
274  if ( theCacheTile.valid() )
275  {
276  theCacheTile->setMinPix(pix, band);
277  }
278 }
bool valid() const
Definition: ossimRefPtr.h:75
ossim_float64 m_minSampleValue
min/max/null These are class attributes so that when behaving as an overview the owner or base image ...
ossimRefPtr< ossimImageData > theCacheTile
virtual void setMinPixelValue(ossim_uint32 band, const ossim_float64 &pix)
convenience method to set min pixel value.
ossimRefPtr< ossimImageData > theTile
virtual void setMinPix(ossim_float64 min_pix)

◆ setNullPixelValue()

void ossimKakaduNitfReader::setNullPixelValue ( ossim_uint32  band,
const ossim_float64 pix 
)
virtual

convenience method to set null pixel value.

Added for overview readers so that the image handler that owns the overview reader can pass on it's max value.

Parameters
bandZero based band to set.
pixNull pixel value.

Reimplemented from ossimImageHandler.

Definition at line 299 of file ossimKakaduNitfReader.cpp.

References ossimImageData::getNullPix(), m_nullSampleValue, ossimImageData::makeBlank(), OSSIM_STATUS_UNKNOWN, ossimDataObject::setDataObjectStatus(), ossimImageData::setNullPix(), ossimImageHandler::setNullPixelValue(), ossimNitfTileSource::theCacheTile, ossimNitfTileSource::theTile, and ossimRefPtr< T >::valid().

301 {
302  //---
303  // NOTES:
304  //
305  // 1) If the null pixel value has changed a makeBlank must be performed or the validate
306  // method will not work correctly.
307  //
308  // 2) Must set the tile status to unknown prior to the makeBlank or it won't
309  // do anything.
310  //
311  // 3) It would be nice to do this after all the calls to setNullPixelValue are finished
312  // with a dirty flag or something. In reality though the makeBlank will only be called
313  // once as this only happens(usually) with elevation data which is one band.
314  //---
315 
316  //---
317  // Store and call base ossimImageHandler::setNullPixelValue in case someone
318  // does a save state on the ossimImageHandler::theMetaData.
319  //---
320  m_nullSampleValue = pix;
322  if ( theTile.valid() )
323  {
324  if ( theTile->getNullPix(band) != pix )
325  {
326  theTile->setNullPix(pix, band);
328  theTile->makeBlank();
329  }
330  }
331  if ( theCacheTile.valid() )
332  {
333  if ( theCacheTile->getNullPix(band) != pix )
334  {
335  theCacheTile->setNullPix(pix, band);
338  }
339  }
340 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual void setNullPix(ossim_float64 null_pix)
virtual const ossim_float64 * getNullPix() const
ossimRefPtr< ossimImageData > theCacheTile
virtual void makeBlank()
Initializes data to null pixel values.
ossimRefPtr< ossimImageData > theTile
virtual void setDataObjectStatus(ossimDataObjectStatus status) const
Full list found in ossimConstants.h.
virtual void setNullPixelValue(ossim_uint32 band, const ossim_float64 &pix)
convenience method to set null pixel value.

Member Data Documentation

◆ m_channels

kdu_supp::kdu_channel_mapping* ossimKakaduNitfReader::m_channels
private

◆ m_codestream

kdu_core::kdu_codestream ossimKakaduNitfReader::m_codestream
private

◆ m_imageDims

std::vector<ossimIrect> ossimKakaduNitfReader::m_imageDims
private

Image dimensions for each level.

Definition at line 354 of file ossimKakaduNitfReader.h.

Referenced by getNumberOfLines(), and getNumberOfSamples().

◆ m_jp2FamilySrc

kdu_supp::jp2_family_src* ossimKakaduNitfReader::m_jp2FamilySrc
private

Definition at line 343 of file ossimKakaduNitfReader.h.

Referenced by ~ossimKakaduNitfReader().

◆ m_jp2Source

kdu_supp::jp2_source* ossimKakaduNitfReader::m_jp2Source
private

Definition at line 344 of file ossimKakaduNitfReader.h.

Referenced by configureChannelMapping(), and ~ossimKakaduNitfReader().

◆ m_maxSampleValue

ossim_float64 ossimKakaduNitfReader::m_maxSampleValue
private

Definition at line 363 of file ossimKakaduNitfReader.h.

Referenced by allocateBuffers(), getMaxPixelValue(), and setMaxPixelValue().

◆ m_minDwtLevels

ossim_uint32 ossimKakaduNitfReader::m_minDwtLevels
private

◆ m_minSampleValue

ossim_float64 ossimKakaduNitfReader::m_minSampleValue
private

min/max/null These are class attributes so that when behaving as an overview the owner or base image handler can pass its min/max/null to us.

For non eight bit data this is critical so that the data gets stretched exactly as the base handler. Did NOT make these a vector the size of bands as it was not needed at time of coding.

Definition at line 362 of file ossimKakaduNitfReader.h.

Referenced by allocateBuffers(), getMinPixelValue(), and setMinPixelValue().

◆ m_nullSampleValue

ossim_float64 ossimKakaduNitfReader::m_nullSampleValue
private

Definition at line 364 of file ossimKakaduNitfReader.h.

Referenced by allocateBuffers(), getNullPixelValue(), and setNullPixelValue().

◆ m_openTileThreadQueue

kdu_core::kdu_thread_queue* ossimKakaduNitfReader::m_openTileThreadQueue
private

Definition at line 348 of file ossimKakaduNitfReader.h.

Referenced by getOverviewTile(), and ~ossimKakaduNitfReader().

◆ m_sourcePrecisionBits

ossim_uint32 ossimKakaduNitfReader::m_sourcePrecisionBits
private

Definition at line 350 of file ossimKakaduNitfReader.h.

◆ m_startOfCodestreamOffset

std::streamoff ossimKakaduNitfReader::m_startOfCodestreamOffset
private

Definition at line 341 of file ossimKakaduNitfReader.h.

Referenced by dumpTiles(), get_pos(), scanForJpegBlockOffsets(), and seek().

◆ m_threadEnv

kdu_core::kdu_thread_env* ossimKakaduNitfReader::m_threadEnv
private

Definition at line 347 of file ossimKakaduNitfReader.h.

Referenced by getOverviewTile(), and ~ossimKakaduNitfReader().


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