Projection

Trait Projection 

Source
pub trait Projection:
    Debug
    + Send
    + Sync
    + Copy
    + Clone
    + PartialEq
    + PartialOrd {
    // Required methods
    fn project_unchecked(&self, lon: f64, lat: f64) -> (f64, f64);
    fn inverse_project_unchecked(&self, x: f64, y: f64) -> (f64, f64);

    // Provided methods
    fn project(&self, lon: f64, lat: f64) -> Result<(f64, f64), ProjectionError> { ... }
    fn inverse_project(
        &self,
        x: f64,
        y: f64,
    ) -> Result<(f64, f64), ProjectionError> { ... }
    fn pipe_to<TARGET: Projection>(
        &self,
        target: &TARGET,
    ) -> ConversionPipe<Self, TARGET> { ... }
}
Expand description

An interface for all projections included in the crate.

This trait is kept relatively simple and the most basic version of projection functions are implemented. Alternative functions for more complex types should be implemented by the user.

Available projections are available in projections module documentation.

Required Methods§

Source

fn project_unchecked(&self, lon: f64, lat: f64) -> (f64, f64)

Same as Projection::project() but does not check the result.

Source

fn inverse_project_unchecked(&self, x: f64, y: f64) -> (f64, f64)

Same as Projection::inverse_project() but does not check the result.

Provided Methods§

Source

fn project(&self, lon: f64, lat: f64) -> Result<(f64, f64), ProjectionError>

Function to project geographical coordinates (in degrees) to cartographical coordinates (in meters) on a map with specified projection.

§Errors

Returns ProjectionError::ProjectionImpossible when result of projection is not finite.

Source

fn inverse_project(&self, x: f64, y: f64) -> Result<(f64, f64), ProjectionError>

Function to inversly project cartographical coordinates (in meters) to geographical coordinates (in degrees) on a map with specified projection.

§Errors

Returns ProjectionError::InverseProjectionImpossible when result of inverse projection is not finite.

Source

fn pipe_to<TARGET: Projection>( &self, target: &TARGET, ) -> ConversionPipe<Self, TARGET>

Creates ConversionPipe from this projection to provided target projection.

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.

Implementors§