vil_geotiff_header.h
Go to the documentation of this file.
1 // This is core/vil/file_formats/vil_geotiff_header.h
2 #ifndef vil_geotiff_header_h_
3 #define vil_geotiff_header_h_
4 //:
5 // \file
6 // \author Gamze Tunali
7 // \date Jan 31, 2007
8 // \brief A header structure for geotiff files
9 //
10 // This class is responsible for extracting (putting) information
11 // from (into) the geotiff header that is required to specify a vil_image_resource
12 // There are bool flags that indicate that the item has been successfully
13 // read (written) to the open geotiff file.
14 //
15 // \verbatim
16 // Modifications
17 // <none>
18 // \endverbatim
19 
20 #include <vector>
21 #ifdef _MSC_VER
22 # include <vcl_msvc_warnings.h>
23 #endif
24 #include <tiffio.h>
25 #include <geotiffio.h>
26 
28 {
29  public:
30 
31  typedef enum {UNDEF=-1, NORTH=0, SOUTH=1} GTIF_HEMISPH;
32  vil_geotiff_header(TIFF* tif);
33 
34  // destructor frees up gtif
35  virtual ~vil_geotiff_header() { GTIFFree(gtif_); }
36 
37  int gtif_number_of_keys() const { return number_of_geokeys_; }
38 
39  bool gtif_tiepoints(std::vector<std::vector<double> > &tiepoints);
40 
41  bool gtif_pixelscale(double &scale_x, double &scale_y, double &scale_z);
42 
43  //:returns the matrix in the argument
44  bool gtif_trans_matrix (double* &trans_matrix);
45 
46  //: returns the Zone and the Hemisphere (0 for N, 1 for S);
47  bool PCS_WGS84_UTM_zone(int &zone, GTIF_HEMISPH &hemisph);
48 
49  //: returns the Zone and the Hemisphere (0 for N, 1 for S);
50  bool PCS_NAD83_UTM_zone(int &zone, GTIF_HEMISPH &hemisph);
51 
52  //: returns true if in geographic coords, linear units are in meters and angular units are in degrees
53  bool GCS_WGS84_MET_DEG();
54 
55  //: <key> : key id
56  // <value>: a single value or an array of values
57  // <size>: the size of individual key values
58  // <length> : the number of values in the value array
59  // <type>: the type of the key
60  bool get_key_value(geokey_t key, void** value,
61  int& size, int& length, tagtype_t& type);
62 
63  void print_gtif(){ if (gtif_) GTIFPrint(gtif_, nullptr, nullptr); }
64 
65  private:
66 
67  TIFF* tif_;
68  GTIF* gtif_;
69 
70  // the current version is 1, changes only Tag's key structure is changed
71  unsigned short key_directory_version_;
72 
73  // the revision number is key_revision.minor_revision
74  unsigned short key_revision_;
75  unsigned short minor_revision_;
76 
77  // the number of keys defined in the rest of the tag
79 
80  modeltype_t model_type_;
81  rastertype_t raster_type_;
82  geographic_t geographic_type_;
83  geounits_t geounits_;
84 
85  bool gtif_modeltype (modeltype_t& type);
86  bool gtif_rastertype (rastertype_t&);
87  bool geounits (geounits_t&);
88  bool geographic_type(geographic_t&);
89 };
90 
91 #endif //vil_geotiff_header_h_
unsigned short key_revision_
unsigned short key_directory_version_
bool geographic_type(geographic_t &)
bool gtif_tiepoints(std::vector< std::vector< double > > &tiepoints)
bool gtif_trans_matrix(double *&trans_matrix)
returns the matrix in the argument.
unsigned short minor_revision_
bool get_key_value(geokey_t key, void **value, int &size, int &length, tagtype_t &type)
<key> : key id.
geographic_t geographic_type_
int gtif_number_of_keys() const
rastertype_t raster_type_
bool gtif_pixelscale(double &scale_x, double &scale_y, double &scale_z)
bool PCS_WGS84_UTM_zone(int &zone, GTIF_HEMISPH &hemisph)
returns the Zone and the Hemisphere (0 for N, 1 for S);.
bool GCS_WGS84_MET_DEG()
returns true if in geographic coords, linear units are in meters and angular units are in degrees.
bool geounits(geounits_t &)
bool gtif_modeltype(modeltype_t &type)
bool gtif_rastertype(rastertype_t &)
bool PCS_NAD83_UTM_zone(int &zone, GTIF_HEMISPH &hemisph)
returns the Zone and the Hemisphere (0 for N, 1 for S);.