Expand description
Geospatial functionality for working with geographic coordinates
This module provides basic geospatial operations including:
- Coordinate system transformations
- Great circle distance calculations (Haversine formula)
- Bearing and azimuth calculations
- Geodesic operations on the sphere
§Coordinate Systems
The module supports common geographic coordinate systems:
- WGS84: World Geodetic System 1984 (GPS standard)
- Geographic: Latitude/Longitude coordinates
- UTM: Universal Transverse Mercator projections
- Web Mercator: Spherical Mercator (EPSG:3857)
§Examples
use scirs2_spatial::geospatial::{haversine_distance, initial_bearing, destination_point};
// Calculate distance between two cities
let london = (51.5074, -0.1278); // Latitude, Longitude
let paris = (48.8566, 2.3522);
let distance = haversine_distance(london, paris);
println!("Distance from London to Paris: {:.1} km", distance / 1000.0);
// Calculate bearing
let bearing = initial_bearing(london, paris);
println!("Initial bearing: {:.1}°", bearing.to_degrees());
// Find destination point
let destination = destination_point(london, 100000.0, bearing); // 100 km
println!("100km from London: ({:.4}, {:.4})", destination.0, destination.1);Constants§
- EARTH_
ECCENTRICITY_ SQ - Earth’s eccentricity squared (WGS84)
- EARTH_
EQUATORIAL_ RADIUS_ M - Earth’s equatorial radius in meters (WGS84)
- EARTH_
FLATTENING - Earth’s flattening (WGS84)
- EARTH_
POLAR_ RADIUS_ M - Earth’s polar radius in meters (WGS84)
- EARTH_
RADIUS_ KM - Earth radius in kilometers
- EARTH_
RADIUS_ M - Earth radius in meters (WGS84 mean radius)
Functions§
- along_
track_ distance - Calculate the along-track distance (distance along a great circle path to the closest point)
- cross_
track_ distance - Calculate the cross-track distance (distance from a point to a great circle path)
- deg_
to_ rad - Convert degrees to radians
- destination_
point - Calculate the destination point given a starting point, distance, and bearing
- final_
bearing - Calculate the final bearing (back azimuth) when arriving at point2 from point1
- geographic_
to_ utm - Convert geographic coordinates to UTM coordinates
- geographic_
to_ web_ mercator - Convert geographic coordinates to Web Mercator (EPSG:3857)
- haversine_
distance - Calculate the great circle distance between two points using the Haversine formula
- initial_
bearing - Calculate the initial bearing (forward azimuth) from point1 to point2
- midpoint
- Calculate the midpoint between two geographic points
- normalize_
angle - Normalize angle to [0, 2π) range
- normalize_
bearing - Normalize bearing to [0°, 360°) range
- point_
in_ spherical_ polygon - Check if a point is inside a spherical polygon using the winding number method
- rad_
to_ deg - Convert radians to degrees
- spherical_
polygon_ area - Calculate the area of a polygon on the sphere using spherical excess
- vincenty_
distance - Calculate the vincenty distance between two points (more accurate than Haversine)
- web_
mercator_ to_ geographic - Convert Web Mercator coordinates to geographic coordinates