Skip to main content

Transformer

Struct Transformer 

Source
pub struct Transformer { /* private fields */ }
Expand description

Coordinate transformer that handles transformations between CRS.

Implementations§

Source§

impl Transformer

Source

pub fn new(source_crs: Crs, target_crs: Crs) -> Result<Self>

Creates a new transformer.

§Arguments
  • source_crs - Source coordinate reference system
  • target_crs - Target coordinate reference system
§Errors

Returns an error if the transformation cannot be initialized.

Source

pub fn from_epsg(source_epsg: u32, target_epsg: u32) -> Result<Self>

Creates a transformer from EPSG codes.

§Arguments
  • source_epsg - Source EPSG code
  • target_epsg - Target EPSG code
§Errors

Returns an error if the EPSG codes are invalid or transformation cannot be initialized.

Source

pub fn source_crs(&self) -> &Crs

Returns the source CRS.

Source

pub fn target_crs(&self) -> &Crs

Returns the target CRS.

Source

pub fn transform(&self, coord: &Coordinate) -> Result<Coordinate>

Transforms a single coordinate.

§Arguments
  • coord - Input coordinate in source CRS
§Errors

Returns an error if the transformation fails.

Source

pub fn transform_3d(&self, coord: &Coordinate3D) -> Result<Coordinate3D>

Transforms a 3D coordinate.

Source

pub fn transform_batch(&self, coords: &[Coordinate]) -> Result<Vec<Coordinate>>

Transforms multiple coordinates in batch.

This is more efficient than transforming one-by-one for large datasets.

§Arguments
  • coords - Input coordinates in source CRS
§Errors

Returns an error if any transformation fails.

Source

pub fn transform_bbox(&self, bbox: &BoundingBox) -> Result<BoundingBox>

Transforms a bounding box.

This transforms all four corners and creates a new bounding box from the results.

§Arguments
  • bbox - Input bounding box in source CRS
§Errors

Returns an error if the transformation fails.

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<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, 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.