Trait Transform

Source
pub trait Transform {
    // Required method
    fn transform_coordinates<F: TransformClosure>(
        &mut self,
        f: &mut F,
    ) -> Result<()>;
}
Expand description

Transform trait

This allow transform to be agnostic in the coordinate’s implementation details (useful for collections of coordinates)

The closure will return error if processing of the coordinate fail. If the method return an error, then the whole processing stop. Indeed, the strategy to stop or continue on error is left to the Transform implementation.

Single point transform example:

use proj4rs::transform::{transform, Transform, TransformClosure};
use proj4rs::errors::Result;

pub struct Point {
    x: f64,
    y: f64,
    z: f64,
}

impl Transform for Point {
    fn transform_coordinates<F: TransformClosure>(&mut self, f: &mut F) -> Result<()>
    {
        f(self.x, self.y, self.z).map(|(x, y, z)| {
            self.x = x;
            self.y = y;
            self.z = z;
        })
    }
}

Required Methods§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Transform for (f64, f64)

Source§

impl Transform for (f64, f64, f64)

Source§

impl Transform for [(f64, f64)]

Source§

impl Transform for [(f64, f64, f64)]

Implementors§