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
impl Bearing<f64> for Geodesic
Source§fn bearing(origin: Point<f64>, destination: Point<f64>) -> f64
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
impl Destination<f64> for Geodesic
Source§fn destination(origin: Point<f64>, bearing: f64, distance: f64) -> Point<f64>
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
impl Distance<f64, Point, Point> for Geodesic
Source§fn distance(origin: Point<f64>, destination: Point<f64>) -> f64
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
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>
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>
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>>
fn points_along_line( start: Point<f64>, end: Point<f64>, max_distance: f64, include_ends: bool, ) -> impl Iterator<Item = Point<f64>>
Interpolates Point
s 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§
impl Freeze for Geodesic
impl RefUnwindSafe for Geodesic
impl Send for Geodesic
impl Sync for Geodesic
impl Unpin for Geodesic
impl UnwindSafe for Geodesic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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