OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfImageHeaderV2_0.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: MIT
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: ossimNitfImageHeaderV2_0.cpp 21518 2012-08-22 21:15:56Z dburken $
13 
15 #include <ossim/base/ossimDrect.h>
16 #include <ossim/base/ossimEndian.h>
17 #include <ossim/base/ossimIpt.h>
19 #include <ossim/base/ossimString.h>
21 #include <ossim/base/ossimTrace.h>
24 
25 #include <cstring> //for memset
26 #include <iomanip>
27 #include <stdexcept>
28 #include <sstream>
29 
30 static const ossimTrace traceDebug(ossimString("ossimNitfImageHeaderV2_0:debug"));
31 
33  "ossimNitfImageHeaderV2_0",
35 
43 
45 {
46  clearFields();
47 }
48 
50 {
51 }
52 
54 {
55  clearFields();
56  theImageBands.clear();
57 
58  in.read(theType, 2);
59  if(ossimString(theType) != "IM")
60  {
61  // error
62  }
63  in.read(theImageId, 10);
64  in.read(theDateTime, 14);
65  in.read(theTargetId, 17);
66  in.read(theTitle, 80);
67  in.read(theSecurityClassification, 1);
68  in.read(theCodewords, 40);
69  in.read(theControlAndHandling, 40);
70  in.read(theReleasingInstructions, 40);
71  in.read(theClassificationAuthority, 20);
72  in.read(theSecurityControlNumber, 20);
73  in.read(theSecurityDowngrade, 6);
74  if(ossimString(theSecurityDowngrade) == "999998")
75  {
76  in.read(theDowngradingEvent, 40);
77  }
78  in.read(theEncryption, 1);
79  in.read(theImageSource, 42);
80  in.read(theSignificantRows, 8);
81  in.read(theSignificantCols, 8);
82  in.read(thePixelValueType, 3);
83  in.read(theRepresentation, 8);
84  in.read(theCategory, 8);
85  in.read(theActualBitsPerPixelPerBand, 2);
86  in.read(theJustification, 1);
87  in.read(theCoordinateSystem, 1);
88  if(theCoordinateSystem[0] != 'N')
89  {
90  in.read(theGeographicLocation, 60);
91  }
92  in.read(theNumberOfComments, 1);
94 
95  // for now let's ignore the comments
96  if(numberOfComments > 0)
97  {
98  theImageComments.resize(numberOfComments);
99  for (ossim_uint32 i=0; i < numberOfComments; ++i)
100  {
101  char comment[81];
102  memset(comment, ' ', 80);
103  comment[80] = '\0';
104  in.read(comment, 80);
105  theImageComments[i] = ossimString(comment).trim();
106  }
107  }
108  in.read(theCompression, 2);
109  // check to see if there is compression
111  if((temp != "NC") &&
112  (temp != "NM"))
113  {
114  // get the rate if compression exists.
115  in.read(theCompressionRateCode, 4);
116  }
117  in.read(theNumberOfBands, 1);
119  theImageBands.resize(numberOfBands);
120  ossim_uint32 idx = 0;
121  while(idx < numberOfBands)
122  {
124  theImageBands[idx]->parseStream(in);
125  ++idx;
126  }
127  in.read(theImageSyncCode, 1);
128  in.read(theImageMode, 1);
129  in.read(theNumberOfBlocksPerRow, 4);
130  in.read(theNumberOfBlocksPerCol, 4);
131  in.read(theNumberOfPixelsPerBlockHoriz, 4);
132  in.read(theNumberOfPixelsPerBlockVert, 4);
133  in.read(theNumberOfBitsPerPixelPerBand, 2);
134  in.read(theDisplayLevel, 3);
135  in.read(theAttachmentLevel, 3);
136  in.read(theImageLocation, 10);
137  in.read(theImageMagnification, 4);
138  in.read(theUserDefinedImageDataLength, 5);
139  std::streampos userDefinedDataLen = (std::streampos)ossimString(theUserDefinedImageDataLength).toUInt32();
140  theTagList.clear();
141  ossimNitfTagInformation headerTag;
142  std::streampos start = in.tellg();
143  std::streampos current = in.tellg();
144  if(userDefinedDataLen > 0)
145  {
146  in.read(theUserDefinedOverflow, 3);
147 
148  while((current - start) < userDefinedDataLen)
149  {
150  headerTag.parseStream(in);
151  theTagList.push_back(headerTag);
152  // in.ignore(headerTag.getTagLength());
153  // headerTag.clearFields();
154  current = in.tellg();
155  }
156  }
157 
158  in.read(theExtendedSubheaderDataLen, 5);
159  std::streampos extSubHeadLen = (std::streampos)ossimString(theExtendedSubheaderDataLen).toUInt32();
160  start = in.tellg();
161  current = in.tellg();
162  if(extSubHeadLen > 0)
163  {
164  in.read(theExtendedSubheaderOverflow, 3);
165 
166  // ossim_uint32 test = 0;
167  while((current - start) < extSubHeadLen)
168  {
169  headerTag.parseStream(in);
170  theTagList.push_back(headerTag);
171  // test = headerTag.getTagLength()+in.tellg();
172  // in.ignore(headerTag.getTagLength());
173  // headerTag.clearFields();
174  current = in.tellg();
175  }
176  }
177 
178  ossimString compressionType = theCompression;
179  compressionType = compressionType.trim().upcase();
180  ossimEndian endian;
181  ossim_uint64 locationBefore = in.tellg();
182 
183  //---
184  // Note: "C4" added to skip over the image data mask subheader.
185  // See MIL-STD-2500A paragraph 5.5.1.5
186  //
187  // Seems like CIB data does not have. Could not find a hard and fast
188  // rule in the specs. Need a better was to detect if this needs to be
189  // read. (drb - 20100317)
190  //---
191  if( (compressionType == "NM") ||
192  (compressionType == "M0") ||
193  (compressionType == "M3") ||
194  (compressionType == "M4") ||
195  ( (compressionType == "C4") && ( !getImageId().contains("CIB")) ) )
196  {
197  in.read((char*)(&theBlockedImageDataOffset), 4);
198  in.read((char*)(&theBlockMaskRecordLength),2);
199  in.read((char*)(&thePadPixelMaskRecordLength), 2);
200  in.read((char*)(&theTransparentOutputPixelCodeLength), 2);
201 
202 
204  {
209  }
211  {
213  {
214  ossim_uint8 padOutputPixelCode;
215  in.read((char*)(&padOutputPixelCode), 1);
216  thePadOutputPixelCode = padOutputPixelCode;
217  }
218  }
219  else
220  {
221  in.read((char*)(&thePadOutputPixelCode), 2);
223  {
224  endian.swap(thePadOutputPixelCode);
225  }
226  // I need to add code here to check for justification when its 2 bytes
227  // but the code length is less than 16 bits.
228  //
229  }
231  {
232  ossim_uint32 totalNumber = 0;
233  if(theImageMode[0] == 'S')
234  {
236  }
237  else
238  {
240  }
241  ossim_uint32 *blockRead = new ossim_uint32[totalNumber];
242  ossim_uint32 idx = 0;
243  theBlockMaskRecords.resize(totalNumber);
244  in.read((char*)(blockRead), totalNumber*4);
245  for(idx = 0; idx < totalNumber; ++idx)
246  {
248  {
249  endian.swap(blockRead[idx]);
250  }
251  theBlockMaskRecords[idx] = blockRead[idx];
252  }
253  delete [] blockRead;
254  }
255  if((thePadPixelMaskRecordLength > 0)||
256  (( (getCompressionCode().upcase() == "M3"))&&
258  {
259  ossim_uint32 totalNumber = 0;
260  if(theImageMode[0] == 'S')
261  {
263  }
264  else
265  {
267  }
268  ossim_uint32 *blockRead = new ossim_uint32[totalNumber];
269  ossim_uint32 idx = 0;
270  thePadPixelMaskRecords.resize(totalNumber);
271  in.read((char*)(blockRead), totalNumber*4);
272  for(idx = 0; idx < totalNumber; ++idx)
273  {
275  {
276  endian.swap(blockRead[idx]);
277  }
278  thePadPixelMaskRecords[idx] = blockRead[idx];
279  }
280  delete [] blockRead;
281  }
282  }
283 
285  if((getCompressionCode() == "C4")||
286  (getCompressionCode() == "M4"))
287  {
290  compressionHeader->parseStream(in);
291  // do a check to see if the compression header is good
292  //
293 
294  if( compressionHeader->getCompressionAlgorithmId()!= 1 )
295  {
296  compressionHeader = 0;
297  }
298  theCompressionHeader = compressionHeader.get();
299  }
300 
301  ossim_uint64 delta = (ossim_uint64)in.tellg() - locationBefore;
302  if(delta < theBlockedImageDataOffset)
303  {
304  in.ignore(theBlockedImageDataOffset-delta);
305  }
306 
307  //
308  // The stream should now be at the start of the data location so capture
309  // it.
310  //
311  theDataLocation = in.tellg();
312 }
313 
315 {
316  out.write(theType, 2);
317  out.write(theImageId, 10);
318  out.write(theDateTime, 14);
319  out.write(theTargetId, 17);
320  out.write(theTitle, 80);
321  out.write(theSecurityClassification, 1);
322  out.write(theCodewords, 40);
323  out.write(theControlAndHandling, 40);
324  out.write(theReleasingInstructions, 40);
325  out.write(theClassificationAuthority, 20);
326  out.write(theSecurityControlNumber, 20);
327  out.write(theSecurityDowngrade, 6);
328  if(ossimString(theSecurityDowngrade) == "999998")
329  {
330  out.write(theDowngradingEvent, 40);
331  }
332  out.write(theEncryption, 1);
333  out.write(theImageSource, 42);
334  out.write(theSignificantRows, 8);
335  out.write(theSignificantCols, 8);
336  out.write(thePixelValueType, 3);
337  out.write(theRepresentation, 8);
338  out.write(theCategory, 8);
339  out.write(theActualBitsPerPixelPerBand, 2);
340  out.write(theJustification, 1);
341  out.write(theCoordinateSystem, 1);
342  if(theCoordinateSystem[0] != 'N')
343  {
344  out.write(theGeographicLocation, 60);
345  }
346  out.write(theNumberOfComments, 1);
347  out.write(theCompression, 2);
348  if(ossimString(theCompression) != "NC")
349  {
350  out.write(theCompressionRateCode, 4);
351  }
352  out.write(theNumberOfBands, 1);
353  ossim_uint32 bandIdx = 0;
354  for(bandIdx=0;bandIdx<theImageBands.size();++bandIdx)
355  {
356  theImageBands[bandIdx]->writeStream(out);
357  }
358  out.write(theImageSyncCode, 1);
359  out.write(theImageMode, 1);
360  out.write(theNumberOfBlocksPerRow, 4);
361  out.write(theNumberOfBlocksPerCol, 4);
362  out.write(theNumberOfPixelsPerBlockHoriz, 4);
363  out.write(theNumberOfPixelsPerBlockVert, 4);
364  out.write(theNumberOfBitsPerPixelPerBand, 2);
365  out.write(theDisplayLevel, 3);
366  out.write(theAttachmentLevel, 3);
367  out.write(theImageLocation, 10);
368  out.write(theImageMagnification, 4);
369  out.write(theUserDefinedImageDataLength, 5);
370  if(ossimString(theUserDefinedImageDataLength).toInt32() > 0)
371  {
372  out.write(theUserDefinedOverflow, 3);
373  }
374  ossim_uint32 totalLength = getTotalTagLength();
375 
376  if(totalLength == 0)
377  {
378  //memcpy(theExtendedSubheaderDataLen, "00000", 5);
379  out.write(theExtendedSubheaderDataLen, 5);
380  }
381  else
382  {
383  totalLength += 3; // per Table A-3 of MIL-STD-2500B
384 
385  if(totalLength <= 99999)
386  {
387  std::ostringstream tempOut;
388 
389  tempOut << std::setw(5)
390  << std::setfill('0')
391  << std::setiosflags(ios::right)
392  << totalLength;
393 
394  memcpy(theExtendedSubheaderDataLen, tempOut.str().c_str(), 5);
395 
396  out.write(theExtendedSubheaderDataLen, 5);
397  memset(theExtendedSubheaderOverflow, '0', 3);
398 
399  if(totalLength > 0)
400  {
401  out.write(theExtendedSubheaderOverflow, 3);
402 
403  ossim_uint32 i = 0;
404 
405  for(i = 0; i < theTagList.size(); ++i)
406  {
407  theTagList[i].writeStream(out);
408  }
409  }
410  }
411  else
412  {
413  ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimNitfFileHeaderV2_0::writeStream: Only support writing of total tag length < 99999" << std::endl;
414  }
415  }
416 }
417 
419 {
420  bool result = ossimNitfImageHeaderV2_X::isValid();
421 
422  if(result)
423  {
424 
425  }
426 
427  return result;
428 }
430  const std::string& prefix) const
431 {
432  out << setiosflags(std::ios::left)
433  << prefix << std::setw(24) << "IM:"
434  << theType << "\n"
435  << prefix << std::setw(24) << "IID:"
436  << theImageId << "\n"
437  << prefix << std::setw(24) << "IDATIM:"
438  << theDateTime << "\n"
439  << prefix << std::setw(24) << "TGTID:"
440  << theTargetId << "\n"
441  << prefix << std::setw(24) << "ITITLE:"
442  << theTitle << "\n"
443  << prefix << std::setw(24) << "ISCLAS:"
444  << theSecurityClassification << "\n"
445  << prefix << std::setw(24) << "ISCODE:"
446  << theCodewords << "\n"
447  << prefix << std::setw(24) << "ISCTLH:"
448  << theControlAndHandling << "\n"
449  << prefix << std::setw(24) << "ISREL:"
450  << theReleasingInstructions << "\n"
451  << prefix << std::setw(24) << "ISCAUT:"
452  << theClassificationAuthority << "\n"
453  << prefix << std::setw(24) << "ISCTLN:"
454  << theSecurityControlNumber << "\n"
455  << prefix << std::setw(24) << "ISDWNG:"
456  << theSecurityDowngrade << "\n"
457  << prefix << std::setw(24) << "ISDEBT:"
458  << theDowngradingEvent << "\n"
459  << prefix << std::setw(24) << "ENCRYP:"
460  << theEncryption << "\n"
461  << prefix << std::setw(24) << "ISORCE:"
462  << theImageSource << "\n"
463  << prefix << std::setw(24) << "NROWS:"
464  << theSignificantRows << "\n"
465  << prefix << std::setw(24) << "NCOLS:"
466  << theSignificantCols << "\n"
467  << prefix << std::setw(24) << "PVTYPE:"
468  << thePixelValueType << "\n"
469  << prefix << std::setw(24) << "IREP:"
470  << theRepresentation << "\n"
471  << prefix << std::setw(24) << "ICAT:"
472  << theCategory << "\n"
473  << prefix << std::setw(24) << "ABPP:"
475  << prefix << std::setw(24) << "PJUST:"
476  << theJustification << "\n"
477  << prefix << std::setw(24) << "ICORDS:"
478  << theCoordinateSystem << "\n"
479  << prefix << std::setw(24) << "IGEOLO:"
480  << theGeographicLocation << "\n"
481  << prefix << std::setw(24) << "NICOM:"
482  << theNumberOfComments << "\n";
483 
484  ossim_uint32 idx = 0;
485  for(idx = 0; idx < theImageComments.size(); ++idx)
486  {
487  ossimString icpre = "ICOM" + ossimString::toString(idx) + ":";
488  out << prefix << std::setw(24) << icpre << theImageComments[idx].trim() << "\n";
489  }
490  out << prefix << std::setw(24) << "IC:"
491  << theCompression << "\n"
492  << prefix << std::setw(24) << "COMRAT:"
493  << theCompressionRateCode << "\n"
494  << prefix << std::setw(24) << "NBANDS:"
495  << theNumberOfBands << "\n";
496 
497  for(idx = 0; idx < theImageBands.size(); ++idx)
498  {
499  if(theImageBands[idx].valid())
500  {
501  theImageBands[idx]->print(out, prefix, idx);
502  }
503  }
504 
505  out << prefix << std::setw(24) << "ISYNC:"
506  << theImageSyncCode << "\n"
507  << prefix << std::setw(24) << "IMODE:"
508  << theImageMode << "\n"
509  << prefix << std::setw(24) << "NBPR:"
510  << theNumberOfBlocksPerRow << "\n"
511  << prefix << std::setw(24) << "NBPC:"
512  << theNumberOfBlocksPerCol << "\n"
513  << prefix << std::setw(24) << "NPPBH:"
515  << prefix << std::setw(24) << "NPPBV:"
517  << prefix << std::setw(24) << "NBPP:"
519  << prefix << std::setw(24) << "IDLVL:"
520  << theDisplayLevel << "\n"
521  << prefix << std::setw(24) << "IALVL:"
522  << theAttachmentLevel << "\n"
523  << prefix << std::setw(24) << "ILOC:"
524  << theImageLocation << "\n"
525  << prefix << std::setw(24) << "IMAG:"
526  << theImageMagnification << "\n"
527  << prefix << std::setw(24) << "UDIDL:"
529  << prefix << std::setw(24) << "UDOFL:"
530  << theUserDefinedOverflow << "\n"
531  << prefix << std::setw(24) << "IXSHDL:"
532  << theExtendedSubheaderDataLen << "\n"
533  << prefix << std::setw(24) << "IXSOFL:"
534  << theExtendedSubheaderOverflow << "\n";
535 
536  if ( traceDebug() )
537  {
538  out << prefix << std::setw(24) << "theDataLocation:"
539  << theDataLocation << "\n"
540  << prefix << std::setw(24) << "theBlockedImageDataOffset:"
541  << theBlockedImageDataOffset << "\n"
542  << prefix << std::setw(24) << "theBlockMaskRecordLength:"
543  << theBlockMaskRecordLength << "\n"
544  << prefix << std::setw(24) << "thePadPixelMaskRecordLength:"
545  << thePadPixelMaskRecordLength << "\n"
546  << prefix << std::setw(24) << "theTransparentOutputPixelCodeLength:"
548  << prefix << std::setw(24) << "thePadOutputPixelCode:"
549  << thePadOutputPixelCode << "\n";
550  }
551 
553  {
554  theCompressionHeader->print(out, prefix);
555  }
556 
557  out << std::endl;
558 
559  return printTags(out, prefix);
560 }
561 
563 {
565  std::ostringstream out;
566 
567  kwl.add(prefix, "ITITLE", theTitle);
568 
569  ossim_uint32 idx = 0;
571  {
572  theCompressionHeader->saveState(kwl, prefix + "compression_header.");
573  }
574 
575  for(idx = 0; idx < theImageBands.size(); ++idx)
576  {
577  if(theImageBands[idx].valid())
578  {
579  theImageBands[idx]->print(out, "", idx);
580  }
581  }
582 
583  out << std::endl;
584 
585  ossimKeywordlist kwlTemp;
586 
587  std::istringstream in(out.str());
588  if(kwlTemp.parseStream(in))
589  {
590  kwl.add(prefix, kwlTemp);
591  }
592  return true;
593 }
594 
596 {
598  temp = temp.trim();
599  return ((temp != "NC") &&
600  (temp != "NM"));
601 }
602 
604 {
605  return (theEncryption[0] == '1');
606 }
607 
609 {
611 }
612 
614 {
616 }
617 
619 {
621 }
622 
624 {
626 }
627 
629 {
631 }
632 
634 {
636 }
637 
639 {
641 }
642 
644 {
645  return theImageId;
646 }
647 
649 {
651 }
652 
654 {
656 }
657 
659 {
660  return ossimString(theImageMode).trim();
661 }
662 
664 {
666 }
667 
669 {
670  return ossimString(theDateTime);
671 }
672 
674 {
675  ossimString result;
676  ossimString month(theDateTime+9,
677  theDateTime+12);
678  month = month.downcase();
679  if(month == "jan")
680  {
681  result += "01";
682  }
683  else if(month == "feb")
684  {
685  result += "02";
686  }
687  else if(month == "mar")
688  {
689  result += "03";
690  }
691  else if(month == "apr")
692  {
693  result += "04";
694  }
695  else if(month == "may")
696  {
697  result += "05";
698  }
699  else if(month == "jun")
700  {
701  result += "06";
702  }
703  else if(month == "jul")
704  {
705  result += "07";
706  }
707  else if(month == "aug")
708  {
709  result += "08";
710  }
711  else if(month == "sep")
712  {
713  result += "09";
714  }
715  else if(month == "oct")
716  {
717  result += "10";
718  }
719  else if(month == "nov")
720  {
721  result += "11";
722  }
723  else if(month == "dec")
724  {
725  result += "12";
726  }
727  result += ossimString(separationChar);
728  result += ossimString(theDateTime,
729  theDateTime + 2);
730  result += ossimString(separationChar);
731  ossimString year(theDateTime+12,
732  theDateTime+14);
733  if(year.toUInt32() < 70)
734  {
735  result += "20";
736  }
737  else
738  {
739  result += "19";
740  }
741  result += ossimString(theDateTime+12,
742  theDateTime+14);
743 
744  return result;
745 }
746 
748 {
749  return theCategory;
750 }
751 
753 {
754  return theImageSource;
755 }
756 
758 {
759  return theRepresentation;
760 }
761 
763 {
764  return theCoordinateSystem;
765 }
766 
768 {
770 }
771 
773 {
774  return (theBlockMaskRecords.size() > 0);
775 }
776 
778 {
779  return (thePadPixelMaskRecords.size() > 0);
780 }
781 
783 {
785 }
786 
788 {
789  return thePadOutputPixelCode;
790 }
791 
793  ossim_uint32 bandNumber)const
794 {
796  ossim_uint32 result = 0xffffffff;
797 
798  if((hasBlockMaskRecords())&&
799  (blockNumber < maxBlock))
800  {
801  if(theImageMode[0] == 'S')
802  {
803  if(bandNumber < (ossim_uint32)getNumberOfBands())
804  {
805  result = theBlockMaskRecords[bandNumber*maxBlock + blockNumber];
806  }
807  }
808  else
809  {
810  result = theBlockMaskRecords[blockNumber];
811  }
812  }
813 
814  return result;
815 }
817  ossim_uint32 bandNumber)const
818 {
820  ossim_uint32 result = 0xffffffff;
821 
822  if((hasPadPixelMaskRecords())&&
823  (blockNumber < maxBlock))
824  {
825  if(theImageMode[0] == 'S')
826  {
827  if(bandNumber < (ossim_uint32)getNumberOfBands())
828  {
829  result = thePadPixelMaskRecords[bandNumber*maxBlock + blockNumber];
830  }
831  }
832  else
833  {
834  result = thePadPixelMaskRecords[blockNumber];
835  }
836  }
837 
838  return result;
839 }
840 
842 {
843  theTagList.clear();
844 
845  memcpy(theType, "IM", 2);
846  memset(theImageId, ' ', 10);
847  memset(theDateTime, ' ', 14);
848  memset(theTargetId, ' ', 17);
849  memset(theTitle, ' ', 80);
850  memset(theSecurityClassification, ' ', 1);
851  memset(theCodewords, ' ', 40);
852  memset(theControlAndHandling, ' ', 40);
853  memset(theReleasingInstructions, ' ', 40);
854  memset(theClassificationAuthority, ' ', 20);
855  memset(theSecurityControlNumber, ' ', 20);
856  memset(theSecurityDowngrade, ' ', 6);
857  memset(theDowngradingEvent, ' ', 40);
858  memset(theEncryption, '0', 1);
859  memset(theImageSource, ' ', 42);
860  memset(theSignificantRows, ' ', 8);
861  memset(theSignificantCols, ' ', 8);
862  memset(thePixelValueType, ' ', 3);
863  memset(theRepresentation, ' ', 8);
864  memset(theCategory, ' ', 8);
865  memset(theActualBitsPerPixelPerBand, '0', 2);
866  memset(theJustification, ' ', 1);
867  memset(theCoordinateSystem, 'N', 1);
868  memset(theGeographicLocation, ' ', 60);
869  memset(theNumberOfComments, '0', 1);
870  memcpy(theCompression, "NC", 2);
871  memset(theCompressionRateCode, ' ', 4);
872  memset(theNumberOfBands, ' ', 1);
873  memset(theImageSyncCode, '0', 1);
874  memset(theImageMode, ' ', 1);
875  memset(theNumberOfBlocksPerRow, ' ', 4);
876  memset(theNumberOfBlocksPerCol, ' ', 4);
877  memset(theNumberOfPixelsPerBlockHoriz, ' ', 4);
878  memset(theNumberOfPixelsPerBlockVert, ' ', 4);
879  memset(theNumberOfBitsPerPixelPerBand, '0', 2);
880  memset(theDisplayLevel, ' ', 3);
881  memset(theAttachmentLevel, ' ', 3);
882  memcpy(theImageLocation, "0000000000", 10);
883  memcpy(theImageMagnification, "1.00", 4);
884  memset(theUserDefinedImageDataLength, '0', 5);
885  memset(theUserDefinedOverflow, '0', 3);
886  memset(theExtendedSubheaderDataLen, '0', 5);
887  memset(theExtendedSubheaderOverflow, ' ', 3);
888 
889  theBlockMaskRecords.clear();
890  thePadPixelMaskRecords.clear();
891 
898  theType[2] = '\0';
899  theImageId[10] = '\0';
900  theDateTime[14] = '\0';
901  theTargetId[17] = '\0';
902  theTitle[80] = '\0';
903  theSecurityClassification[1] = '\0';
904  theCodewords[40] = '\0';
905  theControlAndHandling[40] = '\0';
906  theReleasingInstructions[40] = '\0';
907  theClassificationAuthority[20] = '\0';
908  theSecurityControlNumber[20] = '\0';
909  theSecurityDowngrade[6] = '\0';
910  theDowngradingEvent[40] = '\0';
911  theEncryption[1] = '\0';
912  theImageSource[42] = '\0';
913  theSignificantRows[8] = '\0';
914  theSignificantCols[8] = '\0';
915  thePixelValueType[3] = '\0';
916  theRepresentation[8] = '\0';
917  theCategory[8] = '\0';
919  theJustification[1] = '\0';
920  theCoordinateSystem[1] = '\0';
921  theGeographicLocation[60] = '\0';
922  theNumberOfComments[1] = '\0';
923  theCompression[2] = '\0';
924  theCompressionRateCode[4] = '\0';
925  theNumberOfBands[1] = '\0';
926  theImageSyncCode[1] = '\0';
927  theImageMode[1] = '\0';
928  theNumberOfBlocksPerRow[4] = '\0';
929  theNumberOfBlocksPerCol[4] = '\0';
933  theDisplayLevel[3] = '\0';
934  theAttachmentLevel[3] = '\0';
935  theImageLocation[10] = '\0';
936  theImageMagnification[4] = '\0';
938  theUserDefinedOverflow[3] = '\0';
939  theExtendedSubheaderDataLen[5] = '\0';
940  theExtendedSubheaderOverflow[3] = '\0';
941  theDataLocation = 0;
942 }
943 
945 {
946  return theCompressionHeader;
947 }
948 
950 {
951  if(idx < theImageBands.size())
952  {
953  return (ossimNitfImageBand*)theImageBands[idx].get();
954  }
955 
956  return NULL;
957 }
958 
960 {
961  std::ostringstream out;
962  if(nbands > 9)
963  {
964  if(traceDebug())
965  {
966  ossimNotify(ossimNotifyLevel_WARN) << "ossimNitfImageHeaderV2_0::setNumberOfBands: NBANDS is too large. For 2.0 spec we can only have up to 9 bands\n";
967  }
968  std::string s = "ossimNitfImageHeaderV2_0::setNumberOfBands:";
969  s += " ERROR\nExceeded max number of bands of 9!";
970  throw std::out_of_range(s);
971  }
972  else
973  {
974  out << nbands;
975  theNumberOfBands[0] = out.str().c_str()[0];
976  }
977 
979 }
980 
982  const ossimNitfImageBandV2_0& info)
983 {
984  if(idx < theImageBands.size())
985  {
986  if(!theImageBands[idx].valid())
987  {
989  }
990  (*theImageBands[idx]) = info;
991  }
992 }
994 {
995  std::ostringstream out;
996  if(rows > 99999999) rows = 99999999;
997 
998  out << rows;
999  ossimNitfCommon::setField(theSignificantRows, out.str(), 8, ios::right, '0');
1000 }
1001 
1003 {
1004  std::ostringstream out;
1005  if(cols > 99999999) cols = 99999999;
1006 
1007  out << cols;
1008  ossimNitfCommon::setField(theSignificantCols, out.str(), 8, ios::right, '0');
1009 }
1010 
1012 {
1014 }
1015 
1017 {
1018  ossimRefPtr<ossimProperty> property = 0;
1019  if(name == ISCODE_KW)
1020  {
1021  property = new ossimStringProperty(name, theCodewords);
1022  }
1023  else if(name == ISCTLH_KW)
1024  {
1025  property = new ossimStringProperty(name, theControlAndHandling);
1026  }
1027  else if(name == ISREL_KW)
1028  {
1029  property = new ossimStringProperty(name, theReleasingInstructions);
1030  }
1031  else if(name == ISCAUT_KW)
1032  {
1033  property = new ossimStringProperty(name, theClassificationAuthority);
1034  }
1035  else if(name == CTLN_KW)
1036  {
1037  property = new ossimStringProperty(name, theSecurityControlNumber);
1038  }
1039  else if(name == ISDWNG_KW)
1040  {
1041  property = new ossimStringProperty(name, theSecurityDowngrade);
1042  }
1043  else if(name == ISDEVT_KW)
1044  {
1045  property = new ossimStringProperty(name, theDowngradingEvent);
1046  }
1047  else
1048  {
1049  property = ossimNitfImageHeaderV2_X::getProperty(name);
1050  }
1051  return property;
1052 }
1053 
1054 void ossimNitfImageHeaderV2_0::getPropertyNames(std::vector<ossimString>& propertyNames)const
1055 {
1057  propertyNames.push_back(ISCODE_KW);
1058  propertyNames.push_back(ISCTLH_KW);
1059  propertyNames.push_back(ISREL_KW);
1060  propertyNames.push_back(ISCAUT_KW);
1061  propertyNames.push_back(CTLN_KW);
1062  propertyNames.push_back(ISDWNG_KW);
1063  propertyNames.push_back(ISDEVT_KW);
1064 }
char theSignificantRows[9]
FIELD: NROWS.
static const ossimString ISDWNG_KW
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual bool isValid() const
isValid will test if the fields are valid and will return true or false.
virtual const ossimRefPtr< ossimNitfImageBand > getBandInformation(ossim_uint32 idx) const
virtual bool saveState(ossimKeywordlist &kwl, const ossimString &prefix="") const
ossim_uint16 theBlockMaskRecordLength
FIELD NAME: BMRLNTH.
virtual ossim_uint32 getTotalTagLength() const
char theNumberOfPixelsPerBlockVert[5]
FIELD: NPPBV.
virtual void setNumberOfCols(ossim_uint32 cols)
virtual ossimString getPixelValueType() const
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
char theNumberOfPixelsPerBlockHoriz[5]
FIELD: NPPBH.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
virtual ossimString getSecurityClassification() const
virtual void writeStream(ossim::ostream &out)
char theCompressionRateCode[5]
FIELD COMRAT.
ossim_uint32 theBlockedImageDataOffset
FIELD NAME: IMDATOFF.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual ossim_int32 getNumberOfBlocksPerCol() const
char theRepresentation[9]
FIELD: IREP.
virtual bool saveState(ossimKeywordlist &kwl, const ossimString &prefix="") const
Represents serializable keyword/value map.
ossim_uint16 thePadPixelMaskRecordLength
FIELD: TMRLNTH.
bool valid() const
Definition: ossimRefPtr.h:75
virtual std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
char theNumberOfBands[2]
FIELD: NBANDS.
RTTI_DEF1(ossimNitfImageHeaderV2_0, "ossimNitfImageHeaderV2_0", ossimNitfImageHeaderV2_X)
virtual std::ostream & print(std::ostream &out, const std::string &prefix) const =0
print method that outputs a key/value type format adding prefix to keys.
virtual bool isValid() const
isValid will test if the fields are valid and will return true or false.
virtual void parseStream(ossim::istream &in)
virtual ossimString getImageId() const
char theUserDefinedImageDataLength[6]
FIELD: UDIDL.
ossim_uint16 thePadOutputPixelCode
FIELD: TPXCD.
static ossimString toString(bool aValue)
Numeric to string methods.
char theActualBitsPerPixelPerBand[3]
FIELD: ABPP.
virtual ossimString getCoordinateSystem() const
ossimRefPtr< ossimNitfCompressionHeader > theCompressionHeader
ossim_uint32 toUInt32() const
char theNumberOfBitsPerPixelPerBand[3]
FIELD: NBPP.
char theNumberOfBlocksPerRow[5]
FIELD: NBPR.
char theGeographicLocation[61]
FIELD: IGEOLO.
virtual ossim_uint32 getTransparentCode() const
virtual ossim_int32 getNumberOfRows() const
virtual ossim_int32 getNumberOfPixelsPerBlockHoriz() const
char theImageId[11]
FIELD: IID1 Is a required 10 Alphanumeric value.
virtual bool hasTransparentCode() const
ossim_int32 toInt32() const
std::vector< ossim_uint32 > thePadPixelMaskRecords
virtual ossim_int32 getNumberOfBands() const
virtual bool saveState(ossimKeywordlist &kwl, const ossimString &prefix="") const
char theExtendedSubheaderDataLen[6]
FIELD: IXSHDL.
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
std::vector< ossimNitfTagInformation > theTagList
char theImageMode[2]
FIELD: IMODE.
char theTargetId[18]
FIELD: TGTID.
char theImageLocation[11]
FIELD: ILOC.
char theImageSyncCode[2]
FIELD: ISYNC.
static const ossimString ISDEVT_KW
virtual void setNumberOfBands(ossim_uint32 nbands)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual bool hasBlockMaskRecords() const
virtual void setBandInfo(ossim_uint32 idx, const ossimNitfImageBandV2_0 &info)
virtual const ossimRefPtr< ossimNitfCompressionHeader > getCompressionHeader() const
char theAttachmentLevel[4]
FIELD: IALVL.
char theJustification[2]
FIELD: PJUST.
unsigned long long ossim_uint64
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
char theUserDefinedOverflow[4]
FIELD: UDOFL.
virtual ossim_uint32 getCompressionAlgorithmId() const
virtual ossim_int32 getNumberOfPixelsPerBlockVert() const
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual ossim_uint32 getPadPixelMaskRecordOffset(ossim_uint32 blockNumber, ossim_uint32 bandNumber) const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual void parseStream(std::istream &in)
virtual ossim_int32 getNumberOfBlocksPerRow() const
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
char theNumberOfBlocksPerCol[5]
FIELD: NBPC.
char theDisplayLevel[4]
FIELD: IDLVL.
static const ossimString ISCAUT_KW
static const ossimString ISREL_KW
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
char theImageSource[43]
FIELD: ISORCE.
virtual ossimString getRepresentation() const
std::vector< ossimRefPtr< ossimNitfImageBandV2_0 > > theImageBands
Will contain also the field NBANDS and we will have to recreate the prefix for.
virtual ossim_int32 getBitsPerPixelPerBand() const
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
virtual bool hasPadPixelMaskRecords() const
static const ossimString ISCODE_KW
virtual ossimString getCategory() const
std::vector< ossim_uint32 > theBlockMaskRecords
virtual void setNumberOfRows(ossim_uint32 rows)
virtual ossimString getAcquisitionDateMonthDayYear(ossim_uint8 separationChar='-') const
char theSecurityClassification[2]
FIELD: ISCLAS.
ossim_uint16 theTransparentOutputPixelCodeLength
FIELD: TPXCDLNTH.
virtual ossim_int32 getNumberOfCols() const
virtual bool parseStream(ossim::istream &is, bool ignoreBinaryChars)
deprecated method
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.
static const ossimString CTLN_KW
char theCoordinateSystem[2]
FIELD: ICORDS.
char theSignificantCols[9]
FIELD: NCOLS.
virtual ossimString getImageSource() const
virtual ossimString getIMode() const
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
virtual std::ostream & printTags(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
char theExtendedSubheaderOverflow[4]
FIELD: IXSOFL.
virtual ossimString getImageDateAndTime() const
unsigned char ossim_uint8
virtual void parseStream(ossim::istream &in)
virtual ossim_uint32 getBlockMaskRecordOffset(ossim_uint32 blockNumber, ossim_uint32 bandNumber) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
std::vector< ossimString > theImageComments
char thePixelValueType[4]
FIELD: PVTYPE.
int ossim_int32
virtual ossim_int32 getActualBitsPerPixelPerBand() const
static const ossimString ISCTLH_KW
char theImageMagnification[5]
FIELD: IMAG.