Trait mappers::Projection
source · pub trait Projection: Debug + DynClone + Send + Sync {
fn project_unchecked(&self, lon: f64, lat: f64) -> (f64, f64);
fn inverse_project_unchecked(&self, x: f64, y: f64) -> (f64, f64);
fn project(&self, lon: f64, lat: f64) -> Result<(f64, f64), ProjectionError> { ... }
fn inverse_project(
&self,
x: f64,
y: f64
) -> Result<(f64, f64), ProjectionError> { ... }
}Expand description
An interface for all projections included in the crate.
This trait is kept as simple as possible and the most basic version of projection functions are implemented. Alternative functions for more complex types should be implemented by the user.
Required Methods§
sourcefn project_unchecked(&self, lon: f64, lat: f64) -> (f64, f64)
fn project_unchecked(&self, lon: f64, lat: f64) -> (f64, f64)
Same as Projection::project() but does not check the result.
sourcefn inverse_project_unchecked(&self, x: f64, y: f64) -> (f64, f64)
fn inverse_project_unchecked(&self, x: f64, y: f64) -> (f64, f64)
Same as Projection::inverse_project() but does not check the result.
Provided Methods§
sourcefn project(&self, lon: f64, lat: f64) -> Result<(f64, f64), ProjectionError>
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.
sourcefn inverse_project(&self, x: f64, y: f64) -> Result<(f64, f64), ProjectionError>
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.