OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Public Attributes | List of all members
ossimPiecewiseRemapper::ossimBandRemap Class Reference

Private container class. More...

Public Member Functions

 ossimBandRemap ()
 
 ossimBandRemap (const ossimBandRemap &obj)
 
const ossimBandRemapoperator= (const ossimBandRemap &rhs)
 
void loadState (const ossimKeywordlist &kwl, const std::string &prefix, ossim_uint32 band)
 
void saveState (ossimKeywordlist &kwl, const std::string &prefix, ossimPiecewiseRemapper::PiecewiseRemapType remapType, ossim_uint32 band) const
 
bool initRemapSetFromString (const std::string &s, ossimPiecewiseRemapper::ossimRemapSet &set) const
 Initializes set from string. More...
 
void getRemapSetString (ossimPiecewiseRemapper::PiecewiseRemapType remapType, const ossimPiecewiseRemapper::ossimRemapSet &set, std::string &s) const
 Gets a string from remap set for type. More...
 
void getLinearRemapSetString (const ossimPiecewiseRemapper::ossimRemapSet &set, std::string &s) const
 

Public Attributes

std::vector< ossimRemapSetm_remap
 

Detailed Description

Private container class.

Holds array of ossimRemapSets for a given band.

Definition at line 164 of file ossimPiecewiseRemapper.h.

Constructor & Destructor Documentation

◆ ossimBandRemap() [1/2]

ossimPiecewiseRemapper::ossimBandRemap::ossimBandRemap ( )

Definition at line 64 of file ossimPiecewiseRemapper.cpp.

65  :
66  m_remap(0)
67 {
68 }

◆ ossimBandRemap() [2/2]

ossimPiecewiseRemapper::ossimBandRemap::ossimBandRemap ( const ossimBandRemap obj)

Definition at line 70 of file ossimPiecewiseRemapper.cpp.

71  :
72  m_remap(obj.m_remap)
73 {
74 }

Member Function Documentation

◆ getLinearRemapSetString()

void ossimPiecewiseRemapper::ossimBandRemap::getLinearRemapSetString ( const ossimPiecewiseRemapper::ossimRemapSet set,
std::string &  s 
) const

Definition at line 246 of file ossimPiecewiseRemapper.cpp.

249 {
250  //---
251  // Save in the form of:
252  // ((0, 127, 0, 127), (128, 255, 128, 382))
253  //---
254  s.clear();
255  if ( set.m_set.size() )
256  {
257  const ossim_uint32 TUPLES = set.m_set.size() / 4;
258  if ( TUPLES )
259  {
261  os << std::setprecision(15)
262  << "(";
263  for ( ossim_uint32 i = 0; i < TUPLES; ++i )
264  {
265  ossim_uint32 setIdx = i*4;
266  os << "("
267  << set.m_set[ setIdx ]
268  << ","
269  << set.m_set[ setIdx + 1 ]
270  << ","
271  << set.m_set[ setIdx + 2 ]
272  << ","
273  << set.m_set[ setIdx + 3 ]
274  << ")";
275  if ( i < (TUPLES-1) )
276  {
277  os << ","; // Comma between quadruples.
278  }
279  }
280  os << ")";
281  s = os.str();
282  }
283  }
284 
285 } // End: ossimPiecewiseRemapper::ossimBandRemap::getLinearRemapSetString( ... )
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
unsigned int ossim_uint32

◆ getRemapSetString()

void ossimPiecewiseRemapper::ossimBandRemap::getRemapSetString ( ossimPiecewiseRemapper::PiecewiseRemapType  remapType,
const ossimPiecewiseRemapper::ossimRemapSet set,
std::string &  s 
) const

Gets a string from remap set for type.

Parameters
remapType
set
sInitialized by this.

Definition at line 235 of file ossimPiecewiseRemapper.cpp.

References ossimPiecewiseRemapper::getLinearRemapSetString(), and ossimPiecewiseRemapper::LINEAR_NATIVE.

239 {
240  if ( remapType == ossimPiecewiseRemapper::LINEAR_NATIVE )
241  {
242  getLinearRemapSetString( set, s );
243  }
244 }
void getLinearRemapSetString(const ossimPiecewiseRemapper::ossimRemapSet &set, std::string &s) const

◆ initRemapSetFromString()

bool ossimPiecewiseRemapper::ossimBandRemap::initRemapSetFromString ( const std::string &  s,
ossimPiecewiseRemapper::ossimRemapSet set 
) const

Initializes set from string.

Example input: ((0, 127, 0, 127), (128, 255, 128, 382))

Parameters
sString to initialize from.
setInitialized by this.

Definition at line 163 of file ossimPiecewiseRemapper.cpp.

165 {
166  //---
167  // Example:
168  // ((0, 127, 0, 127), (128, 255, 128, 382))
169  //---
170 
171  bool result = false;
172 
173  if ( s.size() )
174  {
175  std::istringstream in( s );
176  char c;
177  ossim_float64 d;
178 
179  // Gobble the open '('
180  while ( !in.bad() && !in.eof() )
181  {
182  c = in.get();
183  if ( c == '(' ) break;
184  }
185 
186  // Main loop:
187  while( !in.bad() && !in.eof() )
188  {
189  c = in.get();
190 
191  if ( c == ')' ) // Possible end of quadruple...
192  {
193  // Gobble next comma:
194  while( !in.bad() && !in.eof() )
195  {
196  c = in.get();
197  if ( c == ',' )
198  {
199  break;
200  }
201  }
202  c = in.get();
203  }
204 
205  if ( (c == '(') || (c == ',') )
206  {
207  // Next string should be a number:
208  in >> d;
209  if ( in.good() )
210  {
211  set.m_set.push_back(d);
212  }
213  else
214  {
215  break;
216  }
217  }
218  }
219 
220  if ( set.m_set.size() )
221  {
222  result = true;
223  }
224  }
225 
226  if ( !result )
227  {
228  set.m_set.clear();
229  }
230 
231  return result;
232 
233 } // End: ossimPiecewiseRemapper::ossimBandRemap::initRemapSetFromString( ... )
double ossim_float64
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32

◆ loadState()

void ossimPiecewiseRemapper::ossimBandRemap::loadState ( const ossimKeywordlist kwl,
const std::string &  prefix,
ossim_uint32  band 
)

Definition at line 86 of file ossimPiecewiseRemapper.cpp.

References ossimString::string(), and ossimString::toString().

89 {
90  //---
91  // Band Remap set example:
92  // band0.remap0:((0, 127, 0, 127), (128, 255, 128, 382))
93  // band0.remap1:((0, 382, 0, 255))
94  //---
95 
96  // Clear the sets:
97  m_remap.clear();
98 
99  // Get the number of remaps for this band.
100  std::string keyBase = "band";
101  keyBase += ossimString::toString(band).string();
102  keyBase += ".";
103  keyBase += REMAP_KW;
104 
105  ossim_uint32 NUMBER_REMAPS = kwl.numberOf(prefix.c_str(), keyBase.c_str());
106  ossim_uint32 found = 0;
107  ossim_uint32 index = 0;
108 
109  // Loop to find band remaps. This allows for skipping indexes.
110  while ( found < NUMBER_REMAPS )
111  {
112  std::string key = keyBase + ossimString::toString(index).string();
113  std::string value = kwl.findKey( prefix, key );
114  if ( value.size() )
115  {
117  if ( initRemapSetFromString( value, set ) )
118  {
119  m_remap.push_back( set );
120  }
121  ++found;
122  }
123 
124  ++index;
125  if ( index > (NUMBER_REMAPS+100) )
126  {
127  break;
128  }
129  }
130 
131 } // End: ossimPiecewiseRemapper::ossimBandRemap::loadState
ossim_uint32 numberOf(const char *str) const
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static ossimString toString(bool aValue)
Numeric to string methods.
bool initRemapSetFromString(const std::string &s, ossimPiecewiseRemapper::ossimRemapSet &set) const
Initializes set from string.
unsigned int ossim_uint32
const std::string & string() const
Definition: ossimString.h:414

◆ operator=()

const ossimPiecewiseRemapper::ossimBandRemap & ossimPiecewiseRemapper::ossimBandRemap::operator= ( const ossimBandRemap rhs)

Definition at line 77 of file ossimPiecewiseRemapper.cpp.

References m_remap.

78 {
79  if ( this != &rhs )
80  {
81  m_remap = rhs.m_remap;
82  }
83  return *this;
84 }

◆ saveState()

void ossimPiecewiseRemapper::ossimBandRemap::saveState ( ossimKeywordlist kwl,
const std::string &  prefix,
ossimPiecewiseRemapper::PiecewiseRemapType  remapType,
ossim_uint32  band 
) const

Definition at line 133 of file ossimPiecewiseRemapper.cpp.

References ossimString::string(), and ossimString::toString().

138 {
139  //---
140  // Remap set:
141  // Remap set: "band0.remap0":
142  // band0.remap0:((0, 127, 0, 127), (128, 255, 128, 382))
143  // band0.remap1:((0, 382, 0, 255))
144  //---
145  ossim_uint32 remapIndex = 0;
146  std::vector<ossimRemapSet>::const_iterator i = m_remap.begin();
147  while ( i != m_remap.end() )
148  {
149  std::string key = "band";
150  key += ossimString::toString(band).string();
151  key += ".";
152  key += REMAP_KW;
153  key += ossimString::toString(remapIndex).string();
154  std::string value;
155  getRemapSetString( remapType, (*i), value );
156  kwl.addPair( prefix, key, value );
157  ++i;
158  ++remapIndex;
159  }
160 
161 } // End: ossimPiecewiseRemapper::ossimBandRemap::saveState
static ossimString toString(bool aValue)
Numeric to string methods.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
void getRemapSetString(ossimPiecewiseRemapper::PiecewiseRemapType remapType, const ossimPiecewiseRemapper::ossimRemapSet &set, std::string &s) const
Gets a string from remap set for type.
unsigned int ossim_uint32
const std::string & string() const
Definition: ossimString.h:414

Member Data Documentation

◆ m_remap

std::vector<ossimRemapSet> ossimPiecewiseRemapper::ossimBandRemap::m_remap

Definition at line 204 of file ossimPiecewiseRemapper.h.

Referenced by operator=().


The documentation for this class was generated from the following files: