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
impl Geodesic
Sourcepub fn new(a: f64, f: f64) -> Self
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)
Sourcepub fn ellipsoid_area(&self) -> f64
pub fn ellipsoid_area(&self) -> f64
Returns the total surface area of the ellipsoid in square meters.
Sourcepub fn inverse(
&self,
lat1: f64,
lon1: f64,
lat2: f64,
lon2: f64,
) -> Result<InverseResult>
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].
Sourcepub fn distance(
&self,
lat1: f64,
lon1: f64,
lat2: f64,
lon2: f64,
) -> Result<f64>
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.
Sourcepub fn polygon_area(&self, coords: &[Coordinate]) -> Result<PolygonAreaResult>
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.
Sourcepub fn polygon_area_signed(&self, coords: &[Coordinate]) -> Result<f64>
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.
Sourcepub fn polygon_area_full(&self, polygon: &Polygon) -> Result<f64>
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.