Struct mappers::ConversionPipe
source · pub struct ConversionPipe<S: Projection, T: Projection> { /* private fields */ }Expand description
A struct that allows for easy conversion between two projections.
It can be constructed directly with the constructor or
from Projection with pipe_to method.
The implementation is very naive as it converts coordinates to longitude and latitude then projects them to the target projection. Therefore projection and numerical errors are accumulated with every step and long conversion chains are discouraged.
Main purpose of this struct is to allow creating generic conversion patterns independent of projections.
For usage see examples in the main module.
Implementations§
source§impl<S: Projection, T: Projection> ConversionPipe<S, T>
impl<S: Projection, T: Projection> ConversionPipe<S, T>
sourcepub fn new(source: &S, target: &T) -> Self
pub fn new(source: &S, target: &T) -> Self
Creates a new conversion pipe from source to target projection.
sourcepub fn invert(&self) -> ConversionPipe<T, S>
pub fn invert(&self) -> ConversionPipe<T, S>
Reverse the direction of conversion.
sourcepub fn convert(&self, x: f64, y: f64) -> Result<(f64, f64), ProjectionError>
pub fn convert(&self, x: f64, y: f64) -> Result<(f64, f64), ProjectionError>
Converts the coordinates from source to target projection.
§Errors
This function uses checked projection methods and returns ProjectionError if any step
emits non-finite values.
Trait Implementations§
source§impl<S: Clone + Projection, T: Clone + Projection> Clone for ConversionPipe<S, T>
impl<S: Clone + Projection, T: Clone + Projection> Clone for ConversionPipe<S, T>
source§fn clone(&self) -> ConversionPipe<S, T>
fn clone(&self) -> ConversionPipe<S, T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<S: Debug + Projection, T: Debug + Projection> Debug for ConversionPipe<S, T>
impl<S: Debug + Projection, T: Debug + Projection> Debug for ConversionPipe<S, T>
source§impl<S: Default + Projection, T: Default + Projection> Default for ConversionPipe<S, T>
impl<S: Default + Projection, T: Default + Projection> Default for ConversionPipe<S, T>
source§fn default() -> ConversionPipe<S, T>
fn default() -> ConversionPipe<S, T>
source§impl<S: Hash + Projection, T: Hash + Projection> Hash for ConversionPipe<S, T>
impl<S: Hash + Projection, T: Hash + Projection> Hash for ConversionPipe<S, T>
source§impl<S: Ord + Projection, T: Ord + Projection> Ord for ConversionPipe<S, T>
impl<S: Ord + Projection, T: Ord + Projection> Ord for ConversionPipe<S, T>
source§fn cmp(&self, other: &ConversionPipe<S, T>) -> Ordering
fn cmp(&self, other: &ConversionPipe<S, T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<S: PartialEq + Projection, T: PartialEq + Projection> PartialEq for ConversionPipe<S, T>
impl<S: PartialEq + Projection, T: PartialEq + Projection> PartialEq for ConversionPipe<S, T>
source§fn eq(&self, other: &ConversionPipe<S, T>) -> bool
fn eq(&self, other: &ConversionPipe<S, T>) -> bool
self and other values to be equal, and is used
by ==.source§impl<S: PartialOrd + Projection, T: PartialOrd + Projection> PartialOrd for ConversionPipe<S, T>
impl<S: PartialOrd + Projection, T: PartialOrd + Projection> PartialOrd for ConversionPipe<S, T>
source§fn partial_cmp(&self, other: &ConversionPipe<S, T>) -> Option<Ordering>
fn partial_cmp(&self, other: &ConversionPipe<S, T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more