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 const fn new(source: &S, target: &T) -> Self
pub const fn new(source: &S, target: &T) -> Self
Creates a new conversion pipe from source to target projection.
Sourcepub const fn invert(&self) -> ConversionPipe<T, S>
pub const 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 more