1个不稳定发布
0.1.0 | 2024年7月5日 |
---|
#111 in 地理空间
14KB
217 行
coordinate-altitude
获取地球坐标的海拔/高程数据
示例
在 cargo add coordinate_altitude
之后,做
use coordinate_altitude::*;
fn main() {
// coordinate as a tuple
let coord: (f64, f64) = (34.324, 1.88832);
// coordinate as a `Coord`
let coord: Coord = coord.into();
// and finally fetch altitude for `coord`
let coord: Option<Coord> = coord.fetch_altitude();
println!("coordinate: {coord:?}");
}
更多示例请参阅 这里
警告!
open-elevation的精度仅为6位小数 例如:32.324325435
将变为 32.324325
依赖项
- json(反)序列化:serde,serde_json
- GET/POST请求:ureq
- 高程数据源:open-elevation
lib.rs
:
获取地球地理坐标的海拔/高程数据
警告
所有纬度、经度数据将被open-elevation api四舍五入到6位小数精度
用法
use coordinate_altitude::*;
// fetch altitude for a single `Coord`
// could also be a tuple for example, and later converted into Coord
// let coord: (f64, f64) = (34.324, 1.88832);
// let coord: Coord = coord.into();
// coordinate as a `Coord`
let coord = Coord::new(34.324, 1.88832);
// and finally fetch altitude for `coord`
let coord: Option<Coord> = coord.fetch_altitude();
println!("coordinate: {coord:?}");
// add altitude for a `Vec<Coord>`
let mut coords: Vec<Coord> = vec![
(58.2926289, 134.3025286).into(), // Sheep Mountain
(7.4894883, 80.8144869).into(), // Sri Lanka
Coord::new(47.0745464, 12.6938825), // Großglockner
];
add_altitude(&mut coords);
println!("coordinates: {coords:#?}");
- 您还可以为单个
Coord
添加海拔 - 或获取
Vec<Coord>
的海拔 - 您可以通过
impl From<YourWayOfStoringCoordinates> for Coord
轻松实现,请参阅 tests/integ.rs
依赖项
~10–19MB
~364K SLoC