@@ -6,6 +6,7 @@ use num_enum::{IntoPrimitive, TryFromPrimitive};
6
6
use tiff:: decoder:: ifd:: Value ;
7
7
use tiff:: { TiffError , TiffResult } ;
8
8
9
+ /// Geospatial TIFF tag variants
9
10
#[ derive( Clone , Copy , Debug , PartialEq , TryFromPrimitive , IntoPrimitive , Eq , Hash ) ]
10
11
#[ repr( u16 ) ]
11
12
pub enum GeoKeyTag {
@@ -63,60 +64,75 @@ pub enum GeoKeyTag {
63
64
VerticalUnits = 4099 ,
64
65
}
65
66
66
- /// http://docs.opengeospatial.org/is/19-008r4/19-008r4.html#_requirements_class_geokeydirectorytag
67
+ /// Metadata defined by the GeoTIFF standard.
68
+ ///
69
+ /// <http://docs.opengeospatial.org/is/19-008r4/19-008r4.html#_requirements_class_geokeydirectorytag>
67
70
#[ derive( Debug , Clone ) ]
68
71
pub struct GeoKeyDirectory {
69
- model_type : Option < u16 > ,
70
- raster_type : Option < u16 > ,
71
- citation : Option < String > ,
72
+ pub model_type : Option < u16 > ,
73
+ pub raster_type : Option < u16 > ,
74
+ pub citation : Option < String > ,
72
75
73
- geographic_type : Option < u16 > ,
74
- geog_citation : Option < String > ,
75
- geog_geodetic_datum : Option < u16 > ,
76
- geog_prime_meridian : Option < u16 > ,
77
- geog_linear_units : Option < u16 > ,
78
- geog_linear_unit_size : Option < f64 > ,
79
- geog_angular_units : Option < u16 > ,
80
- geog_angular_unit_size : Option < f64 > ,
81
- geog_ellipsoid : Option < u16 > ,
82
- geog_semi_major_axis : Option < f64 > ,
83
- geog_semi_minor_axis : Option < f64 > ,
84
- geog_inv_flattening : Option < f64 > ,
85
- geog_azimuth_units : Option < u16 > ,
86
- geog_prime_meridian_long : Option < f64 > ,
76
+ pub geographic_type : Option < u16 > ,
77
+ pub geog_citation : Option < String > ,
78
+ pub geog_geodetic_datum : Option < u16 > ,
87
79
88
- projected_type : Option < u16 > ,
89
- proj_citation : Option < String > ,
90
- projection : Option < u16 > ,
91
- proj_coord_trans : Option < u16 > ,
92
- proj_linear_units : Option < u16 > ,
93
- proj_linear_unit_size : Option < f64 > ,
94
- proj_std_parallel1 : Option < f64 > ,
95
- proj_std_parallel2 : Option < f64 > ,
96
- proj_nat_origin_long : Option < f64 > ,
97
- proj_nat_origin_lat : Option < f64 > ,
98
- proj_false_easting : Option < f64 > ,
99
- proj_false_northing : Option < f64 > ,
100
- proj_false_origin_long : Option < f64 > ,
101
- proj_false_origin_lat : Option < f64 > ,
102
- proj_false_origin_easting : Option < f64 > ,
103
- proj_false_origin_northing : Option < f64 > ,
104
- proj_center_long : Option < f64 > ,
105
- proj_center_lat : Option < f64 > ,
106
- proj_center_easting : Option < f64 > ,
107
- proj_center_northing : Option < f64 > ,
108
- proj_scale_at_nat_origin : Option < f64 > ,
109
- proj_scale_at_center : Option < f64 > ,
110
- proj_azimuth_angle : Option < f64 > ,
111
- proj_straight_vert_pole_long : Option < f64 > ,
80
+ /// This key is used to specify a Prime Meridian from the GeoTIFF CRS register or to indicate
81
+ /// that the Prime Meridian is user-defined. The default is Greenwich, England.
82
+ /// <https://docs.ogc.org/is/19-008r4/19-008r4.html#_requirements_class_primemeridiangeokey>
83
+ pub geog_prime_meridian : Option < u16 > ,
112
84
113
- vertical : Option < u16 > ,
114
- vertical_citation : Option < String > ,
115
- vertical_datum : Option < u16 > ,
116
- vertical_units : Option < u16 > ,
85
+ pub geog_linear_units : Option < u16 > ,
86
+ pub geog_linear_unit_size : Option < f64 > ,
87
+ pub geog_angular_units : Option < u16 > ,
88
+ pub geog_angular_unit_size : Option < f64 > ,
89
+
90
+ /// This key is provided to specify an ellipsoid (or sphere) from the GeoTIFF CRS register or
91
+ /// to indicate that the ellipsoid (or sphere) is user-defined.
92
+ pub geog_ellipsoid : Option < u16 > ,
93
+ pub geog_semi_major_axis : Option < f64 > ,
94
+ pub geog_semi_minor_axis : Option < f64 > ,
95
+ pub geog_inv_flattening : Option < f64 > ,
96
+ pub geog_azimuth_units : Option < u16 > ,
97
+
98
+ /// This key allows definition of a user-defined Prime Meridian, the location of which is
99
+ /// defined by its longitude relative to the international reference meridian (for the earth
100
+ /// this is Greenwich).
101
+ pub geog_prime_meridian_long : Option < f64 > ,
102
+
103
+ pub projected_type : Option < u16 > ,
104
+ pub proj_citation : Option < String > ,
105
+ pub projection : Option < u16 > ,
106
+ pub proj_coord_trans : Option < u16 > ,
107
+ pub proj_linear_units : Option < u16 > ,
108
+ pub proj_linear_unit_size : Option < f64 > ,
109
+ pub proj_std_parallel1 : Option < f64 > ,
110
+ pub proj_std_parallel2 : Option < f64 > ,
111
+ pub proj_nat_origin_long : Option < f64 > ,
112
+ pub proj_nat_origin_lat : Option < f64 > ,
113
+ pub proj_false_easting : Option < f64 > ,
114
+ pub proj_false_northing : Option < f64 > ,
115
+ pub proj_false_origin_long : Option < f64 > ,
116
+ pub proj_false_origin_lat : Option < f64 > ,
117
+ pub proj_false_origin_easting : Option < f64 > ,
118
+ pub proj_false_origin_northing : Option < f64 > ,
119
+ pub proj_center_long : Option < f64 > ,
120
+ pub proj_center_lat : Option < f64 > ,
121
+ pub proj_center_easting : Option < f64 > ,
122
+ pub proj_center_northing : Option < f64 > ,
123
+ pub proj_scale_at_nat_origin : Option < f64 > ,
124
+ pub proj_scale_at_center : Option < f64 > ,
125
+ pub proj_azimuth_angle : Option < f64 > ,
126
+ pub proj_straight_vert_pole_long : Option < f64 > ,
127
+
128
+ pub vertical : Option < u16 > ,
129
+ pub vertical_citation : Option < String > ,
130
+ pub vertical_datum : Option < u16 > ,
131
+ pub vertical_units : Option < u16 > ,
117
132
}
118
133
119
134
impl GeoKeyDirectory {
135
+ /// Construct a new [`GeoKeyDirectory`] from tag values.
120
136
pub ( crate ) fn from_tags ( mut tag_data : HashMap < GeoKeyTag , Value > ) -> TiffResult < Self > {
121
137
let mut model_type = None ;
122
138
let mut raster_type = None ;
@@ -281,6 +297,9 @@ impl GeoKeyDirectory {
281
297
}
282
298
283
299
/// Return the EPSG code representing the crs of the image
300
+ ///
301
+ /// This will return either [`GeoKeyDirectory::projected_type`] or
302
+ /// [`GeoKeyDirectory::geographic_type`].
284
303
pub fn epsg_code ( & self ) -> Option < u16 > {
285
304
if let Some ( projected_type) = self . projected_type {
286
305
Some ( projected_type)
0 commit comments