Crate mappers

source ·
Expand description

Pure Rust geographical projections library. Similar to Proj in basic functionality but allows for a use in concurrent contexts.

Projections’ implementations closely follow algorithms and instructions provided in: Map projections: A working manual (John P. Snyder, 1987)

This crate in very early stages of development. If you are interested in contributing do not hesitate to contact me on Github.

Usage example

We can project the geographical coordinates to cartographic coordinates on a map with sepcified projection as follows:

 // First, we define the projection

 // We use LCC with reference longitude centered on France
 // parallels set for Europe and WGS84 ellipsoid
 let lcc = LambertConformalConic::new(2.0, 0.0, 30.0, 60.0, Ellipsoid::wgs84())?;

 // Second, we define the coordinates of Mount Blanc
 let (lon, lat) = (6.8651, 45.8326);

 // Project the coordinates
 let (x, y) = lcc.project(lon, lat)?;

 // And print the result
 println!("x: {}, y: {}", x, y); // x: 364836.4407792019, y: 5421073.726335758

We can also inversly project the cartographic coordinates to geographical coordinates:

 // We again start with defining the projection
 let lcc = LambertConformalConic::new(2.0, 0.0, 30.0, 60.0, Ellipsoid::wgs84())?;

 // We take the previously projected coordinates
 let (x, y) = (364836.4407792019, 5421073.726335758);

 // Inversly project the coordinates
 let (lon, lat) = lcc.inverse_project(x, y)?;

 // And print the result
 println!("lon: {}, lat: {}", lon, lat); // lon: 6.8651, lat: 45.83260000001716

Some projections are mathematically exactly inversible, and technically geographical coordinates projected and inverse projected should be identical. However, in practice limitations of floating-point arithmetics will introduce some errors along the way, as shown in the example above.

Modules

Geographical projections implemented by the crate.

Structs

Ellipsoid struct that defines all values contained by reference ellipsoids.

Enums

An interface for errors used within the crate and that the user may face.

Traits

An interface for all projections included in the crate.