OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Static Public Member Functions | List of all members
ossimNitfCommon Class Reference

class ossimNitfCommon for global utility methods More...

#include <ossimNitfCommon.h>

Public Member Functions

 ossimNitfCommon ()
 default constructor More...
 
 ~ossimNitfCommon ()
 destructor More...
 

Static Public Member Functions

static ossimString convertToScientificString (const ossim_float64 &aValue, ossim_uint32 size)
 This method takes a value and a size(or width) and converts it to a scientific notation sting in the format: ±0.999999E±9. More...
 
static ossimString convertToDoubleString (const ossim_float64 &aValue, ossim_uint32 precision, ossim_uint32 size)
 This method takes a value and converts to a string of size with requested precision with a '0' fill. More...
 
static ossimString convertToUIntString (ossim_uint32 aValue, ossim_uint32 size)
 This method takes a value and converts to a string of size with with a '0' fill. More...
 
static ossimString convertToIntString (ossim_int32 aValue, ossim_uint32 size)
 Just like convertToUIntString only takes a signed value. More...
 
static ossimString convertToDdLatLonLocString (const ossimDpt &pt, ossim_uint32 precision)
 Converts pt to a decimal degrees latitude longitude location string. More...
 
static void setField (void *fieldDestination, const ossimString &src, std::streamsize width, std::ios_base::fmtflags ioflags=std::ios::left, char fill=' ')
 Sets a field with a given string, width, and IOS flags. More...
 
static ossimString encodeUtm (ossim_uint32 zone, const ossimDpt &ul, const ossimDpt &ur, const ossimDpt &lr, const ossimDpt &ll)
 This will encode a 60 character IGEOLO field. More...
 
static ossimString encodeGeographicDms (const ossimDpt &ul, const ossimDpt &ur, const ossimDpt &lr, const ossimDpt &ll)
 
static ossimString encodeGeographicDecimalDegrees (const ossimDpt &ul, const ossimDpt &ur, const ossimDpt &lr, const ossimDpt &ll)
 
static ossimString getNitfPixelType (ossimScalarType scalarType)
 Get the nitf pixel type string from scalar type. More...
 
static ossimString getCompressionRate (const ossimIrect &rect, ossim_uint32 bands, ossimScalarType scalar, ossim_uint64 lengthInBytes)
 Get compression rate (COMRAT) which is bits perpixel per band. More...
 

Detailed Description

class ossimNitfCommon for global utility methods

Definition at line 24 of file ossimNitfCommon.h.

Constructor & Destructor Documentation

◆ ossimNitfCommon()

ossimNitfCommon::ossimNitfCommon ( )

default constructor

Definition at line 30 of file ossimNitfCommon.cpp.

30 {}

◆ ~ossimNitfCommon()

ossimNitfCommon::~ossimNitfCommon ( )

destructor

Definition at line 32 of file ossimNitfCommon.cpp.

32 {}

Member Function Documentation

◆ convertToDdLatLonLocString()

ossimString ossimNitfCommon::convertToDdLatLonLocString ( const ossimDpt pt,
ossim_uint32  precision 
)
static

Converts pt to a decimal degrees latitude longitude location string.

Format example: +-dd.dddddd+-ddd.dddddd

Parameters
ptPoint to convert where pt.x = longitude and pt.y = latitude.
precisionThe floating point precision. This will determine the size of the string.

Definition at line 181 of file ossimNitfCommon.cpp.

References convertToDoubleString(), ossimDpt::x, and ossimDpt::y.

Referenced by ossimNitfBlockaTag::setFrfcLoc(), ossimNitfBlockaTag::setFrlcLoc(), ossimNitfBlockaTag::setLrfcLoc(), and ossimNitfBlockaTag::setLrlcLoc().

183 {
184  ossimString lat;
185  ossimString lon;
186  ossim_uint32 latSize = precision+4; // size = precision + "-33."
187  ossim_uint32 lonSize = precision+5; // size = precision + "-122."
188 
189  if (pt.y >= 0.0)
190  {
191  lat = "+";
192  --latSize;
193  }
194  if (pt.x >= 0.0)
195  {
196  lon = "+";
197  --lonSize;
198  }
199  lat += convertToDoubleString(pt.y,
200  precision,
201  latSize);
202  lon += convertToDoubleString(pt.x,
203  precision,
204  lonSize);
205  ossimString result = lat+lon;
206 
207  if (traceDebug())
208  {
210  << "ossimNitfCommon::convertToDdLatLonLocString DEBUG:"
211  << "\nresult: " << result
212  << std::endl;
213  }
214 
215  return result;
216 }
double y
Definition: ossimDpt.h:165
static ossimString convertToDoubleString(const ossim_float64 &aValue, ossim_uint32 precision, ossim_uint32 size)
This method takes a value and converts to a string of size with requested precision with a &#39;0&#39; fill...
unsigned int ossim_uint32
double x
Definition: ossimDpt.h:164
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ convertToDoubleString()

ossimString ossimNitfCommon::convertToDoubleString ( const ossim_float64 aValue,
ossim_uint32  precision,
ossim_uint32  size 
)
static

This method takes a value and converts to a string of size with requested precision with a '0' fill.

Format example: 00925.00

Parameters
aValueValue to convert to string.
precisionThe floating point precision.
sizetotal size of the string.

Definition at line 89 of file ossimNitfCommon.cpp.

References size.

Referenced by convertToDdLatLonLocString(), ossimNitfRpcBase::setErrorBias(), ossimNitfRpcBase::setErrorRand(), ossimNitfRpcBase::setGeodeticLatOffset(), ossimNitfRpcBase::setGeodeticLatScale(), ossimNitfRpcBase::setGeodeticLonOffset(), ossimNitfRpcBase::setGeodeticLonScale(), and ossimNitfJ2klraTag::setLayerBitRate().

93 {
94  ossim_uint32 width = size;
95 
97  s1 << std::setiosflags(std::ios_base::fixed|
98  std::ios_base::internal)
99  << std::setprecision(precision)
100  << std::setfill('0')
101  << std::setw(width)
102  << aValue;
103 
104  ossimString result = s1.str();
105 
106  if (traceDebug())
107  {
109  << "ossimNitfCommon::convertToDoubleString DEBUG:"
110  << "\nresult: " << result << std::endl;
111 
112  if (result.size() != size)
113  {
115  << "ossimNitfCommon::convertToDoubleString DEBUG:"
116  << "\nIncorrect output size!"
117  << std::endl;
118  }
119  }
120  return result;
121 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
yy_size_t size
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ convertToIntString()

ossimString ossimNitfCommon::convertToIntString ( ossim_int32  aValue,
ossim_uint32  size 
)
static

Just like convertToUIntString only takes a signed value.

This method takes a value and converts to a string of size with with a '0' fill.

Format example: 00925

Parameters
aValueValue to convert to string.
sizetotal size of the string.

Definition at line 152 of file ossimNitfCommon.cpp.

References size.

Referenced by ossimNitfBlockaTag::setBlockInstance(), ossimNitfRpcBase::setGeodeticHeightOffset(), and ossimNitfRpcBase::setGeodeticHeightScale().

154 {
155  ossim_uint32 width = size;
156 
158  s1 << std::setiosflags(std::ios_base::fixed|
159  std::ios_base::internal)
160  << std::setfill('0')
161  << std::setw(width)
162  << aValue;
163 
164  ossimString result = s1.str();
165 
166  if (traceDebug())
167  {
168  if (result.size() != size)
169  {
171  << "ossimNitfCommon::convertToIntString DEBUG:"
172  << "\nIncorrect output size!"
173  << "\nValue: " << aValue
174  << "\nString: " << result
175  << std::endl;
176  }
177  }
178  return result;
179 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
yy_size_t size
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ convertToScientificString()

ossimString ossimNitfCommon::convertToScientificString ( const ossim_float64 aValue,
ossim_uint32  size 
)
static

This method takes a value and a size(or width) and converts it to a scientific notation sting in the format: ±0.999999E±9.

Note
If the value is positive, currently there is no + added to the front.
Parameters
aValueValue to convert to string.
sizetotal size of the string. This must be at least 7 if aValue is positive and at least 8 if aValue is negative; else, no action is taken and an empty string is returned.

Definition at line 34 of file ossimNitfCommon.cpp.

References size.

37 {
38  // Precision cannot hit 0 for this to work...
39  if ( ((aValue < 0.0) && (size < 8)) ||
40  ((aValue >= 0.0) && (size < 7)) )
41  {
42  if (traceDebug())
43  {
45  << "ossimNitfCommon::convertToScientificString DEBUG:"
46  << "\nsize range error!"
47  << std::endl;
48  }
49  return ossimString();
50  }
51 
52  //--
53  // Set the precision to account for size with 1.xxxxxE+01
54  //---
55  ossim_uint32 precision = size - 6;
56 
57  if (aValue < 0.0)
58  {
59  --precision;
60  }
61 
63  s1 << std::setiosflags(std::ios_base::scientific|std::ios_base::internal)
64  << std::setfill('0')
65  // << setw(size)
66  << std::setprecision(precision)
67  << aValue;
68 
69  ossimString result = s1.str();
70 
71  // Upcase the "e".
72  result.upcase();
73 
74  if (traceDebug())
75  {
76  if (result.size() != size)
77  {
79  << "ossimNitfCommon::convertToScientificString DEBUG:"
80  << "\nIncorrect output size!"
81  << "\nValue: " << aValue
82  << "\nString: " << result
83  << std::endl;
84  }
85  }
86  return result;
87 }
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
yy_size_t size
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ convertToUIntString()

ossimString ossimNitfCommon::convertToUIntString ( ossim_uint32  aValue,
ossim_uint32  size 
)
static

This method takes a value and converts to a string of size with with a '0' fill.

Format example: 00925

Parameters
aValueValue to convert to string.
sizetotal size of the string.

Definition at line 123 of file ossimNitfCommon.cpp.

References size.

Referenced by ossimNitfJ2klraTag::setBandsI(), ossimNitfJ2klraTag::setBandsO(), ossimNitfJ2klraTag::setLayerId(), ossimNitfJ2klraTag::setLayersI(), ossimNitfJ2klraTag::setLayersO(), ossimNitfBlockaTag::setLayoverAngle(), ossimNitfJ2klraTag::setLevelsI(), ossimNitfJ2klraTag::setLevelsO(), ossimNitfRpcBase::setLineOffset(), ossimNitfRpcBase::setLineScale(), ossimNitfBlockaTag::setLLines(), ossimNitfBlockaTag::setNGray(), ossimNitfRpcBase::setSampleOffset(), ossimNitfRpcBase::setSampleScale(), and ossimNitfBlockaTag::setShadowAngle().

125 {
126  ossim_uint32 width = size;
127 
129  s1 << std::setiosflags(std::ios_base::fixed|
130  std::ios_base::internal)
131  << std::setfill('0')
132  << std::setw(width)
133  << aValue;
134 
135  ossimString result = s1.str();
136 
137  if (traceDebug())
138  {
139  if (result.size() != size)
140  {
142  << "ossimNitfCommon::convertToUIntString DEBUG:"
143  << "\nIncorrect output size!"
144  << "\nValue: " << aValue
145  << "\nString: " << result
146  << std::endl;
147  }
148  }
149  return result;
150 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
yy_size_t size
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ encodeGeographicDecimalDegrees()

ossimString ossimNitfCommon::encodeGeographicDecimalDegrees ( const ossimDpt ul,
const ossimDpt ur,
const ossimDpt lr,
const ossimDpt ll 
)
static

Definition at line 406 of file ossimNitfCommon.cpp.

References ossimDpt::lat, and ossimDpt::lon.

Referenced by ossimNitfImageHeaderV2_X::setGeographicLocationDecimalDegrees().

410 {
411  std::ostringstream out;
412 
413  out << (ul.lat >= 0.0?"+":"")
414  << std::setw(6)
415  << std::setfill('0')
416  << std::setprecision(3)
417  << std::setiosflags(std::ios::fixed)
418  << ul.lat
419  << (ul.lon >= 0.0?"+":"")
420  << std::setw(7)
421  << std::setfill('0')
422  << std::setprecision(3)
423  << std::setiosflags(std::ios::fixed)
424  << ul.lon;
425  out << (ur.lat >= 0.0?"+":"")
426  << std::setw(6)
427  << std::setfill('0')
428  << std::setprecision(3)
429  << std::setiosflags(std::ios::fixed)
430  << ur.lat
431  << (ur.lon >= 0.0?"+":"")
432  << std::setw(7)
433  << std::setfill('0')
434  << std::setprecision(3)
435  << std::setiosflags(std::ios::fixed)
436  << ur.lon;
437  out << (lr.lat >= 0.0?"+":"")
438  << std::setw(6)
439  << std::setfill('0')
440  << std::setprecision(3)
441  << std::setiosflags(std::ios::fixed)
442  << lr.lat
443  << (lr.lon >= 0.0?"+":"")
444  << std::setw(7)
445  << std::setfill('0')
446  << std::setprecision(3)
447  << std::setiosflags(std::ios::fixed)
448  << lr.lon;
449  out << (ll.lat >= 0.0?"+":"")
450  << std::setw(6)
451  << std::setfill('0')
452  << std::setprecision(3)
453  << std::setiosflags(std::ios::fixed)
454  << ll.lat
455  << (ll.lon >= 0.0?"+":"")
456  << std::setw(7)
457  << std::setfill('0')
458  << std::setprecision(3)
459  << std::setiosflags(std::ios::fixed)
460  << ll.lon;
461 
462  return ossimString(out.str());
463 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
double lat
Definition: ossimDpt.h:165
double lon
Definition: ossimDpt.h:164

◆ encodeGeographicDms()

ossimString ossimNitfCommon::encodeGeographicDms ( const ossimDpt ul,
const ossimDpt ur,
const ossimDpt lr,
const ossimDpt ll 
)
static

Definition at line 387 of file ossimNitfCommon.cpp.

References ossimString::c_str(), ossimDms::toString(), ossimDpt::x, and ossimDpt::y.

391 {
392  std::ostringstream out;
393 
394  out << ossimDms(ul.y, true).toString("ddmmssC").c_str();
395  out << ossimDms(ul.x, false).toString("dddmmssC").c_str();
396  out << ossimDms(ur.y, true).toString("ddmmssC").c_str();
397  out << ossimDms(ur.x, false).toString("dddmmssC").c_str();
398  out << ossimDms(lr.y, true).toString("ddmmssC").c_str();
399  out << ossimDms(lr.x, false).toString("dddmmssC").c_str();
400  out << ossimDms(ll.y, true).toString("ddmmssC").c_str();
401  out << ossimDms(ll.x, false).toString("dddmmssC").c_str();
402 
403  return ossimString(out.str());
404 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
double y
Definition: ossimDpt.h:165
double x
Definition: ossimDpt.h:164
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
ossimString toString(const ossimString &formatString=ossimString("")) const
You can specify a number of different formats.
Definition: ossimDms.cpp:294

◆ encodeUtm()

ossimString ossimNitfCommon::encodeUtm ( ossim_uint32  zone,
const ossimDpt ul,
const ossimDpt ur,
const ossimDpt lr,
const ossimDpt ll 
)
static

This will encode a 60 character IGEOLO field.

Definition at line 233 of file ossimNitfCommon.cpp.

Referenced by ossimNitfImageHeaderV2_X::setUtmNorth(), and ossimNitfImageHeaderV2_X::setUtmSouth().

239 {
240  std::ostringstream out;
241 
242  if(zone > 60)
243  {
244  std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUTM zone greate than 60!";
245  if (traceDebug())
246  {
247  ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
248  }
249  throw std::out_of_range(s);
250  }
251 
252  ossim_float64 east = ul.x;
253  ossim_float64 north = ul.y;
254 
255  if((ossim_uint32)(east+.5) > 999999)
256  {
257  std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper left easting too large for NITF field!";
258  if (traceDebug())
259  {
260  ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
261  }
262  throw std::out_of_range(s);
263  }
264 
265  if((ossim_uint32)(north+.5) > 9999999)
266  {
267  std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper left northing too large for NITF field!";
268  if (traceDebug())
269  {
270  ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
271  }
272  throw std::out_of_range(s);
273  }
274 
275  out << std::setw(2)
276  << std::setfill('0')
277  << zone
278  << std::setw(6)
279  << std::setfill('0')
280  <<(ossim_uint32)(east+.5)
281  << std::setw(7)
282  << std::setfill('0')
283  <<(ossim_uint32)(north+.5);
284 
285 
286  east = ur.x;
287  north = ur.y;
288 
289  if((ossim_uint32)(east+.5) > 999999)
290  {
291  std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper right easting too large for NITF field!";
292  if (traceDebug())
293  {
294  ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
295  }
296  throw std::out_of_range(s);
297  }
298 
299  if((ossim_uint32)(north+.5) > 9999999)
300  {
301  std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nUpper right northing too large for NITF field!";
302  if (traceDebug())
303  {
304  ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
305  }
306  throw std::out_of_range(s);
307  }
308 
309  out << std::setw(2)
310  << std::setfill('0')
311  << zone
312  << std::setw(6)
313  << std::setfill('0')
314  <<(ossim_uint32)(east+.5)
315  << std::setw(7)
316  << std::setfill('0')
317  <<(ossim_uint32)(north+.5);
318  east = lr.x;
319  north = lr.y;
320 
321  if((ossim_uint32)(east+.5) > 999999)
322  {
323  std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower right easting too large for NITF field!";
324  if (traceDebug())
325  {
326  ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
327  }
328  throw std::out_of_range(s);
329  }
330 
331  if((ossim_uint32)(north+.5) > 9999999)
332  {
333  std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower right northing too large for NITF field!";
334  if (traceDebug())
335  {
336  ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
337  }
338  throw std::out_of_range(s);
339  }
340 
341  out << std::setw(2)
342  << std::setfill('0')
343  << zone
344  << std::setw(6)
345  << std::setfill('0')
346  <<(ossim_uint32)(east+.5)
347  << std::setw(7)
348  << std::setfill('0')
349  <<(ossim_uint32)(north+.5);
350 
351  east = ll.x;
352  north = ll.y;
353 
354  if((ossim_uint32)(east+.5) > 999999)
355  {
356  std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower left easting too large for NITF field!";
357  if (traceDebug())
358  {
359  ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
360  }
361  throw std::out_of_range(s);
362  }
363 
364  if((ossim_uint32)(north+.5) > 9999999)
365  {
366  std::string s = "ossimNitfImageHeaderV2_1::encodeUtm: ERROR\nLower left northing too large for NITF field!";
367  if (traceDebug())
368  {
369  ossimNotify(ossimNotifyLevel_WARN) << s << std::endl;
370  }
371  throw std::out_of_range(s);
372  }
373 
374  out << std::setw(2)
375  << std::setfill('0')
376  << zone
377  << std::setw(6)
378  << std::setfill('0')
379  <<(ossim_uint32)(east+.5)
380  << std::setw(7)
381  << std::setfill('0')
382  <<(ossim_uint32)(north+.5);
383 
384  return out.str().c_str();
385 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
double y
Definition: ossimDpt.h:165
double ossim_float64
unsigned int ossim_uint32
double x
Definition: ossimDpt.h:164
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getCompressionRate()

ossimString ossimNitfCommon::getCompressionRate ( const ossimIrect rect,
ossim_uint32  bands,
ossimScalarType  scalar,
ossim_uint64  lengthInBytes 
)
static

Get compression rate (COMRAT) which is bits perpixel per band.

This corresponds to the nitf image header COMRAT field. Return is in the form of Nxyz "N" for numerically lossles, where "xyz" indicates the expected achieved bit rate (in bits per pixel per band) for the final layer of each tile. The decimal point is implicit and assumed to be one digit from the right (i.e. xy.z).

Parameters
rectImage rectangles.
bands
scalar
lengthInBytesCompressed length of image pixels.
Returns
Approximate number of bits per pixel for the compressed image as a string which follows the nitf comrat field convention. This will return an empty string if comrat is bigger than three digits.

Definition at line 507 of file ossimNitfCommon.cpp.

References ossim::getBitsPerPixel(), ossimIrect::height(), ossim::scalarSizeInBytes(), ossimString::size(), ossimString::toString(), and ossimIrect::width().

511 {
512  ossimString result("");
513 
514  ossim_float64 uncompressedSize =
515  ossim::scalarSizeInBytes(scalar) * rect.width() * rect.height() * bands;
516  ossim_float64 bitsPerPix = ossim::getBitsPerPixel(scalar);
517  ossim_float64 rate = ( bitsPerPix *
518  (static_cast<ossim_float64>(lengthInBytes) /
519  uncompressedSize) );
520 
521  // Multiply by 100 as there is an implied decimal point.
522  rate *= 100.0;
523 
524  // Convert to string with zero precision.
525  ossimString s = ossimString::toString(rate, 0, 4);
526 
527  if (s.size())
528  {
529  if (s.size() <= 3)
530  {
531  result = "N";
532  if (s.size() == 3)
533  {
534  result = "0";
535  }
536  else if (s.size() == 2)
537  {
538  result = "00";
539  }
540  result += s;
541  }
542  }
543  return result;
544 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
static ossimString toString(bool aValue)
Numeric to string methods.
double ossim_float64
std::string::size_type size() const
Definition: ossimString.h:405
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
ossim_uint32 width() const
Definition: ossimIrect.h:500
OSSIM_DLL ossim_uint32 getBitsPerPixel(ossimScalarType scalarType)
Get bits per pixel for a given scalar type.

◆ getNitfPixelType()

ossimString ossimNitfCommon::getNitfPixelType ( ossimScalarType  scalarType)
static

Get the nitf pixel type string from scalar type.

Parameters
scalarTypeThe scalar type.
Returns
Pixel type as string, e.g.: "INT", "SI", "R"

Definition at line 465 of file ossimNitfCommon.cpp.

References OSSIM_DOUBLE, OSSIM_FLOAT, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SINT16, OSSIM_SINT32, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, ossimNotify(), and ossimNotifyLevel_DEBUG.

Referenced by ossimNitf20Writer::writeBlockBandSeparate(), ossimNitfWriter::writeBlockBandSeparate(), ossimNitf20Writer::writeBlockBandSequential(), and ossimNitfWriter::writeBlockBandSequential().

466 {
467  ossimString pixelType;
468  switch(scalarType)
469  {
470  case OSSIM_UINT8:
471  case OSSIM_USHORT11:
472  case OSSIM_USHORT12:
473  case OSSIM_USHORT13:
474  case OSSIM_USHORT14:
475  case OSSIM_USHORT15:
476  case OSSIM_UINT16:
477  case OSSIM_UINT32:
478  {
479  pixelType = "INT";
480  break;
481  }
482  case OSSIM_SINT16:
483  case OSSIM_SINT32:
484  {
485  pixelType = "SI";
486  break;
487  }
488  case OSSIM_FLOAT:
490  case OSSIM_DOUBLE:
492  {
493  pixelType = "R";
494  break;
495  }
496  default:
497  {
499  << __FILE__ << ":" << __LINE__
500  << "\nUnhandled scalar type: " << scalarType << std::endl;
501  break;
502  }
503  }
504  return pixelType;
505 }
16 bit unsigned integer (15 bits used)
16 bit unsigned integer
16 bit signed integer
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
32 bit unsigned integer
32 bit signed integer
32 bit normalized floating point
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
8 bit unsigned integer
32 bit floating point
64 bit floating point
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
16 bit unsigned integer (12 bits used)

◆ setField()

void ossimNitfCommon::setField ( void *  fieldDestination,
const ossimString src,
std::streamsize  width,
std::ios_base::fmtflags  ioflags = std::ios::left,
char  fill = ' ' 
)
static

Sets a field with a given string, width, and IOS flags.

Parameters
fieldDestinationThe member NITF field to set.
srcThe source string.
widthThe number of characters in fieldDestination to copy from the source string.
ioflagsFormatting flags for the destination string.
fillIf the size of the string is smaller than the field size, this character specifies what the excess character values are.

Definition at line 218 of file ossimNitfCommon.cpp.

References ossimString::c_str(), and ossimString::trim().

Referenced by ossimNitfImageHeaderV2_X::loadState(), ossimNitfImageHeaderV2_X::setActualBitsPerPixel(), ossimNitfImageHeaderV2_X::setAquisitionDateTime(), ossimNitfImageHeaderV2_X::setAttachmentLevel(), ossimNitfImageHeaderV2_X::setBitsPerPixel(), ossimNitfImageHeaderV2_X::setBlocksPerCol(), ossimNitfImageHeaderV2_X::setBlocksPerRow(), ossimNitfImageHeaderV2_X::setCategory(), ossimNitfImageHeaderV2_1::setClassificationAuthority(), ossimNitfFileHeaderV2_0::setClassificationAuthority(), ossimNitfImageHeaderV2_1::setClassificationAuthorityType(), ossimNitfImageHeaderV2_1::setClassificationReason(), ossimNitfImageHeaderV2_1::setClassificationText(), ossimNitfTextHeaderV2_1::setCodewords(), ossimNitfImageHeaderV2_1::setCodewords(), ossimNitfFileHeaderV2_0::setCodeWords(), ossimNitfFileHeaderV2_X::setComplexityLevel(), ossimNitfFileHeaderV2_0::setComplianceLevel(), ossimNitfImageHeaderV2_X::setCompression(), ossimNitfImageHeaderV2_X::setCompressionRateCode(), ossimNitfTextHeaderV2_1::setControlAndHandling(), ossimNitfImageHeaderV2_1::setControlAndHandling(), ossimNitfFileHeaderV2_0::setControlAndHandling(), ossimNitfImageHeaderV2_X::setCoordinateSystem(), ossimNitfFileHeaderV2_X::setCopyNumber(), ossimRpfHeader::setCountryCode(), ossimNitfImageHeaderV2_1::setDeclassificationDate(), ossimNitfImageHeaderV2_1::setDeclassificationExempt(), ossimNitfTextHeaderV2_1::setDeclassificationType(), ossimNitfImageHeaderV2_1::setDeclassificationType(), ossimNitfImageHeaderV2_X::setDisplayLevel(), ossimNitfImageHeaderV2_1::setDowngrade(), ossimNitfImageHeaderV2_1::setDowngradeDate(), ossimNitfFileHeaderV2_0::setDowngradingEvent(), ossimNitfImageHeaderV2_X::setEncryption(), ossimNitfFileHeaderV2_X::setEncryption(), ossimRpfHeader::setFilename(), ossimNitfFileHeaderV2_X::setFileSecurityClassification(), ossimNitfImageHeaderV2_X::setGeographicLocation(), ossimRpfHeader::setGovSpecDate(), ossimRpfHeader::setGovSpecNumber(), ossimNitfImageHeaderV2_X::setImageId(), ossimNitfImageHeaderV2_1::setImageMagnification(), ossimNitfImageHeaderV2_X::setImageSource(), ossimNitfImageHeaderV2_X::setJustification(), ossimRpfReplaceUpdateRecord::setNewFilename(), ossimNitfImageHeaderV2_1::setNumberOfCols(), ossimNitfImageHeaderV2_0::setNumberOfCols(), ossimNitfImageHeaderV2_X::setNumberOfComments(), ossimNitfFileHeaderV2_X::setNumberOfCopies(), ossimNitfImageHeaderV2_X::setNumberOfPixelsPerBlockCol(), ossimNitfImageHeaderV2_X::setNumberOfPixelsPerBlockRow(), ossimNitfImageHeaderV2_1::setNumberOfRows(), ossimNitfImageHeaderV2_0::setNumberOfRows(), ossimRpfReplaceUpdateRecord::setOldFilename(), ossimNitfFileHeaderV2_X::setOriginatingStationId(), ossimNitfFileHeaderV2_0::setOriginatorsName(), ossimNitfFileHeaderV2_0::setOriginatorsPhone(), ossimNitfImageHeaderV2_X::setPixelType(), ossimNitfDataExtensionSegmentV2_1::setProperty(), ossimNitfTextHeaderV2_1::setReleasingInstructions(), ossimNitfImageHeaderV2_1::setReleasingInstructions(), ossimNitfFileHeaderV2_0::setReleasingInstructions(), ossimNitfImageHeaderV2_X::setRepresentation(), ossimNitfImageHeaderV2_X::setSecurityClassification(), ossimNitfTextHeaderV2_1::setSecurityClassification(), ossimRpfHeader::setSecurityClassification(), ossimNitfTextHeaderV2_1::setSecurityClassificationSystem(), ossimNitfImageHeaderV2_1::setSecurityClassificationSystem(), ossimNitfImageHeaderV2_1::setSecurityControlNumber(), ossimNitfFileHeaderV2_0::setSecurityControlNumber(), ossimNitfFileHeaderV2_0::setSecurityDowngrade(), ossimRpfHeader::setSecurityReleaseMarking(), ossimNitfImageHeaderV2_1::setSecuritySourceDate(), ossimNitfFileHeaderV2_X::setSystemType(), ossimNitfImageHeaderV2_X::setTargetId(), ossimNitfImageHeaderV2_X::setTitle(), and ossimNitfFileHeaderV2_X::setTitle().

223 {
224  std::ostringstream out;
225  out << std::setw(width)
226  << std::setfill(fill)
227  << std::setiosflags(ioflags)
228  << src.trim().c_str();
229 
230  memcpy(fieldDestination, out.str().c_str(), width);
231 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
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

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