OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimDtedVol.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 Volume Header Label
8 // (VOL) of a DTED Level 1 file.
9 //
10 //********************************************************************
11 // $Id: ossimDtedVol.cpp 17501 2010-06-02 11:14:55Z dburken $
12 
13 #include <iostream>
14 #include <fstream>
15 #include <string>
16 
18 #include <ossim/base/ossimNotify.h>
21 
23 :theStartOffset(0),
24 theStopOffset(0)
25 {
26 
27 }
28 
29 ossimDtedVol::ossimDtedVol(std::shared_ptr<ossim::istream>& str, ossim_int64 offset)
30  :
31  theStartOffset(0),
32  theStopOffset(0)
33 {
34  if(str)
35  {
36  str->seekg(offset);
37 
38  parse(*str);
39  }
40  else
41  {
43  }
44 }
45 
46 //**************************************************************************
47 // CONSTRUCTOR
48 //**************************************************************************
49 // ossimDtedVol::ossimDtedVol(const ossimFilename& dted_file,
50 // ossim_int32 offset)
51 // :
52 // theStartOffset(0),
53 // theStopOffset(0)
54 // {
55 // if(!dted_file.empty())
56 // {
57 // // Check to see that dted file exists.
58 // if(!dted_file.exists())
59 // {
60 // theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
61 // ossimNotify(ossimNotifyLevel_FATAL)
62 // << "FATAL ossimDtedVol::ossimDtedVol"
63 // << "\nThe DTED file does not exist: " << dted_file << std::endl;
64 // return;
65 // }
66 
67 // // Check to see that the dted file is readable.
68 // if(!dted_file.isReadable())
69 // {
70 // theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
71 // ossimNotify(ossimNotifyLevel_FATAL)
72 // << "FATAL ossimDtedVol::ossimDtedVol"
73 // << "\nThe DTED file is not readable: " << dted_file << std::endl;
74 // return;
75 // }
76 
77 // // Open the dted file for reading.
78 // std::ifstream in(dted_file.c_str());
79 // if(!in)
80 // {
81 // theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
82 // ossimNotify(ossimNotifyLevel_FATAL)
83 // << "FATAL ossimDtedVol::ossimDtedVol"
84 // << "\nUnable to open the DTED file: " << dted_file << std::endl;
85 // return;
86 // }
87 // in.seekg(offset);
88 // parse(in);
89 
90 // in.close();
91 // }
92 // }
93 
94 //**************************************************************************
95 // CONSTRUCTOR
96 //**************************************************************************
97 // ossimDtedVol::ossimDtedVol(std::istream& in)
98 // :
99 // theStartOffset(0),
100 // theStopOffset(0)
101 // {
102 // parse(in);
103 // }
104 
106 {
108  theStartOffset = in.tellg();
110  // Parse theRecSen
111  in.read(theRecSen, FIELD1_SIZE);
112  theRecSen[FIELD1_SIZE] = '\0';
113  if(!(strncmp(theRecSen, "VOL", 3) == 0))
114  {
115  // Not a volume header label.
117  in.seekg(theStartOffset);
118  return;
119  }
120 
121  // Parse Field 2
122  in.read(theField2, FIELD2_SIZE);
123  theField2[FIELD2_SIZE] = '\0';
124 
125  // Parse theReelNumber
126  in.read(theReelNumber, FIELD3_SIZE);
127  theReelNumber[FIELD3_SIZE] = '\0';
128 
129  // Parse Field 4
130  in.read(theField4, FIELD4_SIZE);
131  theField4[FIELD4_SIZE] = '\0';
132 
133  // Parse Field 5
134  in.read(theField5, FIELD5_SIZE);
135  theField5[FIELD5_SIZE] = '\0';
136 
137  // Parse theAccountNumber
138  in.read(theAccountNumber, FIELD6_SIZE);
140 
141  // Parse Field 7
142  in.read(theField7, FIELD7_SIZE);
143  theField7[FIELD7_SIZE] = '\0';
144 
145  // Parse Field 8
146  in.read(theField8, FIELD8_SIZE);
147  theField8[FIELD8_SIZE] = '\0';
148 
149  // Set the stop offset.
151 }
152 
154  const ossimString& /* name */) const
155 {
156  ossimRefPtr<ossimProperty> result = 0;
157  return result;
158 }
159 
161  std::vector<ossimString>& propertyNames) const
162 {
163  propertyNames.push_back(ossimString("dted_vol_record"));
164 }
165 
167 {
168  return ossimString(theRecSen);
169 }
170 
172 {
173  return ossimString(theReelNumber);
174 }
175 
177 {
179 }
180 
182 {
183  return theStartOffset;
184 }
185 
187 {
188  return theStopOffset;
189 }
190 
192  const std::string& prefix) const
193 {
194  std::string pfx = prefix;
195  pfx += "vol.";
196 
197  out << pfx << "recognition_sentinel: " << theRecSen << "\n"
198  << pfx << "field2: " << theField2 << "\n"
199  << pfx << "reel_number: " << theReelNumber << "\n"
200  << pfx << "field4: " << theField4 << "\n"
201  << pfx << "field5: " << theField5 << "\n"
202  << pfx << "account_number: " << theAccountNumber << "\n"
203  << pfx << "field7: " << theField7 << "\n"
204  << pfx << "field8: " << theField8 << "\n"
205  << std::endl;
206  return out;
207 }
208 
209 //**************************************************************************
210 // operator <<
211 //**************************************************************************
213 {
214  std::string prefix;
215  return vol.print(out, prefix);
216 }
217 
219 {
220 }
221 
223 {
224  return rhs;
225 }
226 
const ossimDtedVol & operator=(const ossimDtedVol &rhs)
ossim_int32 theStopOffset
Definition: ossimDtedVol.h:107
std::ostream & operator<<(std::ostream &out, const ossimDtedVol &vol)
char theReelNumber[FIELD3_SIZE+1]
Definition: ossimDtedVol.h:99
ossim_int32 theStartOffset
Definition: ossimDtedVol.h:106
static const ossimErrorCode OSSIM_ERROR
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.
char theField5[FIELD5_SIZE+1]
Definition: ossimDtedVol.h:101
char theField2[FIELD2_SIZE+1]
Definition: ossimDtedVol.h:98
char theField7[FIELD7_SIZE+1]
Definition: ossimDtedVol.h:103
char theField4[FIELD4_SIZE+1]
Definition: ossimDtedVol.h:100
ossim_int32 startOffset() const
char theField8[FIELD8_SIZE+1]
Definition: ossimDtedVol.h:104
char theRecSen[FIELD1_SIZE+1]
Definition: ossimDtedVol.h:97
ossim_int32 stopOffset() const
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
void parse(std::istream &in)
ossimString getReelNumber() const
char theAccountNumber[FIELD6_SIZE+1]
Definition: ossimDtedVol.h:102
ossimString getRecognitionSentinel() const
long long ossim_int64
ossimString getAccountNumber() 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.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int ossim_int32