OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimDtedHdr.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: Ken Melero
8 //
9 // Description: This class gives access to the File Header Label
10 // (HDR) of a DTED Level 1 file.
11 //
12 //********************************************************************
13 // $Id: ossimDtedHdr.cpp 17501 2010-06-02 11:14:55Z dburken $
14 
15 #include <iostream>
16 #include <fstream>
17 #include <string>
18 
20 #include <ossim/base/ossimNotify.h>
23 
25 :
26  theStartOffset(0),
27  theStopOffset(0)
28 {
29 
30 }
31 
32 ossimDtedHdr::ossimDtedHdr(std::shared_ptr<ossim::istream>& str, ossim_int64 offset)
33 :
34  theStartOffset(0),
35  theStopOffset(0)
36 {
37  if(str)
38  {
39  str->seekg(offset);
40  // Continue parsing all the record fields.
41  parse(*str);
42 
43  }
44  else
45  {
47  }
48 }
49 
50 //**************************************************************************
51 // ossimDtedHdr::parse()
52 //**************************************************************************
54 {
56  theStartOffset = in.tellg();
58  // Parse theRecSen
59  in.read(theRecSen, FIELD1_SIZE);
60  theRecSen[FIELD1_SIZE] = '\0';
61 
62  if(!(strncmp(theRecSen, "HDR", 3) == 0))
63  {
65  in.seekg(theStartOffset);
66  return;
67  }
68 
69  // Parse Field 2
70  in.read(theField2, FIELD2_SIZE);
71  theField2[FIELD2_SIZE] = '\0';
72 
73  // Parse theFilename
74  in.read(theFilename, FIELD3_SIZE);
75  theFilename[FIELD3_SIZE] = '\0';
76 
77  // Parse Field 4
78  in.read(theField4, FIELD4_SIZE);
79  theField4[FIELD4_SIZE] = '\0';
80 
81  // Parse Field 5
82  in.read(theField5, FIELD5_SIZE);
83  theField5[FIELD5_SIZE] = '\0';
84 
85  // Parse Field 6
86  in.read(theField6, FIELD6_SIZE);
87  theField6[FIELD6_SIZE] = '\0';
88 
89  // Parse Field 7
90  in.read(theVersion, FIELD7_SIZE);
91  theVersion[FIELD7_SIZE] = '\0';
92 
93  // Parse theCreationDate
94  in.read(theCreationDate, FIELD8_SIZE);
96 
97  // Parse Field 9
98  in.read(theField9, FIELD9_SIZE);
99  theField9[FIELD9_SIZE] = '\0';
100 
101  // Parse Field 10
102  in.read(theField10, FIELD10_SIZE);
103  theField10[FIELD10_SIZE] = '\0';
104 
105  // Parse Field 11
106  in.read(theField11, FIELD11_SIZE);
107  theField11[FIELD11_SIZE] = '\0';
108 
109  // Parse Field 12
110  in.read(theField12, FIELD12_SIZE);
111  theField12[FIELD12_SIZE] = '\0';
112 
113  // Parse Field 13
114  in.read(theField13, FIELD13_SIZE);
115  theField13[FIELD13_SIZE] = '\0';
116 
117  // Parse Field 14
118  in.read(theField14, FIELD14_SIZE);
119  theField14[FIELD14_SIZE] = '\0';
120 
121  // Set the stop offset.
123 }
124 
126  const ossimString& /* name */) const
127 {
128  ossimRefPtr<ossimProperty> result = 0;
129  return result;
130 }
131 
133  std::vector<ossimString>& propertyNames) const
134 {
135  propertyNames.push_back(ossimString("dted_hdr_record"));
136 }
137 
138 
139 //**************************************************************************
140 // operator <<
141 //**************************************************************************
143 {
144  std::string prefix;
145  return hdr.print(os, prefix);
146 }
147 
149  const std::string& prefix) const
150 {
151  std::string pfx = prefix;
152  pfx += "hdr.";
153 
154  out << pfx << "recognition_sentinel: " << theRecSen << "\n"
155  << pfx << "field2: " << theField2 << "\n"
156  << pfx << "filename: " << theFilename << "\n"
157  << pfx << "field4: " << theField4 << "\n"
158  << pfx << "field5: " << theField5 << "\n"
159  << pfx << "field6: " << theField6 << "\n"
160  << pfx << "version: " << theVersion << "\n"
161  << pfx << "creation_date: " << theCreationDate << "\n"
162  << pfx << "field9: " << theField9 << "\n"
163  << pfx << "field10: " << theField10 << "\n"
164  << pfx << "field11: " << theField11 << "\n"
165  << pfx << "field12: " << theField12 << "\n"
166  << pfx << "field13: " << theField13 << "\n"
167  << pfx << "field14: " << theField14 << "\n"
168  << std::endl;
169 
170  return out;
171 }
172 
174 {
175  return theRecSen;
176 }
177 
179 {
180  return theFilename;
181 }
183 { return theVersion;
184 }
185 
187 {
188  return theCreationDate;
189 }
190 
192 {
193  return theStartOffset;
194 }
195 
197 {
198  return theStopOffset;
199 }
200 
202 {}
203 
205 {
206  return rhs;
207 }
char theField6[FIELD6_SIZE+1]
Definition: ossimDtedHdr.h:115
char theCreationDate[FIELD8_SIZE+1]
Definition: ossimDtedHdr.h:117
char theField13[FIELD13_SIZE+1]
Definition: ossimDtedHdr.h:122
ossimString version() const
char theField10[FIELD10_SIZE+1]
Definition: ossimDtedHdr.h:119
char theField11[FIELD11_SIZE+1]
Definition: ossimDtedHdr.h:120
std::ostream & operator<<(std::ostream &os, const ossimDtedHdr &hdr)
ossimString recognitionSentinel() const
char theField9[FIELD9_SIZE+1]
Definition: ossimDtedHdr.h:118
char theRecSen[FIELD1_SIZE+1]
Definition: ossimDtedHdr.h:110
static const ossimErrorCode OSSIM_ERROR
void parse(std::istream &in)
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this class&#39;s properties to list.
char theField4[FIELD4_SIZE+1]
Definition: ossimDtedHdr.h:113
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for name.
ossimString creationDate() const
char theField12[FIELD12_SIZE+1]
Definition: ossimDtedHdr.h:121
ossim_int32 startOffset() const
char theField5[FIELD5_SIZE+1]
Definition: ossimDtedHdr.h:114
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
char theField14[FIELD14_SIZE+1]
Definition: ossimDtedHdr.h:123
const ossimDtedHdr & operator=(const ossimDtedHdr &rhs)
char theVersion[FIELD7_SIZE+1]
Definition: ossimDtedHdr.h:116
std::ostream & print(std::ostream &out, const std::string &prefix) const
print method that outputs a key/value type format adding prefix to keys.
long long ossim_int64
char theFilename[FIELD3_SIZE+1]
Definition: ossimDtedHdr.h:112
ossim_int32 theStartOffset
Definition: ossimDtedHdr.h:125
ossim_int32 stopOffset() const
char theField2[FIELD2_SIZE+1]
Definition: ossimDtedHdr.h:111
ossim_int32 theStopOffset
Definition: ossimDtedHdr.h:126
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
ossimString fileName() const
int ossim_int32