core/vil/file_formats/vil_geotiff_header.h
Go to the documentation of this file.
00001 // This is core/vil/file_formats/vil_geotiff_header.h
00002 #ifndef vil_geotiff_header_h_
00003 #define vil_geotiff_header_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author    Gamze Tunali
00010 // \date      Jan 31, 2007
00011 // \brief A header structure for geotiff files
00012 //
00013 // This class is responsible for extracting (putting) information
00014 // from (into) the geotiff header that is required to specify a vil_image_resource
00015 // There are bool flags that indicate that the item has been successfully
00016 // read (written) to the open geotiff file.
00017 //
00018 // \verbatim
00019 //  Modifications
00020 //   <none>
00021 // \endverbatim
00022 
00023 #include <vcl_vector.h>
00024 #include <tiffio.h>
00025 #include <geotiffio.h>
00026 
00027 class vil_geotiff_header
00028 {
00029  public:
00030 
00031   typedef enum {UNDEF=-1, NORTH=0, SOUTH=1} GTIF_HEMISPH;
00032   vil_geotiff_header(TIFF* tif);
00033 
00034   // destructor frees up gtif
00035   virtual ~vil_geotiff_header() { GTIFFree(gtif_); }
00036 
00037   int gtif_number_of_keys() const { return number_of_geokeys_; }
00038 
00039   bool gtif_tiepoints(vcl_vector<vcl_vector<double> > &tiepoints);
00040 
00041   bool gtif_pixelscale(double &scale_x, double &scale_y, double &scale_z);
00042 
00043   //:returns the matrix in the argument
00044   bool gtif_trans_matrix (double* &trans_matrix);
00045 
00046   //: returns the Zone and the Hemisphere (0 for N, 1 for S);
00047   bool PCS_WGS84_UTM_zone(int &zone, GTIF_HEMISPH &hemisph);
00048 
00049   //: <key> : key id
00050   // <value>: a single value or an array of values
00051   // <size>:  the size of individual key values
00052   // <length> : the number of values in the value array
00053   // <type>: the type of the key
00054   bool get_key_value(geokey_t key, void** value,
00055                      int& size, int& length, tagtype_t& type);
00056 
00057   void print_gtif(){ if (gtif_) GTIFPrint(gtif_, 0, 0); }
00058 
00059  private:
00060 
00061   TIFF* tif_;
00062   GTIF* gtif_;
00063 
00064   // the current version is 1, changes only Tag's key structure is changed
00065   unsigned short key_directory_version_;
00066 
00067   // the revision number is key_revision.minor_revision
00068   unsigned short key_revision_;
00069   unsigned short minor_revision_;
00070 
00071   // the number of keys defined in the rest of the tag
00072   int number_of_geokeys_;
00073 
00074   modeltype_t model_type_;
00075   rastertype_t raster_type_;
00076   geographic_t geographic_type_;
00077   geounits_t geounits_;
00078 
00079   bool gtif_modeltype (modeltype_t& type);
00080   bool gtif_rastertype (rastertype_t&);
00081   bool geounits (geounits_t&);
00082   bool geographic_type(geographic_t&);
00083 };
00084 
00085 #endif //vil_geotiff_header_h_