Skip to content

ZhengLongBing/geo

 
 

Repository files navigation

geo

geo 在 Crates.io 上 覆盖率状态 文档 Discord

geo

地理空间基本类型、算法和工具

Discord 上聊天或提问

geo crate 提供了诸如 PointLineStringPolygon 这样的地理空间基本类型,并提供了诸如以下的算法和操作:

  • 面积和中心点计算
  • 简化和凸包操作
  • 欧几里得和 Haversine 距离测量
  • 相交检查
  • 仿射变换,如旋转和位移
  • 所有 DE-9IM 空间谓词,例如 contains、crosses 和 touches。

请参考文档以获取完整的列表。

基本类型也为 Geo 生态系统中的其他功能提供基础,包括:

示例

// 基本类型
use geo::{line_string, polygon};

// 算法
use geo::ConvexHull;

// 一个 L 形状
let poly = polygon![
    (x: 0.0, y: 0.0),
    (x: 4.0, y: 0.0),
    (x: 4.0, y: 1.0),
    (x: 1.0, y: 1.0),
    (x: 1.0, y: 4.0),
    (x: 0.0, y: 4.0),
    (x: 0.0, y: 0.0),
];

// 计算多边形的凸包
let hull = poly.convex_hull();

assert_eq!(
    hull.exterior(),
    &line_string![
        (x: 4.0, y: 0.0),
        (x: 4.0, y: 1.0),
        (x: 1.0, y: 4.0),
        (x: 0.0, y: 4.0),
        (x: 0.0, y: 0.0),
        (x: 4.0, y: 0.0),
    ]
);

贡献

欢迎贡献!看看这些问题,如果你想添加算法或功能,可以发起一个拉取请求。

许可

可以选择使用以下许可之一:

贡献内容

除非您明确声明,否则您有意提交的任何用于包含在此作品中的贡献,将依据 Apache-2.0 许可证进行上述双重许可,且无任何附加条款或条件。

About

Rust geospatial primitives & algorithms

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 99.9%
  • Python 0.1%