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

#include <ossimGdalFactory.h>

Inheritance diagram for ossimGdalFactory:
ossimImageHandlerFactoryBase ossimObjectFactory ossimObject ossimReferenced

Public Member Functions

virtual ~ossimGdalFactory ()
 
virtual ossimImageHandleropen (const ossimFilename &fileName, bool openOverview=true) const
 open that takes a filename. More...
 
virtual ossimImageHandleropen (const ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual ossimRefPtr< ossimImageHandleropenOverview (const ossimFilename &file) const
 Open overview that takes a file name. More...
 
virtual ossimObjectcreateObject (const ossimString &typeName) const
 
virtual ossimObjectcreateObject (const ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual void getTypeNameList (std::vector< ossimString > &typeList) const
 
virtual void getSupportedExtensions (ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
 
virtual void getImageHandlersBySuffix (ossimImageHandlerFactoryBase::ImageHandlerList &result, const ossimString &ext) const
 
virtual void getImageHandlersByMimeType (ossimImageHandlerFactoryBase::ImageHandlerList &result, const ossimString &mimeType) const
 
- Public Member Functions inherited from ossimImageHandlerFactoryBase
virtual ossimRefPtr< ossimImageHandleropen (std::shared_ptr< ossim::istream > &str, const std::string &connectionString, bool openOverview=true) const
 Open method that takes a stream. More...
 
virtual ossimRefPtr< ossimImageHandleropen (std::shared_ptr< ossim::ImageHandlerState > state) const
 
virtual ossimRefPtr< ossimImageHandleropenOverview (std::shared_ptr< ossim::istream > &str, const ossimString &connectionString) const
 Open method that takes a stream. More...
 
- Public Member Functions inherited from ossimObjectFactory
virtual ~ossimObjectFactory ()
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- 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
 

Static Public Member Functions

static ossimGdalFactoryinstance ()
 

Protected Member Functions

 ossimGdalFactory ()
 
 ossimGdalFactory (const ossimGdalFactory &)
 
void operator= (const ossimGdalFactory &)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Static Protected Attributes

static ossimGdalFactorytheInstance = 0
 

Additional Inherited Members

- Public Types inherited from ossimImageHandlerFactoryBase
typedef UniqueList< ossimStringUniqueStringList
 
typedef std::vector< ossimRefPtr< ossimImageHandler > > ImageHandlerList
 

Detailed Description

Definition at line 25 of file ossimGdalFactory.h.

Constructor & Destructor Documentation

◆ ~ossimGdalFactory()

ossimGdalFactory::~ossimGdalFactory ( )
virtual

Definition at line 32 of file ossimGdalFactory.cpp.

References theInstance.

33 {
35 }
static ossimGdalFactory * theInstance

◆ ossimGdalFactory() [1/2]

ossimGdalFactory::ossimGdalFactory ( )
inlineprotected

Definition at line 74 of file ossimGdalFactory.h.

Referenced by instance().

74 {}

◆ ossimGdalFactory() [2/2]

ossimGdalFactory::ossimGdalFactory ( const ossimGdalFactory )
inlineprotected

Definition at line 75 of file ossimGdalFactory.h.

75 {}

Member Function Documentation

◆ createObject() [1/2]

ossimObject * ossimGdalFactory::createObject ( const ossimString typeName) const
virtual

Creates an object given a type name.

Implements ossimObjectFactory.

Definition at line 218 of file ossimGdalFactory.cpp.

References STATIC_TYPE_NAME.

Referenced by createObject().

219 {
220  if(STATIC_TYPE_NAME(ossimHdfReader) == typeName)
221  {
222  return new ossimHdfReader();
223  }
224  if(STATIC_TYPE_NAME(ossimGdalTileSource) == typeName)
225  {
226  return new ossimGdalTileSource();
227  }
229  {
230  return new ossimOgrGdalTileSource();
231  }
232 
233  return (ossimObject*)0;
234 }
#define STATIC_TYPE_NAME(T)
Definition: ossimRtti.h:325

◆ createObject() [2/2]

ossimObject * ossimGdalFactory::createObject ( const ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Creates and object given a keyword list.

Implements ossimObjectFactory.

Definition at line 236 of file ossimGdalFactory.cpp.

References createObject(), ossimKeywordNames::FILENAME_KW, ossimKeywordlist::find(), ossimObject::loadState(), open(), ossimRefPtr< T >::release(), STATIC_TYPE_NAME, ossimKeywordNames::TYPE_KW, and ossimRefPtr< T >::valid().

238 {
240  const char* type = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
241 
242  if(type)
243  {
244  if (ossimString(type).trim() == STATIC_TYPE_NAME(ossimImageHandler))
245  {
246  const char* lookup = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
247  if (lookup)
248  {
249  // Call the open that takes a filename...
250  result = this->open(kwl, prefix);//ossimFilename(lookup));
251  }
252  }
253  else
254  {
255  result = createObject(ossimString(type));
256  if(result.valid())
257  {
258  result->loadState(kwl, prefix);
259  }
260  }
261  }
262 
263  return result.release();
264 }
virtual ossimObject * createObject(const ossimString &typeName) const
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
virtual ossimImageHandler * open(const ossimFilename &fileName, bool openOverview=true) const
open that takes a filename.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
static const char * TYPE_KW
#define STATIC_TYPE_NAME(T)
Definition: ossimRtti.h:325
T * release()
Definition: ossimRefPtr.h:93
This class defines an abstract Handler which all image handlers(loaders) should derive from...
static const char * FILENAME_KW

◆ getImageHandlersByMimeType()

void ossimGdalFactory::getImageHandlersByMimeType ( ossimImageHandlerFactoryBase::ImageHandlerList result,
const ossimString mimeType 
) const
virtual

Reimplemented from ossimImageHandlerFactoryBase.

Definition at line 332 of file ossimGdalFactory.cpp.

333 {
334  int driverCount = GDALGetDriverCount();
335  int idx = 0;
336 
337  for(idx = 0; idx < driverCount; ++idx)
338  {
339  GDALDriverH driver = GDALGetDriver(idx);
340 
341  if(driver)
342  {
343  const char* metaData = GDALGetMetadataItem(driver, GDAL_DMD_MIMETYPE, 0);
344  int nMetaData = metaData ? strlen(metaData) : 0;
345  if(metaData && nMetaData>0 )
346  {
347  if(ossimString(metaData) == mimeType)
348  {
349  result.push_back(new ossimGdalTileSource());
350  return;
351  }
352  }
353  }
354  }
355 }

◆ getImageHandlersBySuffix()

void ossimGdalFactory::getImageHandlersBySuffix ( ossimImageHandlerFactoryBase::ImageHandlerList result,
const ossimString ext 
) const
virtual

Reimplemented from ossimImageHandlerFactoryBase.

Definition at line 310 of file ossimGdalFactory.cpp.

References ossimString::downcase(), ossimImageHandlerFactoryBase::UniqueList< T >::getList(), getSupportedExtensions(), and ossimString::push_back().

312 {
313  if ( ext == "shp" )
314  {
315  result.push_back(new ossimOgrGdalTileSource);
316  }
317  else
318  {
320  getSupportedExtensions(extList);
321 
322  ossimString testExt = ext.downcase();
323 
324  if(std::find(extList.getList().begin(),
325  extList.getList().end(), testExt) != extList.getList().end())
326  {
327  result.push_back(new ossimGdalTileSource);
328  }
329  }
330 }
virtual void getSupportedExtensions(ossimImageHandlerFactoryBase::UniqueStringList &extensionList) const
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48

◆ getSupportedExtensions()

void ossimGdalFactory::getSupportedExtensions ( ossimImageHandlerFactoryBase::UniqueStringList extensionList) const
virtual

Implements ossimImageHandlerFactoryBase.

Definition at line 273 of file ossimGdalFactory.cpp.

References ossimImageHandlerFactoryBase::UniqueList< T >::push_back(), and ossimString::split().

Referenced by getImageHandlersBySuffix().

274 {
275  // ossimOgrGdalTileSource - shape file reader:
276  extensionList.push_back( ossimString("shp") );
277 
278  int driverCount = GDALGetDriverCount();
279  int idx = 0;
280 
281  for(idx = 0; idx < driverCount; ++idx)
282  {
283  GDALDriverH driver = GDALGetDriver(idx);
284 
285  if(driver)
286  {
287  const char* metaData = GDALGetMetadataItem(driver, GDAL_DMD_EXTENSION, 0);
288  int nMetaData = metaData ? strlen(metaData) : 0;
289  if(metaData && nMetaData>0 )
290  {
291  std::vector<ossimString> splitArray;
292  ossimString(metaData).split(splitArray, " /");
293 
294  ossim_uint32 idxExtension = 0;
295 
296  for(idxExtension = 0; idxExtension < splitArray.size(); ++idxExtension)
297  {
298  extensionList.push_back(splitArray[idxExtension].downcase());
299  }
300  }
301  }
302  }
303 
304  if(GDALGetDriverByName("AAIGrid"))
305  {
306  extensionList.push_back("adf");
307  }
308 }
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
unsigned int ossim_uint32

◆ getTypeNameList()

void ossimGdalFactory::getTypeNameList ( std::vector< ossimString > &  typeList) const
virtual

This should return the type name of all objects in all factories. This is the name used to construct the objects dynamially and this name must be unique.

Implements ossimObjectFactory.

Definition at line 266 of file ossimGdalFactory.cpp.

References STATIC_TYPE_NAME.

267 {
268  typeList.push_back(STATIC_TYPE_NAME(ossimHdfReader));
269  typeList.push_back(STATIC_TYPE_NAME(ossimGdalTileSource));
270  typeList.push_back(STATIC_TYPE_NAME(ossimOgrGdalTileSource));
271 }
#define STATIC_TYPE_NAME(T)
Definition: ossimRtti.h:325

◆ instance()

ossimGdalFactory * ossimGdalFactory::instance ( )
static

Definition at line 38 of file ossimGdalFactory.cpp.

References ossimGdalFactory(), and theInstance.

Referenced by ossimSharedLibraryFinalize(), and ossimSharedLibraryInitialize().

39 {
40  if(!theInstance)
41  {
43  CPLSetErrorHandler((CPLErrorHandler)CPLQuietErrorHandler);
44  GDALAllRegister();
45  OGRRegisterAll();
46  }
47 
48  // lets turn off gdal error reporting
49  //
50 // GDALSetCacheMax(1024*1024*20);
51 // GDALSetCacheMax(0);
52 
53  return theInstance;
54 }
static ossimGdalFactory * theInstance

◆ open() [1/2]

ossimImageHandler * ossimGdalFactory::open ( const ossimFilename fileName,
bool  openOverview = true 
) const
virtual

open that takes a filename.

Parameters
fileNameFile to open.
trySuffixFirstIf true calls code to try to open by suffix first, then goes through the list of available handlers. default=true.
openOverviewIf true image handler will attempt to open overview. default = true
Returns
Pointer to image handler or null if cannot open.

Implements ossimImageHandlerFactoryBase.

Definition at line 56 of file ossimGdalFactory.cpp.

References ossimString::downcase(), and ossimFilename::ext().

Referenced by createObject().

58 {
59  // For GDAL we can't check for file exists since they support encoded opens for
60  // subdatasets
61  //
62 
63  if(fileName.ext().downcase() == "nui") return 0;
64  if(traceDebug())
65  {
67  << "ossimGdalFactory::open(filename) DEBUG: entered..." << std::endl;
68  }
69 
71 
72  //try hdf reader first
73  if (traceDebug())
74  {
76  << "ossimGdalFactory::open(filename) DEBUG:"
77  << "\ntrying ossimHdfReader"
78  << std::endl;
79  }
80  result = new ossimHdfReader;
82  if(result->open(fileName))
83  {
84  return result.release();
85  }
86 
87  if (traceDebug())
88  {
90  << "ossimGdalFactory::open(filename) DEBUG:"
91  << "\ntrying ossimGdalTileSource"
92  << std::endl;
93  }
94 
95  result = new ossimGdalTileSource;
97  if(result->open(fileName))
98  {
99  return result.release();
100  }
101 
102  if (traceDebug())
103  {
105  << "ossimGdalFactory::open(filename) DEBUG:"
106  << "\ntrying ossimOgrVectorTileSource\n";
107  }
108 
109  // No need to set overview flag.
110  result = new ossimOgrVectorTileSource;
111  if(result->open(fileName))
112  {
113  return result.release();
114  }
115 
116  // we will have vector datasets only open if file exists.
117  if(!fileName.exists() ||
118  fileName.before(":", 3).upcase() == "SDE" ||
119  fileName.before(":", 4).upcase() == "GLTP" ||
120  fileName.ext().downcase() == "mdb")
121  {
122  result = 0;
123  return result.release();
124  }
125 
126  // No need to set overview flag.
127  if (traceDebug())
128  {
130  << "ossimGdalFactory::open(filename) DEBUG:"
131  << "\ntrying ossimOgrGdalTileSource\n";
132  }
133 
134  result = new ossimOgrGdalTileSource;
135  if(result->open(fileName))
136  {
137  return result.release();
138  }
139  result = 0;
140  return result.release();
141  if(traceDebug())
142  {
144  << "ossimGdalFactory::open(filename) DEBUG: leaving..."
145  << std::endl;
146  }
147 
148  return (ossimImageHandler*)NULL;
149 }
virtual bool open()=0
Pure virtual open.
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
ossimString before(const ossimString &str, std::string::size_type pos=0) const
METHOD: before(str, pos) Returns string beginning at pos and ending one before the token str If strin...
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
bool exists() const
T * release()
Definition: ossimRefPtr.h:93
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
This class defines an abstract Handler which all image handlers(loaders) should derive from...
ossimString ext() const
virtual ossimRefPtr< ossimImageHandler > openOverview(const ossimFilename &file) const
Open overview that takes a file name.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ open() [2/2]

ossimImageHandler * ossimGdalFactory::open ( const ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Implements ossimImageHandlerFactoryBase.

Definition at line 151 of file ossimGdalFactory.cpp.

153 {
155 
156  if(traceDebug())
157  {
158  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalFactory::open(kwl, prefix) DEBUG: entered..." << std::endl;
159  }
160  if(traceDebug())
161  {
162  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalFactory::open(kwl, prefix) DEBUG: trying ossimHdfReader" << std::endl;
163  }
164  result = new ossimHdfReader;
165  if(result->loadState(kwl, prefix))
166  {
167  return result.release();
168  }
169  result = 0;
170 
171  if(traceDebug())
172  {
173  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalFactory::open(kwl, prefix) DEBUG: trying ossimGdalTileSource" << std::endl;
174  }
175  result = new ossimGdalTileSource;
176  if(result->loadState(kwl, prefix))
177  {
178  return result.release();
179  }
180  result = 0;
181  if(traceDebug())
182  {
183  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalFactory::open(kwl, prefix) DEBUG: trying ossimOgrGdalTileSource" << std::endl;
184  }
185 
186  result = new ossimOgrGdalTileSource;
187  if(result->loadState(kwl, prefix))
188  {
189  return result.release();
190  }
191  result = 0;
192  if(traceDebug())
193  {
194  ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGdalFactory::open(kwl, prefix) DEBUG: leaving..." << std::endl;
195  }
196 
197  return result.release();
198 }
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
T * release()
Definition: ossimRefPtr.h:93
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ openOverview()

ossimRefPtr< ossimImageHandler > ossimGdalFactory::openOverview ( const ossimFilename file) const
virtual

Open overview that takes a file name.

Parameters
fileFile to open.
Returns
ossimRefPtr to image handler on success or null on failure.

Reimplemented from ossimImageHandlerFactoryBase.

Definition at line 200 of file ossimGdalFactory.cpp.

References ossimImageHandler::open(), ossimImageHandler::setOpenOverviewFlag(), and ossimString::size().

202 {
204  if ( file.size() )
205  {
206  result = new ossimGdalTileSource;
207 
208  result->setOpenOverviewFlag( false ); // Always false.
209 
210  if ( result->open( file ) == false )
211  {
212  result = 0;
213  }
214  }
215  return result;
216 }
virtual bool open()=0
Pure virtual open.
void setOpenOverviewFlag(bool flag)
Sets theOpenOverviewFlag.
std::string::size_type size() const
Definition: ossimString.h:405

◆ operator=()

void ossimGdalFactory::operator= ( const ossimGdalFactory )
inlineprotected

Definition at line 76 of file ossimGdalFactory.h.

76 {}

Member Data Documentation

◆ theInstance

ossimGdalFactory * ossimGdalFactory::theInstance = 0
staticprotected

Definition at line 78 of file ossimGdalFactory.h.

Referenced by instance(), and ~ossimGdalFactory().


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