pub struct Transformer { /* private fields */ }Expand description
§PROJ Transformer
§Description
A Transformer class contains all projections necessary for converting coordinates from one projection to another. This is a modular class that can be extended to add new projections as needed to reduce code size and improve performance. Both forward and inverse projections are default set to wgs84.
See the NadGridStore
§Usage
Utilizes the TransformCoordinates trait
§Useful methods
Transformer::forward: Given a point in the source projection, return the point in the destination projectionTransformer::forward_mut: Given a point in the source projection, return the point in the destination projectionTransformer::inverse: Given a point in the destination projection, return the point in the source projectionTransformer::inverse_mut: Given a mutable point in the destination projection, return the point in the source projectionTransformer::set_source: Set the source projectionTransformer::set_destination: Set the destination projectionTransformer::insert_epsg_code: Insert an EPSG code definition
§Example
use gistools::proj::{Coords, Transformer};
let mut transformer = Transformer::new();
// Insert a source or destination as needed
// transformer.set_source("WKT_STRING...".into());
let mut point = Coords::new_xy(0., 0.);
transformer.forward_mut(&mut point);
assert_eq!(point, Coords::new_xy(0., 0.));Implementations§
Source§impl Transformer
impl Transformer
Sourcepub fn forward<P: TransformCoordinates + Debug>(&self, p: &P) -> P
pub fn forward<P: TransformCoordinates + Debug>(&self, p: &P) -> P
Move forward from source projection to destination projection
Sourcepub fn forward_mut<P: TransformCoordinates + Debug>(&self, p: &mut P)
pub fn forward_mut<P: TransformCoordinates + Debug>(&self, p: &mut P)
Move forward from source projection to destination projection in place
Sourcepub fn inverse<P: TransformCoordinates + Debug>(&self, p: &P) -> P
pub fn inverse<P: TransformCoordinates + Debug>(&self, p: &P) -> P
Move backward from destination projection to source projection
Sourcepub fn inverse_mut<P: TransformCoordinates + Debug>(&self, p: &mut P)
pub fn inverse_mut<P: TransformCoordinates + Debug>(&self, p: &mut P)
Move backward from destination projection to source projection in place
Sourcepub fn insert_epsg_code(&mut self, code: String, value: String)
pub fn insert_epsg_code(&mut self, code: String, value: String)
Insert an EPSG code definition
use gistools::proj::Transformer;
let mut transformer = Transformer::new();
transformer.insert_epsg_code("4326".to_string(), "WKT_STRING".to_string());§Parameters
code: EPSG code to insert e.g. “4326”: “WKT_STRING”value: the EPSG definition which is either a WKT string object or proj4 encoded string
Sourcepub fn set_source(&mut self, code: String)
pub fn set_source(&mut self, code: String)
Sourcepub fn set_source_def(&mut self, def: ProjectionTransform)
pub fn set_source_def(&mut self, def: ProjectionTransform)
Sourcepub fn set_destination(&mut self, code: String)
pub fn set_destination(&mut self, code: String)
Sourcepub fn set_destination_def(&mut self, def: ProjectionTransform)
pub fn set_destination_def(&mut self, def: ProjectionTransform)
Sourcepub fn get_epsg_code(&self, code: String) -> Option<String>
pub fn get_epsg_code(&self, code: String) -> Option<String>
Get access to an epsg code
Trait Implementations§
Source§impl Clone for Transformer
impl Clone for Transformer
Source§fn clone(&self) -> Transformer
fn clone(&self) -> Transformer
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Transformer
impl Debug for Transformer
Source§impl Default for Transformer
impl Default for Transformer
Source§fn default() -> Transformer
fn default() -> Transformer
Returns the “default value” for a type. Read more
Source§impl PartialEq for Transformer
impl PartialEq for Transformer
impl StructuralPartialEq for Transformer
Auto Trait Implementations§
impl Freeze for Transformer
impl !RefUnwindSafe for Transformer
impl !Send for Transformer
impl !Sync for Transformer
impl Unpin for Transformer
impl !UnwindSafe for Transformer
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().