OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimDtedAcc.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Ken Melero
6 //
7 // Description: This class gives access to the Accuracy Description
8 // (ACC) of a DTED Level 1 file.
9 //
10 //********************************************************************
11 // $Id: ossimDtedAcc.cpp 23276 2015-04-24 21:01:51Z rashadkm $
12 
13 #include <cstdlib>
14 #include <iostream>
15 #include <iomanip>
16 #include <fstream>
17 #include <string>
18 
20 #include <ossim/base/ossimNotify.h>
25 
27 {
28 
29 }
30 
31 ossimDtedAcc::ossimDtedAcc(std::shared_ptr<ossim::istream>& str, ossim_int64 offset)
32 {
33  if(str)
34  {
35  str->seekg(offset);
36  parse(*str);
37  }
38  else
39  {
41  }
42 }
43 
45 {
46  memset(theRecSen, '\0', FIELD1_SIZE+1);
47  memset(theAbsoluteCE, '\0',FIELD2_SIZE+1);
48  memset(theAbsoluteLE, '\0',FIELD3_SIZE+1);
49  memset(theRelativeCE, '\0',FIELD4_SIZE+1);
50  memset(theRelativeLE, '\0',FIELD5_SIZE+1);
51  memset(theField6, '\0',FIELD6_SIZE+1);
52  memset(theField7, '\0',FIELD7_SIZE+1);
53  memset(theField8, '\0',FIELD8_SIZE+1);
54  memset(theField9, '\0',FIELD9_SIZE+1);
55  memset(theField10, '\0',FIELD10_SIZE+1);
56  memset(theField11, '\0',FIELD11_SIZE+1);
57  memset(theField12, '\0',FIELD12_SIZE+1);
58  memset(theField13, '\0',FIELD13_SIZE+1);
59  memset(theField14, '\0',FIELD14_SIZE+1);
60  memset(theField15, '\0',FIELD15_SIZE+1);
61  memset(theField16, '\0',FIELD16_SIZE+1);
62  memset(theField17, '\0',FIELD17_SIZE+1);
63 
64  theStartOffset = 0;
65  theStopOffset = 0;
66 }
67 //**************************************************************************
68 // ossimDtedAcc::parse()
69 //**************************************************************************
71 {
73  clearFields();
74  theStartOffset = in.tellg();
76  // Parse theRecSen
77  in.read(theRecSen, FIELD1_SIZE);
78  theRecSen[FIELD1_SIZE] = '\0';
79 
80  if(!(strncmp(theRecSen, "ACC", 3) == 0))
81  {
83  in.seekg(theStartOffset);
84  return;
85  }
86 
87  // Parse theAbsoluteCE
88  in.read(theAbsoluteCE, FIELD2_SIZE);
89  theAbsoluteCE[FIELD2_SIZE] = '\0';
90 
91  // Parse theAbsoluteLE
92  in.read(theAbsoluteLE, FIELD3_SIZE);
93  theAbsoluteLE[FIELD3_SIZE] = '\0';
94 
95  // Parse theRelativeCE
96  in.read(theRelativeCE, FIELD4_SIZE);
97  theRelativeCE[FIELD4_SIZE] = '\0';
98 
99  // Parse theRelativeLE
100  in.read(theRelativeLE, FIELD5_SIZE);
101  theRelativeLE[FIELD5_SIZE] = '\0';
102 
103  // Parse Field 6
104  in.read(theField6, FIELD6_SIZE);
105  theField6[FIELD6_SIZE] = '\0';
106 
107  // Parse Field 7
108  in.read(theField7, FIELD7_SIZE);
109  theField7[FIELD7_SIZE] = '\0';
110 
111  // Parse Field 8
112  in.read(theField8, FIELD8_SIZE);
113  theField8[FIELD8_SIZE] = '\0';
114 
115  // Parse Field 9
116  in.read(theField9, FIELD9_SIZE);
117  theField9[FIELD9_SIZE] = '\0';
118 
119  // Parse Field 10
120  in.read(theField10, FIELD10_SIZE);
121  theField10[FIELD10_SIZE] = '\0';
122 
123  // Parse Field 11
124  in.read(theField11, FIELD11_SIZE);
125  theField11[FIELD11_SIZE] = '\0';
126 
127  // Parse Field 12
128  in.read(theField12, FIELD12_SIZE);
129  theField12[FIELD12_SIZE] = '\0';
130 
131  // Parse Field 13
132  in.read(theField13, FIELD13_SIZE);
133  theField13[FIELD13_SIZE] = '\0';
134 
135  // Parse Field 14
136  in.read(theField14, FIELD14_SIZE);
137  theField14[FIELD14_SIZE] = '\0';
138 
139  // Parse Field 15
140  in.read(theField15, FIELD15_SIZE);
141  theField15[FIELD15_SIZE] = '\0';
142 
143  // Parse Field 16
144  in.read(theField16, FIELD16_SIZE);
145  theField16[FIELD16_SIZE] = '\0';
146 
147  // Parse Field 17
148  in.read(theField17, FIELD17_SIZE);
149  theField17[FIELD17_SIZE] = '\0';
150 
151  in.ignore(FIELD18_SIZE);
152  // Set the stop offset.
154 }
155 
157  const ossimString& name) const
158 {
159  ossimRefPtr<ossimProperty> result = 0;
160  if (name == "recognition_sentinel")
161  {
162  result = new ossimStringProperty(name, theRecSen);
163 
164  }
165  else if (name == "absolute_ce")
166  {
167  result = new ossimStringProperty(name, theAbsoluteCE);
168  }
169  else if (name == "absolute_le")
170  {
171  result = new ossimStringProperty(name, theAbsoluteLE);
172  }
173  else if (name == "relative_ce")
174  {
175  result = new ossimStringProperty(name, theRelativeCE);
176  }
177  else if (name == "relative_le")
178  {
179  result = new ossimStringProperty(name, theRelativeLE);
180  }
181  return result;
182 }
183 
185  std::vector<ossimString>& propertyNames) const
186 {
187  propertyNames.push_back(ossimString("recognition_sentinel"));
188  propertyNames.push_back(ossimString("absolute_ce"));
189  propertyNames.push_back(ossimString("absolute_le"));
190  propertyNames.push_back(ossimString("relative_ce"));
191  propertyNames.push_back(ossimString("relative_le"));
192 }
193 
195  const std::string& prefix) const
196 {
197  std::string pfx = prefix;
198  pfx += "acc.";
199 
200  out << setiosflags(ios::left)
201  << pfx << setw(28) << "recognition_sentinel:" << theRecSen << "\n"
202  << pfx << setw(28) << "absolute_ce:" << theAbsoluteCE << "\n"
203  << pfx << setw(28) << "absolute_le:" << theAbsoluteLE << "\n"
204  << pfx << setw(28) << "relative ce:" << theRelativeCE << "\n"
205  << pfx << setw(28) << "relative le:" << theRelativeLE << "\n"
206  << pfx << setw(28) << "start_offset:" << theStartOffset << "\n"
207  << pfx << setw(28) << "stop_offset:" << theStopOffset
208  << std::endl;
209  return out;
210 }
211 
213 {
214  return atoi(theAbsoluteCE);
215 }
216 
218 {
219  return atoi(theAbsoluteLE);
220 }
221 
223 {
224  return atoi(theRelativeCE);
225 }
226 
228 {
229  return atoi(theRelativeLE);
230 }
231 
233 {
234  return theStartOffset;
235 }
236 
238 {
239  return theStopOffset;
240 }
241 
242 
243 
244 //**************************************************************************
245 // operator <<
246 //**************************************************************************
248 {
249  std::string prefix;
250  return acc.print(os, prefix);
251 }
252 
254 {
255  clearFields();
256 }
257 
259 {
260  return rhs;
261 }
ossim_int32 stopOffset() const
char theField7[FIELD7_SIZE+1]
Definition: ossimDtedAcc.h:120
char theField12[FIELD12_SIZE+1]
Definition: ossimDtedAcc.h:125
ossim_int32 startOffset() const
std::ostream & print(std::ostream &out, const std::string &prefix) const
print method that outputs a key/value type format adding prefix to keys.
char theRecSen[FIELD1_SIZE+1]
Definition: ossimDtedAcc.h:114
ossim_int32 absLE() const
ossim_int32 theStopOffset
Definition: ossimDtedAcc.h:133
ossim_int32 relCE() const
static const ossimErrorCode OSSIM_ERROR
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this class&#39;s properties to list.
char theField10[FIELD10_SIZE+1]
Definition: ossimDtedAcc.h:123
char theRelativeCE[FIELD4_SIZE+1]
Definition: ossimDtedAcc.h:117
char theField17[FIELD17_SIZE+1]
Definition: ossimDtedAcc.h:130
char theField16[FIELD16_SIZE+1]
Definition: ossimDtedAcc.h:129
ossim_int32 relLE() const
ossim_int32 absCE() const
char theField6[FIELD6_SIZE+1]
Definition: ossimDtedAcc.h:119
void parse(std::istream &in)
char theField15[FIELD15_SIZE+1]
Definition: ossimDtedAcc.h:128
char theField13[FIELD13_SIZE+1]
Definition: ossimDtedAcc.h:126
char theAbsoluteCE[FIELD2_SIZE+1]
Definition: ossimDtedAcc.h:115
char theField11[FIELD11_SIZE+1]
Definition: ossimDtedAcc.h:124
std::ostream & operator<<(std::ostream &os, const ossimDtedAcc &acc)
char theRelativeLE[FIELD5_SIZE+1]
Definition: ossimDtedAcc.h:118
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for name.
char theField8[FIELD8_SIZE+1]
Definition: ossimDtedAcc.h:121
long long ossim_int64
void clearFields()
char theField9[FIELD9_SIZE+1]
Definition: ossimDtedAcc.h:122
const ossimDtedAcc & operator=(const ossimDtedAcc &rhs)
char theField14[FIELD14_SIZE+1]
Definition: ossimDtedAcc.h:127
ossim_int32 theStartOffset
Definition: ossimDtedAcc.h:132
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
char theAbsoluteLE[FIELD3_SIZE+1]
Definition: ossimDtedAcc.h:116
int ossim_int32