OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimHdf5ProjectionFactory.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 
11 #include <ossim/base/ossimRefPtr.h>
12 #include <ossim/base/ossimString.h>
14 
16 {
17  static ossimHdf5ProjectionFactory* factoryInstance =
19 
20  return factoryInstance;
21 }
22 
24  ossim_uint32 entryIdx)const
25 {
26  // Try external geom file first:
27  ossimRefPtr<ossimProjection> projection = createProjectionFromGeometryFile(filename, entryIdx);
28  if (!projection.valid())
29  {
30  // Try internal grid model. This may be specific to VIIRS. In any case, it is not very
31  // robust as this model simply looks for "Latitude" and "Longitude" dataset names, ignoring
32  // multiple entries with potentially different geometries for each. Eventually should
33  // provide for the specification of specific dataset names or at least path to parent group.
34  // This is not trivial with only an entry index available. (OLK 08/16)
36  if (hdf5->open(filename))
37  {
39  hdf5_grid->initialize(hdf5.get());
40  }
41  }
42 
43  // Must release or pointer will self destruct when it goes out of scope.
44  return projection.release();
45 }
46 
48 {
49  return 0;
50 }
51 
53  const char* prefix) const
54 {
56  ossimString value = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
57  if ((value != "ossimHdf5GridModel") && (value != "ossimH5GridModel"))
58  return 0;
59 
60  // The HDF5 grid model is just an implementation of the coarse grid model, but the geom file
61  // is purely the latter, so trick the KWL to properly load an OCG model:
62  ossimKeywordlist new_kwl (kwl);
63  new_kwl.add(prefix, ossimKeywordNames::TYPE_KW, "ossimCoarseGridModel", true);
64 
65  result = new ossimHdf5GridModel;
66  if( !result->loadState(new_kwl, prefix) )
67  result = 0;
68 
69  return result.release();
70 }
71 
73  const ossimString& typeName)const
74 {
75  return createProjection(typeName);
76 }
77 
79  const ossimKeywordlist& kwl, const char* prefix)const
80 {
81  return createProjection(kwl, prefix);
82 }
83 
84 void ossimHdf5ProjectionFactory::getTypeNameList(std::vector<ossimString>& typeList)const
85 {
86  typeList.push_back(ossimString("ossimHdf5GridModel"));
87 }
88 
90 {
91 }
static ossimHdf5ProjectionFactory * instance()
ossimProjection * createProjectionFromGeometryFile(const ossimFilename &imageFile, ossim_uint32 entryIdx) const
This method takes the filename and tries to find an external ".geom" file.
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
const char * find(const char *key) const
bool open(const ossimFilename &hdf5File)
Opens specified HDF5 file.
Definition: ossimHdf5.cpp:29
static const char * TYPE_KW
virtual void getTypeNameList(std::vector< ossimString > &typeList) const
bool initialize(ossimHdf5 *hdf5, const ossimString &projDataPath="")
Initializes from an open HDF5 file.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
unsigned int ossim_uint32
T * release()
Definition: ossimRefPtr.h:93
Low-level OSSIM interface to HDF5 libraries.
Definition: ossimHdf5.h:27
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
Takes a filename.
virtual ossimObject * createObject(const ossimString &typeName) const