OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimSrtmTileSource.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: David Burken
6 //
7 // Description:
8 //
9 // Image handler class for a Shuttle Radar Topography Mission (SRTM) file.
10 //
11 //----------------------------------------------------------------------------
12 // $Id: ossimSrtmTileSource.cpp 22769 2014-05-08 19:35:04Z dburken $
13 
18 #include <ossim/base/ossimTrace.h>
21 
23  "ossimSrtmTileSource",
25 
26 static ossimTrace traceDebug("ossimSrtmTileSource:debug");
27 
29  :
31  m_SrtmSupportData()
32 {
33 }
34 
36 {
37 }
38 
40 {
41  static const char MODULE[] = "ossimSrtmTileSource::open";
42  if (traceDebug())
43  {
44  CLOG << " Entered..." << std::endl
45  << "srtm " << theImageFile << std::endl;
46  }
47 
48  if(isOpen())
49  {
50  close();
51  }
52 
53  bool result = false;
54 
55  //---
56  // Set the scan for min max flag to true. This will only scan if not found
57  // in a omd file so this is a one time hit typically taken when building
58  // reduced res sets.
59  //---
61  {
62  ossimKeywordlist kwl;
64 
65  ossimGeneralRasterInfo generalRasterInfo;
66  if ( generalRasterInfo.loadState(kwl) )
67  {
68  theMetaData = generalRasterInfo.getImageMetaData();
69 
70  result = ossimGeneralRasterTileSource::open(generalRasterInfo);
71  }
72  }
73  else
74  {
75  if (traceDebug()) CLOG << " Unable to set filename"<< std::endl;
76 
77  return false;
78  }
79 
80  if (traceDebug())
81  {
82  CLOG << " Exited with " << (result?"true":"false") << " ..."
83  << std::endl;
84  }
85 
86  return result;
87 }
88 
89 //************************************************************************************************
92 //************************************************************************************************
94 {
95  if(!theGeometry.valid())
96  {
97  // First time through set the projection.
99 
101 
102  // Set image things the geometry object should know about.
104  }
105  return theGeometry;
106 }
107 
109  const char* prefix)const
110 {
111  if (m_SrtmSupportData.saveState(kwl, prefix))
112  {
113  return ossimImageHandler::saveState(kwl,prefix);
114  }
115  return false;
116 }
117 
119  const char* prefix)
120 {
121  bool result = false;
122 
123  std::string pfx = "";
124  if (prefix) // Cannot give null to std::string.
125  {
126  pfx = prefix;
127  }
128 
129  std::string key = ossimKeywordNames::TYPE_KW;
130  std::string value = kwl.findKey( pfx, key );
131  if ( value == "ossimSrtmTileSource" )
132  {
134  value = kwl.findKey( pfx, key );
135  if ( value.size() )
136  {
137  // Set the file name:
138  theImageFile = value;
139 
140  // Call ossimSrtmTileSource::open which will do the rest of the work.
141  if ( open() )
142  {
143  // Must call to pick up id for connections.
144  result = ossimImageSource::loadState(kwl, prefix);
145  }
146  }
147  }
148 
149  return result;
150 }
151 
153  const ossimString& name)const
154 {
155  if(name == "file_type")
156  {
157  return new ossimStringProperty(name, getShortName());
158  }
159 
160  return ossimImageHandler::getProperty(name);
161 }
162 
164  std::vector<ossimString>& propertyNames)const
165 {
167  propertyNames.push_back("file_type");
168 }
169 
171 {
172  return ossimString("SRTM");
173 }
174 
176 {
177  return ossimString("SRTM reader");
178 }
179 
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of the object to a keyword list.
ossimRefPtr< ossimImageGeometry > theGeometry
virtual bool open()
Pure virtual open.
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
#define CLOG
Definition: ossimTrace.h:23
ossimFilename theImageFile
ossimSrtmSupportData m_SrtmSupportData
Represents serializable keyword/value map.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual ossimString getShortName() const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual bool isOpen() const
Derived classes must implement this method to be concrete.
ossimRefPtr< ossimProjection > getProjection() const
Gets the projection for srtm cell.
static const char * TYPE_KW
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual ossimString getLongName() const
virtual ~ossimSrtmTileSource()
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property.
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds property names to array.
virtual bool open()
Pure virtual open.
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
virtual void close()
Deletes the overview and clears the valid image vertices.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=NULL)
Method to the load (recreate) the state of an object from a keyword list.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
ossimImageMetaData theMetaData
const ossimImageMetaData & getImageMetaData() const
#define RTTI_DEF1(cls, name, b1)
Definition: ossimRtti.h:485
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
static const char * FILENAME_KW
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
bool setFilename(const ossimFilename &srtmFile, bool scanForMinMax=false)
Initializes object from file.