Skip to main content

Geodesic

Struct Geodesic 

Source
pub struct Geodesic { /* private fields */ }
Expand description

Geodesic solver for an ellipsoid of revolution.

Wraps the geographiclib-rs implementation of Karney’s algorithms. The default constructor uses WGS84 parameters.

§Examples

use oxigdal_algorithms::vector::geodesic::Geodesic;

let geod = Geodesic::wgs84();
let result = geod.inverse(0.0, 0.0, 1.0, 0.0);
assert!(result.is_ok());

Implementations§

Source§

impl Geodesic

Source

pub fn wgs84() -> Self

Creates a new Geodesic for the WGS84 ellipsoid.

Source

pub fn new(a: f64, f: f64) -> Self

Creates a new Geodesic for an arbitrary ellipsoid.

§Arguments
  • a - Semi-major axis (meters)
  • f - Flattening (dimensionless)
Source

pub fn ellipsoid_area(&self) -> f64

Returns the total surface area of the ellipsoid in square meters.

Source

pub fn inverse( &self, lat1: f64, lon1: f64, lat2: f64, lon2: f64, ) -> Result<InverseResult>

Solve the inverse geodesic problem: given two points (lat1,lon1) and (lat2,lon2) in degrees, compute distance, azimuths, and area element.

§Arguments
  • lat1 - Latitude of point 1 (degrees, -90..90)
  • lon1 - Longitude of point 1 (degrees)
  • lat2 - Latitude of point 2 (degrees, -90..90)
  • lon2 - Longitude of point 2 (degrees)
§Returns

InverseResult with distance, azimuths, and area element S12.

§Errors

Returns error if latitude is out of range [-90, 90].

Source

pub fn distance( &self, lat1: f64, lon1: f64, lat2: f64, lon2: f64, ) -> Result<f64>

Compute distance between two points in meters.

Convenience method that only returns the distance.

§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)
§Errors

Returns error if latitude is out of range.

Source

pub fn polygon_area(&self, coords: &[Coordinate]) -> Result<PolygonAreaResult>

Compute the area of a polygon whose vertices are given in longitude/latitude degrees.

The polygon should be given as a ring of coordinates. The ring may or may not be closed (last == first). Uses Karney’s geodesic area algorithm for sub-millimeter accuracy on the WGS84 ellipsoid.

§Arguments
  • coords - Ring of (longitude, latitude) coordinates in degrees
§Returns

PolygonAreaResult with absolute area (m^2), perimeter (m), and vertex count.

§Errors

Returns error if fewer than 3 distinct vertices or invalid latitudes.

Source

pub fn polygon_area_signed(&self, coords: &[Coordinate]) -> Result<f64>

Compute the signed area of a polygon ring.

Positive for counter-clockwise, negative for clockwise. This is useful for determining polygon winding order.

§Arguments
  • coords - Ring of (longitude, latitude) coordinates in degrees
§Returns

Signed area in square meters.

§Errors

Returns error if fewer than 3 distinct vertices or invalid latitudes.

Source

pub fn polygon_area_full(&self, polygon: &Polygon) -> Result<f64>

Compute the area of an oxigdal_core::vector::Polygon.

Computes the area of the exterior ring minus the area of all interior rings (holes). Coordinates are expected in (longitude, latitude) degrees.

§Arguments
  • polygon - Input polygon
§Returns

Area in square meters (always non-negative)

§Errors

Returns error if polygon has fewer than 3 coordinates or invalid latitudes.

Trait Implementations§

Source§

impl Clone for Geodesic

Source§

fn clone(&self) -> Geodesic

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Geodesic

Source§

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

Formats the value using the given formatter. Read more

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.