21 releases

Uses new Rust 2021

0.7.6 Jun 24, 2022
0.7.4 Apr 6, 2022
0.7.3 Feb 21, 2022
0.7.2 Apr 19, 2021
0.1.1 May 15, 2018

#51 in Rust patterns

Download history 10251/week @ 2022-04-22 9755/week @ 2022-04-29 9902/week @ 2022-05-06 9428/week @ 2022-05-13 10271/week @ 2022-05-20 7492/week @ 2022-05-27 7937/week @ 2022-06-03 9828/week @ 2022-06-10 8662/week @ 2022-06-17 9684/week @ 2022-06-24 9499/week @ 2022-07-01 13731/week @ 2022-07-08 17035/week @ 2022-07-15 18666/week @ 2022-07-22 18767/week @ 2022-07-29 18239/week @ 2022-08-05

75,824 downloads per month
Used in 132 crates (69 directly)

MIT/Apache

165KB
3K SLoC

geo

geo on Crates.io Coverage Status Documentation

geo

Geospatial Primitives, Algorithms, and Utilities

The geo crate provides geospatial primitive types such as Point, LineString, and Polygon, and provides algorithms and operations such as:

  • Area and centroid calculation
  • Simplification and convex hull operations
  • Euclidean and Haversine distance measurement
  • Intersection checks
  • Affine transforms such as rotation and translation.

Please refer to the documentation for a complete list.

The primitive types also provide the basis for other functionality in the Geo ecosystem, including:

Example

// primitives
use geo::{line_string, polygon};

// algorithms
use geo::ConvexHull;

// An L shape
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),
];

// Calculate the polygon's convex hull
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),
    ]
);

Contributing

Contributions are welcome! Have a look at the issues, and open a pull request if you'd like to add an algorithm or some functionality.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~100–340KB