Skip to main content

GeoKeyParser

Struct GeoKeyParser 

Source
pub struct GeoKeyParser;
Expand description

Parser for GeoTIFF geographic metadata

Implementations§

Source§

impl GeoKeyParser

Source

pub fn parse_geo_key_directory( ifd: &IFD, byte_order_handler: &Box<dyn ByteOrderHandler>, file_path: &str, ) -> TiffResult<Vec<GeoKeyEntry>>

Parse the GeoKey directory from an IFD

GeoKeys are the main way geographic information is stored in GeoTIFF files. They are organized as a directory with a standard structure defined by the GeoTIFF specification, consisting of a header and a series of key entries.

§Arguments
  • ifd - The IFD containing the GeoKey directory
  • byte_order_handler - Handler for the file’s byte order
  • file_path - Path to the TIFF file
§Returns
  • TiffResult<Vec<GeoKeyEntry>> - A vector of GeoKey entries if found
Source

pub fn get_geo_key_value_as_string( ifd: &IFD, key_entry: &GeoKeyEntry, byte_order_handler: &Box<dyn ByteOrderHandler>, file_path: &str, ) -> TiffResult<String>

Get the value of a GeoKey as a string

GeoKeys can store values in three ways:

  1. Directly in the value_offset field (when tiff_tag_location = 0)
  2. In the GeoDoubleParamsTag (when tiff_tag_location = 34736)
  3. In the GeoAsciiParamsTag (when tiff_tag_location = 34737)

This method handles all three cases and returns the value as a string.

§Arguments
  • ifd - The IFD containing the GeoKey
  • key_entry - The specific GeoKey entry to retrieve
  • byte_order_handler - Handler for the file’s byte order
  • file_path - Path to the TIFF file
§Returns
  • TiffResult<String> - The key’s value as a string
Source

pub fn read_model_pixel_scale_values( ifd: &IFD, byte_order_handler: &Box<dyn ByteOrderHandler>, file_path: &str, ) -> TiffResult<Vec<f64>>

Read model pixel scale values (x_scale, y_scale, z_scale)

ModelPixelScaleTag (33550) contains the pixel size in map units, which is essential for converting between pixel and world coordinates. The tag typically contains 3 values: x_scale, y_scale, and z_scale.

§Arguments
  • ifd - The IFD containing the ModelPixelScaleTag
  • byte_order_handler - Handler for the file’s byte order
  • file_path - Path to the TIFF file
§Returns
  • TiffResult<Vec<f64>> - Vector of scale values [x_scale, y_scale, z_scale]
Source

pub fn read_model_tiepoint_values( ifd: &IFD, byte_order_handler: &Box<dyn ByteOrderHandler>, file_path: &str, ) -> TiffResult<Vec<f64>>

Read model tiepoint values (i,j,k,x,y,z)

ModelTiepointTag (33922) defines how raster coordinates map to world coordinates. Each tiepoint consists of 6 values: i,j,k (raster coordinates) and x,y,z (world coordinates). The tag can contain multiple tiepoints, each with 6 values.

§Arguments
  • ifd - The IFD containing the ModelTiepointTag
  • byte_order_handler - Handler for the file’s byte order
  • file_path - Path to the TIFF file
§Returns
  • TiffResult<Vec<f64>> - Vector of tiepoint values [i,j,k,x,y,z,…]
Source

pub fn extract_geo_info( ifd: &IFD, byte_order_handler: &Box<dyn ByteOrderHandler>, file_path: &str, ) -> TiffResult<GeoInfo>

Extract geospatial information from a TIFF IFD

Interprets all the GeoTIFF tags and keys to build a comprehensive GeoInfo structure containing projection information, pixel sizes, and georeferencing parameters.

§Arguments
  • ifd - The IFD to extract information from
  • byte_order_handler - Handler for the file’s byte order
  • file_path - Path to the TIFF file
§Returns
  • TiffResult<GeoInfo> - Structure with extracted geospatial information
Source

pub fn format_projection_string(geo_info: &GeoInfo) -> String

Format a human-readable GeoTIFF projection string

Interprets the projection information in a GeoInfo structure and returns a human-readable description of the coordinate system.

§Arguments
  • geo_info - The GeoInfo structure containing projection information
§Returns
  • String - Human-readable description of the projection
Source

pub fn format_geo_keys( ifd: &IFD, byte_order_handler: &Box<dyn ByteOrderHandler>, file_path: &str, ) -> TiffResult<Vec<(u16, String, u16, u16, u16, String)>>

Format GeoKeys for display

Creates a vector of tuples containing all GeoKey information, formatted for display in a human-readable format.

§Arguments
  • ifd - The IFD containing the GeoKeys
  • byte_order_handler - Handler for the file’s byte order
  • file_path - Path to the TIFF file
§Returns
  • TiffResult<Vec<(u16, String, u16, u16, u16, String)>> - Vector of tuples with (key_id, key_name, tag_location, count, value_offset, value_string)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.