OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimH5ProjectionFactory.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 // License: LGPL
3 //
4 // See LICENSE.txt file in the top level directory for more details.
5 //----------------------------------------------------------------------------
6 // $Id$
7 
10 #include <ossim/base/ossimRefPtr.h>
12 #include "ossimH5GridModel.h"
13 
14 //---
15 // Define Trace flags for use within this file:
16 //---
17 #include <ossim/base/ossimTrace.h>
18 static ossimTrace traceExec = ossimTrace("ossimH5ProjectionFactory:exec");
19 static ossimTrace traceDebug = ossimTrace("ossimH5ProjectionFactory:debug");
20 
22 {
23  static ossimHdf5ProjectionFactory* factoryInstance =
25 
26  return factoryInstance;
27 }
28 
30  const ossimFilename& filename, ossim_uint32 /*entryIdx*/)const
31 {
32  static const char MODULE[] = "ossimH5ProjectionFactory::createProjection(ossimFilename& filename)";
33  ossimRefPtr<ossimProjection> projection = 0;
34 
35  if(traceDebug())
36  {
38  << MODULE << " DEBUG: testing ossimH5GridModel" << std::endl;
39  }
40 
41  ossimKeywordlist kwl;
43  ossimFilename geomFile = filename;
44  geomFile = geomFile.setExtension("geom");
45 
46  if(geomFile.exists()&&
47  kwl.addFile(filename.c_str()))
48  {
49  ossimFilename coarseGrid;
50 
51  const char* type = kwl.find(ossimKeywordNames::TYPE_KW);
52  if(type)
53  {
54  // ossimHdfGridModel included for backward compatibility.
55  if( ( ossimString(type) == ossimString("ossimH5GridModel") ) ||
56  ( ossimString(type) == ossimString("ossimHdfGridModel") ) )
57  {
58  ossimFilename coarseGrid = geomFile;
59  geomFile.setFile(coarseGrid.fileNoExtension()+"_ocg");
60 
61  if(coarseGrid.exists() &&(coarseGrid != ""))
62  {
63  kwl.add("grid_file_name",
64  coarseGrid.c_str(),
65  true);
66  projection = new ossimHdf5GridModel();
67  if ( projection->loadState( kwl ) == false )
68  {
69  projection = 0;
70  }
71  }
72  }
73  }
74  }
75 
76  // Must release or pointer will self destruct when it goes out of scope.
77  return projection.release();
78 }
79 
81  const ossimString& name)const
82 {
83  static const char MODULE[] = "ossimH5ProjectionFactory::createProjection(ossimString& name)";
84 
85  if(traceDebug())
86  {
88  << MODULE << " DEBUG: Entering ...." << std::endl;
89  }
90 
91  // ossimHdfGridModel included for backward compatibility.
92  if ( ( name == "ossimH5GridModel" ) || ( name == "ossimHdfGridModel" ) )
93  {
94  return new ossimHdf5GridModel();
95  }
96 
97  if(traceDebug())
98  {
100  << MODULE << " DEBUG: Leaving ...." << std::endl;
101  }
102 
103  return 0;
104 }
105 
107  const ossimKeywordlist& kwl, const char* prefix)const
108 {
109  ossimRefPtr<ossimProjection> result = 0;
110  static const char MODULE[] = "ossimH5ProjectionFactory::createProjection(ossimKeywordlist& kwl)";
111 
112  if(traceDebug())
113  {
115  << MODULE << " DEBUG: Start ...." << std::endl;
116  }
117 
118  const char* lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
119  if (lookup)
120  {
121  ossimString type = lookup;
122 
123  if ( (type == "ossimH5GridModel") || ( type == "ossimHdfGridModel" ) )
124  {
125  result = new ossimHdf5GridModel();
126  if ( !result->loadState(kwl, prefix) )
127  {
128  result = 0;
129  }
130  }
131  }
132 
133  if(traceDebug())
134  {
136  << MODULE << " DEBUG: End ...." << std::endl;
137  }
138 
139  return result.release();
140 }
141 
143  const ossimString& typeName)const
144 {
145  return createProjection(typeName);
146 }
147 
149  const ossimKeywordlist& kwl, const char* prefix)const
150 {
151  return createProjection(kwl, prefix);
152 }
153 
154 
155 void ossimHdf5ProjectionFactory::getTypeNameList(std::vector<ossimString>& typeList)const
156 {
157  typeList.push_back(ossimString("ossimH5GridModel"));
158 }
159 
161 {
162 }
static ossimHdf5ProjectionFactory * instance()
ossimFilename & setFile(const ossimString &f)
Represents serializable keyword/value map.
bool addFile(const char *file)
const char * find(const char *key) const
static const char * TYPE_KW
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
bool exists() const
unsigned int ossim_uint32
T * release()
Definition: ossimRefPtr.h:93
ossimFilename fileNoExtension() const
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
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
Takes a filename.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
virtual ossimObject * createObject(const ossimString &typeName) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)