00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef NITFMETADATAPARSING_H 00011 #define NITFMETADATAPARSING_H 00012 00013 #include "ConfigurationSettings.h" 00014 #include "PlugInResource.h" 00015 #include "NitfResource.h" 00016 #include "NitfTreParser.h" 00017 00018 #include <map> 00019 #include <ostream> 00020 #include <string> 00021 #include <vector> 00022 00023 class DynamicObject; 00024 class RasterDataDescriptor; 00025 00026 class ossimImageFileWriter; 00027 class ossimNitfFileHeaderV2_X; 00028 class ossimNitfImageHeaderV2_X; 00029 class ossimNitfRegisteredTag; 00030 class ossimNitfTagInformation; 00031 class ossimNitfWriter; 00032 class ossimContainerProperty; 00033 class ossimProperty; 00034 class ossimString; 00035 00036 namespace Nitf 00037 { 00038 /** 00039 * This is a %Resource class for TRE parser plug-ins. 00040 * 00041 * @see TreParserShell 00042 */ 00043 class TrePlugInResource : public PlugInResource 00044 { 00045 public: 00046 /** 00047 * Construct an object to represent a TRE parser. 00048 * 00049 * @param plugInName 00050 * The name of the plug-in to construct. 00051 */ 00052 TrePlugInResource(std::string plugInName) : PlugInResource(plugInName) 00053 {} 00054 00055 /** 00056 * Destruct the TRE parser plug-in. 00057 */ 00058 TrePlugInResource() : PlugInResource() 00059 {} 00060 00061 /** 00062 * Parse a TRE and store it in a DynamicObject and RasterDataDescriptor. 00063 * 00064 * @param input 00065 * The ossimNitfRegisteredTag to read from. 00066 * @param output 00067 * The DynamicObject to write to. 00068 * @param descriptor 00069 * The RasterDataDescriptor which should be updated. 00070 * @param errorMessage 00071 * If this is modified by the function, it will be displayed to the 00072 * user as a warning that imported TREs might be incomplete, missing, etc. 00073 * 00074 * @return \c True on success, \c false otherwise. 00075 */ 00076 bool parseTag(const ossimNitfRegisteredTag& input, DynamicObject& output, 00077 RasterDataDescriptor& descriptor, std::string& errorMessage) const; 00078 00079 /** 00080 * Parse a TRE from a DynamicObject and store it in \c writer. 00081 * 00082 * @param input 00083 * The DynamicObject to read from. 00084 * @param ownerIndex 00085 * The index of the owner in \c writer. 00086 * @param tagType 00087 * The type of tag in \c writer. 00088 * @param writer 00089 * The ossimNitfWriter to write to. 00090 * @param errorMessage 00091 * %Message that exported TREs might be incomplete, missing, etc. 00092 * 00093 * @return \c True on success or if the TRE was excluded from export, \c false otherwise. 00094 */ 00095 bool writeTag(const DynamicObject& input, const ossim_uint32& ownerIndex, const ossimString& tagType, 00096 ossimNitfWriter& writer, std::string& errorMessage) const; 00097 00098 /** 00099 * Exports TRE metadata. 00100 * 00101 * @param descriptor 00102 * The RasterDataDescriptor to read from. 00103 * @param exportDescriptor 00104 * The RasterDataDescriptor to write to. 00105 * @param writer 00106 * The ossimNitfWriter to write to. 00107 * @param errorMessage 00108 * %Message that exported TREs might be incomplete, missing, etc. 00109 * 00110 * @return \c True on success or if the TRE was excluded from export, \c false otherwise. 00111 */ 00112 bool exportMetadata(const RasterDataDescriptor& descriptor, 00113 const RasterFileDescriptor& exportDescriptor, ossimNitfWriter& writer, 00114 std::string& errorMessage) const; 00115 00116 private: 00117 SETTING(ExcludedTres, TrePlugInResource, std::vector<std::string>, std::vector<std::string>()); 00118 }; 00119 00120 /** 00121 * Imports supported metadata for the specified image into a RasterDataDescriptor. 00122 * 00123 * @param currentImage 00124 * The index of the image to import. 00125 * @param pFile 00126 * The source file. 00127 * @param pFileHeader 00128 * The header of the source file. 00129 * @param pImageSubheader 00130 * The current image subheader. 00131 * @param pDescriptor 00132 * The RasterDataDescriptor to populate. 00133 * @param parsers 00134 * Contains TRE parsers which have already been loaded into memory -- included for improved performance. 00135 * @param errorMessage 00136 * %Message for import errors, etc. 00137 * 00138 * @return \c True on success, \c false otherwise. 00139 */ 00140 bool importMetadata(const unsigned int& currentImage, const Nitf::OssimFileResource& pFile, 00141 const ossimNitfFileHeaderV2_X* pFileHeader, const ossimNitfImageHeaderV2_X* pImageSubheader, 00142 RasterDataDescriptor* pDescriptor, std::map<std::string, TrePlugInResource>& parsers, std::string& errorMessage); 00143 00144 /** 00145 * Adds a single TRE to a RasterDataDescriptor. 00146 * 00147 * @param ownerIndex 00148 * The index of the owner of this TRE. 00149 * @param tagInfo 00150 * Information about the TRE. 00151 * @param pDescriptor 00152 * The RasterDataDescriptor to populate. 00153 * @param pTres 00154 * The DynamicObject containing the TREs. 00155 * @param pTreInfo 00156 * The DynamicObject containing the locations of the TREs. 00157 * @param parsers 00158 * Contains TRE parsers which have already been loaded into memory -- included for performance. 00159 * @param errorMessage 00160 * %Message for import errors, etc. 00161 * 00162 * @return \c True on success, \c false otherwise. 00163 */ 00164 bool addTagToMetadata(const unsigned int& ownerIndex, 00165 const ossimNitfTagInformation& tagInfo, RasterDataDescriptor* pDescriptor, DynamicObject* pTres, 00166 DynamicObject* pTreInfo, std::map<std::string, TrePlugInResource>& parsers, std::string& errorMessage); 00167 00168 /** 00169 * Exports supported metadata for the specified image into \c pNitf. 00170 * 00171 * @param pDescriptor 00172 * The RasterDataDescriptor containing the metadata to export. 00173 * @param pExportDescriptor 00174 * The RasterFileDescriptor for export. 00175 * @param pNitf 00176 * The ossimNitfWriter to populate. 00177 * @param pProgress 00178 * The Progress object to use. 00179 * 00180 * @return \c True on success, \c false otherwise. 00181 */ 00182 bool exportMetadata(const RasterDataDescriptor* pDescriptor, 00183 const RasterFileDescriptor* pExportDescriptor, 00184 ossimNitfWriter* pNitf, Progress* pProgress); 00185 } 00186 00187 #endif