| Crates.io | coordtransform |
| lib.rs | coordtransform |
| version | 0.3.0 |
| created_at | 2025-07-25 11:04:18.638451+00 |
| updated_at | 2025-08-03 09:42:08.565393+00 |
| description | Provide mutual conversions between Baidu Coordinate System (BD09), Mars Coordinate System (GCJ02), and WGS84 Coordinate System. |
| homepage | |
| repository | https://github.com/athxx/coordtransform-rs |
| max_upload_size | |
| id | 1767459 |
| size | 48,436 |
提供百度坐标系(BD09)、火星坐标系(国测局坐标系、GCJ02)、WGS84坐标系的相互转换,基于 Rust 语言,无特殊依赖。 Provides mutual conversion between Baidu Coordinate System (BD09), Mars Coordinate System (GCJ02), and WGS84 Coordinate System, implemented in Rust with no special dependencies.
这是 Go版本 的 Rust 移植版本。 This is the Rust port of the Go version.
gcj02_to_bd09)bd09_to_gcj02)wgs84_to_gcj02)gcj02_to_wgs84)wgs84_to_bd09)bd09_to_wgs84)wgs84_to_epsg3857)epsg3857_to_wgs84)gcj02_to_epsg3857)epsg3857_to_gcj02)bd09_to_epsg3857)epsg3857_to_bd09)在你的 Cargo.toml 中添加 Add the following to your Cargo.toml:
[dependencies]
coordtransform = "0.3.0"
use coordtransform::*;
fn main() {
// 百度坐标系 -> 火星坐标系
let (lon, lat) = bd09_to_gcj02(116.404, 39.915);
println!("BD09 to GCJ02: ({}, {})", lon, lat);
// 火星坐标系 -> 百度坐标系
let (lon, lat) = gcj02_to_bd09(116.404, 39.915);
println!("GCJ02 to BD09: ({}, {})", lon, lat);
// WGS84坐标系 -> 火星坐标系
let (lon, lat) = wgs84_to_gcj02(116.404, 39.915);
println!("WGS84 to GCJ02: ({}, {})", lon, lat);
// 火星坐标系 -> WGS84坐标系 gcj02 -> WGS84
let (lon, lat) = gcj02_to_wgs84(116.404, 39.915);
println!("GCJ02 to WGS84: ({}, {})", lon, lat);
// 百度坐标系 -> WGS84坐标系
let (lon, lat) = bd09_to_wgs84(116.404, 39.915);
println!("BD09 to WGS84: ({}, {})", lon, lat);
// WGS84坐标系 -> 百度坐标系
let (lon, lat) = wgs84_to_bd09(116.404, 39.915);
println!("WGS84 to BD09: ({}, {})", lon, lat);
// WGS84坐标系 -> EPSG:3857坐标系 (Web墨卡托投影)
let (x, y) = wgs84_to_epsg3857(116.404, 39.915);
println!("WGS84 to EPSG:3857: ({}, {})", x, y);
// EPSG:3857坐标系 -> WGS84坐标系
let (lon, lat) = epsg3857_to_wgs84(12958752.0, 4825923.0);
println!("EPSG:3857 to WGS84: ({}, {})", lon, lat);
// GCJ02坐标系 -> EPSG:3857坐标系
let (x, y) = gcj02_to_epsg3857(116.404, 39.915);
println!("GCJ02 to EPSG:3857: ({}, {})", x, y);
// BD09坐标系 -> EPSG:3857坐标系
let (x, y) = bd09_to_epsg3857(116.404, 39.915);
println!("BD09 to EPSG:3857: ({}, {})", x, y);
}
运行基准测试 Run the benchmark tests:
cargo bench
运行测试 Run the tests:
cargo test
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。 This project is licensed under the MIT License - see the LICENSE file for details.