pub trait InverseGeodesic<T> {
    // Required method
    fn inverse(&self, lat1: f64, lon1: f64, lat2: f64, lon2: f64) -> T;
}
Expand description

Measure the distance (and other values) between two points.

§Arguments

  • lat1 latitude of point 1 (degrees).
  • lon1 longitude of point 1 (degrees).
  • lat2 latitude of point 2 (degrees).
  • lon2 longitude of point 2 (degrees).

§Returns

There are a variety of outputs associated with this calculation. We save computation by only calculating the outputs you need. See the following impls which return different subsets of the following outputs:

  • s12 distance between point 1 and point 2 (meters).
  • azi1 azimuth at point 1 (degrees).
  • azi2 (forward) azimuth at point 2 (degrees).
  • m12 reduced length of geodesic (meters).
  • M12 geodesic scale of point 2 relative to point 1 (dimensionless).
  • M21 geodesic scale of point 1 relative to point 2 (dimensionless).
  • S12 area under the geodesic (meters2).
  • a12 arc length of between point 1 and point 2 (degrees).

lat1 and lat2 should be in the range [−90°, 90°]. The values of azi1 and azi2 returned are in the range [−180°, 180°].

If either point is at a pole, the azimuth is defined by keeping the longitude fixed, writing lat = ±(90° − ε), and taking the limit ε → 0+.

The solution to the inverse problem is found using Newton’s method. If this fails to converge (this is very unlikely in geodetic applications but does occur for very eccentric ellipsoids), then the bisection method is used to refine the solution.

// Example, determine the distance between two points
use geographiclib_rs::{Geodesic, InverseGeodesic};

let g = Geodesic::wgs84();
let p1 = (34.095925, -118.2884237);
let p2 = (59.4323439, 24.7341649);
let s12: f64 = g.inverse(p1.0, p1.1, p2.0, p2.1);

use approx::assert_relative_eq;
assert_relative_eq!(s12, 9094718.72751138);

Required Methods§

source

fn inverse(&self, lat1: f64, lon1: f64, lat2: f64, lon2: f64) -> T

Implementors§