40 #include <kdu_compressed.h> 41 #include <kdu_elementary.h> 42 #include <kdu_sample_processing.h> 43 #include <kdu_region_decompressor.h> 56 #ifdef OSSIM_ID_ENABLED 57 static const char OSSIM_ID[] =
"$Id";
64 "ossimKakaduJp2Reader",
74 theOpenTileThreadQueue(0),
86 kdu_customize_warnings(&pretty_cout);
87 kdu_customize_errors(&pretty_cerr);
171 static const char MODULE[] =
"ossimKakaduJp2Reader::open";
176 << MODULE <<
" entered...\n" 200 << MODULE <<
" exit status = " << (result?
"true":
"false\n")
217 {0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20,0x0d,0x0a,0x87,0x0a};
226 if (box[i] != J2K_SIGNATURE_BOX[i])
252 static const char MODULE[] =
"ossimKakaduJp2Reader::openJp2File";
257 << MODULE <<
" entered...\n";
267 kdu_supp::jp2_source* src =
new kdu_supp::jp2_source();
276 kdu_supp::jp2_colour colour = src->access_colour();
277 if ( colour.exists() )
280 <<
"jp2 color space: " << colour.get_space() << std::endl;
303 <<
"Unable to create thread!\n";
364 <<
"codestream::get_num_components(true): " 463 <<
"\nFull image rect: " << fullImgRect
474 <<
"theJp2Dims[" << level <<
"]: " 476 <<
"\ntheJp2TileDims[" << level <<
"]: " 480 <<
"threads: " << threads << endl;
494 << MODULE <<
" exit status = " << (result?
"true":
"false\n")
503 << MODULE <<
" exit status = " << (result?
"true":
"false\n")
623 while (tileOrigin.
y < expandedRect.
lr().
y)
626 while (tileOrigin.
x < expandedRect.
lr().
x)
639 clipToRect(clipRect);
654 tileOrigin.
x = expandedRect.
ul().
x;
708 static_cast<int>(resLevel),
716 static_cast<int>(resLevel),
725 << __FILE__ <<
" " << __LINE__ <<
" caught exception\n" 793 if ( !width || !height || ( width > 1024) || (height > 1024) )
828 if (tempTile.
valid())
866 << __FILE__ << __LINE__
867 <<
" ossimKakaduJp2Reader::loadBlock failed!" 926 static const char MODULE[] =
"ossimKakaduJp2Reader::getInternalImageGeometry";
940 if ( geom.
valid() == false )
958 static const char MODULE[] =
"ossimKakaduJp2Reader::getImageGeometryFromGeotiffBox";
974 std::vector<ossim_uint8> box;
984 <<
"Found geotiff uuid at: " << boxPos+8 <<
"\n";
1002 boxStream.str( boxString );
1048 if ( type ==
"pixel_is_area" )
1052 else if ( type ==
"pixel_is_point" )
1075 static const char M[] =
"ossimKakaduJp2Reader::getImageGeometryFromGmlBox";
1089 if ( str.is_open() )
1091 std::vector<ossim_uint8> box;
1094 std::streamoff boxPos = jp2Info.
getGmlBox( str, box );
1096 if ( boxPos && box.size() )
1101 <<
"Found gml box at: " << boxPos+8
1102 <<
"\nbox size: " << box.size() <<
"\n";
1109 boxStream.rdbuf()->pubsetbuf( (
char*)&box.front(), box.size() );
1112 std::string boxString( box.begin(), box.end() );
1114 boxStream.str( boxString );
1147 << M <<
" exit status = " << (geom.
valid()?
"true":
"false\n")
1158 static const char M[] =
"ossimKakaduJp2Reader::getMetadataImageGeometry";
1171 if ( fdgcFile.
exists() == false )
1180 if ( fgdcDoc.
open(fdgcFile) )
1201 if ( worldFile.
exists() )
1211 if ( tfw.
open(worldFile, pixelType, unitType) )
1214 gsd.
y = std::fabs(gsd.
y);
1241 << M <<
" Unhandled rotation in tfw file." << std::endl;
1258 << M <<
" exit status = " << (geom.
valid()?
"true":
"false\n")
1268 bool result =
false;
1278 bool result =
false;
1306 <<
"ossimKakaduJp2Reader::configureChannelMapping() DEBUG:" 1307 <<
"\nkdu_channel_mapping::get_num_channels(): " 1309 <<
"\nkdu_channel_mapping::get_num_colour_channels(): "
virtual void deleteCache(ossimAppFixedCacheId cacheId)
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Gets an overview tile.
kdu_core::kdu_compressed_source * theJp2Source
virtual bool isSourceEnabled() const
bool open(const ossimFilename &file, ossimPixelType ptype, ossimUnitType unit)
static ossimImageGeometryRegistry * instance()
ossimRefPtr< ossimImageGeometry > theGeometry
ossimRefPtr< ossimImageData > theTile
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
16 bit unsigned integer (12 bits used)
virtual ossim_uint32 getNumberOfBands() const
bool loadTile(const ossimIpt &origin)
Loads a block of data to theCacheTile.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const
Gets number of lines for res level.
ossimFilename theImageFile
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
Method to grab a tile(rectangle) from image.
virtual void setImageRectangle(const ossimIrect &rect)
ossimKakaduJp2Reader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
Represents serializable keyword/value map.
std::basic_ifstream< char > ifstream
Class for char input file streams.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
kdu_core::kdu_thread_queue * theOpenTileThreadQueue
const char * find(const char *key) const
16 bit unsigned integer (14 bits used)
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 ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
void initializeTile()
Initializes data member "theTile".
ossim_uint32 height() const
ossimRefPtr< ossimImageGeometry > getMetadataImageGeometry() const
bool getImageGeometry(ossimKeywordlist &geomKwl, ossim_uint32 entryIndex) const
Extracts geometry info to keyword list.
ossimRefPtr< ossimProjection > getGridCoordSysProjection()
Gets projection from Grid Coordinate system node.
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * NUMBER_LINES_KW
kdu_core::kdu_codestream theCodestream
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 closeEntry()
Method to close current entry.
const ossimIpt & ul() const
ossim_uint32 toUInt32() const
16 bit unsigned integer (13 bits used)
bool intersects(const ossimIrect &rect) const
bool isJp2()
Test first 12 bytes of file for the jp2 signature block.
std::vector< ossimIrect > theJp2TileDims
Tile dimensions for each level.
virtual ossimString getClassName() const
Returns class name.
virtual bool extendGeometry(ossimImageHandler *handler) const
virtual void initialize()
Initialize the data buffer.
static ossimAppFixedTileCache * instance(ossim_uint32 maxSize=0)
virtual ~ossimKakaduJp2Reader()
virtural destructor
virtual void setMetersPerPixel(const ossimDpt &gsd)
ossimPixelType thePixelType
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
bool completely_within(const ossimIrect &rect) const
virtual ossimString getLongName() const
Returns long name.
bool loadTileFromCache(const ossimIpt &origin, const ossimIrect &clipRect)
Loads a block of data to theCacheTile from the cache.
bool getImageGeometry(ossimKeywordlist &geomKwl) const
Extracts geometry info to keyword list.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
kdu_core::kdu_thread_env * theThreadEnv
static ossimImageDataFactory * instance()
ossimRefPtr< ossimImageData > theCacheTile
OSSIM_DLL bool isSigned(ossimScalarType scalarType)
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
ossimRefPtr< ossimImageData > getTile(ossimAppFixedCacheId cacheId, const ossimIpt &origin)
const char * findPreference(const char *key) const
kdu_supp::jp2_family_src * theJp2FamilySrc
virtual ossimDataObjectStatus validate() const
virtual const char * what() const
Returns the error message.
virtual ossim_uint32 getNumberOfDecimationLevels() const
Returns the number of decimation levels.
std::ostream & print(std::ostream &out, kdu_core::kdu_codestream &cs)
Convenience print method for kdu_codestream.
unsigned int ossim_uint32
virtual bool open()
Open method.
const char * chars() const
For backward compatibility.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometryFromGmlBox()
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
Class for FGDC XML doc parsing.
virtual ossimIrect getImageRectangle() const
bool configureChannelMapping()
Initializes m_channels to be used with copyRegionToTile if it makes sense.
ossimScalarType theScalarType
const ossimIpt & lr() const
virtual void close()
Deletes the overview and clears the valid image vertices.
static ossimString downcase(const ossimString &aString)
bool initialize(const ossimImageGeometry *geom, const ossimIrect &rect)
Initializes gml block from geometry file.
ossim_uint32 width() const
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
ossimIrect clipToRect(const ossimIrect &rect) const
static ossimPreferences * instance()
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
static ossimProjectionFactoryRegistry * instance()
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual void makeBlank()
Initializes data to null pixel values.
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual void completeOpen()
Will complete the opening process.
16 bit unsigned integer (15 bits used)
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.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometryFromGeotiffBox()
This class defines an abstract Handler which all image handlers(loaders) should derive from...
const ossimDpt & getScale() const
Converts world file parameters into x, y scale (for use in affine transform)
ossimKakaduJp2Reader()
default construtor
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.
virtual const void * getBuf() const
static const char * PIXEL_TYPE_KW
std::vector< ossimIrect > theJp2Dims
Has sub image offset.
const ossimDpt & getTranslation() const
Provides access to the translation (for use in affine transform)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
void stretchToTileBoundary(const ossimIpt &tileWidthHeight)
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
bool openJp2File()
Opens the jp2 and initializes this object.
RTTI_DEF1_INST(ossimKakaduJp2Reader, "ossimKakaduJp2Reader", ossimImageHandler) ossimKakaduJp2Reader
virtual void setUlTiePoints(const ossimGpt &gpt)
bool open(const ossimFilename &xmlFileName)
Open method.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
double getRotation() const
Converts world file parameters into RH rotation in radians (for use in affine transform) ...
std::basic_istringstream< char > istringstream
Class for char input memory streams.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const
Gets the number of samples for res level.
std::streamoff getGmlBox(std::ifstream &str, std::vector< ossim_uint8 > &box) const
Method to get the embedded JP2 GML Box.
virtual ossimRefPtr< ossimImageGeometry > getInternalImageGeometry()
virtual bool isOpen() const
Method to test for open file stream.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
ossimUnitType getUnitType() const
std::streamoff getGeotiffBox(std::ifstream &str, std::vector< ossim_uint8 > &box) const
Method to get the embedded JP2 GeoTIFF box.
16 bit unsigned integer (11 bits used)
virtual ossimString getShortName() const
Returns short name.
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).
static const char * NUMBER_SAMPLES_KW
unsigned char ossim_uint8
ossimRefPtr< ossimImageData > addTile(ossimAppFixedCacheId cacheId, ossimRefPtr< ossimImageData > data, bool duplicateData=true)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
ossim_uint32 theMinDwtLevels
kdu_supp::kdu_channel_mapping * theChannels
ossim_uint32 theNumberOfBands