@@ -137,11 +137,6 @@ pub struct ImageFileDirectory {
137
137
138
138
pub ( crate ) extra_tags : ExtraTagsRegistry ,
139
139
140
- // Geospatial tags
141
- pub ( crate ) geo_key_directory : Option < GeoKeyDirectory > ,
142
- pub ( crate ) model_pixel_scale : Option < Vec < f64 > > ,
143
- pub ( crate ) model_tiepoint : Option < Vec < f64 > > ,
144
-
145
140
// GDAL tags
146
141
// no_data
147
142
// gdal_metadata
@@ -188,11 +183,6 @@ impl ImageFileDirectory {
188
183
let mut sample_format = None ;
189
184
let mut jpeg_tables = None ;
190
185
let mut copyright = None ;
191
- let mut geo_key_directory_data = None ;
192
- let mut model_pixel_scale = None ;
193
- let mut model_tiepoint = None ;
194
- let mut geo_ascii_params: Option < String > = None ;
195
- let mut geo_double_params: Option < Vec < f64 > > = None ;
196
186
197
187
let mut other_tags = HashMap :: new ( ) ;
198
188
@@ -257,13 +247,6 @@ impl ImageFileDirectory {
257
247
Tag :: JPEGTables => jpeg_tables = Some ( value. into_u8_vec ( ) ?. into ( ) ) ,
258
248
Tag :: Copyright => copyright = Some ( value. into_string ( ) ?) ,
259
249
260
- // Geospatial tags
261
- // http://geotiff.maptools.org/spec/geotiff2.4.html
262
- Tag :: GeoKeyDirectoryTag => geo_key_directory_data = Some ( value. into_u16_vec ( ) ?) ,
263
- Tag :: ModelPixelScaleTag => model_pixel_scale = Some ( value. into_f64_vec ( ) ?) ,
264
- Tag :: ModelTiepointTag => model_tiepoint = Some ( value. into_f64_vec ( ) ?) ,
265
- Tag :: GeoAsciiParamsTag => geo_ascii_params = Some ( value. into_string ( ) ?) ,
266
- Tag :: GeoDoubleParamsTag => geo_double_params = Some ( value. into_f64_vec ( ) ?) ,
267
250
// Tag::GdalNodata
268
251
// Tags for which the tiff crate doesn't have a hard-coded enum variant
269
252
Tag :: Unknown ( DOCUMENT_NAME ) => document_name = Some ( value. into_string ( ) ?) ,
@@ -274,81 +257,6 @@ impl ImageFileDirectory {
274
257
Ok :: < _ , TiffError > ( ( ) )
275
258
} ) ?;
276
259
277
- let mut geo_key_directory = None ;
278
-
279
- // We need to actually parse the GeoKeyDirectory after parsing all other tags because the
280
- // GeoKeyDirectory relies on `GeoAsciiParamsTag` having been parsed.
281
- if let Some ( data) = geo_key_directory_data {
282
- let mut chunks = data. chunks ( 4 ) ;
283
-
284
- let header = chunks
285
- . next ( )
286
- . expect ( "If the geo key directory exists, a header should exist." ) ;
287
- let key_directory_version = header[ 0 ] ;
288
- assert_eq ! ( key_directory_version, 1 ) ;
289
-
290
- let key_revision = header[ 1 ] ;
291
- assert_eq ! ( key_revision, 1 ) ;
292
-
293
- let _key_minor_revision = header[ 2 ] ;
294
- let number_of_keys = header[ 3 ] ;
295
-
296
- let mut tags = HashMap :: with_capacity ( number_of_keys as usize ) ;
297
- for _ in 0 ..number_of_keys {
298
- let chunk = chunks
299
- . next ( )
300
- . expect ( "There should be a chunk for each key." ) ;
301
-
302
- let key_id = chunk[ 0 ] ;
303
- let tag_name =
304
- GeoKeyTag :: try_from_primitive ( key_id) . expect ( "Unknown GeoKeyTag id: {key_id}" ) ;
305
-
306
- let tag_location = chunk[ 1 ] ;
307
- let count = chunk[ 2 ] ;
308
- let value_offset = chunk[ 3 ] ;
309
-
310
- if tag_location == 0 {
311
- tags. insert ( tag_name, Value :: Short ( value_offset) ) ;
312
- } else if Tag :: from_u16_exhaustive ( tag_location) == Tag :: GeoAsciiParamsTag {
313
- // If the tag_location points to the value of Tag::GeoAsciiParamsTag, then we
314
- // need to extract a subslice from GeoAsciiParamsTag
315
-
316
- let geo_ascii_params = geo_ascii_params
317
- . as_ref ( )
318
- . expect ( "GeoAsciiParamsTag exists but geo_ascii_params does not." ) ;
319
- let value_offset = value_offset as usize ;
320
- let mut s = & geo_ascii_params[ value_offset..value_offset + count as usize ] ;
321
-
322
- // It seems that this string subslice might always include the final |
323
- // character?
324
- if s. ends_with ( '|' ) {
325
- s = & s[ 0 ..s. len ( ) - 1 ] ;
326
- }
327
-
328
- tags. insert ( tag_name, Value :: Ascii ( s. to_string ( ) ) ) ;
329
- } else if Tag :: from_u16_exhaustive ( tag_location) == Tag :: GeoDoubleParamsTag {
330
- // If the tag_location points to the value of Tag::GeoDoubleParamsTag, then we
331
- // need to extract a subslice from GeoDoubleParamsTag
332
-
333
- let geo_double_params = geo_double_params
334
- . as_ref ( )
335
- . expect ( "GeoDoubleParamsTag exists but geo_double_params does not." ) ;
336
- let value_offset = value_offset as usize ;
337
- let value = if count == 1 {
338
- Value :: Double ( geo_double_params[ value_offset] )
339
- } else {
340
- let x = geo_double_params[ value_offset..value_offset + count as usize ]
341
- . iter ( )
342
- . map ( |val| Value :: Double ( * val) )
343
- . collect ( ) ;
344
- Value :: List ( x)
345
- } ;
346
- tags. insert ( tag_name, value) ;
347
- }
348
- }
349
- geo_key_directory = Some ( GeoKeyDirectory :: from_tags ( tags) ?) ;
350
- }
351
-
352
260
let samples_per_pixel = samples_per_pixel. expect ( "samples_per_pixel not found" ) ;
353
261
let planar_configuration = if let Some ( planar_configuration) = planar_configuration {
354
262
planar_configuration
@@ -400,9 +308,6 @@ impl ImageFileDirectory {
400
308
. unwrap_or ( vec ! [ SampleFormat :: Uint ; samples_per_pixel as _] ) ,
401
309
copyright,
402
310
jpeg_tables,
403
- geo_key_directory,
404
- model_pixel_scale,
405
- model_tiepoint,
406
311
extra_tags : extra_tags_registry,
407
312
other_tags,
408
313
} )
@@ -622,23 +527,23 @@ impl ImageFileDirectory {
622
527
self . copyright . as_deref ( )
623
528
}
624
529
625
- /// Geospatial tags
626
- /// <https://web.archive.org/web/20240329145313/https://www.awaresystems.be/imaging/tiff/tifftags/geokeydirectorytag.html>
627
- pub fn geo_key_directory ( & self ) -> Option < & GeoKeyDirectory > {
628
- self . geo_key_directory . as_ref ( )
629
- }
530
+ // // / Geospatial tags
531
+ // // / <https://web.archive.org/web/20240329145313/https://www.awaresystems.be/imaging/tiff/tifftags/geokeydirectorytag.html>
532
+ // pub fn geo_key_directory(&self) -> Option<&GeoKeyDirectory> {
533
+ // self.geo_key_directory.as_ref()
534
+ // }
630
535
631
- /// Used in interchangeable GeoTIFF files.
632
- /// <https://web.archive.org/web/20240329145238/https://www.awaresystems.be/imaging/tiff/tifftags/modelpixelscaletag.html>
633
- pub fn model_pixel_scale ( & self ) -> Option < & [ f64 ] > {
634
- self . model_pixel_scale . as_deref ( )
635
- }
536
+ // // / Used in interchangeable GeoTIFF files.
537
+ // // / <https://web.archive.org/web/20240329145238/https://www.awaresystems.be/imaging/tiff/tifftags/modelpixelscaletag.html>
538
+ // pub fn model_pixel_scale(&self) -> Option<&[f64]> {
539
+ // self.model_pixel_scale.as_deref()
540
+ // }
636
541
637
- /// Used in interchangeable GeoTIFF files.
638
- /// <https://web.archive.org/web/20240329145303/https://www.awaresystems.be/imaging/tiff/tifftags/modeltiepointtag.html>
639
- pub fn model_tiepoint ( & self ) -> Option < & [ f64 ] > {
640
- self . model_tiepoint . as_deref ( )
641
- }
542
+ // // / Used in interchangeable GeoTIFF files.
543
+ // // / <https://web.archive.org/web/20240329145303/https://www.awaresystems.be/imaging/tiff/tifftags/modeltiepointtag.html>
544
+ // pub fn model_tiepoint(&self) -> Option<&[f64]> {
545
+ // self.model_tiepoint.as_deref()
546
+ // }
642
547
643
548
/// Tags for which the tiff crate doesn't have a hard-coded enum variant.
644
549
pub fn other_tags ( & self ) -> & HashMap < Tag , Value > {
0 commit comments