OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGeneralRasterElevationDatabase.cpp
Go to the documentation of this file.
5 #include <sstream>
6 #include <iomanip>
7 
8 RTTI_DEF1(ossimGeneralRasterElevationDatabase, "ossimGeneralRasterElevationDatabase", ossimElevationCellDatabase);
9 
11 {
12  if(!isSourceEnabled()) return ossim::nan();
14 
15  if(handler.valid())
16  {
17  return handler->getHeightAboveMSL(gpt); // still need to shift
18  }
19  return ossim::nan();
20 }
22 {
23  double h = getHeightAboveMSL(gpt);
24  if(h != ossim::nan())
25  {
26  h += getOffsetFromEllipsoid(gpt);
27  }
28 
29  return h;
30 }
32 {
33  bool result = false;
34  ossimFilename file = ossimFilename(connectionString);
35  m_connectionString = connectionString;
36  result = openGeneralRasterDirectory(file);
37 
38  return result;
39 }
40 
42 {
44  bool foundOne = false;
45 
46  if(dir.exists())
47  {
48  if(dir.isDir())
49  {
50  ossimDirectory d(dir);
51 
52  ossimFilename file;
53  ossim_uint32 maxCount = 10; // search at least the first 10 files to see if there are any here
54  ossim_uint32 count = 0;
55  if(d.getFirst(file))
56  {
57  do
58  {
59  ++count;
60  ossimString ext = file.ext();
61  ext = ext.downcase();
62  if(ext == "ras")
63  {
65  {
67  foundOne = true;
68  }
69  }
70  } while(d.getNext(file) &&
71  (foundOne ||
72  (!foundOne && (count < maxCount))));
73  }
74  }
75  }
76 
77  if(!foundOne)
78  {
79  m_cellHandler = 0;
80  }
81 
82  return m_cellHandler.valid();
83 }
84 
86 {
87  bool result = false;
88 
89  if(m_cellHandler.valid())
90  {
91  result = m_cellHandler->pointHasCoverage(gpt);
92  }
93 
94  return result;
95 }
96 
98  ossimFilename& /* file */, const ossimGpt& /* gpt */)const
99 {
100 }
101 
103 {
104  if(pointHasCoverage(gpt))
105  {
106  return m_cellHandler.get();
107  }
108  return 0;
109 }
110 
112 {
113  if(pointHasCoverage(gpt))
114  {
115  return m_cellHandler.get();
116  }
117  return 0;
118 }
119 
120 
122 {
123  bool result = ossimElevationCellDatabase::loadState(kwl, prefix);
124  if(result)
125  {
127  {
128  result = open(m_connectionString);
129  }
130  else
131  {
132  // can't open the connection because it does not exists or empty
133  result = false;
134  }
135  }
136 
137  return result;
138 }
139 
141 {
142  bool result = ossimElevationCellDatabase::saveState(kwl, prefix);
143 
144  return result;
145 }
146 
147 
149 {
150  ossimKeywordlist kwl;
151  saveState(kwl);
152  out << "\nossimGeneralRasterElevationDatabase @ "<< (ossim_uint64) this << "\n"
153  << kwl <<ends;
154  return out;
155 }
156 
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual bool pointHasCoverage(const ossimGpt &gpt) const
METHOD: pointHasCoverage(gpt) Returns TRUE if coverage exists over gpt:
virtual double getHeightAboveMSL(const ossimGpt &)=0
Height access methods:
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual double getHeightAboveEllipsoid(const ossimGpt &gpt)
virtual double getMeanSpacingMeters() const
METHOD: meanSpacingMeters() Implements pure virtual for.
virtual bool open(const ossimString &connectionString)
Open a connection to a database.
Represents serializable keyword/value map.
bool open(const ossimFilename &file, bool memoryMapFlag=false)
Opens a stream to the srtm cell.
bool valid() const
Definition: ossimRefPtr.h:75
bool getFirst(ossimFilename &filename, int flags=OSSIM_DIR_DEFAULT)
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual double getHeightAboveMSL(const ossimGpt &)
METHODS: accuracyLE90(), accuracyCE90() Returns the vertical and horizontal accuracy (90% confidence)...
bool isDir() const
bool getNext(ossimFilename &filename) const
virtual ossimRefPtr< ossimElevCellHandler > createCell(const ossimGpt &)
ossimRefPtr< ossimElevCellHandler > createHandler(const ossimGpt &)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual ossimRefPtr< ossimElevCellHandler > getOrCreateCellHandler(const ossimGpt &gpt)
bool exists() const
virtual bool pointHasCoverage(const ossimGpt &gpt) const
Loops through ossimGeneralRasterElevHandler::BoundingRectListType and checks for coverage.
unsigned long long ossim_uint64
unsigned int ossim_uint32
void createRelativePath(ossimFilename &file, const ossimGpt &gpt) const
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimRefPtr< ossimGeneralRasterElevHandler > m_cellHandler
virtual double getOffsetFromEllipsoid(const ossimGpt &gpt)
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
bool empty() const
Definition: ossimString.h:411
ossimString ext() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
RTTI_DEF1(ossimGeneralRasterElevationDatabase, "ossimGeneralRasterElevationDatabase", ossimElevationCellDatabase)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23