OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfWriter.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 //*******************************************************************
10 // $Id: ossimNitfWriter.cpp 22814 2014-06-05 15:13:28Z dburken $
11 
15 #include <ossim/base/ossimEndian.h>
18 #include <ossim/base/ossimRefPtr.h>
20 #include <ossim/base/ossimTrace.h>
32 #include <tiffio.h>
33 #include <fstream>
34 #include <algorithm>
35 #include <sstream>
36 #include <iomanip>
37 
38 RTTI_DEF1(ossimNitfWriter, "ossimNitfWriter", ossimNitfWriterBase);
39 
40 static ossimTrace traceDebug(ossimString("ossimNitfWriter:debug"));
41 
42 // Maximum file size
43 static const ossim_uint64 KB = 1024;
44 static const ossim_uint64 MB = KB * KB;
45 static const ossim_uint64 MB50 = 50 * MB;
46 static const ossim_uint64 GB = KB * MB;
47 static const ossim_uint64 GB2 = 2 * GB;
48 static const ossim_uint64 GB10 = 10 * GB;
49 
51  ossimImageSource* inputSource)
52  : ossimNitfWriterBase(filename, inputSource),
53  m_str(0),
54  m_fileHeader(0),
55  m_imageHeader(0),
56  m_textHeader(0),
57  m_textEntry(),
59 {
60  //---
61  // Since the internal nitf tags are not very accurate, write an external
62  // geometry out as default behavior. Users can disable this via the
63  // property interface or keyword list.
64  //---
65  // Added GEOLOB tag for geographic output. UTM is good with BLOCKA.
66  // No longer needed. (drb - 30 March 2018)
67  // setWriteExternalGeometryFlag(true);
68 
71 
72  // m_textHeader is conditional so we will not new here.
73 
74  theOutputImageType = "nitf_block_band_separate";
75 
76  //---
77  // The tile size can be set in the preferences via "tile_size" keyword.
78  // This will get it if set; else, set to default.
79  //---
81 
82  // These are always set:
85 
86  // Set any site defaults.
88  dynamic_cast<ossimNitfFileHeaderV2_X*>(m_fileHeader.get()),
89  dynamic_cast<ossimNitfImageHeaderV2_X*>(m_imageHeader.get()) );
90 }
91 
93 {
94  //---
95  // This looks like a leak but it's not as both of these are ossimRefPtr's.
96  //---
97  m_fileHeader=0;
98  m_imageHeader=0;
99  m_textHeader=0;
100 
101  close();
102 }
103 
105 {
106  return (m_str ? m_str->is_open() : false);
107 }
108 
110 {
111  bool result = true;
112  if(isOpen())
113  {
114  close();
115  }
116 
117  // there is a bug in gcc < 5.0 and we can't use constructors in the
118  // C++11 build. Will refactor to do a new ifstream then use open
119  //
120  m_str = std::make_shared<ossim::ofstream>();
121  m_str->open(theFilename.c_str(), ios::out|ios::binary);
122  if(!m_str->is_open())
123  {
124  m_str.reset();
125  result = false;
126  }
127 
128  //new std::ofstream;
129  //m_str->open(theFilename.c_str(), ios::out|ios::binary);
130 
131  return result;
132 }
133 
135 {
136  if(m_str)
137  {
138  m_str->close();
139  m_str.reset();
140  }
141 }
142 
144 {
146  {
148 
149  return true;
150  }
151 
152  open();
153 
154  if (!isOpen())
155  {
156  if (traceDebug())
157  {
159  << "ossimNitfWriter::writeFile ERROR:"
160  << " Could not open! Returning..."
161  << std::endl;
162  }
163 
164  return false;
165  }
166 
167  // Write out the geometry info.
169 
170  // addStandardTags();
171 
172  bool result = false;
173  if((theOutputImageType == "nitf_block_band_separate")||
174  (theOutputImageType == "image/nitf"))
175  {
176  result = writeBlockBandSeparate();
177  }
178  else if(theOutputImageType == "nitf_block_band_sequential")
179  {
180  result = writeBlockBandSequential();
181  }
182 
183  close();
184 
185  return result;
186 }
187 
188 void ossimNitfWriter::getImageTypeList(std::vector<ossimString>& imageTypeList)const
189 {
190  imageTypeList.push_back(ossimString("nitf_block_band_separate"));
191  imageTypeList.push_back(ossimString("nitf_block_band_sequential"));
192 }
193 
195 {
196  if(!property) return;
197 
198  ossimString name = property->getName();
199 
200  if(name == "file_header")
201  {
203  property.get());
204  if(containerProperty)
205  {
206  std::vector<ossimRefPtr<ossimProperty> > propertyList;
207  containerProperty->getPropertyList(propertyList);
208  m_fileHeader->setProperties(propertyList);
209  }
210  }
211  else if(name == "image_header")
212  {
214  property.get());
215  if(containerProperty)
216  {
217  std::vector<ossimRefPtr<ossimProperty> > propertyList;
218  containerProperty->getPropertyList(propertyList);
219  m_imageHeader->setProperties(propertyList);
220  }
221  }
222  else if(name == "block_size")
223  {
224  ossimIpt blockSize;
225  blockSize.x = property->valueToString().toInt32();
226  blockSize.y = blockSize.x;
227  setTileSize(blockSize);
228  }
229  else
230  {
232  }
233 }
234 
236 {
237  ossimRefPtr<ossimProperty> result = 0;
238 
239  if(name == "file_header")
240  {
241  ossimContainerProperty* container = new ossimContainerProperty(name);
242  std::vector<ossimRefPtr<ossimProperty> > propertyList;
243 
244  m_fileHeader->getPropertyList(propertyList);
245  container->addChildren(propertyList);
246 
247  result = container;
248  }
249  else if(name == "image_header")
250  {
251  ossimContainerProperty* container = new ossimContainerProperty(name);
252  std::vector<ossimRefPtr<ossimProperty> > propertyList;
253 
254  m_imageHeader->getPropertyList(propertyList);
255  container->addChildren(propertyList);
256 
257  result = container;
258  }
259  else if(name == "des_header")
260  {
261  ossimContainerProperty* container = new ossimContainerProperty(name);
262  std::vector<ossimRefPtr<ossimProperty> > propertyList;
263 
264  // Create a temporary DES in order to populate propertyList.
266  des.getPropertyList(propertyList);
267  container->addChildren(propertyList);
268 
269  result = container;
270  }
271  else if(name == "block_size")
272  {
273  ossimStringProperty* stringProp =
274  new ossimStringProperty(name,
276  false); // editable flag
277  stringProp->addConstraint(ossimString("64"));
278  stringProp->addConstraint(ossimString("128"));
279  stringProp->addConstraint(ossimString("256"));
280  stringProp->addConstraint(ossimString("512"));
281  stringProp->addConstraint(ossimString("1024"));
282  stringProp->addConstraint(ossimString("2048"));
283  return stringProp;
284  }
285  else
286  {
288  }
289 
290  return result;
291 }
292 
294  std::vector<ossimString>& propertyNames)const
295 {
297 
298  propertyNames.push_back("file_header");
299  propertyNames.push_back("image_header");
300  propertyNames.push_back("des_header");
301  propertyNames.push_back("block_size");
302 }
303 
305 {
307  ossim_uint64 byteSize = ossim::scalarSizeInBytes(scalarType);
310  ossim_uint64 idx = 0;
311  ossim_uint64 headerStart = (ossim_uint64)m_str->tellp();
312 
313  // Set the sequencer block size to be the same as output.
315 
319 
320  ossimNitfImageInfoRecordV2_1 imageInfoRecord;
321  imageInfoRecord.setSubheaderLength(439); // ok if no tags
322  imageInfoRecord.setImageLength(bands*byteSize*blocksVertical*m_blockSize.y*blocksHorizontal*m_blockSize.x);
323 
325  m_fileHeader->addImageInfoRecord(imageInfoRecord);
326 
327  if ( m_textHeader.valid() )
328  {
329  // Add any text headers
330  ossimNitfTextFileInfoRecordV2_1 textInfoRecord;
331  textInfoRecord.setSubheaderLength(285); //default
332  // Set length of text to be that of input text
333  textInfoRecord.setTextLength(m_textEntry.length());
334  m_fileHeader->addTextInfoRecord(textInfoRecord);
335  }
336 
337  // Get the overflow tags from the file header and the image subheader
338  takeOverflowTags(true, true);
339  takeOverflowTags(true, false);
340  takeOverflowTags(false, true);
341  takeOverflowTags(false, false);
342 
343  for (vector<ossimNitfDataExtensionSegmentV2_1>::iterator iter = m_dataExtensionSegments.begin();
344  iter != m_dataExtensionSegments.end(); iter++)
345  {
346  ossimNitfDataExtSegInfoRecordV2_1 desInfoRecord;
347  iter->setSecurityMarkings(*m_fileHeader);
348  std::ostringstream headerOut;
349  headerOut << std::setw(4)
350  << std::setfill('0')
351  << std::setiosflags(ios::right)
352  << iter->getHeaderLength();
353  strcpy(desInfoRecord.theDataExtSegSubheaderLength, headerOut.str().c_str());
354 
355  std::ostringstream dataOut;
356  dataOut << std::setw(9)
357  << std::setfill('0')
358  << std::setiosflags(ios::right)
359  << iter->getDataLength();
360  strcpy(desInfoRecord.theDataExtSegLength, dataOut.str().c_str());
361 
362  m_fileHeader->addDataExtSegInfoRecord(desInfoRecord);
363  }
364 
365  //---
366  // This makes space for the file header; it is written again at the end of
367  // this method with updated values
368  // need a better way to get the length. This should be queried on the
369  // header before writing
370  //---
372  ossim_uint64 headerLength = ((ossim_uint64)m_str->tellp() - headerStart) /* + 1 */;
373 
374  ossimString representation;
379  m_imageHeader->setImageMode('B');// blocked
380 
381  bool masked = (m_imageHeader->getCompressionCode() == "NM");
383  datamask.setBlockCount(blocksVertical * blocksHorizontal);
384  ossim_uint64 blockLength = bands * byteSize * m_blockSize.x * m_blockSize.y;
385  datamask.setBlockLengthInBytes(blockLength);
386  std::vector<char> blockZeros;
387 
388 
389  if((bands == 3)&&
390  (scalarType == OSSIM_UCHAR))
391  {
393  m_imageHeader->setCategory("VIS");
394  }
395  else if(bands == 1)
396  {
398  m_imageHeader->setCategory("VIS");
399  }
400  else
401  {
403  m_imageHeader->setCategory("MS");
404  }
405 
406  m_imageHeader->setBlocksPerRow(blocksHorizontal);
407  m_imageHeader->setBlocksPerCol(blocksVertical);
412 
413  ossimNitfImageBandV2_1 bandInfo;
414  for(idx = 0; idx < bands; ++idx)
415  {
416  std::ostringstream out;
417 
418  out << std::setfill('0')
419  << std::setw(2)
420  << idx;
421 
422  bandInfo.setBandRepresentation(out.str().c_str());
423  m_imageHeader->setBandInfo(idx, bandInfo);
424  }
425 
426  ossim_uint64 imageHeaderStart = m_str->tellp();
428  ossim_uint64 imageHeaderEnd = m_str->tellp();
429  ossim_uint64 imageHeaderSize = imageHeaderEnd - imageHeaderStart;
430 
431  // Start the sequence through tiles:
433 
436  ossimEndian endian;
437 
438  // write out mask if needed
439  if(masked)
440  {
441  blockZeros.resize(blockLength);
442  memset(&blockZeros.front(), '\0', blockLength);
443  datamask.writeStream( *m_str );
444  }
445  while( data.valid() && !needsAborting())
446  {
447  bool write = true;
449  {
450  switch(data->getScalarType())
451  {
452  case OSSIM_USHORT16:
453  case OSSIM_USHORT11:
454  case OSSIM_USHORT12:
455  case OSSIM_USHORT13:
456  case OSSIM_USHORT14:
457  case OSSIM_USHORT15:
458  {
459  endian.swap((ossim_uint16*)data->getBuf(),
460  data->getWidth()*data->getHeight()*data->getNumberOfBands());
461  break;
462  }
463  case OSSIM_SSHORT16:
464  {
465  endian.swap((ossim_sint16*)data->getBuf(),
466  data->getWidth()*data->getHeight()*data->getNumberOfBands());
467  break;
468  }
469  case OSSIM_FLOAT:
471  {
472  endian.swap((ossim_float32*)data->getBuf(),
473  data->getWidth()*data->getHeight()*data->getNumberOfBands());
474  break;
475  }
476  case OSSIM_DOUBLE:
478  {
479  endian.swap((ossim_float64*)data->getBuf(),
480  data->getWidth()*data->getHeight()*data->getNumberOfBands());
481  break;
482  }
483  default:
484  break;
485  }
486  }
487 
488  if (masked)
489  {
490  if (memcmp(data->getBuf(), &blockZeros.front(), blockLength) == 0)
491  {
492  write = false;
493  datamask.setIncludeBlock(tileNumber-1, false);
494  }
495  }
496  if(write)
497  {
498  m_str->write((char*)(data->getBuf()), data->getSizeInBytes());
499  }
500 
501  setPercentComplete(((double)tileNumber / (double)numberOfTiles) * 100);
502 
503  if(!needsAborting())
504  {
506  }
507  ++tileNumber;
508  }
509 
510  // ossim_uint64 imageSegmentEnd = m_str->tellp();
511 
512  // Let's write our text header
513  if ( m_textHeader.valid() )
514  {
516  //Now write the text
517  m_str->write((char*)(m_textEntry.c_str()), m_textEntry.length());
518  }
519 
520 
521  for (vector<ossimNitfDataExtensionSegmentV2_1>::iterator iter = m_dataExtensionSegments.begin();
522  iter != m_dataExtensionSegments.end(); iter++)
523  {
524  iter->writeStream( *m_str );
525  }
526 
527  if (masked)
528  {
529  m_str->seekp(imageHeaderEnd);
530  datamask.writeStream( *m_str );
531  //delete [] blockZeros;
532  }
533 
534  std::streamoff pos = m_str->tellp();
535 
537 
538  /*
539  * Need to change the way I compute file length and header length later
540  * We need to figure out a better way to compute.
541  */
542  m_fileHeader->setFileLength(static_cast<ossim_uint64>(pos));
543  m_fileHeader->setHeaderLength(headerLength);
544  m_str->seekp(0, ios::beg);
545  imageInfoRecord.setSubheaderLength(imageHeaderSize);
546  m_fileHeader->replaceImageInfoRecord(0, imageInfoRecord);
548 
549  return true;
550 }
551 
553 {
555  ossim_uint64 byteSize = ossim::scalarSizeInBytes(scalarType);
558  ossim_uint64 idx = 0;
559  ossim_uint64 headerStart = (ossim_uint64)m_str->tellp();
560 
561  // Set the sequencer block size to be the same as output.
563 
567 
568  ossimNitfImageInfoRecordV2_1 imageInfoRecord;
569  imageInfoRecord.setSubheaderLength(439);
570  imageInfoRecord.setImageLength(bands*byteSize*blocksHorizontal*blocksVertical*m_blockSize.x*m_blockSize.y);
571 
573  m_fileHeader->addImageInfoRecord(imageInfoRecord);
574 
575  if ( m_textHeader.valid() )
576  {
577  // Add any text headers
578  ossimNitfTextFileInfoRecordV2_1 textInfoRecord;
579  textInfoRecord.setSubheaderLength(285); //default
580  // Set length of text to be that of input text
581  textInfoRecord.setTextLength(m_textEntry.length());
582  m_fileHeader->addTextInfoRecord(textInfoRecord);
583  }
584 
585  //---
586  // This makes space for the file header; it is written again at the end of
587  // this method with updated values
588  // need a better way to get the length. This should be queried on the
589  // header before writing
590  //---
592  ossim_uint64 headerLength = ((ossim_uint64)m_str->tellp() - headerStart) /* + 1 */;
593 
594  ossimString representation;
599  m_imageHeader->setImageMode('S');// blocked
600 
601  if((bands == 3)&&
602  (scalarType == OSSIM_UCHAR))
603  {
605  m_imageHeader->setCategory("VIS");
606  }
607  else if(bands == 1)
608  {
610  m_imageHeader->setCategory("VIS");
611  }
612  else
613  {
615  m_imageHeader->setCategory("MS");
616  }
617  m_imageHeader->setBlocksPerRow(blocksHorizontal);
618  m_imageHeader->setBlocksPerCol(blocksVertical);
623 
624  ossimNitfImageBandV2_1 bandInfo;
625  for(idx = 0; idx < bands; ++idx)
626  {
627  std::ostringstream out;
628 
629  out << std::setfill('0')
630  << std::setw(2)
631  << idx;
632 
633  bandInfo.setBandRepresentation(out.str().c_str());
634  m_imageHeader->setBandInfo(idx, bandInfo);
635  }
636 
637  ossim_uint64 imageHeaderStart = m_str->tellp();
639  ossim_uint64 imageHeaderEnd = m_str->tellp();
640  ossim_uint64 imageHeaderSize = imageHeaderEnd - imageHeaderStart;
641 
642  // ossimIpt ul = rect.ul();
643 
644  // Start the sequence through tiles:
646 
649  ossimEndian endian;
650 
651  // get the start to the first band of data block
652  //
653  ossim_uint64 streamOffset = m_str->tellp();
654 
655  // holds the total pixels to the next band
656 
658  ossim_uint64 bandOffsetInBytes = (blockSizeInBytes*blocksHorizontal*blocksVertical);
659 
660  bool needSwapping = endian.getSystemEndianType() == OSSIM_LITTLE_ENDIAN;
661  while(data.valid() && !needsAborting())
662  {
663  if(needSwapping)
664  {
665  switch(data->getScalarType())
666  {
667  case OSSIM_USHORT16:
668  case OSSIM_USHORT11:
669  case OSSIM_USHORT12:
670  case OSSIM_USHORT13:
671  case OSSIM_USHORT14:
672  case OSSIM_USHORT15:
673  {
674  endian.swap((ossim_uint16*)data->getBuf(),
675  data->getWidth()*data->getHeight()*data->getNumberOfBands());
676  break;
677  }
678  case OSSIM_SSHORT16:
679  {
680  endian.swap((ossim_sint16*)data->getBuf(),
681  data->getWidth()*data->getHeight()*data->getNumberOfBands());
682  break;
683  }
684  case OSSIM_FLOAT:
686  {
687  endian.swap((ossim_float32*)data->getBuf(),
688  data->getWidth()*data->getHeight()*data->getNumberOfBands());
689  break;
690  }
691  case OSSIM_DOUBLE:
693  {
694  endian.swap((ossim_float64*)data->getBuf(),
695  data->getWidth()*data->getHeight()*data->getNumberOfBands());
696  break;
697  }
698  default:
699  break;
700  }
701  }
702 
703  for(idx = 0; idx < bands; ++idx)
704  {
705  m_str->seekp(streamOffset+ // start of image stream
706  tileNumber*blockSizeInBytes + // start of block for band separate output
707  bandOffsetInBytes*idx, // which band offset is it
708  ios::beg);
709 
710  m_str->write((char*)(data->getBuf(idx)),
711  blockSizeInBytes);
712  }
713  ++tileNumber;
714 
715  setPercentComplete(((double)tileNumber / (double)numberOfTiles) * 100);
716 
717  if(!needsAborting())
718  {
720  }
721  }
722 
723  // Let's write our text header
724  if ( m_textHeader.valid() )
725  {
727  //Now write the text
728  m_str->write((char*)(m_textEntry.c_str()), m_textEntry.length());
729  }
730 
731  ossim_uint64 pos = m_str->tellp();
732 
734 
735  /*
736  * Need to change the way I compute file length and header length later
737  * We need to figure out a better way to compute.
738  */
739  m_fileHeader->setFileLength(static_cast<ossim_uint64>(pos));
740  m_fileHeader->setHeaderLength(headerLength);
741  m_str->seekp(0, ios::beg);
742  imageInfoRecord.setSubheaderLength(imageHeaderSize);
743  m_fileHeader->replaceImageInfoRecord(0, imageInfoRecord);
745 
746  return true;
747 }
748 
750  bool unique)
751 {
752  addRegisteredTag(registeredTag, unique, 1, ossimString("IXSHD"));
753 }
754 
756  bool unique, const ossim_uint32& ownerIndex, const ossimString& tagType)
757 {
758  ossimNitfTagInformation tagInfo;
759  tagInfo.setTagData(registeredTag.get());
760  tagInfo.setTagType(tagType);
761 
762  switch (ownerIndex)
763  {
764  case 0:
765  {
766  m_fileHeader->addTag(tagInfo, unique);
767  break;
768  }
769 
770  case 1:
771  {
772  m_imageHeader->addTag(tagInfo, unique);
773  break;
774  }
775 
776  default:
777  {
778  // Do nothing
779  }
780  }
781 }
782 
783 bool ossimNitfWriter::addTextToNitf(std::string &inputText)
784 {
785  // Initialize the m_textHeader
786  m_textEntry = inputText;
787  if ( m_textHeader.valid() == false )
788  {
789  // Only created if we need it.
791  }
792  return true;
793 }
795 {
796  size = m_blockSize;
797 }
798 
800 {
801  const ossim_int32 MIN_BLOCK_SIZE = 64;
802  if ( (tileSize.x % MIN_BLOCK_SIZE) || (tileSize.y % MIN_BLOCK_SIZE) )
803  {
804  if(traceDebug())
805  {
807  << "ossimNitfWriter::setTileSize ERROR:"
808  << "\nBlock size must be a multiple of " << MIN_BLOCK_SIZE
809  << "\nSize remains: " << m_blockSize
810  << std::endl;
811  }
812  }
813  else
814  {
815  m_blockSize = tileSize;
816  }
817 }
818 
819 #if 0
820 void ossimNitfWriter::addStandardTags()
821 {
822 
823  if(!theInputConnection)
824  {
825  return;
826  }
827 
828  // commenting this out for now. For some reason the pixels
829  // are off when I add this tag. I checked the parsing and it
830  // appears to be the correct length??? So, I am not sure
831  // why we are off when reading the output back in.
832  //
833  // first lets do the projection tag. I REALLY need to add
834  // parameter support soon or this tag is useless.
835  //
836  ossimKeywordlist kwl;
841  ossimNitfTagInformation tagInfo;
842 
843  if(mapProj)
844  {
845 
846  if(!PTR_CAST(ossimUtmProjection, mapProj))
847  {
849 
851  ossimString nitfName = table.convertNitfCodeToNitfProjectionName(nitfCode);
852 
853  parameterTag->setName(nitfName);
854  parameterTag->setCode(nitfCode);
855  parameterTag->setFalseX(mapProj->getFalseEasting());
856  parameterTag->setFalseY(mapProj->getFalseNorthing());
857 
858  tagInfo.setTagData(parameterTag.get());
859  m_imageHeader->addTag(tagInfo);
860  }
861  }
862 }
863 #endif
864 
866  const char* prefix) const
867 {
868  return ossimNitfWriterBase::saveState(kwl, prefix);
869 }
870 
872  const char* prefix)
873 {
874  return ossimNitfWriterBase::loadState(kwl, prefix);
875 }
876 
878 {
879  return m_imageHeader.get();
880 }
881 
883 {
884  return m_fileHeader.get();
885 }
886 
888 {
889  if (allowTreOverflow == false)
890  {
892  if ( !pId.valid() ||
893  pId->valueToString() == "TRE_OVERFLOW" ||
894  pId->valueToString() == "REGISTERED EXTENSIONS" ||
895  pId->valueToString() == "CONTROLLED EXTENSIONS")
896  {
897  return;
898  }
899  }
900 
901  m_dataExtensionSegments.push_back(des);
902 }
903 void ossimNitfWriter::takeOverflowTags(bool useFileHeader, bool userDefinedTags)
904 {
905  ossimString itemIndex;
906  std::vector<ossimNitfTagInformation> overflowTags;
907  const ossim_uint32 potentialDesIndex = m_dataExtensionSegments.size() + 1;
908 
909  if (useFileHeader)
910  {
911  m_fileHeader->takeOverflowTags(overflowTags, potentialDesIndex, userDefinedTags);
912  itemIndex = "0";
913  }
914  else
915  {
916  m_imageHeader->takeOverflowTags(overflowTags, potentialDesIndex, userDefinedTags);
917  itemIndex = "1";
918  }
919 
920  if (overflowTags.empty() == false)
921  {
925  des.setProperty(pDe);
926 
929  des.setProperty(pId);
930 
931  ossimRefPtr<ossimProperty> pVersion =
933  des.setProperty(pVersion);
934 
935  ossimRefPtr<ossimProperty> pOverflow =
936  new ossimStringProperty(ossimNitfDataExtensionSegmentV2_1::DESOFLW_KW, overflowTags[0].getTagType());
937  des.setProperty(pOverflow);
938 
941  des.setProperty(pItem);
942 
943  des.setTagList(overflowTags);
944  addDataExtensionSegment(des, true);
945  }
946 }
947 
virtual void getImageTypeList(std::vector< ossimString > &imageTypeList) const
void getImageTypeList(std::vector<ossimString>& imageTypeList)const
virtual void setProperty(ossimRefPtr< ossimProperty > property)
Set the properties.
virtual void setTileSize(const ossimIpt &tileSize)
Sets the nitf output block size.
16 bit unsigned integer (15 bits used)
virtual void valueToString(ossimString &valueResult) const =0
virtual ossim_uint32 getWidth() const
virtual ~ossimNitfWriter()
virtual bool takeOverflowTags(std::vector< ossimNitfTagInformation > &overflowTags, ossim_uint32 potentialDesIndex, bool userDefinedTags=false)
void setBlockLengthInBytes(ossim_uint32 blockLength)
void getPropertyList(std::vector< ossimRefPtr< ossimProperty > > &propertyList) const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
void setPixelType(const ossimString &pixelType=ossimString("INT"))
virtual void setFileLength(ossim_uint64 fileLength)
Sets file length (FL) field.
void setProperties(std::vector< ossimRefPtr< ossimProperty > > &propertyList)
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
virtual ossim_uint32 getNumberOfBands() const
virtual double getFalseNorthing() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the state of the writer to kwl with prefix then calls base class ossimImageFileWriter::saveStat...
void setNumberOfPixelsPerBlockRow(ossim_uint32 pixels)
virtual void getPropertyList(std::vector< ossimRefPtr< ossimProperty > > &children) const
virtual bool writeFile()
void setActualBitsPerPixel(ossim_uint32 bitsPerPixel)
virtual void setNumberOfBands(ossim_uint32 nbands)
ossim_uint32 tileNumber
Represents serializable keyword/value map.
void setDate(const ossimLocalTm &d)
Sets field FDT.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual void addDataExtSegInfoRecord(const ossimNitfDataExtSegInfoRecordV2_1 &recordInfo)
virtual void writeStream(std::ostream &out)
bool valid() const
Definition: ossimRefPtr.h:75
void setBlockCount(ossim_uint32 blockCount)
std::shared_ptr< ossim::ofstream > m_str
Currently disabled...
virtual void setProperty(ossimRefPtr< ossimProperty > property)
float ossim_float32
virtual bool addTextToNitf(std::string &inputText)
virtual void writeStream(std::ostream &out)
void setSubheaderLength(ossim_uint32 length)
ossim_uint32 height() const
Definition: ossimIrect.h:487
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
void addTag(ossimNitfTagInformation tag, bool unique=true)
static ossimString getNitfPixelType(ossimScalarType scalarType)
Get the nitf pixel type string from scalar type.
char theDataExtSegLength[10]
Is a 9 byte numeric 0-999999999.
static ossimString toString(bool aValue)
Numeric to string methods.
void setTagType(const ossimString &tagType) const
bool takeOverflowTags(std::vector< ossimNitfTagInformation > &overflowTags, ossim_uint32 potentialDesIndex, bool userDefinedTags=false)
virtual void addTag(const ossimNitfTagInformation &tag, bool unique=true)
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
virtual void setHeaderLength(ossim_uint64 headerLength)
Sets header length (HL) field.
virtual void replaceImageInfoRecord(int i, const ossimNitfImageInfoRecordV2_1 &recordInfo)
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual ossim_uint32 getHeight() const
16 bit unsigned integer (14 bits used)
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
OSSIM_DLL ossim_uint32 getActualBitsPerPixel(ossimScalarType scalarType)
Get actual bits per pixel for a given scalar type.
16 bit unsigned integer (13 bits used)
void addConstraint(const ossimString &value)
char theDataExtSegSubheaderLength[5]
Is a 4 byte numeric 200-9999.
virtual bool writeBlockBandSequential()
Outputs in band sequential format.
unsigned short ossim_uint16
virtual ossimNitfFileHeaderV2_1 * getFileHeader()
Get the file header used for export.
virtual bool writeBlockBandSeparate()
write out block band separate
virtual void addDataExtensionSegment(const ossimNitfDataExtensionSegmentV2_1 &des, bool allowTreOverflow)
Add a DES to the file.
ossimNitfWriter(const ossimFilename &filename=ossimFilename(""), ossimImageSource *inputSource=(ossimImageSource *) NULL)
#define OSSIM_DEFAULT_TILE_WIDTH
ossimString convertMapProjectionNameToNitfCode(const ossimString &mapProjectionName) const
void setBitsPerPixel(ossim_uint32 bitsPerPixel)
double ossim_float64
void setBlocksPerRow(ossim_uint32 blocks)
RTTI_DEF1(ossimNitfWriter, "ossimNitfWriter", ossimNitfWriterBase)
void setTagData(ossimRefPtr< ossimNitfRegisteredTag > tagData)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
void takeOverflowTags(bool useFileHeader, bool userDefinedTags)
virtual void getTileSize(ossimIpt &size) const
Gets the block size.
virtual ossim_uint32 getSizeInBytes() const
Returns the total number of bytes for all bands.
yy_size_t size
signed short ossim_sint16
std::vector< ossimNitfDataExtensionSegmentV2_1 > m_dataExtensionSegments
void setCategory(const ossimString &category)
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
unsigned long long ossim_uint64
void setImageLength(ossim_uint64 length)
unsigned int ossim_uint32
32 bit normalized floating point
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
OSSIM nitf writer base class to hold methods common to all nitf writers.
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
void setIncludeBlock(ossim_uint32 blockNumber, bool included)
virtual void setTagList(const std::vector< ossimNitfTagInformation > &tagList)
void setNumberOfPixelsPerBlockCol(ossim_uint32 pixels)
ossim_uint32 width() const
Definition: ossimIrect.h:500
void setEncryption(const ossimString &encryption)
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
virtual void setNumberOfRows(ossim_uint32 rows)
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
ossimRefPtr< ossimNitfFileHeaderV2_1 > m_fileHeader
ossimScalarType
OSSIM_DLL ossim_uint32 getBitsPerPixel(ossimScalarType scalarType)
Get bits per pixel for a given scalar type.
virtual void addImageInfoRecord(const ossimNitfImageInfoRecordV2_1 &recordInfo)
virtual void addChildren(std::vector< ossimRefPtr< ossimProperty > > &propertyList)
static ossimProjectionFactoryRegistry * instance()
virtual void setNumberOfCols(ossim_uint32 cols)
virtual double getFalseEasting() const
virtual ossimScalarType getScalarType() const
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
void addRegisteredTag(ossimRefPtr< ossimNitfRegisteredTag > registeredTag, bool unique=true)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Initializes the state of the writer from kwl with prefix then calls base class ossimImageFileWriter::...
ossim_int64 getNumberOfTilesHorizontal() const
void setBlocksPerCol(ossim_uint32 blocks)
virtual void initializeDefaultsFromConfigFile(ossimNitfFileHeaderV2_X *fileHdr, ossimNitfImageHeaderV2_X *imgHdr)
Sets file header and image header defaults from config file if found in preferences.
void setRepresentation(const ossimString &rep)
std::string m_textEntry
void writeGeometry(ossimNitfImageHeaderV2_X *hdr, ossimImageSourceSequencer *seq)
Populates tags with geometry info from projection.
ossim_int32 y
Definition: ossimIpt.h:142
virtual ossimNitfImageHeaderV2_1 * getImageHeader()
Get the image header used for export.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
Set the properties.
virtual bool isOpen() const
virtual const void * getBuf() const
ossimRefPtr< ossimNitfImageHeaderV2_1 > m_imageHeader
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Initializes the state of the writer from kwl with prefix then calls base class ossimImageFileWriter::...
void setComplexityLevel(std::streamoff, ossimNitfFileHeaderV2_X *hdr)
Sets the complexity level of theFileHeader.
ossimRefPtr< ossimNitfTextHeaderV2_1 > m_textHeader
virtual void writeStream(ossim::ostream &out)
#define OSSIM_DEFAULT_TILE_HEIGHT
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
str write(os2.str().data(), os2.str().size())
ossim_int32 x
Definition: ossimIpt.h:141
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property.
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property.
virtual void setBandRepresentation(const ossimString &rep)
Sets the band representation.
virtual void setPercentComplete(double percentComplete)
virtual void setTileSize(const ossimIpt &tileSize)
32 bit floating point
virtual void addTextInfoRecord(const ossimNitfTextFileInfoRecordV2_1 &recordInfo)
ossimString convertNitfCodeToNitfProjectionName(const ossimString &nitfProjectionCode) const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the state of the writer to kwl with prefix then calls base class ossimImageFileWriter::saveStat...
void setSubheaderLength(ossim_uint64 length)
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
16 bit unsigned iteger
64 bit floating point
16 bit signed integer
virtual void close()
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_int64 getNumberOfTilesVertical() const
8 bit unsigned iteger
virtual bool open()
int ossim_int32
void setJustification(const ossimString &value)
16 bit unsigned integer (12 bits used)
virtual void setBandInfo(ossim_uint32 idx, const ossimNitfImageBandV2_1 &info)