geo::algorithm::line_measures::metric_spaces

Struct Geodesic

Source
pub struct Geodesic;
Expand description

An ellipsoidal model of the earth, using methods given by Karney (2013).

Distances are computed using geodesic lines and are measured in meters.

Trait Implementations§

Source§

impl Bearing<f64> for Geodesic

Source§

fn bearing(origin: Point<f64>, destination: Point<f64>) -> f64

Returns the bearing from origin to destination in degrees along a geodesic line.

§Units
  • origin, destination: Point where x/y are lon/lat degree coordinates
  • returns: degrees, where: North: 0°, East: 90°, South: 180°, West: 270°
use geo::{Geodesic, Bearing};
use geo::Point;

let origin = Point::new(9.0, 10.0);
let destination = Point::new(9.5, 10.1);
let bearing = Geodesic::bearing(origin, destination);
// A little north of east
assert_relative_eq!(bearing, 78.54, epsilon = 1.0e-2);
§References

This uses the geodesic methods given by Karney (2013).

Source§

impl Destination<f64> for Geodesic

Source§

fn destination(origin: Point<f64>, bearing: f64, distance: f64) -> Point<f64>

Returns a new point having travelled the distance along a geodesic line from the origin point with the given bearing.

This uses the geodesic methods given by Karney (2013).

§Units
  • bearing: degrees, where: North: 0°, East: 90°, South: 180°, West: 270°
  • distance: meters
  • returns: Point where x/y are lon/lat degree coordinates
§Examples
use geo::{Geodesic, Destination};
use geo::Point;

// Determine the point 100 km NE of JFK airport.
let jfk = Point::new(-73.78, 40.64);
let northeast_bearing = 45.0;
let distance = 100_000.0;

let northeast_of_jfk = Geodesic::destination(jfk, northeast_bearing, distance);
assert_relative_eq!(Point::new(-72.94, 41.27), northeast_of_jfk, epsilon = 1.0e-2);
§References

This uses the geodesic methods given by Karney (2013).

Source§

impl Distance<f64, Point, Point> for Geodesic

Source§

fn distance(origin: Point<f64>, destination: Point<f64>) -> f64

Determine the length of the geodesic line between two geometries on an ellipsoidal model of the earth.

§Units
  • origin, destination: Point where x/y are lon/lat degree coordinates/
  • returns: meters
§Examples
use geo::{Geodesic, Distance};
use geo::Point;

// New York City
let new_york_city = Point::new(-74.006, 40.7128);

// London
let london = Point::new(-0.1278, 51.5074);

let distance = Geodesic::distance(new_york_city, london);

assert_eq!(
    5_585_234., // meters
    distance.round()
);
§References

This uses the geodesic methods given by Karney (2013).

Source§

impl InterpolatePoint<f64> for Geodesic

Interpolate Point(s) along a geodesic line.

Source§

fn point_at_distance_between( start: Point<f64>, end: Point<f64>, meters_from_start: f64, ) -> Point<f64>

Returns a new Point along a geodesic line between two existing points on an ellipsoidal model of the earth.

§Units
  • meters_from_start: meters
§Examples
use geo::{Geodesic, InterpolatePoint};
use geo::Point;


let p1 = Point::new(10.0, 20.0);
let p2 = Point::new(125.0, 25.0);

let closer_to_p1 = Geodesic::point_at_distance_between(p1, p2, 100_000.0);
assert_relative_eq!(closer_to_p1, Point::new(10.81, 20.49), epsilon = 1.0e-2);

let closer_to_p2 = Geodesic::point_at_distance_between(p1, p2, 10_000_000.0);
assert_relative_eq!(closer_to_p2, Point::new(112.20, 30.67), epsilon = 1.0e-2);
§References

This uses the geodesic methods given by Karney (2013).

Source§

fn point_at_ratio_between( start: Point<f64>, end: Point<f64>, ratio_from_start: f64, ) -> Point<f64>

Returns a new Point along a geodesic line between two existing points on an ellipsoidal model of the earth.

§Examples
use geo::{Geodesic, InterpolatePoint};
use geo::Point;

let p1 = Point::new(10.0, 20.0);
let p2 = Point::new(125.0, 25.0);

let closer_to_p1 = Geodesic::point_at_ratio_between(p1, p2, 0.1);
assert_relative_eq!(closer_to_p1, Point::new(19.52, 25.31), epsilon = 1.0e-2);

let closer_to_p2 = Geodesic::point_at_ratio_between(p1, p2, 0.9);
assert_relative_eq!(closer_to_p2, Point::new(114.73, 29.69), epsilon = 1.0e-2);

let midpoint = Geodesic::point_at_ratio_between(p1, p2, 0.5);
assert_relative_eq!(midpoint, Point::new(65.88, 37.72), epsilon = 1.0e-2);
§References

This uses the geodesic methods given by Karney (2013).

Source§

fn points_along_line( start: Point<f64>, end: Point<f64>, max_distance: f64, include_ends: bool, ) -> impl Iterator<Item = Point<f64>>

Interpolates Points along a geodesic line between start and end.

As many points as necessary will be added such that the geodesic distance between points never exceeds max_distance. If the distance between start and end is less than max_distance, no additional points will be included in the output.

include_ends: Should the start and end points be included in the output?

§References

This uses the geodesic methods given by Karney (2013).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool