#大圆 #问题 #解决 #计算 #doi #包装器

geographiclib

解决大圆问题的库,GeographicLib 的包装器

1 个不稳定版本

0.1.0 2019年2月20日

#4 in #doi

Download history 40/week @ 2024-03-11 40/week @ 2024-03-18 31/week @ 2024-03-25 75/week @ 2024-04-01 37/week @ 2024-04-08 18/week @ 2024-04-15 48/week @ 2024-04-22 15/week @ 2024-04-29 109/week @ 2024-05-06 59/week @ 2024-05-13 44/week @ 2024-05-20 33/week @ 2024-05-27 18/week @ 2024-06-03 74/week @ 2024-06-10 79/week @ 2024-06-17 72/week @ 2024-06-24

244 每月下载量
2 crates 中使用

MIT/X11 许可证

145KB
3K SLoC

C 2.5K SLoC // 0.2% comments Rust 304 SLoC

GeographicLib

Documentation

Rust 对 GeographicLib 的接口

解决大圆问题的库

用法

将此内容添加到您的 Cargo.toml

[dependencies]
geographiclib = "0.1.0"

示例

use geographiclib::Geodesic;
let g = Geodesic::wgs84();
let (lat1, lon1) = (37.87622, -122.23558); // Berkeley, California
let (lat2, lon2) = (-9.4047, 147.1597);    // Port Moresby, New Guinea
let (d_deg, d_m, az1, az2) = g.inverse(lat1, lon1, lat2, lon2);

assert_eq!(d_deg, 96.39996198449684); // Distance in degrees
assert_eq!(d_m, 10700471.955233702);  // Distance in meters
assert_eq!(az1, -96.91639942294974);  // Azimuth at (lat1, lon1)
assert_eq!(az2, -127.32548874543627); // Azimuth at (lat2, lon2)

许可证

此版本与 GeographicLib 使用相同的许可证;MIT/X11 许可证


lib.rs:

GeographicLib 的 Rust 接口,用于大圆计算

注意:直接从 geodesic.h 复制。更多和更好的信息可以在那里找到。

这是在 C 中实现的大圆算法(带有 Rust 接口),这些算法在以下文献中描述:

示例

use geographiclib::Geodesic;
let g = Geodesic::wgs84();
let (lat1, lon1) = (37.87622, -122.23558); // Berkeley, California
let (lat2, lon2) = (-9.4047, 147.1597);    // Port Moresby, New Guinea
let (d_deg, d_m, az1, az2) = g.inverse(lat1, lon1, lat2, lon2);

assert_eq!(d_deg, 96.39996198449684); // Distance in degrees
assert_eq!(d_m, 10700471.955233702);  // Distance in meters
assert_eq!(az1, -96.91639942294974);  // Azimuth at (lat1, lon1)
assert_eq!(az2, -127.32548874543627); // Azimuth at (lat2, lon2)

原理

与先前算法(例如,Vincenty,1975)相比,这些算法的主要优点是

- accurate to round off for |f| < 1/50;
- the solution of the inverse problem is always found;
- differential and integral properties of geodesics are computed.

在(lat1, lon1)和(lat2, lon2)两点之间的椭球面上的最短路径称为大圆。其长度为 s12,从点 1 到点 2 的大圆在两个端点具有前向方位角 azi1 和 azi2。

传统上考虑两种大圆问题

- [direct](struct.Geodesic.html#method.direct) – given lat1, lon1, s12, and azi1, determine lat2, lon2, and azi2.
- [inverse](struct.Geodesic.html#method.inverse) – given lat1, lon1, and lat2, lon2, determine s12, azi1, and azi2.

椭球体由其赤道半径 a(通常以米为单位)和偏心率 f 来指定。只要 |f| < 1/50,这些例程的精度就足以进行舍入,并使用双精度算术。对于 WGS84 椭球体,误差小于 15 纳米。(对于 |f| < 1/5,可以获得合理准确的结果。)对于长椭球体,指定 f < 0。

无运行时依赖项

~180KB