24 releases

0.7.9 Mar 7, 2023
0.7.8 Nov 16, 2022
0.7.7 Aug 25, 2022
0.7.6 Jun 24, 2022
0.1.1 May 15, 2018

#39 in Algorithms

Download history 20114/week @ 2022-12-08 17280/week @ 2022-12-15 13397/week @ 2022-12-22 14002/week @ 2022-12-29 19139/week @ 2023-01-05 19765/week @ 2023-01-12 19544/week @ 2023-01-19 21206/week @ 2023-01-26 27102/week @ 2023-02-02 25318/week @ 2023-02-09 24597/week @ 2023-02-16 25382/week @ 2023-02-23 25470/week @ 2023-03-02 27249/week @ 2023-03-09 24047/week @ 2023-03-16 24129/week @ 2023-03-23

105,758 downloads per month
Used in 177 crates (88 directly)

MIT/Apache

175KB
3K SLoC

geo

geo on Crates.io Coverage Status Documentation Discord

geo

Geospatial Primitives, Algorithms, and Utilities

Chat or ask questions on Discord

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

~0.5–0.8MB
~17K SLoC