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

Info Base. More...

#include <ossimKakaduJpipInfo.h>

Inheritance diagram for ossimKakaduJpipInfo:
ossimInfoBase ossimReferenced

Public Member Functions

 ossimKakaduJpipInfo ()
 default constructor More...
 
virtual ~ossimKakaduJpipInfo ()
 virtual destructor More...
 
virtual bool open (const ossimFilename &file)
 open method. More...
 
virtual std::ostream & print (std::ostream &out) const
 Print method. More...
 
virtual void setHandler (ossimKakaduJpipHandler *handler)
 
- Public Member Functions inherited from ossimInfoBase
 ossimInfoBase ()
 default constructor More...
 
virtual bool open (std::shared_ptr< ossim::istream > &str, const std::string &connectionString)
 open method. More...
 
void setProcessOverviewFlag (bool flag)
 Sets the overview flag. More...
 
bool getProcessOverviewFlag () const
 Method to get the overview flag. More...
 
virtual bool getKeywordlist (ossimKeywordlist &kwl) const
 Method to dump info to a keyword list. More...
 
virtual bool getKeywordlist (ossimKeywordlist &kwl, ossim_uint32 entryIndex) const
 Method to dump info to a keyword list. More...
 
- 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
 

Protected Attributes

ossimRefPtr< ossimKakaduJpipHandlerm_handler
 
- Protected Attributes inherited from ossimInfoBase
bool theOverviewFlag
 

Additional Inherited Members

- Protected Member Functions inherited from ossimInfoBase
virtual ~ossimInfoBase ()
 virtual destructor More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Detailed Description

Info Base.

This is the base class for all info objects. The purpose of an Info object is to dump whatever info is available for a given file name to user.

Definition at line 31 of file ossimKakaduJpipInfo.h.

Constructor & Destructor Documentation

◆ ossimKakaduJpipInfo()

ossimKakaduJpipInfo::ossimKakaduJpipInfo ( )

default constructor

Definition at line 15 of file ossimKakaduJpipInfo.cpp.

16 {
17 
18 }

◆ ~ossimKakaduJpipInfo()

ossimKakaduJpipInfo::~ossimKakaduJpipInfo ( )
virtual

virtual destructor

Definition at line 20 of file ossimKakaduJpipInfo.cpp.

21 {
22 
23 }

Member Function Documentation

◆ open()

bool ossimKakaduJpipInfo::open ( const ossimFilename file)
virtual

open method.

Parameters
fileFile name to open.
Returns
true on success false on error.

Reimplemented from ossimInfoBase.

Definition at line 25 of file ossimKakaduJpipInfo.cpp.

References ossimKeywordlist::addFile(), ossimString::c_str(), ossimString::downcase(), ossimFilename::ext(), ossimImageHandler::loadState(), and ossimImageHandler::open().

26 {
28  ossimImageHandler* handler = m_handler.get();
29  bool result = false;
30  ossimUrl url(file.c_str());
31  ossimString protocol = url.getProtocol().downcase();
32  if((protocol == "jpip")||
33  (protocol == "jpips"))
34  {
35  result = handler->open(file);
36 
37  }
38  else
39  {
40  url = ossimUrl();
41  if(file.ext() == "jpip")
42  {
43  ossimKeywordlist kwl;
44 
45  if(kwl.addFile(file.c_str()))
46  {
47  result = handler->loadState(kwl);
48  }
49  }
50  }
51  if(!result) m_handler = 0;
52 
53  return result;
54 }
virtual bool open()=0
Pure virtual open.
Represents serializable keyword/value map.
bool addFile(const char *file)
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< ossimKakaduJpipHandler > m_handler
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
This class defines an abstract Handler which all image handlers(loaders) should derive from...
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
ossimString ext() const

◆ print()

std::ostream & ossimKakaduJpipInfo::print ( std::ostream &  out) const
virtual

Print method.

Parameters
outStream to print to.
Returns
std::ostream&

Implements ossimInfoBase.

Definition at line 56 of file ossimKakaduJpipInfo.cpp.

References ossimXmlNode::addChildNode(), ossimKeywordlist::addPrefixToAll(), ossimRefPtr< T >::get(), ossimTiffInfo::getImageGeometry(), ossimXmlDocument::getRoot(), ossimXmlDocument::initRoot(), ossimXmlDocument::read(), ossimXmlNode::read(), ossimInfoBase::setProcessOverviewFlag(), ossimXmlNode::setTag(), ossimKeywordlist::stripPrefixFromAll(), ossimXmlDocument::toKwl(), and ossimRefPtr< T >::valid().

57 {
58  if(m_handler.valid())
59  {
60  ossimKeywordlist kwl;
61  ossimString xml;
63  m_handler->extractBoxes(boxes);
64 
65  ossim_uint32 idx = 0;
66  for(idx = 0; idx < boxes.size(); ++idx)
67  {
68  if(boxes[idx].m_type == jp2_xml_4cc)
69  {
71  //std::istringstream in(ossimString((char*)&boxes[idx].m_buffer.front(),
72  // (char*)&boxes[idx].m_buffer.front() + boxes[idx].m_buffer.size()));
73  ossimByteStreamBuffer byteStreamBuf((char*)&boxes[idx].m_buffer.front(), boxes[idx].m_buffer.size());
74  std::iostream in(&byteStreamBuf);
75 
76  // std::cout << "________________________________________________" << std::endl;
77  // std::cout << ossimString((char*)&boxes[idx].m_buffer.front(),
78  // (char*)&boxes[idx].m_buffer.front() + boxes[idx].m_buffer.size()) << std::endl;
79  // std::cout << "________________________________________________" << std::endl;
80  if(ossimString((char*)&boxes[idx].m_buffer.front(), (char*)&boxes[idx].m_buffer.front()+4) ==
81  "<?xm")
82  {
83  xmlDoc->read(in);
84  }
85  else
86  {
88  if(node->read(in))
89  {
90  xmlDoc->initRoot(node);
91  }
92  }
93  if(xmlDoc->getRoot().valid())
94  {
96  node->setTag("jpip.image0");
97  node->addChildNode(xmlDoc->getRoot().get());
98  xmlDoc->initRoot(node.get());
99  xmlDoc->toKwl(kwl);
100  out << kwl;
101  }
102  }
103  else if(boxes[idx].m_type == jp2_uuid_4cc)
104  {
105  kdu_byte geojp2_uuid[16] = {0xB1,0x4B,0xF8,0xBD,0x08,0x3D,0x4B,0x43,
106  0xA5,0xAE,0x8C,0xD7,0xD5,0xA6,0xCE,0x03};
107 
108  if(memcmp(&boxes[idx].m_buffer.front(),geojp2_uuid, 16)==0)
109  {
110  ossimTiffInfo info;
111 
112  //---
113  // Have geotiff boxes with badly terminated geotiffs. So to keep
114  // the tag parser from walking past the first image file directory
115  // (IFD) into garbage we will set the process overview flag to false.
116  //
117  // Note if we ever get multiple entries we will need to take this out.
118  //---
119  info.setProcessOverviewFlag(false);
120  //ossimByteStreamBuffer buf((char*)&boxList[idx].m_buffer.front()+16,
121  // boxList[idx].m_buffer.size()-16);
122  //std::istream str(&buf);
123  std::ofstream outStr("/tmp/dump.bin", std::ios::out|std::ios::binary);
124  outStr.write((char*)&boxes[idx].m_buffer.front(),
125  boxes[idx].m_buffer.size());
126  outStr.close();
127  std::istringstream str(ossimString((char*)&boxes[idx].m_buffer.front()+16,
128  (char*)&boxes[idx].m_buffer.front() + boxes[idx].m_buffer.size()));
129  ossim_uint32 entry = 0;
130  ossimKeywordlist kwl; // Used to capture geometry data.
131  // std::cout << ossimString((char*)&boxList[idx].m_buffer.front() + 16,
132  // (char*)&boxList[idx].m_buffer.front() + boxList[idx].m_buffer.size()) << std::endl;
133  if ( info.getImageGeometry(str, kwl, entry) )
134  {
135  kwl.stripPrefixFromAll("image0.");
136  kwl.addPrefixToAll("jpip.image0.geojp2.");
137  out << kwl << std::endl;
138  // ossimRefPtr<ossimProjection> proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl, "image0.");
139  //if(proj.valid())
140  // {
141  // ossimKeywordlist projKwl;
142  // proj->saveState(projKwl,"jpip.image0.geojp2.");
143  // out << projKwl << std::endl;
144  // }
145  }
146  }
147  else
148  {
149  }
150  }
151  }
152  }
153  return out;
154 }
void setTag(const ossimString &tag)
void stripPrefixFromAll(const ossimString &regularExpression)
void setProcessOverviewFlag(bool flag)
Sets the overview flag.
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
bool read(std::istream &in)
virtual void extractBoxes(BoxList &boxList)
bool getImageGeometry(ossimKeywordlist &geomKwl, ossim_uint32 entryIndex) const
Extracts geometry info to keyword list.
TIFF info class.
Definition: ossimTiffInfo.h:36
ossimRefPtr< ossimKakaduJpipHandler > m_handler
unsigned int ossim_uint32
void addPrefixToAll(const ossimString &prefix)
void toKwl(ossimKeywordlist &kwl, const ossimString &prefix="") const
bool read(std::istream &in)
std::basic_iostream< char > iostream
Base class for char mixed input and output streams.
Definition: ossimIosFwd.h:26
std::basic_ofstream< char > ofstream
Class for char output file streams.
Definition: ossimIosFwd.h:47
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
ossimRefPtr< ossimXmlNode > getRoot()
void initRoot(ossimRefPtr< ossimXmlNode > node)
void addChildNode(ossimRefPtr< ossimXmlNode > node)

◆ setHandler()

void ossimKakaduJpipInfo::setHandler ( ossimKakaduJpipHandler handler)
virtual

Definition at line 156 of file ossimKakaduJpipInfo.cpp.

Referenced by ossimKakaduJpipHandler::getImageGeometry().

157 {
158  m_handler = handler;
159 }
ossimRefPtr< ossimKakaduJpipHandler > m_handler

Member Data Documentation

◆ m_handler

ossimRefPtr<ossimKakaduJpipHandler> ossimKakaduJpipInfo::m_handler
mutableprotected

Definition at line 61 of file ossimKakaduJpipInfo.h.


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