geoutils

A Rust crate for geographic distance computations and geofencing utilities

Library
Cargo
v0.5.1
28stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
27/100Needs Attention
Development Activity0
Maintenance20
Community16
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
62/100Good
Architecture58
Code Quality62
Innovation60
Learning Curve68

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 Location type 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_circle and a Distance helper

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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search