Skip to main content

Module position

Module position 

Source
Expand description

Geographic position: latitude, longitude, position.

Both coordinates enforce their range: a Latitude is in [-90°, 90°]; a Longitude is in [-180°, 180°) and wraps, so crossing the antimeridian cannot produce an invalid value.

§Example

use kinavis_kernel::{Latitude, Longitude, KernelError, NorthSouth, Position};

// Decimal degrees, or the degrees-and-minutes a chart is marked in.
let position = Position::new(
    Latitude::from_degrees_minutes(50, 45.3, NorthSouth::North)?,
    Longitude::from_degrees(-1.296_667)?,
);

assert_eq!(format!("{position}"), "50°45.3'N 001°17.8'W");
assert_eq!(position.latitude().degrees(), 50.755);

// Out of range is rejected; longitude wraps.
assert!(Latitude::from_degrees(91.0).is_err());
assert_eq!(Longitude::from_degrees(180.0)?.degrees(), -180.0);

Structs§

GeocentricUnit
Unit vector from the Earth’s centre.
Latitude
Latitude in [-90°, 90°], north positive.
Longitude
Longitude in [-180°, 180°), east positive.
Position
Position on the Earth’s surface (WGS 84).

Enums§

EastWest
Longitude hemisphere.
NorthSouth
Latitude hemisphere.

Constants§

WGS84_ECCENTRICITY_SQUARED
WGS 84 first eccentricity squared, f·(2 − f).
WGS84_FLATTENING
WGS 84 flattening.
WGS84_SEMI_MAJOR_AXIS_METRES
WGS 84 semi-major axis, m.