plane-projection

Crates.ioplane-projection
lib.rsplane-projection
version0.3.6
created_at2025-01-14 11:44:12.384968+00
updated_at2025-08-16 09:42:57.457358+00
descriptionZero-dependency fact approximate distance on Earth calculation
homepage
repositoryhttps://github.com/kinkard/plane-projection
max_upload_size
id1515884
size23,259
Stefan Kizim (kinkard)

documentation

README

About

A plane projection, useful for blazingly fast approximate distance calculations. Based on WGS84 ellipsoid model of the Earth, plane projection provides 0.1% precision on distances under 500km at latitudes up to the 65°. See the article about Cheap Ruler for more details about the principle and formulas behind.

Comparing to another Rust crates that provide the same functionality, cheap-ruler-rs and flat-projection, this crate has zero dependencies and minimalistic API.

Usage

Add this to your Cargo.toml:

[dependencies]
plane-projection = "0.3"

Example

use plane_projection::PlaneProjection;

let proj = PlaneProjection::new(55.65);
let distance = proj.distance((55.7041417, 13.1913041), (55.6033090, 13.0019737));
assert_eq!(distance as u32, 16373);

let distance = proj.distance_to_segment((55.6781798, 13.0587896), ((55.7041417, 13.1913041), (55.6033090, 13.0019737)));
assert_eq!(distance as u32, 3615);

let heading = proj.heading((55.7041417, 13.1913041), (55.6033090, 13.0019737));
assert_eq!(heading as u32, 226);

License

All code in this project is dual-licensed under either:

at your option.

Commit count: 12

cargo fmt