OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimDtedFactory.cpp
Go to the documentation of this file.
1 //**************************************************************************
2 // FILE: ossimDtedFactory.cc
3 //
4 // License: See top level LICENSE.txt file.
5 //
6 // Author: David Burken
7 //
8 // Description:
9 //
10 // Class definition for ossimDtedFactory.
11 //
12 // This is the base class interface for elevation source factories. Contains
13 // pure virtual methods that all elevation source factories must implement.
14 //
15 //**************************************************************************
16 // $Id: ossimDtedFactory.cpp 16104 2009-12-17 18:09:59Z gpotts $
17 
18 #include <cstdlib> /* abs() */
19 #include <sstream>
20 #include <iomanip>
23 #include <ossim/base/ossimTrace.h>
24 #include <ossim/base/ossimGpt.h>
27 
28 static ossimTrace traceDebug ("ossimDtedFactory:debug");
29 
31 
34 {}
35 
38 {
39  theDirectory = dir;
40 }
41 
43 {}
44 
46 {
47  if (traceDebug())
48  {
50  << "DEBUG ossimDtedFactory::getNewElevSource: Entered..."
51  << std::endl;
52  }
53 
55 
57  {
59  << "FATAL ossimDtedFactory::getNewElevSource: "
60  << "DTED directory has not been set!"
61  << "\nReturning null elevation source..."
62  << std::endl;
63  return dted_ptr.release();
64  }
65 
66  // Build up a dted file name.
67  ossimFilename dted_file_base;
68 
69  int ilon = static_cast<int>(floor(gpt.lond()));
70 
71  if (ilon < 0)
72  {
73  dted_file_base = "w";
74  }
75  else
76  {
77  dted_file_base = "e";
78  }
79 
80  ilon = abs(ilon);
82  s1 << std::setfill('0') << std::setw(3)<< ilon;
83 
84  dted_file_base += s1.str().c_str();//ossimString::toString(ilon);
85  dted_file_base += "/";
86 
87  int ilat = static_cast<int>(floor(gpt.latd()));
88  if (ilat < 0)
89  {
90  dted_file_base += "s";
91  }
92  else
93  {
94  dted_file_base += "n";
95  }
96 
97  ilat = abs(ilat);
99 
100  s2<< std::setfill('0') << std::setw(2)<< ilat;
101 
102  dted_file_base += s2.str().c_str();
103 
104  // Look for a dted file with a level 2 extension first.
105  ossimFilename dted_name = theDirectory.dirCat(dted_file_base);
106  dted_name += ".dt2";
107 
108  if (traceDebug())
109  {
111  << "DEBUG ossimDtedFactory::getNewElevSource:"
112  << "\nSearching for file: " << dted_name
113  << std::endl;
114  }
115 
116  if (dted_name.exists())
117  {
118  dted_ptr = new ossimDtedHandler(dted_name);
119  if ( (!(dted_ptr->getErrorStatus())) &&
120  dted_ptr->pointHasCoverage(gpt) )
121  {
122  return dted_ptr.release();
123  }
124  else
125  {
126  dted_ptr = 0;
127  }
128  }
129 
130  // Look for a dted file with a level 1 extension next.
131  dted_name = theDirectory.dirCat(dted_file_base);
132  dted_name += ".dt1";
133 
134  if (traceDebug())
135  {
137  << "DEBUG ossimDtedFactory::getNewElevSource:"
138  << "\nSearching for file: " << dted_name
139  << std::endl;
140  }
141 
142  if (dted_name.exists() )
143  {
144  dted_ptr = new ossimDtedHandler(dted_name);
145  if ( (!(dted_ptr->getErrorStatus())) &&
146  dted_ptr->pointHasCoverage(gpt) )
147  {
148  return dted_ptr.release();
149  }
150  else
151  {
152  dted_ptr = 0;
153  }
154  }
155 
156  // Look for a dted file with a level 0 extension next.
157  dted_name = theDirectory.dirCat(dted_file_base);
158  dted_name += ".dt0";
159 
160  if (traceDebug())
161  {
163  << "DEBUG ossimDtedFactory::getNewElevSource:"
164  << "\nSearching for file: " << dted_name
165  << std::endl;
166  }
167 
168  if (dted_name.exists() )
169  {
170  dted_ptr = new ossimDtedHandler(dted_name);
171  if ( (!(dted_ptr->getErrorStatus())) &&
172  dted_ptr->pointHasCoverage(gpt) )
173  {
174  return dted_ptr.release();
175  }
176  else
177  {
178  dted_ptr = 0;
179  }
180  }
181 
182  return dted_ptr.release();
183 }
184 
186 {
187 }
CLASS: ossimDtedFactory.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
#define abs(a)
Definition: auxiliary.h:74
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
bool exists() const
T * release()
Definition: ossimRefPtr.h:93
virtual bool pointHasCoverage(const ossimGpt &) const =0
METHOD: pointHasCoverage(gpt) Returns TRUE if coverage exists over gpt:
the DTED handler is an elevation source that allows for handling of a single cell of data...
virtual void createIndex()
virtual ossimErrorCode getErrorStatus() const
virtual ossimElevSource * getNewElevSource(const ossimGpt &gpt) const
Pure virtual method.
ossimFilename dirCat(const ossimFilename &file) 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
#define RTTI_DEF1(cls, name, b1)
Definition: ossimRtti.h:485
virtual ~ossimDtedFactory()
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)