18 lines
687 B
Rust
18 lines
687 B
Rust
use geo::{algorithm::haversine_destination::HaversineDestination, Point};
|
|
pub fn calculate_coverage(lat_deg: f64, lon_deg: f64, radius_km: f64) -> (f64, f64, f64, f64) {
|
|
let center = Point::new(lon_deg, lat_deg);
|
|
|
|
// 计算四个方向(北、南、东、西)的点
|
|
let north = center.haversine_destination(0.0, radius_km);
|
|
let south = center.haversine_destination(180.0, radius_km);
|
|
let east = center.haversine_destination(90.0, radius_km);
|
|
let west = center.haversine_destination(270.0, radius_km);
|
|
|
|
let min_lat = south.y();
|
|
let max_lat = north.y();
|
|
let min_lon = west.x();
|
|
let max_lon = east.x();
|
|
|
|
(min_lat, max_lat, min_lon, max_lon)
|
|
}
|