76 catch ( kdu_core::kdu_exception exc )
79 e <<
"ossimKakaduNitfReader::~ossimKakaduNitfReader\n" 80 <<
"Caught exception from kdu_region_decompressor: " << exc <<
"\n";
83 catch ( std::bad_alloc& )
86 "Caught exception from kdu_region_decompressor: std::bad_alloc";
92 "Caught unhandled exception from kdu_region_decompressor";
118 return KDU_PRECINCT_DATABIN;
122 return KDU_TILE_HEADER_DATABIN;
127 return KDU_TILE_DATABIN;
131 return KDU_MAIN_HEADER_DATABIN;
135 return KDU_META_DATABIN;
148 kdu_supp::jp2_input_box box;
157 box.open(pParentBox);
161 kdu_uint32 boxType = box.get_box_type();
162 char ch[] = { (char) ( boxType >> 24 ), (char) ( boxType >> 16 ), (char) ( boxType >> 8 ) , (char) ( boxType >> 0 ),
'\0' };
166 if ( box.get_box_type() == jp2_xml_4cc )
169 std::vector<kdu_byte> bytes(box.get_remaining_bytes());
170 box.read(&bytes.front(), bytes.size());
174 if(box.get_box_type() == jp2_uuid_4cc)
176 std::vector<kdu_byte> bytes(box.get_remaining_bytes());
177 box.read(&bytes.front(), bytes.size());
185 if ( jp2_is_superbox( box.get_box_type() ) )
204 kdu_codestream codestream;
205 kdu_region_decompressor decompressor;
207 codestream.set_persistent();
209 kdu_channel_mapping oChannels;
210 oChannels.configure(codestream);
212 kdu_coords ref_expansion(1, 1);
213 kdu_dims view_dims = decompressor.get_rendered_image_dims(codestream, &oChannels, -1, 0,
214 ref_expansion, ref_expansion,
215 KDU_WANT_OUTPUT_COMPONENTS);
216 siz_params* siz_in = codestream.access_siz();
217 kdu_params* cod_in = siz_in->access_cluster(
"COD");
219 m_client->set_read_scope(KDU_META_DATABIN, 0, 0);
238 box.open(pParentBox);
243 boxList.push_back(Box());
244 boxList[idx].m_type = box.get_box_type();
245 if(box.get_remaining_bytes()>0)
247 boxList[idx].m_buffer.resize(box.get_remaining_bytes());
248 box.read(&boxList[idx].m_buffer.front(), boxList[idx].m_buffer.size());
250 if ( jp2_is_superbox( box.get_box_type() ) )
271 protocolString = protocolString.
downcase();
274 if(protocolString ==
"jpip")
280 if(protocolString ==
"jpips")
300 m_client->set_read_scope(KDU_MAIN_HEADER_DATABIN, 0, 0);
301 kdu_codestream codestream;
302 kdu_region_decompressor decompressor;
304 codestream.set_persistent();
306 kdu_channel_mapping oChannels;
307 oChannels.configure(codestream);
311 kdu_coords ref_expansion(1, 1);
312 kdu_dims view_dims = decompressor.get_rendered_image_dims(codestream, &oChannels, -1, 0,
313 ref_expansion, ref_expansion,
314 KDU_WANT_OUTPUT_COMPONENTS);
315 siz_params* siz_in = codestream.access_siz();
316 kdu_params* cod_in = siz_in->access_cluster(
"COD");
318 m_client->set_read_scope(KDU_META_DATABIN, 0, 0);
326 int nQualityLayers = 0;
330 cod_in->get(
"Clevels", 0, 0, nResLevels);
331 cod_in->get(
"Clayers", 0, 0, nQualityLayers);
332 siz_in->get(
"Stiles", 0, 0, nTileSizeY);
333 siz_in->get(
"Stiles", 0, 1, nTileSizeX);
341 m_signed = codestream.get_signed(0);
343 if(nTileSizeX&&nTileSizeY)
354 cod_in->get(
"Cycc", 0, 0,
m_bYCC);
360 std::cout << std::dec <<
"width = " << width << std::endl;
361 std::cout << std::dec <<
"height = " << height << std::endl;
363 std::cout <<
"m_nInputBands = " <<
m_nInputBands << std::endl;
364 std::cout <<
"BitDepth = " <<
m_bitDepth << std::endl;
365 std::cout <<
"Overviews = " << nResLevels<< std::endl;
367 std::cout <<
"nTileSize = " <<
m_tileSize << std::endl;
445 params =
"type=jpp-stream&stream=0&cnew=http";
447 std::cout <<
"URL------------------------- " << imageInfoUrl.
toString() << std::endl;
453 std::cout <<
"__________________________" << std::endl;
454 std::cout << response->
headerKwl() << std::endl;
456 jpipCnew = jpipCnew.
trim();
457 if(!jpipCnew.
empty())
466 if(kwl.parseStream(in))
475 std::cout <<
"PATH === " <<
m_path << std::endl;
486 if(!client)
return result;
498 bool needNewChannel =
false;
503 needNewChannel =
true;
511 if(window.region.size.x == 0&&
512 window.region.size.y == 0)
515 params =
"type=jpp-stream&stream=0";
519 params =
"type=jpp-stream&stream=0";
529 params += (
"&cid=" +
m_cid);
534 params +=
"&cnew=http";
551 jpipCnew = jpipCnew.
trim();
553 if(!jpipCnew.
empty())
562 if(kwl.parseStream(in))
571 std::cout <<
"PATH === " <<
m_path << std::endl;
600 client->add_to_databin(
id,
623 else if(response.
valid())
646 while( !client->is_idle() &&client->is_alive())
785 if(test&power2Value)
break;
802 ossim_int32 targetLevel = nLevels - ossim::round<ossim_uint32>(log(1.0+((scalePower2*
m_quality)/100.0))/log(2.0));
805 if(targetLevel > static_cast<ossim_int32>(resLevel))
807 double scale = 1.0/(1<<targetLevel);
811 scaledRectRound.
ul().
y - 1,
812 scaledRectRound.
lr().
x + 1,
813 scaledRectRound.
lr().
y + 1);
822 transform->
scale(1<<targetLevel, 1<<targetLevel);
827 result = renderer->
getTile(rect);
843 catch ( kdu_exception exc )
846 e <<
"ossimKakaduNitfReader::~ossimKakaduNitfReader\n" 847 <<
"Caught exception from kdu_region_decompressor: " << exc <<
"\n";
850 catch ( std::bad_alloc& )
853 "Caught exception from kdu_region_decompressor: std::bad_alloc";
859 "Caught unhandled exception from kdu_region_decompressor";
898 kdu_coords ref_expansion;
899 kdu_coords exp_numerator;
900 kdu_coords exp_denominator;
910 for(idx=0;idx<nBands;++idx)
935 for(;ulx < maxx; ulx += tileSize.
x)
937 for(;uly < maxy; uly += tileSize.
y)
944 if(
x+w-1 > maxx) w = maxx-
x;
945 if(
y+h-1 > maxy) h = maxy-
y;
948 if(!cacheTile.
valid())
959 nQualityLayers = nQualityLayers<1?1:nQualityLayers;
961 window.set_region(region);
963 window.set_max_layers(nQualityLayers);
964 window.resolution.x = bounds.
width();
965 window.resolution.y = bounds.
height();
972 bool gotRegion =
true;
976 kdu_window reqWindow;
977 m_client->get_window_in_progress(&reqWindow);
978 gotRegion = ((reqWindow.region.size.x>0)&&
979 (reqWindow.region.size.y>0));
988 jp2_family_src jp2FamilySource;
991 jpx_source jpxSource;
992 if(jpxSource.open(&jp2FamilySource,
true)==1)
994 jpx_codestream_source jpx_codestream = jpxSource.access_codestream(0);
995 kdu_codestream codestream;
996 jpx_input_box* inputBox = jpx_codestream.open_stream();
999 codestream.create(inputBox);
1000 codestream.set_persistent();
1001 codestream.apply_input_restrictions(
1003 resLevel, nQualityLayers, ®ion,
1004 KDU_WANT_CODESTREAM_COMPONENTS);
1010 kdu_channel_mapping channels;
1011 channels.configure(codestream);
1014 region.pos.x + region.size.x - 1,
1015 region.pos.y+region.size.y - 1));
1024 jp2FamilySource.close();
1041 if(cacheTile.
valid())
1055 if(!client->is_alive())
1062 return client->is_alive();
1084 for(nDiscard = 0; nDiscard <
m_resLevels; ++nDiscard)
1087 codestream.apply_input_restrictions( 0, 0, nDiscard, 0, NULL );
1088 codestream.get_dims( 0, dims );
1089 ossimIrect rect(0,0,dims.size.x-1, dims.size.y-1);
1117 bool refreshCache =
false;
1118 if(property.
valid())
1121 if(name ==
"quality")
1125 m_quality =
property->valueToString().toDouble();
1143 if(name ==
"quality")
1151 return result.
get();
1198 if(!qualityString.empty())
1219 if(protocol ==
"http") protocol =
"jpip";
1220 else if(protocol ==
"https") protocol =
"jpips";
virtual void deleteCache(ossimAppFixedCacheId cacheId)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual void valueToString(ossimString &valueResult) const =0
virtual bool isSourceEnabled() const
virtual bool getKeywordlist(ossimKeywordlist &kwl) const
Method to dump info to a keyword list.
static ossimImageGeometryRegistry * instance()
RTTI_DEF1(ossimKakaduJpipHandler, "ossimKakaduJpipHandler", ossimImageHandler)
ossimRefPtr< ossimImageGeometry > theGeometry
ossimString substitute(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
Substitutes searchKey string with replacementValue and returns a string.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
ossimRefPtr< ossimImageData > getTileAtRes(const ossimIrect &rect, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
virtual void setImageRectangle(const ossimIrect &rect)
RLevelCacheList m_rlevelBlockCache
ossim_uint32 getStatusCode() const
void performRlevelSetup(kdu_core::kdu_codestream &codestream)
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
Represents serializable keyword/value map.
bool addFile(const char *file)
virtual bool isOpen() const
Derived classes must implement this method to be concrete.
void showBoxes(kdu_supp::jp2_input_box *pParentBox=0)
const char * find(const char *key) const
16 bit unsigned integer (14 bits used)
virtual void extractBoxes(BoxList &boxList)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
bool almostEqual(T x, T y, T tolerance=FLT_EPSILON)
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual void setHandler(ossimKakaduJpipHandler *handler)
kdu_supp::kdu_client * m_client
ossimRefPtr< ossimHttpRequest > m_request
ossim_uint32 height() const
std::vector< Box > BoxList
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
static ossimString toString(bool aValue)
Numeric to string methods.
RLevelBlockSizeList m_rlevelTileSize
void setImage(ossimRefPtr< ossimImageData > image)
ossimKeywordlist & headerKwl()
const ossimIpt & ul() const
ossimJpipMessageHeader * header()
ossim_uint64 bufferSize() const
16 bit unsigned integer (13 bits used)
MessageBodyType & messageBody()
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual ossim_uint32 getNumberOfInputBands() const
virtual ossimHttpRequest * createHttp(const ossimUrl &url)
bool intersects(const ossimIrect &rect) const
void setProtocol(const ossimString &protocol)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
static void sleepInMicroSeconds(ossim_uint64 micros)
Utility method to allow one to sleep in microseconds.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &origin, ossim_uint32 resLevel=0)
the resampler will need the tile request to come from the view.
virtual void initialize()
Initialize the data buffer.
void setImageViewTransform(ossimImageViewTransform *transform)
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
static ossimAppFixedTileCache * instance(ossim_uint32 maxSize=0)
void setFilterType(ossimFilterResamplerType filterType)
char_type * buffer()
Returns a pointer to the buffer.
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
virtual ossimJpipMessage * readMessage()
virtual ossimRefPtr< ossimWebResponse > getResponse()
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
virtual void close()
Deletes the overview and clears the valid image vertices.
ossimString toString() const
kdu_supp::jp2_family_src m_jp2Family
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Method to get an overview tile.
static ossimImageDataFactory * instance()
virtual ossimImageGeometry * createGeometry(const ossimString &typeName) const
ossimRefPtr< ossimImageData > getTile(ossimAppFixedCacheId cacheId, const ossimIpt &origin)
virtual ossimDataObjectStatus validate() const
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual const ossimFilename & getFilename() const
Returns the filename.
static ossimWebRequestFactoryRegistry * instance()
unsigned long long ossim_uint64
const ossimString & getProtocol() const
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
bool set(const ossimUrl &url, const ossimKeywordlist &headerOptions, HttpMethodType methodType=HTTP_METHOD_GET)
ossimByteStreamBuffer & inputStreamBuffer()
virtual ossimIrect getImageRectangle() const
const ossimString & getPath() const
ossimRefPtr< ossimImageData > m_tile
const ossimIpt & lr() const
virtual void close()
Deletes the overview and clears the valid image vertices.
virtual ossim_uint32 getCurrentEntry() const
void initializeRlevelCache()
static ossimString downcase(const ossimString &aString)
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
ossim_uint32 width() const
ossim_uint32 m_nInputBands
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
ossim_uint64 findLevel(ossim_uint64 power2Value, ossim_uint32 maxLevel)
void addHeaderOption(const ossimString &name, const ossimString &value)
ossimFilterResampler * getResampler()
ossimByteStreamBuffer & headerBuffer()
std::streambuf * setBuf(char *buf, std::streamsize bufSize, bool shared)
bool clipRegionToImage(kdu_core::kdu_codestream &codestream, kdu_core::kdu_dims ®ion, int discard_levels, kdu_core::kdu_dims &clipRegion)
Sets clipRegion from region, and image dimensions for level.
const ossimString & getPort() const
virtual void makeBlank()
Initializes data to null pixel values.
virtual ~ossimKakaduJpipHandler()
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)
void copyAllDataFromInputStream(ByteBuffer &buffer)
ossim_uint32 m_nQualityLayers
ossimRefPtr< ossimImageHandler > theOverview
virtual bool open()
Pure virtual open.
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.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual const void * getBuf() const
void clearHeaderOptions()
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const
Pure virtual, derived classes must implement.
bool loadClient(kdu_supp::kdu_client *client, kdu_supp::kdu_window &window)
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
ossim_uint32 m_nOutputBands
RectList m_overviewDimensions
bool makeConnectionIfNeeded(kdu_supp::kdu_client *client)
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)
std::vector< char > ByteBuffer
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
const ossimString & getIp() const
int convertClassIdToKdu(int id)
std::basic_istringstream< char > istringstream
Class for char input memory streams.
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
kdu_supp::kdu_client * m_headerClient
static const char * QUALITY_KW
virtual void setProperty(ossimRefPtr< ossimProperty > property)
16 bit unsigned integer (11 bits used)
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const
Pure virtual, derived classes must implement.
void setParams(const ossimString ¶ms)
ossimRefPtr< ossimImageData > addTile(ossimAppFixedCacheId cacheId, ossimRefPtr< ossimImageData > data, bool duplicateData=true)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
void setCacheRefreshBit()
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)