Skip to main content

Spheroid

Struct Spheroid 

Source
pub struct Spheroid {
    pub equatorial_radius: f64,
    pub flattening: f64,
}
Expand description

Reference ellipsoid for geographic coordinate systems.

Field semantics match Boost’s srs::spheroid<T> (boost/geometry/srs/spheroid.hpp:49-112), except the second stored value is the flattening instead of the polar radius — the two forms are interconvertible via polar_radius / flattening but f is what the geodesic formulas actually take as input.

§Examples

use geometry_cs::Spheroid;
let s = Spheroid::WGS84;
assert_eq!(s.equatorial_radius, 6_378_137.0);
// The WGS84 polar radius is ~6 356 752.3 m.
assert!((s.polar_radius() - 6_356_752.314_245).abs() < 0.01);

Fields§

§equatorial_radius: f64

Equatorial (semi-major) radius a, in metres.

§flattening: f64

Flattening f = (a − b) / a, dimensionless.

Implementations§

Source§

impl Spheroid

Source

pub const WGS84: Self

The WGS84 reference ellipsoid.

Equatorial radius and flattening per the WGS84 defining parameters; matches the default-constructed srs::spheroid<RadiusType> in boost/geometry/srs/spheroid.hpp:62-69, which seeds m_a = 6_378_137.0 and m_b = 6_356_752.314_245_179_3.

Source

pub fn polar_radius(&self) -> f64

Semi-minor axis b = a · (1 − f), in metres.

Counterpart to srs::spheroid<T>::get_radius<2>() in boost/geometry/srs/spheroid.hpp:78-92.

Source

pub fn eccentricity_squared(&self) -> f64

First eccentricity squared e² = 2f − f².

Used by the geodesic strategies (Andoyer / Vincenty / Thomas) in boost/geometry/strategies/geographic/*.hpp. The identity e² = 2f − f² follows from b = a(1 − f) and e² = (a² − b²) / a².

Trait Implementations§

Source§

impl Clone for Spheroid

Source§

fn clone(&self) -> Spheroid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Spheroid

Source§

impl Debug for Spheroid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Spheroid

Source§

fn eq(&self, other: &Spheroid) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Spheroid

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.