Exemplo n.º 1
0
void ossimNitfFileHeaderV2_1::writeStream(std::ostream &out)
{
   out.write(theFileTypeVersion, 9);
   out.write(theComplexityLevel, 2);
   out.write(theSystemType, 4);
   out.write(theOriginatingStationId, 10);
   out.write(theDateTime, 14);
   out.write(theFileTitle, 80);
   out.write(theSecurityClassification, 1);
   out.write(theSecurityClassificationSys, 2);
   out.write(theCodewords, 11);
   out.write(theControlAndHandling, 2);
   out.write(theReleasingInstructions, 20);
   out.write(theDeclassificationType, 2);
   out.write(theDeclassificationDate, 8);
   out.write(theDeclassificationExemption, 4);
   out.write(theDowngrade, 1);
   out.write(theDowngradingDate, 8);
   out.write(theClassificationText, 43);
   out.write(theClassificationAuthorityType, 1);
   out.write(theClassificationAuthority, 40);
   out.write(theClassificationReason, 1);
   out.write(theSecuritySourceDate, 8);
   out.write(theSecurityControlNumber, 15);
   out.write(theCopyNumber, 5);
   out.write(theNumberOfCopies, 5);
   out.write(theEncryption, 1);
   out.write((char*)theFileBackgroundColor, 3);
   out.write(theOriginatorsName, 24);
   out.write(theOriginatorsPhone, 18);
   out.write(theFileLength, 12);
   out.write(theHeaderLength, 6);
   ossim_uint32 idx = 0;
   {
      ostringstream outString;
      
      
      outString << std::setw(3)
                << std::setfill('0')
                << std::setiosflags(ios::right)
                << theNitfImageInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      
      for(idx = 0; idx < theNitfImageInfoRecords.size(); ++idx)
      {
         out.write(theNitfImageInfoRecords[idx].theImageSubheaderLength, 6);
         out.write(theNitfImageInfoRecords[idx].theImageLength, 10);
      }
   }
   {
      ostringstream outString;
      
      
      outString << std::setw(3)
                << std::setfill('0')
                << std::setiosflags(ios::right)
                << theNitfGraphicInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      for(idx = 0; idx < theNitfGraphicInfoRecords.size(); ++idx)
      {
         out.write(theNitfGraphicInfoRecords[idx].theGraphicSubheaderLength, 4);
         out.write(theNitfGraphicInfoRecords[idx].theGraphicLength, 6);
      }
   }
   out.write(theReservedForFutureUse1, 3);
   {
      ostringstream outString;
      
      
      outString << std::setw(3)
                << std::setfill('0')
                << std::setiosflags(ios::right)
                << theNitfTextFileInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      for(idx = 0; idx < theNitfTextFileInfoRecords.size(); ++idx)
      {
         out.write(theNitfTextFileInfoRecords[idx].theTextFileSubheaderLength, 4);
         out.write(theNitfTextFileInfoRecords[idx].theTextFileLength, 5);
      }
   }
   {
      ostringstream outString;
      
      
      outString << std::setw(3)
                << std::setfill('0')
                << std::setiosflags(ios::right)
                << theNitfDataExtSegInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      for(idx = 0; idx < theNitfDataExtSegInfoRecords.size(); ++idx)
      {
         out.write(theNitfDataExtSegInfoRecords[idx].theDataExtSegSubheaderLength, 4);
         out.write(theNitfDataExtSegInfoRecords[idx].theDataExtSegLength, 9);
      }
   }
   {
      ostringstream outString;
      
      
      outString << std::setw(3)
                << std::setfill('0')
                << std::setiosflags(ios::right)
                << theNitfResExtSegInfoRecords.size();

      out.write(outString.str().c_str(), 3);
      for(idx = 0; idx < theNitfResExtSegInfoRecords.size(); ++idx)
      {
         out.write(theNitfResExtSegInfoRecords[idx].theResExtSegSubheaderLength, 4);
         out.write(theNitfResExtSegInfoRecords[idx].theResExtSegLength, 7);
      }
   }
   out.write(theUserDefinedHeaderDataLength, 5);
   if(ossimString(theUserDefinedHeaderDataLength).toInt32() > 0)
   {
      out.write(theUserDefinedHeaderOverflow, 3);
   }

   ossim_uint32 totalLength = getTotalTagLength();
   if(totalLength <= 99999)
   {
      std::ostringstream tempOut;

      tempOut << std::setw(5)
              << std::setfill('0')
	      << std::setiosflags(ios::right)
              << totalLength;
      
      memcpy(theExtendedHeaderDataLength, tempOut.str().c_str(), 5);
      
      out.write(theExtendedHeaderDataLength, 5);

      // for now we hard code the 000 for we do not currently support writing to the DES if the total tag length is
      // larger than supported
      //
      memset(theExtendedHeaderDataOverflow, '0', 3);

      if(totalLength > 0)
      {
         out.write(theExtendedHeaderDataOverflow, 3);
         ossim_uint32 i = 0;
         
         for(i = 0; i < theTagList.size(); ++i)
         {
            theTagList[i].writeStream(out);
         }
      }
   }
   else
   {
      ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimNitfFileHeaderV2_1::writeStream: Only support writing of total tag length < 99999" << std::endl;
   }
}
Exemplo n.º 2
0
void ossimNitfImageHeaderV2_1::writeStream(std::ostream &out)
{
   out.write(theType, 2);
   out.write(theImageId, 10);
   out.write(theDateTime,14);
   out.write(theTargetId, 17);
   out.write(theTitle, 80);
   out.write(theSecurityClassification, 1);
   out.write(theSecurityClassificationSys, 2);
   out.write(theCodewords, 11);
   out.write(theControlAndHandling, 2);
   out.write(theReleasingInstructions, 20);
   out.write(theDeclassificationType, 2);
   out.write(theDeclassificationDate, 8);
   out.write(theDeclassificationExempt, 4);
   out.write(theDowngrade, 1);
   out.write(theDowngradeDate, 8);
   out.write(theClassificationText, 43);
   out.write(theClassificationAuthType, 1);
   out.write(theClassificationAuthority, 40);
   out.write(theClassificationReason, 1);
   out.write(theSecuritySourceDate, 8);
   out.write(theSecurityControlNumber, 15);
   out.write(theEncryption, 1);
   out.write(theImageSource, 42);
   out.write(theSignificantRows, 8);
   out.write(theSignificantCols, 8);
   out.write(thePixelValueType, 3);
   out.write(theRepresentation, 8);
   out.write(theCategory, 8);
   out.write(theActualBitsPerPixelPerBand, 2);
   out.write(theJustification, 1);
   out.write(theCoordinateSystem, 1);
   
   if(theCoordinateSystem[0] != ' ')
   {
      out.write(theGeographicLocation, 60);
   }
   // for now force the number of comments to be 0
   out.write(theNumberOfComments, 1);
   
   out.write(theCompression, 2);
   ossimString compressionTest = theCompression;
   if(compressionTest != "NC" &&
      compressionTest != "NM")
     {
      out.write(theCompressionRateCode, 4);
     }

   out.write(theNumberOfBands, 1);

   if(ossimString(theNumberOfBands).toInt32() == 0)
   {
      out.write(theNumberOfMultispectralBands, 5);
   }

   if(theImageBands.size())
   {
      ossim_uint32 idx = 0;
      for(idx = 0; idx < theImageBands.size(); ++idx)
      {
         theImageBands[idx]->writeStream(out);
      }
   }

   out.write(theImageSyncCode, 1);
   out.write(theImageMode, 1);
   out.write(theNumberOfBlocksPerRow, 4);
   out.write(theNumberOfBlocksPerCol, 4);
   out.write(theNumberOfPixelsPerBlockHoriz, 4);
   out.write(theNumberOfPixelsPerBlockVert, 4);
   out.write(theNumberOfBitsPerPixelPerBand, 2);
   out.write(theDisplayLevel, 3);
   out.write(theAttachmentLevel, 3);
   out.write(theImageLocation, 10);
   out.write(theImageMagnification, 4);
   out.write(theUserDefinedImageDataLength, 5);

   if(ossimString(theUserDefinedImageDataLength).toInt32() > 0)
   {
      out.write(theUserDefinedOverflow, 3);
   }

   // need to ouput tagged data
   // here
   //
   ossim_uint32 totalLength = getTotalTagLength();

   if (totalLength == 0)
   {
      out.write(theExtendedSubheaderDataLen, 5);
   }
   else
   {
      totalLength += 3; // per Table A-3 of MIL-STD-2500B
      
      if(totalLength <= 99999)
      {
         std::ostringstream tempOut;
         
         tempOut << std::setw(5)
                 << std::setfill('0')
                 << std::setiosflags(ios::right)
                 << totalLength;
         
         memcpy(theExtendedSubheaderDataLen, tempOut.str().c_str(), 5);
         
         out.write(theExtendedSubheaderDataLen, 5);
         memset(theExtendedSubheaderOverflow, '0', 3);
         
         if(totalLength > 0)
         {
            out.write(theExtendedSubheaderOverflow, 3);
            
            ossim_uint32 i = 0;
            
            for(i = 0; i < theTagList.size(); ++i)
            {
               theTagList[i].writeStream(out);
            }
         }
      }
      else
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << "WARNING ossimNitfFileHeaderV2_1::writeStream: Only support writing of total tag length < 99999" << std::endl;
      }
   }
}
Exemplo n.º 3
0
void ossimNitfImageHeaderV2_0::writeStream(std::ostream &out)
{
   out.write(theType, 2);
   out.write(theImageId, 10);
   out.write(theDateTime, 14);
   out.write(theTargetId, 17);
   out.write(theTitle, 80);
   out.write(theSecurityClassification, 1);
   out.write(theCodewords, 40);
   out.write(theControlAndHandling, 40);
   out.write(theReleasingInstructions, 40);
   out.write(theClassificationAuthority, 20);
   out.write(theSecurityControlNumber, 20);
   out.write(theSecurityDowngrade, 6);
   if(ossimString(theSecurityDowngrade) == "999998")
   {
      out.write(theDowngradingEvent, 40);
   }
   out.write(theEncryption, 1);
   out.write(theImageSource, 42);
   out.write(theSignificantRows, 8);
   out.write(theSignificantCols, 8);
   out.write(thePixelValueType, 3);
   out.write(theRepresentation, 8);
   out.write(theCategory, 8);
   out.write(theActualBitsPerPixelPerBand, 2);
   out.write(theJustification, 1);
   out.write(theCoordinateSystem, 1);
   if(theCoordinateSystem[0] != 'N')
   {
      out.write(theGeographicLocation, 60);
   }
   out.write(theNumberOfComments, 1);
   out.write(theCompression, 2);
   if(ossimString(theCompression) != "NC")
   {
      out.write(theCompressionRateCode, 4);
   }
   out.write(theNumberOfBands, 1);
   ossim_uint32 bandIdx = 0;
   for(bandIdx=0;bandIdx<theImageBands.size();++bandIdx)
   {
      theImageBands[bandIdx]->writeStream(out);
   }
   out.write(theImageSyncCode, 1);
   out.write(theImageMode, 1);
   out.write(theNumberOfBlocksPerRow, 4);
   out.write(theNumberOfBlocksPerCol, 4);
   out.write(theNumberOfPixelsPerBlockHoriz, 4);
   out.write(theNumberOfPixelsPerBlockVert, 4);
   out.write(theNumberOfBitsPerPixelPerBand, 2);
   out.write(theDisplayLevel, 3);
   out.write(theAttachmentLevel, 3);
   out.write(theImageLocation, 10);
   out.write(theImageMagnification, 4);
   out.write(theUserDefinedImageDataLength, 5);
   if(ossimString(theUserDefinedImageDataLength).toInt32() > 0)
   {
      out.write(theUserDefinedOverflow, 3);
   }
   ossim_uint32 totalLength = getTotalTagLength();
   
   if(totalLength == 0)
   {
      //memcpy(theExtendedSubheaderDataLen, "00000", 5);
      out.write(theExtendedSubheaderDataLen, 5);
   }
   else
   {
      totalLength += 3; // per Table A-3 of MIL-STD-2500B
      
      if(totalLength <= 99999)
      {
         std::ostringstream tempOut;
         
         tempOut << std::setw(5)
         << std::setfill('0')
         << std::setiosflags(ios::right)
         << totalLength;
         
         memcpy(theExtendedSubheaderDataLen, tempOut.str().c_str(), 5);
         
         out.write(theExtendedSubheaderDataLen, 5);
         memset(theExtendedSubheaderOverflow, '0', 3);
         
         if(totalLength > 0)
         {
            out.write(theExtendedSubheaderOverflow, 3);
            
            ossim_uint32 i = 0;
            
            for(i = 0; i < theTagList.size(); ++i)
            {
               theTagList[i].writeStream(out);
            }
         }
      }
      else
      {
         ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimNitfFileHeaderV2_0::writeStream: Only support writing of total tag length < 99999" << std::endl;
      }
   }
}
Exemplo n.º 4
0
void ossimNitfFileHeaderV2_0::writeStream(std::ostream &out)
{
   // identification and origination group
   out.write(theFileTypeVersion, 9);
   out.write(theComplexityLevel, 2);
   out.write(theSystemType, 4);
   out.write(theOriginatingStationId, 10);
   out.write(theDateTime, 14);
   out.write(theFileTitle, 80);
   
   // read security group
   out.write(theSecurityClassification, 1);
   out.write(theCodewords, 40);
   out.write(theControlAndHandling, 40);
   out.write(theReleasingInstructions, 40);
   out.write(theClassificationAuthority, 20);
   out.write(theSecurityControlNumber, 20);
   out.write(theSecurityDowngrade, 6);
   if(ossimString(theSecurityDowngrade) == "999998")
   {
      out.write(theDowngradingEvent, 40);
   }      
   out.write(theCopyNumber, 5);
   out.write(theNumberOfCopies, 5);
   out.write(theEncryption, 1);
   out.write(theOriginatorsName, 27);
   out.write(theOriginatorsPhone, 18);
   
   out.write(theFileLength, 12);
   out.write(theHeaderLength, 6);   
   ossim_uint32 idx = 0;
   {
      ostringstream outString;
      
      
      outString << std::setw(3)
      << std::setfill('0')
      << std::setiosflags(ios::right)
      << theNitfImageInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      
      for(idx = 0; idx < theNitfImageInfoRecords.size(); ++idx)
      {
         out.write(theNitfImageInfoRecords[idx].theImageSubheaderLength, 6);
         out.write(theNitfImageInfoRecords[idx].theImageLength, 10);
      }
   }
   {
      ostringstream outString;
      
      outString << std::setw(3)
      << std::setfill('0')
      << std::setiosflags(ios::right)
      << theNitfSymbolInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      
      for(idx = 0; idx < theNitfSymbolInfoRecords.size(); ++idx)
      {
         out.write(theNitfSymbolInfoRecords[idx].theSymbolSubheaderLength, 4);
         out.write(theNitfSymbolInfoRecords[idx].theSymbolLength, 6);
      }
   }
   {
      ostringstream outString;
      
      outString << std::setw(3)
      << std::setfill('0')
      << std::setiosflags(ios::right)
      << theNitfLabelInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      
      for(idx = 0; idx < theNitfLabelInfoRecords.size(); ++idx)
      {
         out.write(theNitfLabelInfoRecords[idx].theLabelSubheaderLength, 4);
         out.write(theNitfLabelInfoRecords[idx].theLabelLength, 3);
      }
   }
   {
      ostringstream outString;
      
      outString << std::setw(3)
      << std::setfill('0')
      << std::setiosflags(ios::right)
      << theNitfTextInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      
      for(idx = 0; idx < theNitfTextInfoRecords.size(); ++idx)
      {
         out.write(theNitfTextInfoRecords[idx].theTextSubheaderLength, 4);
         out.write(theNitfTextInfoRecords[idx].theTextLength, 5);
      }
   }
   {
      ostringstream outString;
      
      outString << std::setw(3)
      << std::setfill('0')
      << std::setiosflags(ios::right)
      << theNitfDataExtSegInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      
      for(idx = 0; idx < theNitfDataExtSegInfoRecords.size(); ++idx)
      {
         out.write(theNitfDataExtSegInfoRecords[idx].theDataExtSegSubheaderLength, 4);
         out.write(theNitfDataExtSegInfoRecords[idx].theDataExtSegLength, 9);
      }
   }
   {
      ostringstream outString;
      
      outString << std::setw(3)
      << std::setfill('0')
      << std::setiosflags(ios::right)
      << theNitfResExtSegInfoRecords.size();
      
      out.write(outString.str().c_str(), 3);
      
      for(idx = 0; idx < theNitfResExtSegInfoRecords.size(); ++idx)
      {
         out.write(theNitfResExtSegInfoRecords[idx].theResExtSegSubheaderLength, 4);
         out.write(theNitfResExtSegInfoRecords[idx].theResExtSegLength, 7);
      }
   }
   out.write(theUserDefinedHeaderDataLength, 5);
   if(ossimString(theUserDefinedHeaderDataLength).toInt32() > 0)
   {
      out.write(theUserDefinedHeaderOverflow, 3);
   }
   ossim_uint32 totalLength = getTotalTagLength();
   if(totalLength <= 99999)
   {
      std::ostringstream tempOut;
      
      tempOut << std::setw(5)
      << std::setfill('0')
      << std::setiosflags(ios::right)
      << totalLength;
      
      memcpy(theExtendedHeaderDataLength, tempOut.str().c_str(), 5);
      
      out.write(theExtendedHeaderDataLength, 5);
      
      // for now we hard code te 000 for we do not currently support writing to the DES if the total tag length is
      // larger than supported
      //
      memset(theExtendedHeaderOverflow, '0', 3);
      if(totalLength > 0)
      {
         ossim_uint32 i = 0;
         out.write(theExtendedHeaderOverflow, 3);
         
         for(i = 0; i < theTagList.size(); ++i)
         {
            theTagList[i].writeStream(out);
         }
      }
   }
   else
   {
      ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimNitfFileHeaderV2_0::writeStream: Only support writing of total tag length < 99999" << std::endl;
   }
}