geoutils
A Rust crate for geographic distance computations and geofencing utilities
Repository Health
Technical Analysis
geoutils is a small Rust crate that provides common geographic computations built around a Location type. It calculates the distance between two coordinates using either Vincenty’s inverse formula or the Haversine formula, finds the geographic center of a set of points, and tests whether a point falls within a given radius of another.
The API is deliberately compact: most functionality hangs off methods on Location and a Distance helper, making it easy to drop into applications that need lightweight geolocation math without pulling in a full GIS stack.
What You Get
- A
Locationtype built from latitude/longitude pairs - Distance calculation via Vincenty’s inverse formula (
distance_to) - Distance calculation via the Haversine formula (
haversine_distance_to) - Centroid computation over a list of locations (
Location::center) - Radius / geofence checks with
is_in_circleand aDistancehelper
Common Use Cases
- Measuring the distance between two GPS coordinates in an application
- Checking whether a user is within a geofenced radius of a point
- Computing the center of a cluster of coordinates
Under The Hood
Architecture - The crate is just two files. lib.rs defines the public Location and Distance types and their methods, delegating the numeric heavy lifting to formula.rs, which implements Vincenty’s inverse formula and the Haversine formula. All operations are pure functions over floating-point latitude/longitude values with no shared state.
Tech Stack - Written in Rust (edition 2018) with essentially no runtime dependencies; serde (with derive) is the only dependency and it is optional and off by default. The crate is dependency-light by design so it can be embedded cheaply.
Code Quality - For its size the code is clean and focused, with the numeric formulas isolated in formula.rs and the ergonomic surface in lib.rs. The README documents each method with runnable examples, and the crate has doc-comment coverage on docs.rs. Activity has been dormant since 2022, so it is stable rather than actively evolving.
API Design - The API is intuitive: build a Location, then call distance_to, haversine_distance_to, center, or is_in_circle. Distances are wrapped in a Distance type with unit accessors like meters(), avoiding raw-number ambiguity. Getting started takes only a couple of lines, and the method names map directly onto the geographic operations they perform.