OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfImageBandV2_0.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: Garrett Potts
8 //
9 // Description: Nitf support class
10 //
11 //********************************************************************
12 // $Id: ossimNitfImageBandV2_0.cpp 23245 2015-04-08 20:53:04Z rashadkm $
13 
14 #include <sstream>
15 #include <iostream>
16 #include <iomanip>
18 #include <ossim/base/ossimString.h>
19 
21 {
22  clearFields();
23 }
24 
26 {
27 }
28 
30 {
31  theLookupTables.clear();
32  if(in)
33  {
34  theLookupTables.clear();
35  in.read(theBandRepresentation, 2);
36  in.read(theBandSignificance, 6);
37  in.read(theBandImageFilterCondition, 1);
39  in.read(theBandNumberOfLuts, 1);
40 
41  long numberOfLuts = ossimString(theBandNumberOfLuts).toLong();
42 
43  if(numberOfLuts > 0)
44  {
45  theLookupTables.resize(numberOfLuts);
46  in.read(theBandNumberOfLutEntries, 5);
47 
48  ossim_uint32 numberOfLutsIndex = numberOfLuts;
50  ossim_uint32 idx = 0;
51 
52  while(idx < numberOfLutsIndex)
53  {
55  theLookupTables[idx]->setNumberOfEntries(numberOfLutEntries);
56  theLookupTables[idx]->parseStream(in);
57 
58  ++idx;
59  }
60  }
61  }
62 }
63 
65 {
66  out.write(theBandRepresentation, 2);
67  out.write(theBandSignificance, 6);
68  out.write(theBandImageFilterCondition, 1);
69  out.write(theBandStandardImageFilterCode, 3);
70  out.write(theBandNumberOfLuts, 1);
71 
72  if(ossimString(theBandNumberOfLuts).toUInt32() > 0)
73  {
74  // lut output not supported currently
75  }
76 }
77 
79  const std::string& prefix,
80  ossim_uint32 band)const
81 {
83  os << std::setw(3) << std::setfill('0') << (band+1) << ":";
84 
85  ossimString tmpStr = "IREPBAND";
86  tmpStr += os.str();
87 
88  out << prefix << std::setw(24)
89  << tmpStr << theBandRepresentation << "\n";
90 
91  tmpStr = "ISUBCAT";
92  tmpStr += os.str();
93 
94  out << prefix << std::setw(24)
95  << tmpStr << theBandSignificance << "\n";
96 
97  tmpStr = "IFC";
98  tmpStr += os.str();
99 
100  out << prefix << std::setw(24)
101  << tmpStr << theBandImageFilterCondition << "\n";
102 
103  tmpStr = "IMFLT";
104  tmpStr += os.str();
105 
106  out << prefix << std::setw(24)
107  << tmpStr << theBandStandardImageFilterCode << "\n";
108 
109  tmpStr = "NLUTS";
110  tmpStr += os.str();
111 
112  out << prefix << std::setw(24)
113  << tmpStr << theBandNumberOfLuts << "\n";
114 
115  tmpStr = "NELUTS";
116  tmpStr += os.str();
117 
118  out << prefix << std::setw(24)
119  << tmpStr << theBandNumberOfLutEntries << "\n";
120 
121  for(ossim_uint32 idx = 0; idx < theLookupTables.size(); ++idx)
122  {
123  out << *theLookupTables[idx] << std::endl;
124  }
125 
126  return out;
127 }
128 
130 {
131  return static_cast<ossim_uint32>(theLookupTables.size());
132 }
133 
135 {
136  if(idx < getNumberOfLuts())
137  {
138  return theLookupTables[idx];
139  }
140 
141  return NULL;
142 }
143 
145 {
146  if(idx < getNumberOfLuts())
147  {
148  return theLookupTables[idx];
149  }
150 
151  return NULL;
152 }
153 
155 {
157 }
158 
160 {
161  std::ostringstream out;
162 
163  out << std::setw(2)
164  << std::setfill(' ')
165  << std::setiosflags(std::ios::left)
166  << rep.c_str();
167 
168  memcpy(theBandRepresentation, out.str().c_str(), 2);
169 }
170 
172 {
174 }
175 
177 {
178  std::ostringstream out;
179 
180  out << std::setw(6)
181  << std::setfill(' ')
182  << rep.c_str();
183 
184  memcpy(theBandSignificance, out.str().c_str(), 6);
185 }
186 
188 {
189  memset(theBandRepresentation, ' ', 2);
190  memset(theBandSignificance, ' ', 6);
191  memset(theBandImageFilterCondition, 'N', 1);
192  memset(theBandStandardImageFilterCode, ' ', 3);
193  memset(theBandNumberOfLutEntries, ' ', 5);
194 
195  theLookupTables.clear();
196  theBandRepresentation[2] = '\0';
197  theBandSignificance[6] = '\0';
198  theBandImageFilterCondition[1] = '\0';
200  theBandNumberOfLuts[0] = 0x30;
201  theBandNumberOfLuts[1] = '\0';
202  theBandNumberOfLutEntries[5] = '\0';
203 }
204 
206 {
207  std::vector<ossimRefPtr<ossimNitfImageLut> >::const_iterator tables;
208 
209  tables = theLookupTables.begin();
210  while(tables != theLookupTables.end())
211  {
212  if((*tables).valid())
213  {
214  out << *((*tables).get());
215  }
216  ++tables;
217  if(tables != theLookupTables.end())
218  {
219  out << std::endl;
220  }
221  }
222 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
virtual ossim_uint32 getNumberOfLuts() const
std::vector< ossimRefPtr< ossimNitfImageLut > > theLookupTables
virtual void parseStream(ossim::istream &in)
void printLookupTables(std::ostream &out) const
virtual void setBandSignificance(const ossimString &rep)
Sets the band significance.
virtual std::ostream & print(std::ostream &out, const std::string &prefix=std::string(), ossim_uint32 band=0) const
print method that outputs a key/value type format adding prefix to keys.
virtual const ossimRefPtr< ossimNitfImageLut > getLut(ossim_uint32 idx) const
virtual ~ossimNitfImageBandV2_0()
virtual destructory
virtual ossimString getBandRepresentation() const
unsigned int ossim_uint32
virtual ossimString getBandSignificance() const
virtual void writeStream(ossim::ostream &out)
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
long toLong() const
toLong&#39;s deprecated, please use the toInts...
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
ossimNitfImageBandV2_0()
default constructor
virtual void setBandRepresentation(const ossimString &rep)
Sets the band representation.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23