flat_projection

Crates.ioflat_projection
lib.rsflat_projection
version0.4.0
sourcesrc
created_at2018-01-28 19:12:29.687533
updated_at2020-09-14 22:17:35.396533
descriptionFast geodesic distance approximations via flat surface projection.
homepagehttps://github.com/Turbo87/flat-projection-rs.git
repositoryhttps://github.com/Turbo87/flat-projection-rs.git
max_upload_size
id48681
size25,811
Tobias Bieniek (Turbo87)

documentation

https://docs.rs/flat_projection/

README

flat-projection

Build Status

Fast geodesic distance approximations via flat surface projection

The FlatProjection struct can by used to project geographical coordinates from WGS84 into a cartesian coordinate system. In the projected form approximated distance and bearing calculations can be performed much faster than on a sphere. The precision of these calculations is very precise for distances up to about 500 km.

Usage

extern crate flat_projection;

use flat_projection::FlatProjection;

fn main() {
    let (lon1, lat1) = (6.186389, 50.823194);
    let (lon2, lat2) = (6.953333, 51.301389);

    let proj = FlatProjection::new(51.05);

    let p1 = proj.project(lon1, lat1);
    let p2 = proj.project(lon2, lat2);

    let distance = p1.distance(&p2);
    // -> 75.648 km
}

Benchmark

$ cargo bench

distance/flat           time:   [322.21 ps 323.82 ps 326.41 ps]
distance/haversine      time:   [12.604 ns 12.831 ns 13.162 ns]
distance/vincenty       time:   [346.79 ns 348.00 ns 349.61 ns]

According to these results the flat surface approximation is about 40x faster than the Haversine formula.

Related

License

This project is released under the MIT license.

Commit count: 90

cargo fmt