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
ossimKakaduJp2Reader Class Reference

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

#include <ossimKakaduJp2Reader.h>

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

Public Types

enum  { SIGNATURE_BOX_SIZE = 12, GEOTIFF_UUID_SIZE = 16 }
 Anonymous enumerations: More...
 
- 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

 ossimKakaduJp2Reader ()
 default construtor More...
 
virtual ~ossimKakaduJp2Reader ()
 virtural destructor More...
 
virtual ossimString getShortName () const
 Returns short name. More...
 
virtual ossimString getLongName () const
 Returns long name. More...
 
virtual ossimString getClassName () const
 Returns class name. More...
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIrect &rect, ossim_uint32 resLevel=0)
 Method to grab a tile(rectangle) from image. More...
 
virtual ossim_uint32 getNumberOfInputBands () const
 Returns the number of bands in the image. More...
 
virtual ossim_uint32 getNumberOfOutputBands () const
 Returns the number of bands in a tile returned from this TileSource. 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 ossimScalarType getOutputScalarType () const
 Returns the output pixel type of the tile source. 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 bool open ()
 Open method. More...
 
virtual bool isOpen () const
 Method to test for open file stream. More...
 
virtual void closeEntry ()
 Method to close current entry. More...
 
virtual ossimRefPtr< ossimImageGeometrygetImageGeometry ()
 Returns the image geometry object associated with this tile source or NULL if non defined. 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...
 
- 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 void close ()
 Deletes the overview and clears the valid image vertices. More...
 
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 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 saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Method to save the state of an object to a keyword list. 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 double getMinPixelValue (ossim_uint32 band=0) const
 Retuns the min pixel value. More...
 
virtual double getMaxPixelValue (ossim_uint32 band=0) const
 Returns the max pixel of the band. More...
 
virtual double getNullPixelValue (ossim_uint32 band=0) const
 Each band has a null pixel associated with it. 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_uint32 getCurrentEntry () const
 
virtual ossim_uint32 getNumberOfEntries () const
 
virtual void getEntryName (ossim_uint32 entryIdx, std::string &name) const
 Get the name of entry as a string. More...
 
virtual void getEntryList (std::vector< ossim_uint32 > &entryList) const
 
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
 
virtual bool setCurrentEntry (ossim_uint32 entryIdx)
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) 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...
 
virtual bool getRgbBandList (std::vector< ossim_uint32 > &bandList) const
 Convenience method to get the zero based rgb output band list. 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 ossim_uint32 getTileWidth () const
 Returns the default processing tile width. More...
 
virtual ossim_uint32 getTileHeight () const
 Returns the default processing tile height. 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 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...
 
- 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 void establishDecimationFactors ()
 Virtual method determines the decimation factors at each resolution level. 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

virtual ossimRefPtr< ossimImageGeometrygetInternalImageGeometry ()
 
virtual ossimRefPtr< ossimImageGeometrygetImageGeometryFromGeotiffBox ()
 
virtual ossimRefPtr< ossimImageGeometrygetImageGeometryFromGmlBox ()
 
ossimRefPtr< ossimImageGeometrygetMetadataImageGeometry () const
 
bool isJp2 ()
 Test first 12 bytes of file for the jp2 signature block. More...
 
bool openJp2File ()
 Opens the jp2 and initializes this object. More...
 
void initializeTile ()
 Initializes data member "theTile". More...
 
bool loadTileFromCache (const ossimIpt &origin, const ossimIrect &clipRect)
 Loads a block of data to theCacheTile from the cache. More...
 
bool loadTile (const ossimIpt &origin)
 Loads a block of data to theCacheTile. More...
 
bool configureChannelMapping ()
 Initializes m_channels to be used with copyRegionToTile if it makes sense. More...
 

Private Attributes

kdu_supp::jp2_family_src * theJp2FamilySrc
 
kdu_core::kdu_compressed_source * theJp2Source
 
kdu_supp::kdu_channel_mapping * theChannels
 
kdu_core::kdu_codestream theCodestream
 
kdu_core::kdu_thread_env * theThreadEnv
 
kdu_core::kdu_thread_queue * theOpenTileThreadQueue
 
ossim_uint32 theMinDwtLevels
 
ossim_uint32 theNumberOfBands
 
ossimIpt theCacheSize
 
ossimScalarType theScalarType
 
ossimIrect theImageRect
 
std::vector< ossimIrecttheJp2Dims
 Has sub image offset. More...
 
std::vector< ossimIrecttheJp2TileDims
 Tile dimensions for each level. More...
 
ossimRefPtr< ossimImageDatatheTile
 
ossimRefPtr< ossimImageDatatheCacheTile
 
ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId
 Cache initialized to image rect with sub image offset. More...
 

Additional Inherited Members

- 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

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

Definition at line 54 of file ossimKakaduJp2Reader.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Anonymous enumerations:

Enumerator
SIGNATURE_BOX_SIZE 
GEOTIFF_UUID_SIZE 

Definition at line 186 of file ossimKakaduJp2Reader.h.

Constructor & Destructor Documentation

◆ ossimKakaduJp2Reader()

ossimKakaduJp2Reader::ossimKakaduJp2Reader ( )

default construtor

◆ ~ossimKakaduJp2Reader()

ossimKakaduJp2Reader::~ossimKakaduJp2Reader ( )
virtual

virtural destructor

Definition at line 90 of file ossimKakaduJp2Reader.cpp.

References closeEntry().

91 {
92  closeEntry();
93 }
virtual void closeEntry()
Method to close current entry.

Member Function Documentation

◆ closeEntry()

void ossimKakaduJp2Reader::closeEntry ( )
virtual

Method to close current entry.

Note
There is a bool kdu_compressed_source::close() and a void ossimImageHandler::close(); hence, a new close to avoid conflicting return types.

Definition at line 518 of file ossimKakaduJp2Reader.cpp.

References ossimImageHandler::close(), ossimAppFixedTileCache::deleteCache(), ossimAppFixedTileCache::instance(), theCacheId, theCacheTile, theChannels, theCodestream, theJp2FamilySrc, theJp2Source, theOpenTileThreadQueue, theThreadEnv, and theTile.

Referenced by ~ossimKakaduJp2Reader().

519 {
520  // Cleanup processing environment
521  if ( theThreadEnv )
522  {
523  theThreadEnv->join(NULL,true); // Wait until all internal processing is complete.
524  theThreadEnv->terminate(theOpenTileThreadQueue, true);
525  theThreadEnv->cs_terminate(theCodestream); // Terminates background codestream processing.
526  theThreadEnv->destroy();
527  delete theThreadEnv;
528  theThreadEnv = 0;
529  }
530 
531  theTile = 0;
532  theCacheTile = 0;
533 
534  if (theChannels)
535  {
536  theChannels->clear();
537  delete theChannels;
538  theChannels = 0;
539  }
540  if(theCodestream.exists())
541  {
542  theCodestream.destroy();
543  }
544 
545  if (theJp2Source)
546  {
547  delete theJp2Source;
548  theJp2Source = 0;
549  }
550 
551  if (theJp2FamilySrc)
552  {
553  delete theJp2FamilySrc;
554  theJp2FamilySrc = 0;
555  }
556 
558  {
560  }
561 
562  if (theCacheId != -1)
563  {
565  theCacheId = -1;
566  }
567 
569 }
virtual void deleteCache(ossimAppFixedCacheId cacheId)
kdu_core::kdu_compressed_source * theJp2Source
ossimRefPtr< ossimImageData > theTile
kdu_core::kdu_thread_queue * theOpenTileThreadQueue
kdu_core::kdu_codestream theCodestream
static ossimAppFixedTileCache * instance(ossim_uint32 maxSize=0)
kdu_core::kdu_thread_env * theThreadEnv
ossimRefPtr< ossimImageData > theCacheTile
kdu_supp::jp2_family_src * theJp2FamilySrc
virtual void close()
Deletes the overview and clears the valid image vertices.
ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId
Cache initialized to image rect with sub image offset.
kdu_supp::kdu_channel_mapping * theChannels

◆ configureChannelMapping()

bool ossimKakaduJp2Reader::configureChannelMapping ( )
private

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

Also set number of bands if channel mapping was successful.

Returns
true on success, false on error.

Definition at line 1276 of file ossimKakaduJp2Reader.cpp.

References theChannels, theCodestream, theJp2Source, and theNumberOfBands.

1277 {
1278  bool result = false;
1279 
1280  if ( theChannels )
1281  {
1282  theChannels->clear();
1283  }
1284  else
1285  {
1286  theChannels = new kdu_supp::kdu_channel_mapping;
1287  }
1288 
1289  if ( theJp2Source )
1290  {
1291  // bool flag "ignore_alpha", turns on off alpha channel.
1292  result = theChannels->configure(static_cast<kdu_supp::jp2_source*>(theJp2Source), true);
1293  }
1294  else
1295  {
1296  result = theChannels->configure(theCodestream);
1297  }
1298 
1299  if ( result )
1300  {
1301  theNumberOfBands = (ossim_uint32)theChannels->get_num_colour_channels();
1302 
1303  if (traceDebug())
1304  {
1306  << "ossimKakaduJp2Reader::configureChannelMapping() DEBUG:"
1307  << "\nkdu_channel_mapping::get_num_channels(): "
1308  << theChannels->get_num_channels()
1309  << "\nkdu_channel_mapping::get_num_colour_channels(): "
1310  << theChannels->get_num_colour_channels()
1311  << "\ntheNumberOfBands: " << theNumberOfBands << endl;
1312  }
1313  }
1314 
1315  // Force a per component kdu region decompress.
1316  if ( !result || ( theNumberOfBands != (ossim_uint32)theChannels->get_num_channels() ) )
1317  {
1318  // Remove the channel mapping.
1319  theChannels->clear();
1320  delete theChannels;
1321  theChannels = 0;
1322  }
1323 
1324  return result;
1325 }
kdu_core::kdu_compressed_source * theJp2Source
kdu_core::kdu_codestream theCodestream
unsigned int ossim_uint32
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
kdu_supp::kdu_channel_mapping * theChannels

◆ getClassName()

ossimString ossimKakaduJp2Reader::getClassName ( ) const
virtual

Returns class name.

Returns
"ossimKakaduJp2Reader"

Reimplemented from ossimObject.

Definition at line 105 of file ossimKakaduJp2Reader.cpp.

106 {
107  return ossimString("ossimKakaduJp2Reader");
108 }

◆ getImageGeometry()

ossimRefPtr< ossimImageGeometry > ossimKakaduJp2Reader::getImageGeometry ( )
virtual

Returns the image geometry object associated with this tile source or NULL if non defined.

The geometry contains full-to-local image transform as well as projection (image-to-world).

Reimplemented from ossimImageHandler.

Definition at line 875 of file ossimKakaduJp2Reader.cpp.

References ossimImageGeometryRegistry::extendGeometry(), ossimRefPtr< T >::get(), ossimImageHandler::getExternalImageGeometry(), getInternalImageGeometry(), getMetadataImageGeometry(), ossimImageGeometry::getProjection(), ossimImageHandler::initImageParameters(), ossimImageGeometryRegistry::instance(), and ossimImageHandler::theGeometry.

876 {
877  if ( !theGeometry )
878  {
879  //---
880  // Check for external geom - this is a file.geom not to be confused with
881  // geometries picked up from dot.xml, dot.prj, dot.j2w and so on. We
882  // will check for that later if the getInternalImageGeometry fails.
883  //---
885 
886  if ( !theGeometry )
887  {
888  //---
889  // Check for external files other than .geom, i.e. file.xml & j2w:
890  //---
892 
893  if ( !theGeometry )
894  {
895  // Check the internal geometry first to avoid a factory call.
897 
898  //---
899  // WARNING:
900  // Must create/set the geometry at this point or the next call to
901  // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop
902  // as it does a recursive call back to ossimImageHandler::getImageGeometry().
903  //---
904  if ( !theGeometry )
905  {
907  }
908 
909  // Check for set projection.
910  if ( !theGeometry->getProjection() )
911  {
912  // Last try factories for projection.
914  }
915  }
916  }
917 
918  // Set image things the geometry object should know about.
920  }
921  return theGeometry;
922 }
static ossimImageGeometryRegistry * instance()
ossimRefPtr< ossimImageGeometry > theGeometry
ossimRefPtr< ossimImageGeometry > getMetadataImageGeometry() const
virtual bool extendGeometry(ossimImageHandler *handler) const
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual ossimRefPtr< ossimImageGeometry > getInternalImageGeometry()

◆ getImageGeometryFromGeotiffBox()

ossimRefPtr< ossimImageGeometry > ossimKakaduJp2Reader::getImageGeometryFromGeotiffBox ( )
privatevirtual
Parameters
Methodto get geometry from the embedded JP2 GeoTIFF Box.

Definition at line 956 of file ossimKakaduJp2Reader.cpp.

957 {
958  static const char MODULE[] = "ossimKakaduJp2Reader::getImageGeometryFromGeotiffBox";
959 
960  if (traceDebug())
961  {
962  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
963  }
964 
966 
967  if ( isOpen() )
968  {
969  std::ifstream str;
970  str.open( theImageFile.c_str(), std::ios_base::in | std::ios_base::binary);
971 
972  if ( str.is_open() )
973  {
974  std::vector<ossim_uint8> box;
975  ossimJp2Info jp2Info;
976 
977  std::streamoff boxPos = jp2Info.getGeotiffBox( str, box );
978 
979  if ( box.size() )
980  {
981  if (traceDebug())
982  {
984  << "Found geotiff uuid at: " << boxPos+8 << "\n";
985  }
986 
987  //---
988  // Create a string stream and set the vector buffer as its source.
989  // Note: The box has the 16 GEOTIFF_UUID bytes in there so offset
990  // address and size.
991  //---
992 #if 0
993  // This doesn't work with VS2010...
994  // Create a string stream and set the vector buffer as its source.
995  std::istringstream boxStream;
996  boxStream.rdbuf()->pubsetbuf( (char*)&box.front()+GEOTIFF_UUID_SIZE,
997  box.size()-GEOTIFF_UUID_SIZE );
998 #else
999  // convert the vector into a string
1000  std::string boxString( box.begin()+GEOTIFF_UUID_SIZE, box.end() );
1001  std::istringstream boxStream;
1002  boxStream.str( boxString );
1003 #endif
1004 
1005  // Give the stream to tiff info to create a geometry.
1006  ossimTiffInfo info;
1007  ossim_uint32 entry = 0;
1008  ossimKeywordlist kwl; // Used to capture geometry data.
1009 
1010  if ( info.getImageGeometry(boxStream, kwl, entry) )
1011  {
1012  //---
1013  // The tiff embedded in the geojp2 only has one line
1014  // and one sample by design so overwrite the lines and
1015  // samples with the real value.
1016  //---
1017  ossimString pfx = "image";
1018  pfx += ossimString::toString(entry);
1019  pfx += ".";
1020 
1021  // Add the lines.
1023  getNumberOfLines(0), true);
1024 
1025  // Add the samples.
1027  getNumberOfSamples(0), true);
1028 
1029  // Create the projection.
1032  if ( proj.valid() )
1033  {
1034  // Create and assign projection to our ossimImageGeometry object.
1035  geom = new ossimImageGeometry();
1036  geom->setProjection( proj.get() );
1037  if (traceDebug())
1038  {
1039  ossimNotify(ossimNotifyLevel_DEBUG) << "Found GeoTIFF box." << std::endl;
1040  }
1041 
1042  // Get the internal raster pixel alignment type and set the base class.
1043  const char* lookup = kwl.find(pfx.chars(), ossimKeywordNames::PIXEL_TYPE_KW);
1044  if ( lookup )
1045  {
1046  ossimString type = lookup;
1047  type.downcase();
1048  if ( type == "pixel_is_area" )
1049  {
1051  }
1052  else if ( type == "pixel_is_point" )
1053  {
1055  }
1056  }
1057  }
1058  }
1059  }
1060  }
1061  }
1062 
1063  if (traceDebug())
1064  {
1065  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exited...\n";
1066  }
1067 
1068  return geom;
1069 
1070 } // End: ossimKakaduJp2Reader::getImageGeometryFromGeotiffBox
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const
Gets number of lines for res level.
ossimFilename theImageFile
Represents serializable keyword/value map.
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
bool getImageGeometry(ossimKeywordlist &geomKwl, ossim_uint32 entryIndex) const
Extracts geometry info to keyword list.
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * NUMBER_LINES_KW
TIFF info class.
Definition: ossimTiffInfo.h:36
ossimPixelType thePixelType
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
JP2 info class.
Definition: ossimJp2Info.h:21
unsigned int ossim_uint32
const char * chars() const
For backward compatibility.
Definition: ossimString.h:77
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
static ossimProjectionFactoryRegistry * instance()
static const char * PIXEL_TYPE_KW
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const
Gets the number of samples for res level.
virtual bool isOpen() const
Method to test for open file stream.
std::streamoff getGeotiffBox(std::ifstream &str, std::vector< ossim_uint8 > &box) const
Method to get the embedded JP2 GeoTIFF box.
static const char * NUMBER_SAMPLES_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getImageGeometryFromGmlBox()

ossimRefPtr< ossimImageGeometry > ossimKakaduJp2Reader::getImageGeometryFromGmlBox ( )
privatevirtual
Parameters
Methodto get geometry from the embedded JP2 GML Box.

Definition at line 1073 of file ossimKakaduJp2Reader.cpp.

1074 {
1075  static const char M[] = "ossimKakaduJp2Reader::getImageGeometryFromGmlBox";
1076 
1077  if (traceDebug())
1078  {
1079  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
1080  }
1081 
1083 
1084  if ( isOpen() )
1085  {
1086  std::ifstream str;
1087  str.open( theImageFile.c_str(), std::ios_base::in | std::ios_base::binary);
1088 
1089  if ( str.is_open() )
1090  {
1091  std::vector<ossim_uint8> box;
1092  ossimJp2Info jp2Info;
1093 
1094  std::streamoff boxPos = jp2Info.getGmlBox( str, box );
1095 
1096  if ( boxPos && box.size() )
1097  {
1098  if (traceDebug())
1099  {
1101  << "Found gml box at: " << boxPos+8
1102  << "\nbox size: " << box.size() << "\n";
1103  }
1104 
1105 #if 0
1106  // This doesn't work with VS2010...
1107  // Create a string stream and set the vector buffer as its source.
1108  std::istringstream boxStream;
1109  boxStream.rdbuf()->pubsetbuf( (char*)&box.front(), box.size() );
1110 #else
1111  // convert the vector into a string
1112  std::string boxString( box.begin(), box.end() );
1113  std::istringstream boxStream;
1114  boxStream.str( boxString );
1115 #endif
1116 
1118 
1119  if ( gml->initialize( boxStream ) )
1120  {
1121  ossimKeywordlist geomKwl;
1122  if ( gml->getImageGeometry( geomKwl ) )
1123  {
1124  // Make projection:
1125  // Create the projection.
1128  if ( proj.valid() )
1129  {
1130  // Create and assign projection to our ossimImageGeometry object.
1131  geom = new ossimImageGeometry();
1132  geom->setProjection( proj.get() );
1133  }
1134  }
1135  }
1136 
1137  // Cleanup:
1138  delete gml;
1139  gml = 0;
1140  }
1141  }
1142  }
1143 
1144  if (traceDebug())
1145  {
1147  << M << " exit status = " << (geom.valid()?"true":"false\n")
1148  << std::endl;
1149  }
1150 
1151  return geom;
1152 
1153 } // End: ossimKakaduJp2Reader::getImageGeometryFromGmlBox
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
ossimFilename theImageFile
Represents serializable keyword/value map.
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
bool valid() const
Definition: ossimRefPtr.h:75
GML support data class.
bool getImageGeometry(ossimKeywordlist &geomKwl) const
Extracts geometry info to keyword list.
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
JP2 info class.
Definition: ossimJp2Info.h:21
bool initialize(const ossimImageGeometry *geom, const ossimIrect &rect)
Initializes gml block from geometry file.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
static ossimProjectionFactoryRegistry * instance()
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
std::streamoff getGmlBox(std::ifstream &str, std::vector< ossim_uint8 > &box) const
Method to get the embedded JP2 GML Box.
virtual bool isOpen() const
Method to test for open file stream.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getImageTileHeight()

ossim_uint32 ossimKakaduJp2Reader::getImageTileHeight ( ) const
virtual

Returns the tile width of the image or 0 if the image is not tiled.

Note: this is not the same as the ossimImageSource::getTileWidth which returns the output tile width which can be different than the internal image tile width on disk.

Implements ossimImageHandler.

Definition at line 768 of file ossimKakaduJp2Reader.cpp.

References ossimIrect::height(), theImageRect, and theJp2TileDims.

Referenced by initializeTile().

769 {
770  ossim_uint32 result = 0;
771  if ( theJp2TileDims.size() )
772  {
773  if ( theJp2TileDims[0].height() != theImageRect.height() )
774  {
775  // Not a single tile.
776  result = static_cast<ossim_uint32>(theJp2TileDims[0].height());
777  }
778  }
779  return result;
780 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
std::vector< ossimIrect > theJp2TileDims
Tile dimensions for each level.
unsigned int ossim_uint32

◆ getImageTileWidth()

ossim_uint32 ossimKakaduJp2Reader::getImageTileWidth ( ) const
virtual

Returns the tile width of the image or 0 if the image is not tiled.

Note: this is not the same as the ossimImageSource::getTileWidth which returns the output tile width which can be different than the internal image tile width on disk.

Implements ossimImageHandler.

Definition at line 754 of file ossimKakaduJp2Reader.cpp.

References theImageRect, theJp2TileDims, and ossimIrect::width().

Referenced by initializeTile().

755 {
756  ossim_uint32 result = 0;
757  if ( theJp2TileDims.size() )
758  {
759  if ( theJp2TileDims[0].width() != theImageRect.width() )
760  {
761  // Not a single tile.
762  result = theJp2TileDims[0].width();
763  }
764  }
765  return result;
766 }
std::vector< ossimIrect > theJp2TileDims
Tile dimensions for each level.
unsigned int ossim_uint32
ossim_uint32 width() const
Definition: ossimIrect.h:500

◆ getInternalImageGeometry()

ossimRefPtr< ossimImageGeometry > ossimKakaduJp2Reader::getInternalImageGeometry ( )
privatevirtual
Parameters
Methodto get geometry from the embedded JP2 Boxes.

Definition at line 924 of file ossimKakaduJp2Reader.cpp.

Referenced by getImageGeometry().

925 {
926  static const char MODULE[] = "ossimKakaduJp2Reader::getInternalImageGeometry";
927 
928  if (traceDebug())
929  {
930  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
931  }
932 
934 
935  if ( isOpen() )
936  {
937  // Try to get geom from GML box:
939 
940  if ( geom.valid() == false )
941  {
942  // Try to get geom from geotiff box:
944  }
945  }
946 
947  if (traceDebug())
948  {
949  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exited...\n";
950  }
951 
952  return geom;
953 
954 } // End: ossimKakaduJp2Reader::getInternalImageGeometry()
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimRefPtr< ossimImageGeometry > getImageGeometryFromGmlBox()
virtual ossimRefPtr< ossimImageGeometry > getImageGeometryFromGeotiffBox()
virtual bool isOpen() const
Method to test for open file stream.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getLongName()

ossimString ossimKakaduJp2Reader::getLongName ( ) const
virtual

Returns long name.

Returns
"ossim kakadu jp2 reader"

Reimplemented from ossimObject.

Definition at line 100 of file ossimKakaduJp2Reader.cpp.

101 {
102  return ossimString("ossim kakadu jp2 reader");
103 }

◆ getMetadataImageGeometry()

ossimRefPtr< ossimImageGeometry > ossimKakaduJp2Reader::getMetadataImageGeometry ( ) const
private
Parameters
Methodto get geometry from the various external files like .prj, .j2w .xml and so on.

Definition at line 1156 of file ossimKakaduJp2Reader.cpp.

Referenced by getImageGeometry().

1157 {
1158  static const char M[] = "ossimKakaduJp2Reader::getMetadataImageGeometry";
1159  if ( traceDebug() )
1160  {
1161  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
1162  }
1163 
1166 
1167  // See if we can pick up the projection from the FGDC file:
1168  ossimFilename fdgcFile = theImageFile;
1169 
1170  fdgcFile += ".xml"; // file.jp2.xml
1171  if ( fdgcFile.exists() == false )
1172  {
1173  fdgcFile = theImageFile;
1174  fdgcFile.setExtension(ossimString("xml")); // file.xml
1175  }
1176 
1177  if ( fdgcFile.exists() )
1178  {
1179  ossimFgdcXmlDoc fgdcDoc;
1180  if ( fgdcDoc.open(fdgcFile) )
1181  {
1182  try
1183  {
1184  proj = fgdcDoc.getGridCoordSysProjection();
1185  }
1186  catch (const ossimException& e)
1187  {
1188  ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
1189  }
1190 
1191  if ( proj.valid() )
1192  {
1193  geom = new ossimImageGeometry();
1194 
1195  ossimMapProjection* mapProj = dynamic_cast<ossimMapProjection*>(proj.get());
1196  if ( mapProj )
1197  {
1198  // See if we have a world file. Seems they have a more accurate tie point.
1199  ossimFilename worldFile = theImageFile;
1200  worldFile.setExtension(ossimString("j2w")); // file.j2w
1201  if ( worldFile.exists() )
1202  {
1203  //---
1204  // Note need a way to determine pixel type from fgdc doc.
1205  // This can result in a half pixel shift.
1206  //---
1208  ossimUnitType unitType = fgdcDoc.getUnitType();
1209 
1210  ossimTiffWorld tfw;
1211  if ( tfw.open(worldFile, pixelType, unitType) )
1212  {
1213  ossimDpt gsd = tfw.getScale();
1214  gsd.y = std::fabs(gsd.y); // y positive up so negate.
1215  ossimDpt tie = tfw.getTranslation();
1216 
1217  if ( unitType != OSSIM_METERS )
1218  {
1220 
1221  // GSD (scale):
1222  uct.setValue(gsd.x, unitType);
1223  gsd.x = uct.getValue(OSSIM_METERS);
1224  uct.setValue(gsd.y, unitType);
1225  gsd.y = uct.getValue(OSSIM_METERS);
1226 
1227  // Tie point:
1228  uct.setValue(tie.x, unitType);
1229  tie.x = uct.getValue(OSSIM_METERS);
1230  uct.setValue(tie.y, unitType);
1231  tie.y = uct.getValue(OSSIM_METERS);
1232  }
1233 
1234  mapProj->setMetersPerPixel(gsd);
1235  mapProj->setUlTiePoints(tie);
1236  }
1237 
1238  if ( tfw.getRotation() != 0.0 )
1239  {
1241  << M << " Unhandled rotation in tfw file." << std::endl;
1242  }
1243  }
1244 
1245  } // if ( worldFile.exists() )
1246 
1247  geom->setProjection( proj.get() );
1248 
1249  } // if ( proj.valid() )
1250 
1251  } // if ( fgdcDoc.open(fdgcFile) )
1252 
1253  } // if ( fdgcFile.exists() )
1254 
1255  if (traceDebug())
1256  {
1258  << M << " exit status = " << (geom.valid()?"true":"false\n")
1259  << std::endl;
1260  }
1261 
1262  return geom;
1263 }
bool open(const ossimFilename &file, ossimPixelType ptype, ossimUnitType unit)
double getValue(ossimUnitType unitType=OSSIM_METERS) const
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
ossimFilename theImageFile
ossimUnitType
bool valid() const
Definition: ossimRefPtr.h:75
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)
double y
Definition: ossimDpt.h:165
ossimRefPtr< ossimProjection > getGridCoordSysProjection()
Gets projection from Grid Coordinate system node.
virtual void setMetersPerPixel(const ossimDpt &gsd)
bool exists() const
virtual const char * what() const
Returns the error message.
Class for FGDC XML doc parsing.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
ossimPixelType
const ossimDpt & getScale() const
Converts world file parameters into x, y scale (for use in affine transform)
double x
Definition: ossimDpt.h:164
const ossimDpt & getTranslation() const
Provides access to the translation (for use in affine transform)
virtual void setUlTiePoints(const ossimGpt &gpt)
bool open(const ossimFilename &xmlFileName)
Open method.
double getRotation() const
Converts world file parameters into RH rotation in radians (for use in affine transform) ...
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
ossimUnitType getUnitType() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getNumberOfDecimationLevels()

ossim_uint32 ossimKakaduJp2Reader::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 110 of file ossimKakaduJp2Reader.cpp.

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

Referenced by getOverviewTile().

111 {
112  ossim_uint32 result = 1; // Add r0
113 
114  if (theMinDwtLevels)
115  {
116  //---
117  // Add internal overviews.
118  //---
119  result += theMinDwtLevels;
120  }
121 
122  if (theOverview.valid())
123  {
124  //---
125  // Add external overviews.
126  //---
128  }
129 
130  return result;
131 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
unsigned int ossim_uint32
ossimRefPtr< ossimImageHandler > theOverview

◆ getNumberOfInputBands()

ossim_uint32 ossimKakaduJp2Reader::getNumberOfInputBands ( ) const
virtual

Returns the number of bands in the image.

Satisfies pure virtual from ImageHandler class.

Implements ossimImageSource.

Definition at line 744 of file ossimKakaduJp2Reader.cpp.

References theNumberOfBands.

745 {
746  return theNumberOfBands;
747 }

◆ getNumberOfLines()

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

Gets number of lines for res level.

Overrides ossimJ2kTileSource::getNumberOfLines

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

Implements ossimImageHandler.

Definition at line 133 of file ossimKakaduJp2Reader.cpp.

References ossimImageHandler::getNumberOfLines(), ossimImageHandler::isValidRLevel(), theJp2Dims, ossimImageHandler::theOverview, and ossimRefPtr< T >::valid().

135 {
136  ossim_uint32 result = 0;
137  if ( isValidRLevel(resLevel) )
138  {
139  if (resLevel < theJp2Dims.size() )
140  {
141  result = theJp2Dims[resLevel].height();
142  }
143  else if (theOverview.valid())
144  {
145  result = theOverview->getNumberOfLines(resLevel);
146  }
147  }
148  return result;
149 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
unsigned int ossim_uint32
ossimRefPtr< ossimImageHandler > theOverview
std::vector< ossimIrect > theJp2Dims
Has sub image offset.

◆ getNumberOfOutputBands()

ossim_uint32 ossimKakaduJp2Reader::getNumberOfOutputBands ( ) const
virtual

Returns the number of bands in a tile returned from this TileSource.

Note: we are supporting sources that can have multiple data objects. If you want to know the scalar type of an object you can pass in the

Reimplemented from ossimImageSource.

Definition at line 749 of file ossimKakaduJp2Reader.cpp.

References theNumberOfBands.

Referenced by getOverviewTile(), and initializeTile().

750 {
751  return theNumberOfBands;
752 }

◆ getNumberOfSamples()

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

Gets the number of samples for res level.

Overrides ossimJ2kTileSource::getNumberOfSamples

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

Implements ossimImageHandler.

Definition at line 151 of file ossimKakaduJp2Reader.cpp.

References ossimImageHandler::getNumberOfSamples(), ossimImageHandler::isValidRLevel(), theJp2Dims, ossimImageHandler::theOverview, and ossimRefPtr< T >::valid().

153 {
154  ossim_uint32 result = 0;
155  if ( isValidRLevel(resLevel) )
156  {
157  if (resLevel < theJp2Dims.size() )
158  {
159  result = theJp2Dims[resLevel].width();
160  }
161  else if (theOverview.valid())
162  {
163  result = theOverview->getNumberOfSamples(resLevel);
164  }
165  }
166  return result;
167 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
unsigned int ossim_uint32
ossimRefPtr< ossimImageHandler > theOverview
std::vector< ossimIrect > theJp2Dims
Has sub image offset.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.

◆ getOutputScalarType()

ossimScalarType ossimKakaduJp2Reader::getOutputScalarType ( ) const
virtual

Returns the output pixel type of the tile source.

Reimplemented from ossimImageSource.

Definition at line 782 of file ossimKakaduJp2Reader.cpp.

References theScalarType.

Referenced by initializeTile().

783 {
784  return theScalarType;
785 }
ossimScalarType theScalarType

◆ getOverviewTile()

bool ossimKakaduJp2Reader::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 671 of file ossimKakaduJp2Reader.cpp.

References ossim::copyRegionToTile(), ossimImageData::getImageRectangle(), ossimImageData::getNumberOfBands(), getNumberOfDecimationLevels(), getNumberOfOutputBands(), ossimImageSource::getTile(), ossimNotify(), ossimNotifyLevel_WARN, ossimImageData::setImageRectangle(), status, theChannels, theCodestream, theJp2Dims, theMinDwtLevels, theOpenTileThreadQueue, ossimImageHandler::theOverview, theThreadEnv, and ossimException::what().

Referenced by getTile(), and loadTile().

673 {
674  bool status = false;
675 
676  if ( (resLevel < getNumberOfDecimationLevels()) && result &&
677  (result->getNumberOfBands() == getNumberOfOutputBands()) )
678  {
679  if (resLevel <= theMinDwtLevels)
680  {
681  // Using internal overviews.
682 
683  //---
684  // NOTE:
685  //
686  // The geojp2 doqq's that I have all have an offset in them. In
687  // other words the "pos" from "get_dims" is not always 0,0. I
688  // think this was intended for mosaicing without any projection. I
689  // do NOT think it was intended to be used as a sub image offset
690  // into the projection picked up by the geotiff_box. If this were
691  // so the current code here would not mosaic correctly.
692  //
693  // This may not be the case though with all data sets... In which
694  // case some kind of logic would have to be added to this code.
695  //---
696  ossimIrect originalTileRect = result->getImageRectangle();
697 
698  ossimIrect shiftedRect = originalTileRect + theJp2Dims[resLevel].ul();
699 
700  result->setImageRectangle(shiftedRect);
701 
702  try
703  {
704  if ( theChannels )
705  {
708  static_cast<int>(resLevel),
709  theThreadEnv,
711  result);
712  }
713  else
714  {
716  static_cast<int>(resLevel),
717  theThreadEnv,
719  result);
720  }
721  }
722  catch(const ossimException& e)
723  {
725  << __FILE__ << " " << __LINE__ << " caught exception\n"
726  << e.what();
727  status = false;
728  }
729 
730  // Set the rect back.
731  result->setImageRectangle(originalTileRect);
732 
733  } // matches: if (resLevel <= theMinDwtLevels)
734  else
735  {
736  // Using external overview.
737  status = theOverview->getTile(result, resLevel);
738  }
739  }
740 
741  return status;
742 }
virtual ossim_uint32 getNumberOfBands() const
virtual void setImageRectangle(const ossimIrect &rect)
kdu_core::kdu_thread_queue * theOpenTileThreadQueue
kdu_core::kdu_codestream theCodestream
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
kdu_core::kdu_thread_env * theThreadEnv
virtual const char * what() const
Returns the error message.
virtual ossim_uint32 getNumberOfDecimationLevels() const
Returns the number of decimation levels.
virtual ossimIrect getImageRectangle() const
return status
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.
std::vector< ossimIrect > theJp2Dims
Has sub image offset.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
kdu_supp::kdu_channel_mapping * theChannels

◆ getShortName()

ossimString ossimKakaduJp2Reader::getShortName ( ) const
virtual

Returns short name.

Returns
"ossim_kakadu_jp2_reader"

Reimplemented from ossimObject.

Definition at line 95 of file ossimKakaduJp2Reader.cpp.

96 {
97  return ossimString("ossim_kakadu_jp2_reader");
98 }

◆ getTile()

ossimRefPtr< ossimImageData > ossimKakaduJp2Reader::getTile ( const ossimIrect rect,
ossim_uint32  resLevel = 0 
)
virtual

Method to grab a tile(rectangle) from image.

Parameters
rectThe zero based rectangle to grab.
resLevelThe reduced resolution level to grab from.
Returns
The ref pointer with the image data pointer.

Reimplemented from ossimImageSource.

Definition at line 571 of file ossimKakaduJp2Reader.cpp.

References ossimIrect::clipToRect(), ossimIrect::completely_within(), ossimRefPtr< T >::get(), ossimImageData::getBuf(), ossimImageData::getImageRectangle(), getOverviewTile(), ossimIrect::intersects(), isOpen(), ossimSource::isSourceEnabled(), ossimImageHandler::isValidRLevel(), loadTile(), ossimImageData::loadTile(), loadTileFromCache(), ossimIrect::lr(), ossimImageData::makeBlank(), OSSIM_BSQ, ossimImageData::setImageRectangle(), ossimIrect::stretchToTileBoundary(), theCacheSize, theCacheTile, theImageRect, theTile, ossimIrect::ul(), ossimRefPtr< T >::valid(), ossimImageData::validate(), ossimIpt::x, and ossimIpt::y.

573 {
574  // This tile source bypassed, or invalid res level, return null tile.
575  if(!isSourceEnabled() || !isOpen() || !isValidRLevel(resLevel))
576  {
578  }
579 
580  if (theTile.valid())
581  {
582  // Rectangle must be set prior to getOverviewTile call.
583  theTile->setImageRectangle(rect);
584 
585  if (resLevel)
586  {
587  if ( getOverviewTile(resLevel, theTile.get()) == false )
588  {
589  theTile->makeBlank();
590  }
591  }
592  else // r0
593  {
594  // NOTE: Using cache for r0 tiles.
595 
596  //---
597  // See if the whole tile is going to be filled, if not, start out with
598  // a blank tile so data from a previous load gets wiped out.
599  //---
600  if ( !rect.completely_within(theImageRect) )
601  {
602  // Start with a blank tile.
603  theTile->makeBlank();
604  }
605 
606  //---
607  // See if any point of the requested tile is in the image.
608  //---
609  if ( rect.intersects(theImageRect) )
610  {
611  ossimIrect clipRect = rect.clipToRect(theImageRect);
612 
613  ossimIrect expandedRect = clipRect;
614  expandedRect.stretchToTileBoundary(theCacheSize);
615 
616  //---
617  // Shift the upper left corner of the "clip_rect" to the an even
618  // j2k tile boundry.
619  //---
620  ossimIpt tileOrigin = expandedRect.ul();
621 
622  // Vertical tile loop.
623  while (tileOrigin.y < expandedRect.lr().y)
624  {
625  // Horizontal tile loop.
626  while (tileOrigin.x < expandedRect.lr().x)
627  {
628  if ( loadTileFromCache(tileOrigin, clipRect) == false )
629  {
630  if ( loadTile(tileOrigin) )
631  {
632  //---
633  // Note: Clip the cache tile to the image clipRect
634  // since there are j2k tiles that go beyond the image
635  // dimensions, i.e., edge tiles.
636  //---
637  ossimIrect cr =
639  clipToRect(clipRect);
640 
643  cr,
644  OSSIM_BSQ);
645  }
646 
647  }
648 
649  tileOrigin.x += theCacheSize.x; // Go to next tile.
650 
651  } // End loop in x direction.
652 
653  // Go to next row of tiles.
654  tileOrigin.x = expandedRect.ul().x;
655  tileOrigin.y += theCacheSize.y;
656 
657  } // End loop in y direction.
658 
659  // Set the tile status.
660  theTile->validate();
661 
662  } // matches: if ( rect.intersects(theImageRect) )
663 
664  } // r0 block
665 
666  } // matches: if (theTile.valid())
667 
668  return theTile;
669 }
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Gets an overview tile.
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
ossimRefPtr< ossimImageData > theTile
bool loadTile(const ossimIpt &origin)
Loads a block of data to theCacheTile.
virtual void setImageRectangle(const ossimIrect &rect)
bool valid() const
Definition: ossimRefPtr.h:75
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
bool completely_within(const ossimIrect &rect) const
Definition: ossimIrect.cpp:425
bool loadTileFromCache(const ossimIpt &origin, const ossimIrect &clipRect)
Loads a block of data to theCacheTile from the cache.
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
ossimRefPtr< ossimImageData > theCacheTile
virtual ossimDataObjectStatus validate() const
virtual ossimIrect getImageRectangle() const
const ossimIpt & lr() const
Definition: ossimIrect.h:276
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
virtual void makeBlank()
Initializes data to null pixel values.
ossim_int32 y
Definition: ossimIpt.h:142
virtual const void * getBuf() const
void stretchToTileBoundary(const ossimIpt &tileWidthHeight)
Definition: ossimIrect.cpp:212
ossim_int32 x
Definition: ossimIpt.h:141
virtual bool isOpen() const
Method to test for open file stream.

◆ initializeTile()

void ossimKakaduJp2Reader::initializeTile ( )
private

Initializes data member "theTile".

Definition at line 787 of file ossimKakaduJp2Reader.cpp.

References ossim::defaultTileSize(), getImageTileHeight(), getImageTileWidth(), getNumberOfOutputBands(), getOutputScalarType(), ossimImageData::initialize(), ossimImageDataFactory::instance(), theCacheSize, theCacheTile, theTile, ossimIpt::x, and ossimIpt::y.

788 {
789  ossim_uint32 width = this->getImageTileWidth();
790  ossim_uint32 height = this->getImageTileHeight();
791 
792  // Check for zero width, height and limit output tile sizes to 1024.
793  if ( !width || !height || ( width > 1024) || (height > 1024) )
794  {
795  ossimIpt tileSize;
796  ossim::defaultTileSize(tileSize);
797 
798  width = tileSize.x;
799  height = tileSize.y;
800  }
801 
803  create( this,
804  this->getOutputScalarType(),
805  this->getNumberOfOutputBands(),
806  width,
807  height);
808 
809  theTile->initialize();
810 
812  create( this,
813  this->getOutputScalarType(),
814  this->getNumberOfOutputBands(),
815  theCacheSize.x,
816  theCacheSize.y );
817 
819 }
ossimRefPtr< ossimImageData > theTile
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
virtual void initialize()
Initialize the data buffer.
static ossimImageDataFactory * instance()
ossimRefPtr< ossimImageData > theCacheTile
unsigned int ossim_uint32
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
ossim_int32 y
Definition: ossimIpt.h:142
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
ossim_int32 x
Definition: ossimIpt.h:141

◆ isJp2()

bool ossimKakaduJp2Reader::isJp2 ( )
private

Test first 12 bytes of file for the jp2 signature block.

Returns
true is theImageFile is a jp2, false if not.

Definition at line 207 of file ossimKakaduJp2Reader.cpp.

References ossimString::chars(), SIGNATURE_BOX_SIZE, and ossimImageHandler::theImageFile.

208 {
209  bool result = true;
210 
211  std::ifstream str;
212  str.open(theImageFile.chars(), ios::in | ios::binary);
213 
214  if ( str.is_open() )
215  {
216  const ossim_uint8 J2K_SIGNATURE_BOX[SIGNATURE_BOX_SIZE] =
217  {0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20,0x0d,0x0a,0x87,0x0a};
218 
220 
221  // Read in the box.
222  str.read((char*)box, SIGNATURE_BOX_SIZE);
223 
224  for (ossim_uint32 i = 0; i < SIGNATURE_BOX_SIZE; ++i)
225  {
226  if (box[i] != J2K_SIGNATURE_BOX[i])
227  {
228  result = false;
229  break;
230  }
231  }
232 
233  str.close();
234  }
235  else
236  {
237  result = false;
238 
239  if(traceDebug())
240  {
242  << "isJp2 ERROR:"
243  << "\nCannot open: " << theImageFile.chars() << endl;
244  }
245  }
246 
247  return result;
248 }
ossimFilename theImageFile
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
unsigned int ossim_uint32
const char * chars() const
For backward compatibility.
Definition: ossimString.h:77
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ isOpen()

bool ossimKakaduJp2Reader::isOpen ( ) const
virtual

Method to test for open file stream.

Returns
true if open, false if not.

Implements ossimImageHandler.

Definition at line 510 of file ossimKakaduJp2Reader.cpp.

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

Referenced by getTile().

511 {
512  return theTile.valid();
513 
514  // return theCodestream.exists()
515  // return theFileStr.is_open();
516 }
ossimRefPtr< ossimImageData > theTile
bool valid() const
Definition: ossimRefPtr.h:75

◆ loadState()

bool ossimKakaduJp2Reader::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 ossimImageHandler.

Definition at line 1265 of file ossimKakaduJp2Reader.cpp.

References ossimImageHandler::loadState(), and open().

1267 {
1268  bool result = false;
1269  if ( ossimImageHandler::loadState(kwl, prefix) )
1270  {
1271  result = open();
1272  }
1273  return result;
1274 }
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual bool open()
Open method.

◆ loadTile()

bool ossimKakaduJp2Reader::loadTile ( const ossimIpt origin)
private

Loads a block of data to theCacheTile.

Parameters
originStarting position of block to load.
Returns
true on success, false on error.

Definition at line 847 of file ossimKakaduJp2Reader.cpp.

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

Referenced by getTile().

848 {
849  bool result = true;
850 
851  ossimIpt lr(origin.x + theCacheSize.x - 1,
852  origin.y + theCacheSize.y - 1);
853 
854  // Set the cache rectangle to be an even j2k tile.
856 
857  // Let the getOverviewTile do the rest of the work.
858  if ( getOverviewTile(0, theCacheTile.get()) )
859  {
860  // Add it to the cache for the next time.
862  }
863  else
864  {
866  << __FILE__ << __LINE__
867  << " ossimKakaduJp2Reader::loadBlock failed!"
868  << std::endl;
869  result = false;
870  }
871 
872  return result;
873 }
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Gets an overview tile.
virtual void setImageRectangle(const ossimIrect &rect)
static ossimAppFixedTileCache * instance(ossim_uint32 maxSize=0)
ossimRefPtr< ossimImageData > theCacheTile
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId
Cache initialized to image rect with sub image offset.
ossimRefPtr< ossimImageData > addTile(ossimAppFixedCacheId cacheId, ossimRefPtr< ossimImageData > data, bool duplicateData=true)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ loadTileFromCache()

bool ossimKakaduJp2Reader::loadTileFromCache ( const ossimIpt origin,
const ossimIrect clipRect 
)
private

Loads a block of data to theCacheTile from the cache.

Parameters
originThis is the point used for the cache query.
clipRectThe rectangle to fill.
Returns
true on success, false on error.

Definition at line 821 of file ossimKakaduJp2Reader.cpp.

References ossimIrect::clipToRect(), ossimRefPtr< T >::get(), ossimImageData::getBuf(), ossimImageData::getImageRectangle(), ossimAppFixedTileCache::getTile(), ossimAppFixedTileCache::instance(), ossimImageData::loadTile(), OSSIM_BSQ, theCacheId, theTile, and ossimRefPtr< T >::valid().

Referenced by getTile().

823 {
824  bool result = false;
825 
826  ossimRefPtr<ossimImageData> tempTile =
828  if (tempTile.valid())
829  {
830  //---
831  // Note: Clip the cache j2k tile to the image clipRect since
832  // there are j2k tiles that go beyond the image dimensions, i.e.,
833  // edge tiles.
834  //---
835  ossimIrect cr = tempTile->getImageRectangle().clipToRect(clipRect);
836 
837  theTile->loadTile(tempTile.get()->getBuf(),
838  tempTile->getImageRectangle(),
839  cr,
840  OSSIM_BSQ);
841  result = true;
842  }
843 
844  return result;
845 }
ossimRefPtr< ossimImageData > theTile
bool valid() const
Definition: ossimRefPtr.h:75
static ossimAppFixedTileCache * instance(ossim_uint32 maxSize=0)
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
ossimRefPtr< ossimImageData > getTile(ossimAppFixedCacheId cacheId, const ossimIpt &origin)
virtual ossimIrect getImageRectangle() const
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
virtual const void * getBuf() const
ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId
Cache initialized to image rect with sub image offset.

◆ open()

bool ossimKakaduJp2Reader::open ( )
virtual

Open method.

Returns
true on success, false on error.

Implements ossimImageHandler.

Definition at line 169 of file ossimKakaduJp2Reader.cpp.

Referenced by loadState().

170 {
171  static const char MODULE[] = "ossimKakaduJp2Reader::open";
172 
173  if (traceDebug())
174  {
176  << MODULE << " entered...\n"
177  << "image: " << theImageFile << "\n";
178  }
179 
180  bool result = false;
181 
182  if(isOpen())
183  {
184  closeEntry();
185  }
186 
187  if ( isJp2() )
188  {
189  result = openJp2File();
190 
191  if ( !result )
192  {
193  closeEntry();
194  }
195  }
196 
197  if (traceDebug())
198  {
200  << MODULE << " exit status = " << (result?"true":"false\n")
201  << std::endl;
202  }
203 
204  return result;
205 }
ossimFilename theImageFile
virtual void closeEntry()
Method to close current entry.
bool isJp2()
Test first 12 bytes of file for the jp2 signature block.
bool openJp2File()
Opens the jp2 and initializes this object.
virtual bool isOpen() const
Method to test for open file stream.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ openJp2File()

bool ossimKakaduJp2Reader::openJp2File ( )
private

Opens the jp2 and initializes this object.

Returns
true on success, false on error.

Definition at line 250 of file ossimKakaduJp2Reader.cpp.

251 {
252  static const char MODULE[] = "ossimKakaduJp2Reader::openJp2File";
253 
254  if (traceDebug())
255  {
257  << MODULE << " entered...\n";
258  }
259 
260  bool result = false;
261 
262  theJp2FamilySrc = new kdu_supp::jp2_family_src();
263  theJp2FamilySrc->open(theImageFile.c_str(), true);
264 
265  if (theJp2FamilySrc->exists())
266  {
267  kdu_supp::jp2_source* src = new kdu_supp::jp2_source();
268  theJp2Source = src;
269 
270  src->open(theJp2FamilySrc);
271 
272  src->read_header();
273 
274  if (traceDebug())
275  {
276  kdu_supp::jp2_colour colour = src->access_colour();
277  if ( colour.exists() )
278  {
280  << "jp2 color space: " << colour.get_space() << std::endl;
281  }
282  }
283 
284  theThreadEnv = new kdu_core::kdu_thread_env();
285 
286  theThreadEnv->create(); // Creates the single "owner" thread
287 
288  ossim_uint32 threads = 1;
289 
290  const char* lookup = ossimPreferences::instance()->findPreference("kakadu_threads");
291  if ( lookup )
292  {
293  threads = ossimString::toUInt32(lookup);
294  if ( threads > 1 )
295  {
296  for (ossim_uint32 nt=1; nt < threads; ++nt)
297  {
298  if ( !theThreadEnv->add_thread() )
299  {
300  if (traceDebug())
301  {
303  << "Unable to create thread!\n";
304  }
305  }
306  }
307  }
308  }
309 
311  theThreadEnv->add_queue(NULL,NULL,"open_tile_q");
312 
314 
315  if ( theCodestream.exists() )
316  {
317  // This must be done before anything else...
318  theCodestream.set_persistent();
319 
320  theCodestream.enable_restart(); // ????
321 
322  // Get the image and tile dimensions.
324  theJp2Dims,
325  theJp2TileDims) )
326  {
327  //---
328  // Set the image size.
329  //
330  // NOTE:
331  //
332  // The geojp2 doqq's that I have all have an offset in them. In
333  // other words the "pos" from "get_dims" is not always 0,0. I
334  // think this was intended for mosaicing without any projection. I
335  // do NOT think it was intended to be used as a sub image offset
336  // into the projection picked up by the geotiff_box. If this were
337  // so the current code here would not mosaic correctly.
338  //
339  // This may not be the case though with all data sets... In which
340  // case some kind of logic would have to be added to this code.
341  //---
343  0,
344  theJp2Dims[0].width() -1,
345  theJp2Dims[0].height()-1);
346 
347  // Number of internal dwl layers
348  theMinDwtLevels = theCodestream.get_min_dwt_levels();
349 
350  //---
351  // Set up channel mapping for copyRegionToTile if it makes sense.
352  // This will set the number of bands if successful, ignoring the
353  // alpha channel.
354  //---
355  if ( configureChannelMapping() == false )
356  {
358  static_cast<ossim_uint32>(theCodestream.get_num_components(true));
359  }
360 
361  if (traceDebug())
362  {
364  << "codestream::get_num_components(true): "
365  << theCodestream.get_num_components(true)
366  << "\ntheNumberOfBands: " << theNumberOfBands << "\n";
367  }
368 
369  //---
370  // Set the cache tile size. Use the internal j2k tile size if it's
371  // reasonable else clamp to some max. Some j2k writer make one
372  // BIG tile so this must be done.
373  //---
374  const ossim_uint32 MAX_CACHE_TILE_DIMENSION = 1024;
375  theCacheSize.x =
376  static_cast<ossim_int32>(
377  (theJp2TileDims[0].width() <= MAX_CACHE_TILE_DIMENSION) ?
378  theJp2TileDims[0].width() : MAX_CACHE_TILE_DIMENSION );
379  theCacheSize.y =
380  static_cast<ossim_int32>(
381  (theJp2TileDims[0].height() <= MAX_CACHE_TILE_DIMENSION) ?
382  theJp2TileDims[0].height() : MAX_CACHE_TILE_DIMENSION );
383 
384  // Set the scalar:
385  int bitDepth = theCodestream.get_bit_depth(0, true);
386  bool isSigned = theCodestream.get_signed(0, true);
387 
388  switch (bitDepth)
389  {
390  case 8:
391  {
393  break;
394  }
395  case 11:
396  {
398  break;
399  }
400  case 12:
401  {
403  break;
404  }
405  case 13:
406  {
408  break;
409  }
410  case 14:
411  {
413  break;
414  }
415  case 15:
416  {
418  break;
419  }
420  case 16:
421  {
423  break;
424  }
425  default:
426  {
428  break;
429  }
430  }
431 
433  {
434  // Initialize the cache.
435  if (theCacheId != -1)
436  {
438  theCacheId = -1;
439  }
440 
441  ossimIrect fullImgRect = theImageRect;
442  fullImgRect.stretchToTileBoundary(theCacheSize);
443 
445  newTileCache(fullImgRect, theCacheSize);
446 
447  // Initialize the tile we will return.
448  initializeTile();
449 
450  // Call the base complete open to pick up overviews.
451  completeOpen();
452 
453 
454  // We should be good now so set the return result to true.
455  result = true;
456 
457  if (traceDebug())
458  {
460  theCodestream);
462  << "\ntheImageRect: " << theImageRect
463  << "\nFull image rect: " << fullImgRect
464  << "\ntheCacheSize: " << theCacheSize
465  << "\nscalar type: "
467  getEntryString(theScalarType)
468  << "\n";
469 
470  for (ossim_uint32 level=0;
471  level < theJp2Dims.size(); ++level)
472  {
474  << "theJp2Dims[" << level << "]: "
475  << theJp2Dims[level]
476  << "\ntheJp2TileDims[" << level << "]: "
477  << theJp2TileDims[level] << "\n";
478  }
480  << "threads: " << threads << endl;
481  }
482 
483  } // if (theScalarType != OSSIM_SCALAR_UNKNOWN)
484 
485  } // matches: if ( ossim::getCodestreamDimensions
486 
487  } // matches: if ( theCodestream.exists() )
488 
489  } // if (theJp2FamilySrc->exists())
490 
491  if (traceDebug())
492  {
494  << MODULE << " exit status = " << (result?"true":"false\n")
495  << std::endl;
496  }
497 
498  return result;
499 
500  if (traceDebug())
501  {
503  << MODULE << " exit status = " << (result?"true":"false\n")
504  << std::endl;
505  }
506 
507  return result;
508 }
virtual void deleteCache(ossimAppFixedCacheId cacheId)
kdu_core::kdu_compressed_source * theJp2Source
16 bit unsigned integer (12 bits used)
ossimFilename theImageFile
16 bit unsigned integer
kdu_core::kdu_thread_queue * theOpenTileThreadQueue
16 bit unsigned integer (14 bits used)
void initializeTile()
Initializes data member "theTile".
kdu_core::kdu_codestream theCodestream
16 bit signed integer
ossim_uint32 toUInt32() const
16 bit unsigned integer (13 bits used)
std::vector< ossimIrect > theJp2TileDims
Tile dimensions for each level.
static ossimAppFixedTileCache * instance(ossim_uint32 maxSize=0)
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
kdu_core::kdu_thread_env * theThreadEnv
OSSIM_DLL bool isSigned(ossimScalarType scalarType)
const char * findPreference(const char *key) const
kdu_supp::jp2_family_src * theJp2FamilySrc
std::ostream & print(std::ostream &out, kdu_core::kdu_codestream &cs)
Convenience print method for kdu_codestream.
unsigned int ossim_uint32
bool configureChannelMapping()
Initializes m_channels to be used with copyRegionToTile if it makes sense.
ossimScalarType theScalarType
static ossimPreferences * instance()
virtual void completeOpen()
Will complete the opening process.
16 bit unsigned integer (15 bits used)
ossim_int32 y
Definition: ossimIpt.h:142
std::vector< ossimIrect > theJp2Dims
Has sub image offset.
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
void stretchToTileBoundary(const ossimIpt &tileWidthHeight)
Definition: ossimIrect.cpp:212
ossim_int32 x
Definition: ossimIpt.h:141
8 bit unsigned integer
16 bit unsigned integer (11 bits used)
ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId
Cache initialized to image rect with sub image offset.
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).
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

Member Data Documentation

◆ theCacheId

ossimAppFixedTileCache::ossimAppFixedCacheId ossimKakaduJp2Reader::theCacheId
private

Cache initialized to image rect with sub image offset.

Definition at line 317 of file ossimKakaduJp2Reader.h.

Referenced by closeEntry(), loadTile(), and loadTileFromCache().

◆ theCacheSize

ossimIpt ossimKakaduJp2Reader::theCacheSize
private

Definition at line 303 of file ossimKakaduJp2Reader.h.

Referenced by getTile(), initializeTile(), and loadTile().

◆ theCacheTile

ossimRefPtr<ossimImageData> ossimKakaduJp2Reader::theCacheTile
private

Definition at line 314 of file ossimKakaduJp2Reader.h.

Referenced by closeEntry(), getTile(), initializeTile(), and loadTile().

◆ theChannels

kdu_supp::kdu_channel_mapping* ossimKakaduJp2Reader::theChannels
private

Definition at line 296 of file ossimKakaduJp2Reader.h.

Referenced by closeEntry(), configureChannelMapping(), and getOverviewTile().

◆ theCodestream

kdu_core::kdu_codestream ossimKakaduJp2Reader::theCodestream
private

Definition at line 297 of file ossimKakaduJp2Reader.h.

Referenced by closeEntry(), configureChannelMapping(), and getOverviewTile().

◆ theImageRect

ossimIrect ossimKakaduJp2Reader::theImageRect
private

Definition at line 305 of file ossimKakaduJp2Reader.h.

Referenced by getImageTileHeight(), getImageTileWidth(), and getTile().

◆ theJp2Dims

std::vector<ossimIrect> ossimKakaduJp2Reader::theJp2Dims
private

Has sub image offset.

Image dimensions for each level.

Definition at line 308 of file ossimKakaduJp2Reader.h.

Referenced by getNumberOfLines(), getNumberOfSamples(), and getOverviewTile().

◆ theJp2FamilySrc

kdu_supp::jp2_family_src* ossimKakaduJp2Reader::theJp2FamilySrc
private

Definition at line 294 of file ossimKakaduJp2Reader.h.

Referenced by closeEntry().

◆ theJp2Source

kdu_core::kdu_compressed_source* ossimKakaduJp2Reader::theJp2Source
private

Definition at line 295 of file ossimKakaduJp2Reader.h.

Referenced by closeEntry(), and configureChannelMapping().

◆ theJp2TileDims

std::vector<ossimIrect> ossimKakaduJp2Reader::theJp2TileDims
private

Tile dimensions for each level.

Definition at line 311 of file ossimKakaduJp2Reader.h.

Referenced by getImageTileHeight(), and getImageTileWidth().

◆ theMinDwtLevels

ossim_uint32 ossimKakaduJp2Reader::theMinDwtLevels
private

Definition at line 301 of file ossimKakaduJp2Reader.h.

Referenced by getNumberOfDecimationLevels(), and getOverviewTile().

◆ theNumberOfBands

ossim_uint32 ossimKakaduJp2Reader::theNumberOfBands
private

◆ theOpenTileThreadQueue

kdu_core::kdu_thread_queue* ossimKakaduJp2Reader::theOpenTileThreadQueue
private

Definition at line 299 of file ossimKakaduJp2Reader.h.

Referenced by closeEntry(), and getOverviewTile().

◆ theScalarType

ossimScalarType ossimKakaduJp2Reader::theScalarType
private

Definition at line 304 of file ossimKakaduJp2Reader.h.

Referenced by getOutputScalarType().

◆ theThreadEnv

kdu_core::kdu_thread_env* ossimKakaduJp2Reader::theThreadEnv
private

Definition at line 298 of file ossimKakaduJp2Reader.h.

Referenced by closeEntry(), and getOverviewTile().

◆ theTile

ossimRefPtr<ossimImageData> ossimKakaduJp2Reader::theTile
private

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