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   //: returns the Zone and the Hemisphere (0 for N, 1 for S);
00050   bool PCS_NAD83_UTM_zone(int &zone, GTIF_HEMISPH &hemisph);
00051 
00052   //: returns true if in geographic coords, linear units are in meters and angular units are in degrees
00053   bool GCS_WGS84_MET_DEG();
00054 
00055   //: <key> : key id
00056   // <value>: a single value or an array of values
00057   // <size>:  the size of individual key values
00058   // <length> : the number of values in the value array
00059   // <type>: the type of the key
00060   bool get_key_value(geokey_t key, void** value,
00061                      int& size, int& length, tagtype_t& type);
00062 
00063   void print_gtif(){ if (gtif_) GTIFPrint(gtif_, 0, 0); }
00064 
00065  private:
00066 
00067   TIFF* tif_;
00068   GTIF* gtif_;
00069 
00070   // the current version is 1, changes only Tag's key structure is changed
00071   unsigned short key_directory_version_;
00072 
00073   // the revision number is key_revision.minor_revision
00074   unsigned short key_revision_;
00075   unsigned short minor_revision_;
00076 
00077   // the number of keys defined in the rest of the tag
00078   int number_of_geokeys_;
00079 
00080   modeltype_t model_type_;
00081   rastertype_t raster_type_;
00082   geographic_t geographic_type_;
00083   geounits_t geounits_;
00084 
00085   bool gtif_modeltype (modeltype_t& type);
00086   bool gtif_rastertype (rastertype_t&);
00087   bool geounits (geounits_t&);
00088   bool geographic_type(geographic_t&);
00089 };
00090 
00091 #endif //vil_geotiff_header_h_