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 NITFIMPORTERSHELL_H 00011 #define NITFIMPORTERSHELL_H 00012 00013 #include "RasterElementImporterShell.h" 00014 00015 #include <ossim/base/ossimConstants.h> 00016 #include <string> 00017 #include <map> 00018 00019 class ossimNitfFile; 00020 class ossimNitfFileHeaderV2_X; 00021 class ossimNitfImageHeaderV2_X; 00022 00023 namespace Nitf 00024 { 00025 /** 00026 * Base class for NITF importers. 00027 */ 00028 class NitfImporterShell : public RasterElementImporterShell 00029 { 00030 public: 00031 /** 00032 * Creates the NITF importer plug-in. 00033 * 00034 * @see RasterElementImporterShell 00035 */ 00036 NitfImporterShell(); 00037 00038 /** 00039 * Destroys the NITF importer plug-in. 00040 */ 00041 virtual ~NitfImporterShell(); 00042 00043 /** 00044 * @copydoc RasterElementImporterShell::getImportDescriptors() 00045 * 00046 * @default The default implementation returns image segments which can be imported by this importer. 00047 */ 00048 virtual std::vector<ImportDescriptor*> getImportDescriptors(const std::string& filename); 00049 00050 /** 00051 * @copydoc RasterElementImporterShell::getFileAffinity() 00052 * 00053 * @default The default implementation returns Importer::CAN_LOAD for all NITF 2.00 and NITF 2.10 files. 00054 */ 00055 virtual unsigned char getFileAffinity(const std::string& filename); 00056 00057 /** 00058 * @copydoc RasterElementImporterShell::validate() 00059 * \par 00060 * The default implementation also returns warnings when lookup tables (LUTs) or other issues are detected. 00061 */ 00062 virtual bool validate(const DataDescriptor* pDescriptor, std::string& errorMessage) const; 00063 00064 /** 00065 * @copydoc RasterElementImporterShell::createView() 00066 * 00067 * @default The default implementation sets the background color. 00068 */ 00069 virtual SpatialDataView* createView() const; 00070 00071 /** 00072 * @copydoc RasterElementImporterShell::getGeoreferencePlugIn() 00073 * 00074 * @default The default implementation returns the RPC %Georeference 00075 * plug-in when available and GCP %Georeference otherwise. 00076 */ 00077 virtual PlugIn* getGeoreferencePlugIn() const; 00078 00079 /** 00080 * @copydoc RasterElementImporterShell::createRasterPager() 00081 * 00082 * @default The default implementation creates an instance of the internal "NitfPager" plug-in. 00083 */ 00084 virtual bool createRasterPager(RasterElement* pRaster) const; 00085 00086 /** 00087 * Return the data type of the specified image. 00088 * 00089 * @param pImgHeader 00090 * The parsed subheader for this image segment. 00091 * 00092 * @return The EncodingType to use for the specified image header. 00093 */ 00094 static EncodingType ossimImageHeaderToEncodingType(ossimNitfImageHeaderV2_X* pImgHeader); 00095 00096 protected: 00097 /** 00098 * @copydoc ImporterShell::getValidationTest() 00099 * 00100 * \par 00101 * The following raster-specific tests are added to the base class defaults 00102 * listed above: 00103 * - \link ImporterShell::VALID_CLASSIFICATION VALID_CLASSIFICATION \endlink 00104 * - \link ImporterShell::RASTER_SIZE RASTER_SIZE \endlink 00105 * - \link ImporterShell::VALID_DATA_TYPE VALID_DATA_TYPE \endlink 00106 * - \link ImporterShell::VALID_METADATA VALID_METADATA \endlink 00107 * . 00108 * \par 00109 * Additionally, the following test is added if the ::ProcessingLocation is 00110 * ::IN_MEMORY: 00111 * - \link ImporterShell::AVAILABLE_MEMORY AVAILABLE_MEMORY \endlink 00112 * . 00113 * \par 00114 * The following tests are added if the ::ProcessingLocation is 00115 * ::ON_DISK_READ_ONLY: 00116 * - \link ImporterShell::NO_INTERLEAVE_CONVERSIONS NO_INTERLEAVE_CONVERSIONS \endlink 00117 * - \link ImporterShell::NO_SUBSETS NO_SUBSETS \endlink 00118 * - \link ImporterShell::NO_SKIP_FACTORS NO_SKIP_FACTORS \endlink 00119 * - \link ImporterShell::NO_BAND_FILES NO_BAND_FILES \endlink 00120 * . 00121 * \par 00122 * The following tests are added if the ::InterleaveFormatType is not ::BSQ: 00123 * - \link ImporterShell::NO_PRE_POST_BAND_BYTES NO_PRE_POST_BAND_BYTES \endlink 00124 * - \link ImporterShell::NO_BAND_FILES NO_BAND_FILES \endlink 00125 * . 00126 * \par 00127 * The following test is added if multiple band files are present: 00128 * - \link ImporterShell::EXISTING_BAND_FILES EXISTING_BAND_FILES \endlink 00129 * . 00130 */ 00131 virtual int getValidationTest(const DataDescriptor* pDescriptor) const; 00132 00133 /** 00134 * Allocate and return an ImportDescriptor for the specified image. This method should allocate an 00135 * ImportDescriptor (if desired) and set whether it is imported by default. This method should not set any fields 00136 * in the data descriptor or the file descriptor of the import descriptor. If changes to the defaults are 00137 * required, the subclass should override getImportDescriptors(), call the base class implementation, and then 00138 * make the necessary changes. 00139 * 00140 * @param filename 00141 * The full path and name of the file. 00142 * 00143 * @param imageName 00144 * The name which will be used for image identification. This is a string of the form "I1", "I2", etc. 00145 * Using this name for the import descriptor is optional. This name will be used for the default pager and 00146 * image segment. 00147 * 00148 * @param pFile 00149 * The NITF file being loaded. 00150 * 00151 * @param pFileHeader 00152 * The parsed header for this NITF file. 00153 * 00154 * @param pImageSubheader 00155 * The parsed subheader for this image segment. 00156 * 00157 * @return A pointer to a newly created ImportDescriptor or \c NULL if no ImportDescriptor should be created. 00158 * 00159 * @see getImportDescriptors() 00160 * 00161 * @default The default implementation returns a descriptor marked as 00162 * imported for all image segments except those marked as NODISPLY. 00163 */ 00164 virtual ImportDescriptor* getImportDescriptor(const std::string& filename, const std::string& imageName, 00165 const ossimNitfFile* pFile, const ossimNitfFileHeaderV2_X* pFileHeader, 00166 const ossimNitfImageHeaderV2_X* pImageSubheader); 00167 00168 private: 00169 std::map<std::string, std::string> mParseMessages; 00170 }; 00171 } 00172 #endif