OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimDtedInfo.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description: DTED Info object.
10 //
11 //----------------------------------------------------------------------------
12 // $Id$
13 
14 #include <iostream>
19 #include <ossim/base/ossimRegExp.h>
20 
21 
23 {
24 }
25 
27 {
28 }
29 
30 bool ossimDtedInfo::open(std::shared_ptr<ossim::istream>& str,
31  const std::string& connectionString)
32 {
33  bool result = false;
34  if(!str) return false;
35  // Test for extension, like dt0, dt1...
36  ossimString ext = ossimFilename(connectionString).ext();
37  ossimRegExp regExp("^[d|D][t|T][0-9]");
38  m_dtedFileStr.reset();
39  if ( regExp.find( ext.c_str() ) )
40  {
41  m_vol.parse(*str);
42  m_hdr.parse(*str);
43  m_uhl.parse(*str);
44  m_dsi.parse(*str);
45  m_acc.parse(*str);
46  //---
47  // Check for errors. Must have uhl, dsi and acc records. vol and hdr
48  // are for magnetic tape only; hence, may or may not be there.
49  //---
53  {
54  result = true;
55  m_connectionString = connectionString;
56  m_dtedFileStr = str;
57  }
58  else
59  {
60  m_connectionString.clear();
61  m_dtedFileStr.reset();
62  }
63  }
64 
65  return result;
66 }
67 
69 {
70  std::string prefix = "dted.";
72  {
73  m_vol.print(out, prefix);
74  }
76  {
77  m_hdr.print(out, prefix);
78  }
80  {
81  m_uhl.print(out, prefix);
82  }
84  {
85  m_dsi.print(out, prefix);
86  }
88  {
89  m_acc.print(out, prefix);
90  }
91  return out;
92 }
93 
95  const ossimString& name)const
96 {
97  ossimRefPtr<ossimProperty> result = 0;
98 
99  //---
100  // Look through dted records.
101  // Must have uhl, dsi and acc records. vol and hdr
102  // are for magnetic tape only; hence, may or may not be there.
103  //---
104  //ossimDtedVol vol(m_dtedFileStr, 0);
106  {
107  if (name == "dted_vol_record")
108  {
110  box->setName(name);
111 
112  std::vector<ossimString> list;
113  m_vol.getPropertyNames(list);
114 
115  std::vector< ossimRefPtr<ossimProperty> > propList;
116 
117  std::vector<ossimString>::const_iterator i = list.begin();
118  while (i != list.end())
119  {
121  if (prop.valid())
122  {
123  propList.push_back(prop);
124  }
125  ++i;
126  }
127  box->addChildren(propList);
128  result = box;
129  }
130  }
131  if (result.valid() == false)
132  {
133  //ossimDtedHdr hdr(m_dtedFileStr, vol.stopOffset());
135  {
136  if (name == "dted_hdr_record")
137  {
139  box->setName(name);
140 
141  std::vector<ossimString> list;
142  m_hdr.getPropertyNames(list);
143 
144  std::vector< ossimRefPtr<ossimProperty> > propList;
145 
146  std::vector<ossimString>::const_iterator i = list.begin();
147  while (i != list.end())
148  {
150  if (prop.valid())
151  {
152  propList.push_back(prop);
153  }
154  ++i;
155  }
156  box->addChildren(propList);
157  result = box;
158  }
159  }
160  if (result.valid() == false)
161  {
162  // ossimDtedUhl uhl(m_dtedFileStr, hdr.stopOffset());
164  {
165  if (name == "dted_uhl_record")
166  {
168  box->setName(name);
169 
170  std::vector<ossimString> list;
171  m_uhl.getPropertyNames(list);
172 
173  std::vector< ossimRefPtr<ossimProperty> > propList;
174 
175  std::vector<ossimString>::const_iterator i = list.begin();
176  while (i != list.end())
177  {
179  if (prop.valid())
180  {
181  propList.push_back(prop);
182  }
183  ++i;
184  }
185  box->addChildren(propList);
186  result = box;
187  }
188  }
189  if (result.valid() == false)
190  {
191  //ossimDtedDsi dsi(m_dtedFileStr, uhl.stopOffset());
193  {
194  if (name == "dted_dsi_record")
195  {
198  box->setName(name);
199 
200  std::vector<ossimString> list;
201  m_dsi.getPropertyNames(list);
202 
203  std::vector< ossimRefPtr<ossimProperty> > propList;
204 
205  std::vector<ossimString>::const_iterator i = list.begin();
206  while (i != list.end())
207  {
209  m_dsi.getProperty( (*i) );
210  if (prop.valid())
211  {
212  propList.push_back(prop);
213  }
214  ++i;
215  }
216  box->addChildren(propList);
217  result = box;
218  }
219  }
220  if (result.valid() == false)
221  {
222  //ossimDtedAcc acc(m_dtedFileStr, dsi.stopOffset());
224  {
225  if (name == "dted_acc_record")
226  {
229  box->setName(name);
230 
231  std::vector<ossimString> list;
232  m_acc.getPropertyNames(list);
233 
234  std::vector< ossimRefPtr<ossimProperty> > propList;
235 
237  std::vector<ossimString>::const_iterator i =
238  list.begin();
239  while (i != list.end())
240  {
242  m_acc.getProperty( (*i) );
243  if (prop.valid())
244  {
245  propList.push_back(prop);
246  }
247  ++i;
248  }
249  box->addChildren(propList);
250  result = box;
251  }
252  }
253  }
254  }
255  }
256  }
257 
258  return result;
259 }
260 
262  std::vector<ossimString>& propertyNames)const
263 {
264  propertyNames.push_back(ossimString("dted_vol_record"));
265  propertyNames.push_back(ossimString("dted_hdr_record"));
266  propertyNames.push_back(ossimString("dted_uhl_record"));
267  propertyNames.push_back(ossimString("dted_dsi_record"));
268  propertyNames.push_back(ossimString("dted_acc_record"));
269 }
270 
271 
std::ostream & print(std::ostream &out, const std::string &prefix) const
print method that outputs a key/value type format adding prefix to keys.
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for name.
std::ostream & print(std::ostream &out, const std::string &prefix) const
print method that outputs a key/value type format adding prefix to keys.
static const ossimErrorCode OSSIM_OK
bool valid() const
Definition: ossimRefPtr.h:75
std::shared_ptr< ossim::istream > m_dtedFileStr
Definition: ossimDtedInfo.h:81
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this class&#39;s properties to list.
ossimDtedVol m_vol
Definition: ossimDtedInfo.h:83
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this class&#39;s properties to list.
std::ostream & print(std::ostream &out, const std::string &prefix) const
print method that outputs a key/value type format adding prefix to keys.
void parse(std::istream &in)
ossimDtedDsi m_dsi
Definition: ossimDtedInfo.h:86
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this class&#39;s properties to list.
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for name.
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for name.
ossimDtedUhl m_uhl
Definition: ossimDtedInfo.h:85
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this class&#39;s properties to list.
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for name.
ossimDtedAcc m_acc
Definition: ossimDtedInfo.h:87
std::string m_connectionString
Definition: ossimDtedInfo.h:82
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this class&#39;s properties to list.
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this class&#39;s properties to list.
void parse(std::istream &in)
virtual bool open(std::shared_ptr< ossim::istream > &str, const std::string &connectionString)
open method.
void parse(std::istream &in)
virtual void addChildren(std::vector< ossimRefPtr< ossimProperty > > &propertyList)
void parse(std::istream &in)
virtual ossimErrorCode getErrorStatus() const
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for name.
ossimDtedHdr m_hdr
Definition: ossimDtedInfo.h:84
std::ostream & print(std::ostream &out, const std::string &prefix) const
print method that outputs a key/value type format adding prefix to keys.
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 std::ostream & print(std::ostream &out) const
Print method.
virtual ~ossimDtedInfo()
virtual destructor
void parse(std::istream &in)
ossimString ext() const
void setName(const ossimString &name)
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for name.
std::ostream & print(std::ostream &out, const std::string &prefix) const
print method that outputs a key/value type format adding prefix to keys.
bool find(const char *)
ossimDtedInfo()
default constructor
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23