#wrapper #interface #cargo-toml #geodesic #solving #add

geographiclib

Library for solving geodesic problems, wrapper around GeographicLib

1 unstable release

0.1.0 Feb 20, 2019
Download history 5/week @ 2021-10-08 10/week @ 2021-10-15 10/week @ 2021-10-22 6/week @ 2021-10-29 13/week @ 2021-11-05 24/week @ 2021-11-12 17/week @ 2021-11-19 13/week @ 2021-11-26 18/week @ 2021-12-03 43/week @ 2021-12-10 26/week @ 2021-12-17 12/week @ 2021-12-24 20/week @ 2021-12-31 24/week @ 2022-01-07 24/week @ 2022-01-14 26/week @ 2022-01-21

95 downloads per month
Used in 2 crates

MIT/X11 license

145KB
3K SLoC

C 2.5K SLoC // 0.2% comments Rust 304 SLoC

GeographicLib

Documentation

A Rust interface to GeographicLib

A library for solving geodesic problems

Usage

Add this to your Cargo.toml:

[dependencies]
geographiclib = "0.1.0"

Example

use geographiclib::Geodesic;
let g = Geodesic::wgs84();
let (lat1, lon1) = (37.87622, -122.23558); // Berkeley, California
let (lat2, lon2) = (-9.4047, 147.1597);    // Port Moresby, New Guinea
let (d_deg, d_m, az1, az2) = g.inverse(lat1, lon1, lat2, lon2);

assert_eq!(d_deg, 96.39996198449684); // Distance in degrees
assert_eq!(d_m, 10700471.955233702);  // Distance in meters
assert_eq!(az1, -96.91639942294974);  // Azimuth at (lat1, lon1)
assert_eq!(az2, -127.32548874543627); // Azimuth at (lat2, lon2)

License

This version is released under the same license as GeographicLib; MIT/X11 License


lib.rs:

Rust interface for GeographicLib for geodesic calculations

Note: Copied directly from geodesic.h. Much more and better information can be found there.

This an implementation in C (with a Rust Interface) of the geodesic algorithms described in

Example

use geographiclib::Geodesic;
let g = Geodesic::wgs84();
let (lat1, lon1) = (37.87622, -122.23558); // Berkeley, California
let (lat2, lon2) = (-9.4047, 147.1597);    // Port Moresby, New Guinea
let (d_deg, d_m, az1, az2) = g.inverse(lat1, lon1, lat2, lon2);

assert_eq!(d_deg, 96.39996198449684); // Distance in degrees
assert_eq!(d_m, 10700471.955233702);  // Distance in meters
assert_eq!(az1, -96.91639942294974);  // Azimuth at (lat1, lon1)
assert_eq!(az2, -127.32548874543627); // Azimuth at (lat2, lon2)

Rationale

The principal advantages of these algorithms over previous ones (e.g., Vincenty, 1975) are

- accurate to round off for |f| < 1/50;
- the solution of the inverse problem is always found;
- differential and integral properties of geodesics are computed.

The shortest path between two points on the ellipsoid at (lat1, lon1) and (lat2, lon2) is called the geodesic. Its length is s12 and the geodesic from point 1 to point 2 has forward azimuths azi1 and azi2 at the two end points.

Traditionally two geodesic problems are considered:

- [direct](struct.Geodesic.html#method.direct) – given lat1, lon1, s12, and azi1, determine lat2, lon2, and azi2.
- [inverse](struct.Geodesic.html#method.inverse) – given lat1, lon1, and lat2, lon2, determine s12, azi1, and azi2.

The ellipsoid is specified by its equatorial radius a (typically in meters) and flattening f. The routines are accurate to round off with double precision arithmetic provided that |f| < 1/50; for the WGS84 ellipsoid, the errors are less than 15 nanometers. (Reasonably accurate results are obtained for |f| < 1/5.) For a prolate ellipsoid, specify f < 0.

No runtime deps

~140KB